30
31 CompileTask* CompileTask::_task_free_list = NULL;
32 #ifdef ASSERT
33 int CompileTask::_num_allocated_tasks = 0;
34 #endif
35
36 /**
37 * Allocate a CompileTask, from the free list if possible.
38 */
39 CompileTask* CompileTask::allocate() {
40 MutexLocker locker(CompileTaskAlloc_lock);
41 CompileTask* task = NULL;
42
43 if (_task_free_list != NULL) {
44 task = _task_free_list;
45 _task_free_list = task->next();
46 task->set_next(NULL);
47 } else {
48 task = new CompileTask();
49 DEBUG_ONLY(_num_allocated_tasks++;)
50 assert (WhiteBoxAPI || _num_allocated_tasks < 10000, "Leaking compilation tasks?");
51 task->set_next(NULL);
52 task->set_is_free(true);
53 }
54 assert(task->is_free(), "Task must be free.");
55 task->set_is_free(false);
56 return task;
57 }
58
59 /**
60 * Add a task to the free list.
61 */
62
63 void CompileTask::free(CompileTask* task) {
64 MutexLocker locker(CompileTaskAlloc_lock);
65 if (!task->is_free()) {
66 task->set_code(NULL);
67 assert(!task->lock()->is_locked(), "Should not be locked when freed");
68 JNIHandles::destroy_global(task->_method_holder);
69 JNIHandles::destroy_global(task->_hot_method_holder);
70
|
30
31 CompileTask* CompileTask::_task_free_list = NULL;
32 #ifdef ASSERT
33 int CompileTask::_num_allocated_tasks = 0;
34 #endif
35
36 /**
37 * Allocate a CompileTask, from the free list if possible.
38 */
39 CompileTask* CompileTask::allocate() {
40 MutexLocker locker(CompileTaskAlloc_lock);
41 CompileTask* task = NULL;
42
43 if (_task_free_list != NULL) {
44 task = _task_free_list;
45 _task_free_list = task->next();
46 task->set_next(NULL);
47 } else {
48 task = new CompileTask();
49 DEBUG_ONLY(_num_allocated_tasks++;)
50 assert (WhiteBoxAPI || JVMCI_ONLY(UseJVMCICompiler ||) _num_allocated_tasks < 10000, "Leaking compilation tasks?");
51 task->set_next(NULL);
52 task->set_is_free(true);
53 }
54 assert(task->is_free(), "Task must be free.");
55 task->set_is_free(false);
56 return task;
57 }
58
59 /**
60 * Add a task to the free list.
61 */
62
63 void CompileTask::free(CompileTask* task) {
64 MutexLocker locker(CompileTaskAlloc_lock);
65 if (!task->is_free()) {
66 task->set_code(NULL);
67 assert(!task->lock()->is_locked(), "Should not be locked when freed");
68 JNIHandles::destroy_global(task->_method_holder);
69 JNIHandles::destroy_global(task->_hot_method_holder);
70
|