src/share/vm/compiler/compileBroker.cpp

Print this page




 235 
 236 
 237 CompileTask*  CompileTask::_task_free_list = NULL;
 238 #ifdef ASSERT
 239 int CompileTask::_num_allocated_tasks = 0;
 240 #endif
 241 /**
 242  * Allocate a CompileTask, from the free list if possible.
 243  */
 244 CompileTask* CompileTask::allocate() {
 245   MutexLocker locker(CompileTaskAlloc_lock);
 246   CompileTask* task = NULL;
 247 
 248   if (_task_free_list != NULL) {
 249     task = _task_free_list;
 250     _task_free_list = task->next();
 251     task->set_next(NULL);
 252   } else {
 253     task = new CompileTask();
 254     DEBUG_ONLY(_num_allocated_tasks++;)
 255     assert (_num_allocated_tasks < 10000, "Leaking compilation tasks?");
 256     task->set_next(NULL);
 257     task->set_is_free(true);
 258   }
 259   assert(task->is_free(), "Task must be free.");
 260   task->set_is_free(false);
 261   return task;
 262 }
 263 
 264 
 265 /**
 266  * Add a task to the free list.
 267  */
 268 void CompileTask::free(CompileTask* task) {
 269   MutexLocker locker(CompileTaskAlloc_lock);
 270   if (!task->is_free()) {
 271     task->set_code(NULL);
 272     assert(!task->lock()->is_locked(), "Should not be locked when freed");
 273     JNIHandles::destroy_global(task->_method_holder);
 274     JNIHandles::destroy_global(task->_hot_method_holder);
 275 




 235 
 236 
 237 CompileTask*  CompileTask::_task_free_list = NULL;
 238 #ifdef ASSERT
 239 int CompileTask::_num_allocated_tasks = 0;
 240 #endif
 241 /**
 242  * Allocate a CompileTask, from the free list if possible.
 243  */
 244 CompileTask* CompileTask::allocate() {
 245   MutexLocker locker(CompileTaskAlloc_lock);
 246   CompileTask* task = NULL;
 247 
 248   if (_task_free_list != NULL) {
 249     task = _task_free_list;
 250     _task_free_list = task->next();
 251     task->set_next(NULL);
 252   } else {
 253     task = new CompileTask();
 254     DEBUG_ONLY(_num_allocated_tasks++;)
 255     assert (WhiteBoxAPI || WhiteBox::compilation_locked || _num_allocated_tasks < 10000, "Leaking compilation tasks?");
 256     task->set_next(NULL);
 257     task->set_is_free(true);
 258   }
 259   assert(task->is_free(), "Task must be free.");
 260   task->set_is_free(false);
 261   return task;
 262 }
 263 
 264 
 265 /**
 266  * Add a task to the free list.
 267  */
 268 void CompileTask::free(CompileTask* task) {
 269   MutexLocker locker(CompileTaskAlloc_lock);
 270   if (!task->is_free()) {
 271     task->set_code(NULL);
 272     assert(!task->lock()->is_locked(), "Should not be locked when freed");
 273     JNIHandles::destroy_global(task->_method_holder);
 274     JNIHandles::destroy_global(task->_hot_method_holder);
 275