< prev index next >

src/hotspot/share/compiler/compileTask.cpp

Print this page
rev 53255 : 8230402: Allocation of compile task fails with assert: "Leaking compilation tasks?"
Summary: Remove assert that is only hit with hand written edge case tests.
Reviewed-by: kvn, thartmann


  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileTask.hpp"
  27 #include "compiler/compileLog.hpp"
  28 #include "compiler/compileBroker.hpp"
  29 #include "compiler/compilerDirectives.hpp"
  30 #include "logging/log.hpp"
  31 #include "logging/logStream.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "runtime/handles.inline.hpp"
  34 
  35 CompileTask*  CompileTask::_task_free_list = NULL;
  36 #ifdef ASSERT
  37 int CompileTask::_num_allocated_tasks = 0;
  38 #endif
  39 
  40 /**
  41  * Allocate a CompileTask, from the free list if possible.
  42  */
  43 CompileTask* CompileTask::allocate() {
  44   MutexLocker locker(CompileTaskAlloc_lock);
  45   CompileTask* task = NULL;
  46 
  47   if (_task_free_list != NULL) {
  48     task = _task_free_list;
  49     _task_free_list = task->next();
  50     task->set_next(NULL);
  51   } else {
  52     task = new CompileTask();
  53     DEBUG_ONLY(_num_allocated_tasks++;)
  54     assert (WhiteBoxAPI || JVMCI_ONLY(UseJVMCICompiler ||) _num_allocated_tasks < 10000, "Leaking compilation tasks?");
  55     task->set_next(NULL);
  56     task->set_is_free(true);
  57   }
  58   assert(task->is_free(), "Task must be free.");
  59   task->set_is_free(false);
  60   return task;
  61 }
  62 
  63 /**
  64 * Add a task to the free list.
  65 */
  66 void CompileTask::free(CompileTask* task) {
  67   MutexLocker locker(CompileTaskAlloc_lock);
  68   if (!task->is_free()) {
  69     task->set_code(NULL);
  70     assert(!task->lock()->is_locked(), "Should not be locked when freed");
  71     if ((task->_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_method_holder)) ||
  72         (task->_hot_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_hot_method_holder))) {
  73       JNIHandles::destroy_weak_global(task->_method_holder);
  74       JNIHandles::destroy_weak_global(task->_hot_method_holder);




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileTask.hpp"
  27 #include "compiler/compileLog.hpp"
  28 #include "compiler/compileBroker.hpp"
  29 #include "compiler/compilerDirectives.hpp"
  30 #include "logging/log.hpp"
  31 #include "logging/logStream.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "runtime/handles.inline.hpp"
  34 
  35 CompileTask*  CompileTask::_task_free_list = NULL;



  36 
  37 /**
  38  * Allocate a CompileTask, from the free list if possible.
  39  */
  40 CompileTask* CompileTask::allocate() {
  41   MutexLocker locker(CompileTaskAlloc_lock);
  42   CompileTask* task = NULL;
  43 
  44   if (_task_free_list != NULL) {
  45     task = _task_free_list;
  46     _task_free_list = task->next();
  47     task->set_next(NULL);
  48   } else {
  49     task = new CompileTask();


  50     task->set_next(NULL);
  51     task->set_is_free(true);
  52   }
  53   assert(task->is_free(), "Task must be free.");
  54   task->set_is_free(false);
  55   return task;
  56 }
  57 
  58 /**
  59 * Add a task to the free list.
  60 */
  61 void CompileTask::free(CompileTask* task) {
  62   MutexLocker locker(CompileTaskAlloc_lock);
  63   if (!task->is_free()) {
  64     task->set_code(NULL);
  65     assert(!task->lock()->is_locked(), "Should not be locked when freed");
  66     if ((task->_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_method_holder)) ||
  67         (task->_hot_method_holder != NULL && JNIHandles::is_weak_global_handle(task->_hot_method_holder))) {
  68       JNIHandles::destroy_weak_global(task->_method_holder);
  69       JNIHandles::destroy_weak_global(task->_hot_method_holder);


< prev index next >