28 #include "code/nmethod.hpp" 29 #include "compiler/compileBroker.hpp" 30 #include "memory/allocation.hpp" 31 #include "runtime/vm_operations.hpp" 32 #include "utilities/growableArray.hpp" 33 34 // The CompilationPolicy selects which method (if any) should be compiled. 35 // It also decides which methods must always be compiled (i.e., are never 36 // interpreted). 37 class CompileTask; 38 class CompileQueue; 39 40 class CompilationPolicy : public CHeapObj<mtCompiler> { 41 static CompilationPolicy* _policy; 42 // Accumulated time 43 static elapsedTimer _accumulated_time; 44 45 static bool _in_vm_startup; 46 47 // m must be compiled before executing it 48 static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all); 49 50 public: 51 static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; } 52 static void completed_vm_startup(); 53 static bool delay_compilation_during_startup() { return _in_vm_startup; } 54 55 // If m must_be_compiled then request a compilation from the CompileBroker. 56 // This supports the -Xcomp option. 57 static void compile_if_required(methodHandle m, TRAPS); 58 59 // m is allowed to be compiled 60 static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all); 61 // m is allowed to be osr compiled 62 static bool can_be_osr_compiled(methodHandle m, int comp_level = CompLevel_all); 63 static bool is_compilation_enabled(); 64 static void set_policy(CompilationPolicy* policy) { _policy = policy; } 65 static CompilationPolicy* policy() { return _policy; } 66 67 static CompileTask* select_task_helper(CompileQueue* compile_queue); 68 69 // Profiling 70 elapsedTimer* accumulated_time() { return &_accumulated_time; } 71 void print_time() PRODUCT_RETURN; 72 // Return initial compile level that is used with Xcomp 73 virtual CompLevel initial_compile_level() = 0; 74 virtual int compiler_count(CompLevel comp_level) = 0; 75 // main notification entry, return a pointer to an nmethod if the OSR is required, 76 // returns NULL otherwise. 77 virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) = 0; 78 // safepoint() is called at the end of the safepoint 79 virtual void do_safepoint_work() = 0; 80 // reprofile request 81 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0; 82 // delay_compilation(method) can be called by any component of the runtime to notify the policy | 28 #include "code/nmethod.hpp" 29 #include "compiler/compileBroker.hpp" 30 #include "memory/allocation.hpp" 31 #include "runtime/vm_operations.hpp" 32 #include "utilities/growableArray.hpp" 33 34 // The CompilationPolicy selects which method (if any) should be compiled. 35 // It also decides which methods must always be compiled (i.e., are never 36 // interpreted). 37 class CompileTask; 38 class CompileQueue; 39 40 class CompilationPolicy : public CHeapObj<mtCompiler> { 41 static CompilationPolicy* _policy; 42 // Accumulated time 43 static elapsedTimer _accumulated_time; 44 45 static bool _in_vm_startup; 46 47 // m must be compiled before executing it 48 static bool must_be_compiled(const methodHandle& m, int comp_level = CompLevel_all); 49 50 public: 51 static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; } 52 static void completed_vm_startup(); 53 static bool delay_compilation_during_startup() { return _in_vm_startup; } 54 55 // If m must_be_compiled then request a compilation from the CompileBroker. 56 // This supports the -Xcomp option. 57 static void compile_if_required(const methodHandle& m, TRAPS); 58 59 // m is allowed to be compiled 60 static bool can_be_compiled(const methodHandle& m, int comp_level = CompLevel_all); 61 // m is allowed to be osr compiled 62 static bool can_be_osr_compiled(const methodHandle& m, int comp_level = CompLevel_all); 63 static bool is_compilation_enabled(); 64 static void set_policy(CompilationPolicy* policy) { _policy = policy; } 65 static CompilationPolicy* policy() { return _policy; } 66 67 static CompileTask* select_task_helper(CompileQueue* compile_queue); 68 69 // Profiling 70 elapsedTimer* accumulated_time() { return &_accumulated_time; } 71 void print_time() PRODUCT_RETURN; 72 // Return initial compile level that is used with Xcomp 73 virtual CompLevel initial_compile_level() = 0; 74 virtual int compiler_count(CompLevel comp_level) = 0; 75 // main notification entry, return a pointer to an nmethod if the OSR is required, 76 // returns NULL otherwise. 77 virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) = 0; 78 // safepoint() is called at the end of the safepoint 79 virtual void do_safepoint_work() = 0; 80 // reprofile request 81 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0; 82 // delay_compilation(method) can be called by any component of the runtime to notify the policy |