< prev index next >

src/share/vm/compiler/compileBroker.cpp

Print this page
rev 8983 : 8222670: pathological case of JIT recompilation and code cache bloat
Summary: Prevent downgraded compilation tasks from recompiling.
Reviewed-by: thartmann, sgehwolf, phh, andrew
   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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  *


 734       // no need to invoke the sweeper. As a result, the hotness of methods
 735       // remains unchanged. This behavior is desired, since we want to keep
 736       // the stable state, i.e., we do not want to evict methods from the
 737       // code cache if it is unnecessary.
 738       // We need a timed wait here, since compiler threads can exit if compilation
 739       // is disabled forever. We use 5 seconds wait time; the exiting of compiler threads
 740       // is not critical and we do not want idle compiler threads to wake up too often.
 741       lock()->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
 742     }
 743   }
 744 
 745   if (CompileBroker::is_compilation_disabled_forever()) {
 746     return NULL;
 747   }
 748 
 749   CompileTask* task;
 750   {
 751     No_Safepoint_Verifier nsv;
 752     task = CompilationPolicy::policy()->select_task(this);
 753   }

 754   remove(task);
 755   purge_stale_tasks(); // may temporarily release MCQ lock

 756   return task;
 757 }
 758 
 759 // Clean & deallocate stale compile tasks.
 760 // Temporarily releases MethodCompileQueue lock.
 761 void CompileQueue::purge_stale_tasks() {
 762   assert(lock()->owned_by_self(), "must own lock");
 763   if (_first_stale != NULL) {
 764     // Stale tasks are purged when MCQ lock is released,
 765     // but _first_stale updates are protected by MCQ lock.
 766     // Once task processing starts and MCQ lock is released,
 767     // other compiler threads can reuse _first_stale.
 768     CompileTask* head = _first_stale;
 769     _first_stale = NULL;
 770     {
 771       MutexUnlocker ul(lock());
 772       for (CompileTask* task = head; task != NULL; ) {
 773         CompileTask* next_task = task->next();
 774         CompileTaskWrapper ctw(task); // Frees the task
 775         task->set_failure_reason("stale task");


   1 /*
   2  * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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  *


 734       // no need to invoke the sweeper. As a result, the hotness of methods
 735       // remains unchanged. This behavior is desired, since we want to keep
 736       // the stable state, i.e., we do not want to evict methods from the
 737       // code cache if it is unnecessary.
 738       // We need a timed wait here, since compiler threads can exit if compilation
 739       // is disabled forever. We use 5 seconds wait time; the exiting of compiler threads
 740       // is not critical and we do not want idle compiler threads to wake up too often.
 741       lock()->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
 742     }
 743   }
 744 
 745   if (CompileBroker::is_compilation_disabled_forever()) {
 746     return NULL;
 747   }
 748 
 749   CompileTask* task;
 750   {
 751     No_Safepoint_Verifier nsv;
 752     task = CompilationPolicy::policy()->select_task(this);
 753   }
 754   if (task != NULL) {
 755     remove(task);
 756     purge_stale_tasks(); // may temporarily release MCQ lock
 757   }
 758   return task;
 759 }
 760 
 761 // Clean & deallocate stale compile tasks.
 762 // Temporarily releases MethodCompileQueue lock.
 763 void CompileQueue::purge_stale_tasks() {
 764   assert(lock()->owned_by_self(), "must own lock");
 765   if (_first_stale != NULL) {
 766     // Stale tasks are purged when MCQ lock is released,
 767     // but _first_stale updates are protected by MCQ lock.
 768     // Once task processing starts and MCQ lock is released,
 769     // other compiler threads can reuse _first_stale.
 770     CompileTask* head = _first_stale;
 771     _first_stale = NULL;
 772     {
 773       MutexUnlocker ul(lock());
 774       for (CompileTask* task = head; task != NULL; ) {
 775         CompileTask* next_task = task->next();
 776         CompileTaskWrapper ctw(task); // Frees the task
 777         task->set_failure_reason("stale task");


< prev index next >