src/share/vm/runtime/compilationPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File adv-tiered-policy Sdiff src/share/vm/runtime

src/share/vm/runtime/compilationPolicy.cpp

Print this page


   1 /*
   2  * Copyright (c) 2000, 2010, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/compiledIC.hpp"
  27 #include "code/nmethod.hpp"
  28 #include "code/scopeDesc.hpp"
  29 #include "compiler/compilerOracle.hpp"
  30 #include "interpreter/interpreter.hpp"
  31 #include "oops/methodDataOop.hpp"
  32 #include "oops/methodOop.hpp"
  33 #include "oops/oop.inline.hpp"
  34 #include "prims/nativeLookup.hpp"

  35 #include "runtime/compilationPolicy.hpp"
  36 #include "runtime/frame.hpp"
  37 #include "runtime/handles.inline.hpp"
  38 #include "runtime/rframe.hpp"
  39 #include "runtime/simpleThresholdPolicy.hpp"
  40 #include "runtime/stubRoutines.hpp"
  41 #include "runtime/thread.hpp"
  42 #include "runtime/timer.hpp"
  43 #include "runtime/vframe.hpp"
  44 #include "runtime/vm_operations.hpp"
  45 #include "utilities/events.hpp"
  46 #include "utilities/globalDefinitions.hpp"
  47 
  48 CompilationPolicy* CompilationPolicy::_policy;
  49 elapsedTimer       CompilationPolicy::_accumulated_time;
  50 bool               CompilationPolicy::_in_vm_startup;
  51 
  52 // Determine compilation policy based on command line argument
  53 void compilationPolicy_init() {
  54   CompilationPolicy::set_in_vm_startup(DelayCompilationDuringStartup);
  55 
  56   switch(CompilationPolicyChoice) {
  57   case 0:
  58     CompilationPolicy::set_policy(new SimpleCompPolicy());
  59     break;
  60 
  61   case 1:
  62 #ifdef COMPILER2
  63     CompilationPolicy::set_policy(new StackWalkCompPolicy());
  64 #else
  65     Unimplemented();
  66 #endif
  67     break;
  68   case 2:
  69 #ifdef TIERED
  70     CompilationPolicy::set_policy(new SimpleThresholdPolicy());
  71 #else
  72     Unimplemented();
  73 #endif
  74     break;







  75   default:
  76     fatal("CompilationPolicyChoice must be in the range: [0-2]");
  77   }
  78   CompilationPolicy::policy()->initialize();
  79 }
  80 
  81 void CompilationPolicy::completed_vm_startup() {
  82   if (TraceCompilationPolicy) {
  83     tty->print("CompilationPolicy: completed vm startup.\n");
  84   }
  85   _in_vm_startup = false;
  86 }
  87 
  88 // Returns true if m must be compiled before executing it
  89 // This is intended to force compiles for methods (usually for
  90 // debugging) that would otherwise be interpreted for some reason.
  91 bool CompilationPolicy::must_be_compiled(methodHandle m, int comp_level) {
  92   if (m->has_compiled_code()) return false;       // already compiled
  93   if (!can_be_compiled(m, comp_level)) return false;
  94 
  95   return !UseInterpreter ||                                              // must compile all methods
  96          (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods


   1 /*
   2  * Copyright (c) 2000, 2011, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/compiledIC.hpp"
  27 #include "code/nmethod.hpp"
  28 #include "code/scopeDesc.hpp"
  29 #include "compiler/compilerOracle.hpp"
  30 #include "interpreter/interpreter.hpp"
  31 #include "oops/methodDataOop.hpp"
  32 #include "oops/methodOop.hpp"
  33 #include "oops/oop.inline.hpp"
  34 #include "prims/nativeLookup.hpp"
  35 #include "runtime/advancedThresholdPolicy.hpp"
  36 #include "runtime/compilationPolicy.hpp"
  37 #include "runtime/frame.hpp"
  38 #include "runtime/handles.inline.hpp"
  39 #include "runtime/rframe.hpp"
  40 #include "runtime/simpleThresholdPolicy.hpp"
  41 #include "runtime/stubRoutines.hpp"
  42 #include "runtime/thread.hpp"
  43 #include "runtime/timer.hpp"
  44 #include "runtime/vframe.hpp"
  45 #include "runtime/vm_operations.hpp"
  46 #include "utilities/events.hpp"
  47 #include "utilities/globalDefinitions.hpp"
  48 
  49 CompilationPolicy* CompilationPolicy::_policy;
  50 elapsedTimer       CompilationPolicy::_accumulated_time;
  51 bool               CompilationPolicy::_in_vm_startup;
  52 
  53 // Determine compilation policy based on command line argument
  54 void compilationPolicy_init() {
  55   CompilationPolicy::set_in_vm_startup(DelayCompilationDuringStartup);
  56 
  57   switch(CompilationPolicyChoice) {
  58   case 0:
  59     CompilationPolicy::set_policy(new SimpleCompPolicy());
  60     break;
  61 
  62   case 1:
  63 #ifdef COMPILER2
  64     CompilationPolicy::set_policy(new StackWalkCompPolicy());
  65 #else
  66     Unimplemented();
  67 #endif
  68     break;
  69   case 2:
  70 #ifdef TIERED
  71     CompilationPolicy::set_policy(new SimpleThresholdPolicy());
  72 #else
  73     Unimplemented();
  74 #endif
  75     break;
  76   case 3:
  77 #ifdef TIERED
  78     CompilationPolicy::set_policy(new AdvancedThresholdPolicy());
  79 #else
  80     Unimplemented();
  81 #endif
  82     break;
  83   default:
  84     fatal("CompilationPolicyChoice must be in the range: [0-3]");
  85   }
  86   CompilationPolicy::policy()->initialize();
  87 }
  88 
  89 void CompilationPolicy::completed_vm_startup() {
  90   if (TraceCompilationPolicy) {
  91     tty->print("CompilationPolicy: completed vm startup.\n");
  92   }
  93   _in_vm_startup = false;
  94 }
  95 
  96 // Returns true if m must be compiled before executing it
  97 // This is intended to force compiles for methods (usually for
  98 // debugging) that would otherwise be interpreted for some reason.
  99 bool CompilationPolicy::must_be_compiled(methodHandle m, int comp_level) {
 100   if (m->has_compiled_code()) return false;       // already compiled
 101   if (!can_be_compiled(m, comp_level)) return false;
 102 
 103   return !UseInterpreter ||                                              // must compile all methods
 104          (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods


src/share/vm/runtime/compilationPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File