105 |
105 |
106 return !UseInterpreter || // must compile all methods |
106 return !UseInterpreter || // must compile all methods |
107 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods |
107 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods |
108 } |
108 } |
109 |
109 |
|
110 void CompilationPolicy::compile_if_required(methodHandle selected_method, TRAPS) { |
|
111 if (must_be_compiled(selected_method)) { |
|
112 // This path is unusual, mostly used by the '-Xcomp' stress test mode. |
|
113 |
|
114 // Note: with several active threads, the must_be_compiled may be true |
|
115 // while can_be_compiled is false; remove assert |
|
116 // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile"); |
|
117 if (!THREAD->can_call_java() || THREAD->is_Compiler_thread()) { |
|
118 // don't force compilation, resolve was on behalf of compiler |
|
119 return; |
|
120 } |
|
121 if (selected_method->method_holder()->is_not_initialized()) { |
|
122 // 'is_not_initialized' means not only '!is_initialized', but also that |
|
123 // initialization has not been started yet ('!being_initialized') |
|
124 // Do not force compilation of methods in uninitialized classes. |
|
125 // Note that doing this would throw an assert later, |
|
126 // in CompileBroker::compile_method. |
|
127 // We sometimes use the link resolver to do reflective lookups |
|
128 // even before classes are initialized. |
|
129 return; |
|
130 } |
|
131 CompileBroker::compile_method(selected_method, InvocationEntryBci, |
|
132 CompilationPolicy::policy()->initial_compile_level(), |
|
133 methodHandle(), 0, "must_be_compiled", CHECK); |
|
134 } |
|
135 } |
|
136 |
110 // Returns true if m is allowed to be compiled |
137 // Returns true if m is allowed to be compiled |
111 bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) { |
138 bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) { |
112 // allow any levels for WhiteBox |
139 // allow any levels for WhiteBox |
113 assert(WhiteBoxAPI || comp_level == CompLevel_all || is_compile(comp_level), "illegal compilation level"); |
140 assert(WhiteBoxAPI || comp_level == CompLevel_all || is_compile(comp_level), "illegal compilation level"); |
114 |
141 |