Tue, 29 Aug 2017 15:31:19 +0800
#6062 The disassembler is implemented by hsdis instead of disassembler_mips.cpp.
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_COMPILER_COMPILEBROKER_HPP |
aoqi@0 | 26 | #define SHARE_VM_COMPILER_COMPILEBROKER_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "ci/compilerInterface.hpp" |
aoqi@0 | 29 | #include "compiler/abstractCompiler.hpp" |
aoqi@0 | 30 | #include "runtime/perfData.hpp" |
aoqi@0 | 31 | |
aoqi@0 | 32 | class nmethod; |
aoqi@0 | 33 | class nmethodLocker; |
aoqi@0 | 34 | |
aoqi@0 | 35 | // CompileTask |
aoqi@0 | 36 | // |
aoqi@0 | 37 | // An entry in the compile queue. It represents a pending or current |
aoqi@0 | 38 | // compilation. |
aoqi@0 | 39 | class CompileTask : public CHeapObj<mtCompiler> { |
aoqi@0 | 40 | friend class VMStructs; |
aoqi@0 | 41 | |
aoqi@0 | 42 | private: |
aoqi@0 | 43 | Monitor* _lock; |
aoqi@0 | 44 | uint _compile_id; |
aoqi@0 | 45 | Method* _method; |
aoqi@0 | 46 | jobject _method_holder; |
aoqi@0 | 47 | int _osr_bci; |
aoqi@0 | 48 | bool _is_complete; |
aoqi@0 | 49 | bool _is_success; |
aoqi@0 | 50 | bool _is_blocking; |
aoqi@0 | 51 | int _comp_level; |
aoqi@0 | 52 | int _num_inlined_bytecodes; |
aoqi@0 | 53 | nmethodLocker* _code_handle; // holder of eventual result |
aoqi@0 | 54 | CompileTask* _next, *_prev; |
aoqi@0 | 55 | |
aoqi@0 | 56 | // Fields used for logging why the compilation was initiated: |
aoqi@0 | 57 | jlong _time_queued; // in units of os::elapsed_counter() |
aoqi@0 | 58 | Method* _hot_method; // which method actually triggered this task |
aoqi@0 | 59 | jobject _hot_method_holder; |
aoqi@0 | 60 | int _hot_count; // information about its invocation counter |
aoqi@0 | 61 | const char* _comment; // more info about the task |
aoqi@0 | 62 | |
aoqi@0 | 63 | public: |
aoqi@0 | 64 | CompileTask() { |
aoqi@0 | 65 | _lock = new Monitor(Mutex::nonleaf+2, "CompileTaskLock"); |
aoqi@0 | 66 | } |
aoqi@0 | 67 | |
aoqi@0 | 68 | void initialize(int compile_id, methodHandle method, int osr_bci, int comp_level, |
aoqi@0 | 69 | methodHandle hot_method, int hot_count, const char* comment, |
aoqi@0 | 70 | bool is_blocking); |
aoqi@0 | 71 | |
aoqi@0 | 72 | void free(); |
aoqi@0 | 73 | |
aoqi@0 | 74 | int compile_id() const { return _compile_id; } |
aoqi@0 | 75 | Method* method() const { return _method; } |
aoqi@0 | 76 | int osr_bci() const { return _osr_bci; } |
aoqi@0 | 77 | bool is_complete() const { return _is_complete; } |
aoqi@0 | 78 | bool is_blocking() const { return _is_blocking; } |
aoqi@0 | 79 | bool is_success() const { return _is_success; } |
aoqi@0 | 80 | |
aoqi@0 | 81 | nmethodLocker* code_handle() const { return _code_handle; } |
aoqi@0 | 82 | void set_code_handle(nmethodLocker* l) { _code_handle = l; } |
aoqi@0 | 83 | nmethod* code() const; // _code_handle->code() |
aoqi@0 | 84 | void set_code(nmethod* nm); // _code_handle->set_code(nm) |
aoqi@0 | 85 | |
aoqi@0 | 86 | Monitor* lock() const { return _lock; } |
aoqi@0 | 87 | |
aoqi@0 | 88 | void mark_complete() { _is_complete = true; } |
aoqi@0 | 89 | void mark_success() { _is_success = true; } |
aoqi@0 | 90 | |
aoqi@0 | 91 | int comp_level() { return _comp_level;} |
aoqi@0 | 92 | void set_comp_level(int comp_level) { _comp_level = comp_level;} |
aoqi@0 | 93 | |
aoqi@0 | 94 | int num_inlined_bytecodes() const { return _num_inlined_bytecodes; } |
aoqi@0 | 95 | void set_num_inlined_bytecodes(int n) { _num_inlined_bytecodes = n; } |
aoqi@0 | 96 | |
aoqi@0 | 97 | CompileTask* next() const { return _next; } |
aoqi@0 | 98 | void set_next(CompileTask* next) { _next = next; } |
aoqi@0 | 99 | CompileTask* prev() const { return _prev; } |
aoqi@0 | 100 | void set_prev(CompileTask* prev) { _prev = prev; } |
aoqi@0 | 101 | |
aoqi@0 | 102 | private: |
aoqi@0 | 103 | static void print_compilation_impl(outputStream* st, Method* method, int compile_id, int comp_level, |
aoqi@0 | 104 | bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false, |
aoqi@0 | 105 | const char* msg = NULL, bool short_form = false); |
aoqi@0 | 106 | |
aoqi@0 | 107 | public: |
aoqi@0 | 108 | void print_compilation(outputStream* st = tty, const char* msg = NULL, bool short_form = false); |
aoqi@0 | 109 | static void print_compilation(outputStream* st, const nmethod* nm, const char* msg = NULL, bool short_form = false) { |
aoqi@0 | 110 | print_compilation_impl(st, nm->method(), nm->compile_id(), nm->comp_level(), |
aoqi@0 | 111 | nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false, |
aoqi@0 | 112 | msg, short_form); |
aoqi@0 | 113 | } |
aoqi@0 | 114 | |
aoqi@0 | 115 | static void print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg = NULL); |
aoqi@0 | 116 | static void print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) { |
aoqi@0 | 117 | print_inlining(tty, method, inline_level, bci, msg); |
aoqi@0 | 118 | } |
aoqi@0 | 119 | |
aoqi@0 | 120 | // Redefine Classes support |
aoqi@0 | 121 | void mark_on_stack(); |
aoqi@0 | 122 | |
aoqi@0 | 123 | static void print_inline_indent(int inline_level, outputStream* st = tty); |
aoqi@0 | 124 | |
aoqi@0 | 125 | void print(); |
aoqi@0 | 126 | void print_line(); |
aoqi@0 | 127 | void print_line_on_error(outputStream* st, char* buf, int buflen); |
aoqi@0 | 128 | |
aoqi@0 | 129 | void log_task(xmlStream* log); |
aoqi@0 | 130 | void log_task_queued(); |
aoqi@0 | 131 | void log_task_start(CompileLog* log); |
aoqi@0 | 132 | void log_task_done(CompileLog* log); |
aoqi@0 | 133 | }; |
aoqi@0 | 134 | |
aoqi@0 | 135 | // CompilerCounters |
aoqi@0 | 136 | // |
aoqi@0 | 137 | // Per Compiler Performance Counters. |
aoqi@0 | 138 | // |
aoqi@0 | 139 | class CompilerCounters : public CHeapObj<mtCompiler> { |
aoqi@0 | 140 | |
aoqi@0 | 141 | public: |
aoqi@0 | 142 | enum { |
aoqi@0 | 143 | cmname_buffer_length = 160 |
aoqi@0 | 144 | }; |
aoqi@0 | 145 | |
aoqi@0 | 146 | private: |
aoqi@0 | 147 | |
aoqi@0 | 148 | char _current_method[cmname_buffer_length]; |
aoqi@0 | 149 | PerfStringVariable* _perf_current_method; |
aoqi@0 | 150 | |
aoqi@0 | 151 | int _compile_type; |
aoqi@0 | 152 | PerfVariable* _perf_compile_type; |
aoqi@0 | 153 | |
aoqi@0 | 154 | PerfCounter* _perf_time; |
aoqi@0 | 155 | PerfCounter* _perf_compiles; |
aoqi@0 | 156 | |
aoqi@0 | 157 | public: |
aoqi@0 | 158 | CompilerCounters(const char* name, int instance, TRAPS); |
aoqi@0 | 159 | |
aoqi@0 | 160 | // these methods should be called in a thread safe context |
aoqi@0 | 161 | |
aoqi@0 | 162 | void set_current_method(const char* method) { |
aoqi@0 | 163 | strncpy(_current_method, method, (size_t)cmname_buffer_length); |
aoqi@0 | 164 | if (UsePerfData) _perf_current_method->set_value(method); |
aoqi@0 | 165 | } |
aoqi@0 | 166 | |
aoqi@0 | 167 | char* current_method() { return _current_method; } |
aoqi@0 | 168 | |
aoqi@0 | 169 | void set_compile_type(int compile_type) { |
aoqi@0 | 170 | _compile_type = compile_type; |
aoqi@0 | 171 | if (UsePerfData) _perf_compile_type->set_value((jlong)compile_type); |
aoqi@0 | 172 | } |
aoqi@0 | 173 | |
aoqi@0 | 174 | int compile_type() { return _compile_type; } |
aoqi@0 | 175 | |
aoqi@0 | 176 | PerfCounter* time_counter() { return _perf_time; } |
aoqi@0 | 177 | PerfCounter* compile_counter() { return _perf_compiles; } |
aoqi@0 | 178 | }; |
aoqi@0 | 179 | |
aoqi@0 | 180 | // CompileQueue |
aoqi@0 | 181 | // |
aoqi@0 | 182 | // A list of CompileTasks. |
aoqi@0 | 183 | class CompileQueue : public CHeapObj<mtCompiler> { |
aoqi@0 | 184 | private: |
aoqi@0 | 185 | const char* _name; |
aoqi@0 | 186 | Monitor* _lock; |
aoqi@0 | 187 | |
aoqi@0 | 188 | CompileTask* _first; |
aoqi@0 | 189 | CompileTask* _last; |
aoqi@0 | 190 | |
aoqi@0 | 191 | int _size; |
aoqi@0 | 192 | public: |
aoqi@0 | 193 | CompileQueue(const char* name, Monitor* lock) { |
aoqi@0 | 194 | _name = name; |
aoqi@0 | 195 | _lock = lock; |
aoqi@0 | 196 | _first = NULL; |
aoqi@0 | 197 | _last = NULL; |
aoqi@0 | 198 | _size = 0; |
aoqi@0 | 199 | } |
aoqi@0 | 200 | |
aoqi@0 | 201 | const char* name() const { return _name; } |
aoqi@0 | 202 | Monitor* lock() const { return _lock; } |
aoqi@0 | 203 | |
aoqi@0 | 204 | void add(CompileTask* task); |
aoqi@0 | 205 | void remove(CompileTask* task); |
aoqi@0 | 206 | CompileTask* first() { return _first; } |
aoqi@0 | 207 | CompileTask* last() { return _last; } |
aoqi@0 | 208 | |
aoqi@0 | 209 | CompileTask* get(); |
aoqi@0 | 210 | |
aoqi@0 | 211 | bool is_empty() const { return _first == NULL; } |
aoqi@0 | 212 | int size() const { return _size; } |
aoqi@0 | 213 | |
aoqi@0 | 214 | // Redefine Classes support |
aoqi@0 | 215 | void mark_on_stack(); |
aoqi@0 | 216 | void delete_all(); |
aoqi@0 | 217 | void print(); |
aoqi@0 | 218 | |
aoqi@0 | 219 | ~CompileQueue() { |
aoqi@0 | 220 | assert (is_empty(), " Compile Queue must be empty"); |
aoqi@0 | 221 | } |
aoqi@0 | 222 | }; |
aoqi@0 | 223 | |
aoqi@0 | 224 | // CompileTaskWrapper |
aoqi@0 | 225 | // |
aoqi@0 | 226 | // Assign this task to the current thread. Deallocate the task |
aoqi@0 | 227 | // when the compilation is complete. |
aoqi@0 | 228 | class CompileTaskWrapper : StackObj { |
aoqi@0 | 229 | public: |
aoqi@0 | 230 | CompileTaskWrapper(CompileTask* task); |
aoqi@0 | 231 | ~CompileTaskWrapper(); |
aoqi@0 | 232 | }; |
aoqi@0 | 233 | |
aoqi@0 | 234 | |
aoqi@0 | 235 | // Compilation |
aoqi@0 | 236 | // |
aoqi@0 | 237 | // The broker for all compilation requests. |
aoqi@0 | 238 | class CompileBroker: AllStatic { |
aoqi@0 | 239 | friend class Threads; |
aoqi@0 | 240 | friend class CompileTaskWrapper; |
aoqi@0 | 241 | |
aoqi@0 | 242 | public: |
aoqi@0 | 243 | enum { |
aoqi@0 | 244 | name_buffer_length = 100 |
aoqi@0 | 245 | }; |
aoqi@0 | 246 | |
aoqi@0 | 247 | // Compile type Information for print_last_compile() and CompilerCounters |
aoqi@0 | 248 | enum { no_compile, normal_compile, osr_compile, native_compile }; |
aoqi@0 | 249 | static int assign_compile_id (methodHandle method, int osr_bci); |
aoqi@0 | 250 | |
aoqi@0 | 251 | |
aoqi@0 | 252 | private: |
aoqi@0 | 253 | static bool _initialized; |
aoqi@0 | 254 | static volatile bool _should_block; |
aoqi@0 | 255 | |
aoqi@0 | 256 | // This flag can be used to stop compilation or turn it back on |
aoqi@0 | 257 | static volatile jint _should_compile_new_jobs; |
aoqi@0 | 258 | |
aoqi@0 | 259 | // The installed compiler(s) |
aoqi@0 | 260 | static AbstractCompiler* _compilers[2]; |
aoqi@0 | 261 | |
aoqi@0 | 262 | // These counters are used for assigning id's to each compilation |
aoqi@0 | 263 | static volatile jint _compilation_id; |
aoqi@0 | 264 | static volatile jint _osr_compilation_id; |
aoqi@0 | 265 | |
aoqi@0 | 266 | static int _last_compile_type; |
aoqi@0 | 267 | static int _last_compile_level; |
aoqi@0 | 268 | static char _last_method_compiled[name_buffer_length]; |
aoqi@0 | 269 | |
aoqi@0 | 270 | static CompileQueue* _c2_method_queue; |
aoqi@0 | 271 | static CompileQueue* _c1_method_queue; |
aoqi@0 | 272 | static CompileTask* _task_free_list; |
aoqi@0 | 273 | |
aoqi@0 | 274 | static GrowableArray<CompilerThread*>* _compiler_threads; |
aoqi@0 | 275 | |
aoqi@0 | 276 | // performance counters |
aoqi@0 | 277 | static PerfCounter* _perf_total_compilation; |
aoqi@0 | 278 | static PerfCounter* _perf_native_compilation; |
aoqi@0 | 279 | static PerfCounter* _perf_osr_compilation; |
aoqi@0 | 280 | static PerfCounter* _perf_standard_compilation; |
aoqi@0 | 281 | |
aoqi@0 | 282 | static PerfCounter* _perf_total_bailout_count; |
aoqi@0 | 283 | static PerfCounter* _perf_total_invalidated_count; |
aoqi@0 | 284 | static PerfCounter* _perf_total_compile_count; |
aoqi@0 | 285 | static PerfCounter* _perf_total_native_compile_count; |
aoqi@0 | 286 | static PerfCounter* _perf_total_osr_compile_count; |
aoqi@0 | 287 | static PerfCounter* _perf_total_standard_compile_count; |
aoqi@0 | 288 | |
aoqi@0 | 289 | static PerfCounter* _perf_sum_osr_bytes_compiled; |
aoqi@0 | 290 | static PerfCounter* _perf_sum_standard_bytes_compiled; |
aoqi@0 | 291 | static PerfCounter* _perf_sum_nmethod_size; |
aoqi@0 | 292 | static PerfCounter* _perf_sum_nmethod_code_size; |
aoqi@0 | 293 | |
aoqi@0 | 294 | static PerfStringVariable* _perf_last_method; |
aoqi@0 | 295 | static PerfStringVariable* _perf_last_failed_method; |
aoqi@0 | 296 | static PerfStringVariable* _perf_last_invalidated_method; |
aoqi@0 | 297 | static PerfVariable* _perf_last_compile_type; |
aoqi@0 | 298 | static PerfVariable* _perf_last_compile_size; |
aoqi@0 | 299 | static PerfVariable* _perf_last_failed_type; |
aoqi@0 | 300 | static PerfVariable* _perf_last_invalidated_type; |
aoqi@0 | 301 | |
aoqi@0 | 302 | // Timers and counters for generating statistics |
aoqi@0 | 303 | static elapsedTimer _t_total_compilation; |
aoqi@0 | 304 | static elapsedTimer _t_osr_compilation; |
aoqi@0 | 305 | static elapsedTimer _t_standard_compilation; |
aoqi@0 | 306 | |
aoqi@0 | 307 | static int _total_compile_count; |
aoqi@0 | 308 | static int _total_bailout_count; |
aoqi@0 | 309 | static int _total_invalidated_count; |
aoqi@0 | 310 | static int _total_native_compile_count; |
aoqi@0 | 311 | static int _total_osr_compile_count; |
aoqi@0 | 312 | static int _total_standard_compile_count; |
aoqi@0 | 313 | static int _sum_osr_bytes_compiled; |
aoqi@0 | 314 | static int _sum_standard_bytes_compiled; |
aoqi@0 | 315 | static int _sum_nmethod_size; |
aoqi@0 | 316 | static int _sum_nmethod_code_size; |
aoqi@0 | 317 | static long _peak_compilation_time; |
aoqi@0 | 318 | |
aoqi@0 | 319 | static volatile jint _print_compilation_warning; |
aoqi@0 | 320 | |
aoqi@0 | 321 | static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS); |
aoqi@0 | 322 | static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count); |
aoqi@0 | 323 | static bool compilation_is_complete (methodHandle method, int osr_bci, int comp_level); |
aoqi@0 | 324 | static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level); |
aoqi@0 | 325 | static bool is_compile_blocking (methodHandle method, int osr_bci); |
aoqi@0 | 326 | static void preload_classes (methodHandle method, TRAPS); |
aoqi@0 | 327 | |
aoqi@0 | 328 | static CompileTask* create_compile_task(CompileQueue* queue, |
aoqi@0 | 329 | int compile_id, |
aoqi@0 | 330 | methodHandle method, |
aoqi@0 | 331 | int osr_bci, |
aoqi@0 | 332 | int comp_level, |
aoqi@0 | 333 | methodHandle hot_method, |
aoqi@0 | 334 | int hot_count, |
aoqi@0 | 335 | const char* comment, |
aoqi@0 | 336 | bool blocking); |
aoqi@0 | 337 | static CompileTask* allocate_task(); |
aoqi@0 | 338 | static void free_task(CompileTask* task); |
aoqi@0 | 339 | static void wait_for_completion(CompileTask* task); |
aoqi@0 | 340 | |
aoqi@0 | 341 | static void invoke_compiler_on_method(CompileTask* task); |
aoqi@0 | 342 | static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level); |
aoqi@0 | 343 | static void push_jni_handle_block(); |
aoqi@0 | 344 | static void pop_jni_handle_block(); |
aoqi@0 | 345 | static bool check_break_at(methodHandle method, int compile_id, bool is_osr); |
aoqi@0 | 346 | static void collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task); |
aoqi@0 | 347 | |
aoqi@0 | 348 | static void compile_method_base(methodHandle method, |
aoqi@0 | 349 | int osr_bci, |
aoqi@0 | 350 | int comp_level, |
aoqi@0 | 351 | methodHandle hot_method, |
aoqi@0 | 352 | int hot_count, |
aoqi@0 | 353 | const char* comment, |
aoqi@0 | 354 | Thread* thread); |
aoqi@0 | 355 | static CompileQueue* compile_queue(int comp_level) { |
aoqi@0 | 356 | if (is_c2_compile(comp_level)) return _c2_method_queue; |
aoqi@0 | 357 | if (is_c1_compile(comp_level)) return _c1_method_queue; |
aoqi@0 | 358 | return NULL; |
aoqi@0 | 359 | } |
aoqi@0 | 360 | static bool init_compiler_runtime(); |
aoqi@0 | 361 | static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread); |
aoqi@0 | 362 | |
aoqi@0 | 363 | public: |
aoqi@0 | 364 | enum { |
aoqi@0 | 365 | // The entry bci used for non-OSR compilations. |
aoqi@0 | 366 | standard_entry_bci = InvocationEntryBci |
aoqi@0 | 367 | }; |
aoqi@0 | 368 | |
aoqi@0 | 369 | static AbstractCompiler* compiler(int comp_level) { |
aoqi@0 | 370 | if (is_c2_compile(comp_level)) return _compilers[1]; // C2 |
aoqi@0 | 371 | if (is_c1_compile(comp_level)) return _compilers[0]; // C1 |
aoqi@0 | 372 | return NULL; |
aoqi@0 | 373 | } |
aoqi@0 | 374 | |
aoqi@0 | 375 | static bool compilation_is_in_queue(methodHandle method, int osr_bci); |
aoqi@0 | 376 | static int queue_size(int comp_level) { |
aoqi@0 | 377 | CompileQueue *q = compile_queue(comp_level); |
aoqi@0 | 378 | return q != NULL ? q->size() : 0; |
aoqi@0 | 379 | } |
aoqi@0 | 380 | static void compilation_init(); |
aoqi@0 | 381 | static void init_compiler_thread_log(); |
aoqi@0 | 382 | static nmethod* compile_method(methodHandle method, |
aoqi@0 | 383 | int osr_bci, |
aoqi@0 | 384 | int comp_level, |
aoqi@0 | 385 | methodHandle hot_method, |
aoqi@0 | 386 | int hot_count, |
aoqi@0 | 387 | const char* comment, Thread* thread); |
aoqi@0 | 388 | |
aoqi@0 | 389 | static void compiler_thread_loop(); |
aoqi@0 | 390 | static uint get_compilation_id() { return _compilation_id; } |
aoqi@0 | 391 | |
aoqi@0 | 392 | // Set _should_block. |
aoqi@0 | 393 | // Call this from the VM, with Threads_lock held and a safepoint requested. |
aoqi@0 | 394 | static void set_should_block(); |
aoqi@0 | 395 | |
aoqi@0 | 396 | // Call this from the compiler at convenient points, to poll for _should_block. |
aoqi@0 | 397 | static void maybe_block(); |
aoqi@0 | 398 | |
aoqi@0 | 399 | enum { |
aoqi@0 | 400 | // Flags for toggling compiler activity |
aoqi@0 | 401 | stop_compilation = 0, |
aoqi@0 | 402 | run_compilation = 1, |
aoqi@0 | 403 | shutdown_compilaton = 2 |
aoqi@0 | 404 | }; |
aoqi@0 | 405 | |
aoqi@0 | 406 | static bool should_compile_new_jobs() { return UseCompiler && (_should_compile_new_jobs == run_compilation); } |
aoqi@0 | 407 | static bool set_should_compile_new_jobs(jint new_state) { |
aoqi@0 | 408 | // Return success if the current caller set it |
aoqi@0 | 409 | jint old = Atomic::cmpxchg(new_state, &_should_compile_new_jobs, 1-new_state); |
aoqi@0 | 410 | return (old == (1-new_state)); |
aoqi@0 | 411 | } |
aoqi@0 | 412 | |
aoqi@0 | 413 | static void disable_compilation_forever() { |
aoqi@0 | 414 | UseCompiler = false; |
aoqi@0 | 415 | AlwaysCompileLoopMethods = false; |
aoqi@0 | 416 | Atomic::xchg(shutdown_compilaton, &_should_compile_new_jobs); |
aoqi@0 | 417 | } |
aoqi@0 | 418 | |
aoqi@0 | 419 | static bool is_compilation_disabled_forever() { |
aoqi@0 | 420 | return _should_compile_new_jobs == shutdown_compilaton; |
aoqi@0 | 421 | } |
aoqi@0 | 422 | static void handle_full_code_cache(); |
aoqi@0 | 423 | // Ensures that warning is only printed once. |
aoqi@0 | 424 | static bool should_print_compiler_warning() { |
aoqi@0 | 425 | jint old = Atomic::cmpxchg(1, &_print_compilation_warning, 0); |
aoqi@0 | 426 | return old == 0; |
aoqi@0 | 427 | } |
aoqi@0 | 428 | // Return total compilation ticks |
aoqi@0 | 429 | static jlong total_compilation_ticks() { |
aoqi@0 | 430 | return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0; |
aoqi@0 | 431 | } |
aoqi@0 | 432 | |
aoqi@0 | 433 | // Redefine Classes support |
aoqi@0 | 434 | static void mark_on_stack(); |
aoqi@0 | 435 | |
aoqi@0 | 436 | // Print a detailed accounting of compilation time |
aoqi@0 | 437 | static void print_times(); |
aoqi@0 | 438 | |
aoqi@0 | 439 | // Debugging output for failure |
aoqi@0 | 440 | static void print_last_compile(); |
aoqi@0 | 441 | |
aoqi@0 | 442 | static void print_compiler_threads_on(outputStream* st); |
aoqi@0 | 443 | |
aoqi@0 | 444 | // compiler name for debugging |
aoqi@0 | 445 | static const char* compiler_name(int comp_level); |
aoqi@0 | 446 | |
aoqi@0 | 447 | static int get_total_compile_count() { return _total_compile_count; } |
aoqi@0 | 448 | static int get_total_bailout_count() { return _total_bailout_count; } |
aoqi@0 | 449 | static int get_total_invalidated_count() { return _total_invalidated_count; } |
aoqi@0 | 450 | static int get_total_native_compile_count() { return _total_native_compile_count; } |
aoqi@0 | 451 | static int get_total_osr_compile_count() { return _total_osr_compile_count; } |
aoqi@0 | 452 | static int get_total_standard_compile_count() { return _total_standard_compile_count; } |
aoqi@0 | 453 | static int get_sum_osr_bytes_compiled() { return _sum_osr_bytes_compiled; } |
aoqi@0 | 454 | static int get_sum_standard_bytes_compiled() { return _sum_standard_bytes_compiled; } |
aoqi@0 | 455 | static int get_sum_nmethod_size() { return _sum_nmethod_size;} |
aoqi@0 | 456 | static int get_sum_nmethod_code_size() { return _sum_nmethod_code_size; } |
aoqi@0 | 457 | static long get_peak_compilation_time() { return _peak_compilation_time; } |
aoqi@0 | 458 | static long get_total_compilation_time() { return _t_total_compilation.milliseconds(); } |
aoqi@0 | 459 | }; |
aoqi@0 | 460 | |
aoqi@0 | 461 | #endif // SHARE_VM_COMPILER_COMPILEBROKER_HPP |