1 /*
2 * Copyright (c) 1999, 2013, 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 *
322 static elapsedTimer _t_total_compilation;
323 static elapsedTimer _t_osr_compilation;
324 static elapsedTimer _t_standard_compilation;
325
326 static int _total_compile_count;
327 static int _total_bailout_count;
328 static int _total_invalidated_count;
329 static int _total_native_compile_count;
330 static int _total_osr_compile_count;
331 static int _total_standard_compile_count;
332 static int _sum_osr_bytes_compiled;
333 static int _sum_standard_bytes_compiled;
334 static int _sum_nmethod_size;
335 static int _sum_nmethod_code_size;
336 static long _peak_compilation_time;
337
338 static volatile jint _print_compilation_warning;
339
340 static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS);
341 static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count);
342 static bool compilation_is_complete (methodHandle method, int osr_bci, int comp_level);
343 static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
344 static bool is_compile_blocking ();
345 static void preload_classes (methodHandle method, TRAPS);
346
347 static CompileTask* create_compile_task(CompileQueue* queue,
348 int compile_id,
349 methodHandle method,
350 int osr_bci,
351 int comp_level,
352 methodHandle hot_method,
353 int hot_count,
354 const char* comment,
355 bool blocking);
356 static void wait_for_completion(CompileTask* task);
357
358 static void invoke_compiler_on_method(CompileTask* task);
359 static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level);
360 static void push_jni_handle_block();
361 static void pop_jni_handle_block();
362 static bool check_break_at(methodHandle method, int compile_id, bool is_osr);
372 static CompileQueue* compile_queue(int comp_level) {
373 if (is_c2_compile(comp_level)) return _c2_compile_queue;
374 if (is_c1_compile(comp_level)) return _c1_compile_queue;
375 return NULL;
376 }
377 static bool init_compiler_runtime();
378 static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread);
379
380 public:
381 enum {
382 // The entry bci used for non-OSR compilations.
383 standard_entry_bci = InvocationEntryBci
384 };
385
386 static AbstractCompiler* compiler(int comp_level) {
387 if (is_c2_compile(comp_level)) return _compilers[1]; // C2
388 if (is_c1_compile(comp_level)) return _compilers[0]; // C1
389 return NULL;
390 }
391
392 static bool compilation_is_in_queue(methodHandle method);
393 static int queue_size(int comp_level) {
394 CompileQueue *q = compile_queue(comp_level);
395 return q != NULL ? q->size() : 0;
396 }
397 static void compilation_init();
398 static void init_compiler_thread_log();
399 static nmethod* compile_method(methodHandle method,
400 int osr_bci,
401 int comp_level,
402 methodHandle hot_method,
403 int hot_count,
404 const char* comment, Thread* thread);
405
406 static void compiler_thread_loop();
407 static uint get_compilation_id() { return _compilation_id; }
408
409 // Set _should_block.
410 // Call this from the VM, with Threads_lock held and a safepoint requested.
411 static void set_should_block();
|
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 *
322 static elapsedTimer _t_total_compilation;
323 static elapsedTimer _t_osr_compilation;
324 static elapsedTimer _t_standard_compilation;
325
326 static int _total_compile_count;
327 static int _total_bailout_count;
328 static int _total_invalidated_count;
329 static int _total_native_compile_count;
330 static int _total_osr_compile_count;
331 static int _total_standard_compile_count;
332 static int _sum_osr_bytes_compiled;
333 static int _sum_standard_bytes_compiled;
334 static int _sum_nmethod_size;
335 static int _sum_nmethod_code_size;
336 static long _peak_compilation_time;
337
338 static volatile jint _print_compilation_warning;
339
340 static CompilerThread* make_compiler_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, TRAPS);
341 static void init_compiler_threads(int c1_compiler_count, int c2_compiler_count);
342 static bool compilation_is_prohibited(methodHandle method, int osr_bci, int comp_level);
343 static bool is_compile_blocking ();
344 static void preload_classes (methodHandle method, TRAPS);
345
346 static CompileTask* create_compile_task(CompileQueue* queue,
347 int compile_id,
348 methodHandle method,
349 int osr_bci,
350 int comp_level,
351 methodHandle hot_method,
352 int hot_count,
353 const char* comment,
354 bool blocking);
355 static void wait_for_completion(CompileTask* task);
356
357 static void invoke_compiler_on_method(CompileTask* task);
358 static void set_last_compile(CompilerThread *thread, methodHandle method, bool is_osr, int comp_level);
359 static void push_jni_handle_block();
360 static void pop_jni_handle_block();
361 static bool check_break_at(methodHandle method, int compile_id, bool is_osr);
371 static CompileQueue* compile_queue(int comp_level) {
372 if (is_c2_compile(comp_level)) return _c2_compile_queue;
373 if (is_c1_compile(comp_level)) return _c1_compile_queue;
374 return NULL;
375 }
376 static bool init_compiler_runtime();
377 static void shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread);
378
379 public:
380 enum {
381 // The entry bci used for non-OSR compilations.
382 standard_entry_bci = InvocationEntryBci
383 };
384
385 static AbstractCompiler* compiler(int comp_level) {
386 if (is_c2_compile(comp_level)) return _compilers[1]; // C2
387 if (is_c1_compile(comp_level)) return _compilers[0]; // C1
388 return NULL;
389 }
390
391 static bool compilation_is_complete(methodHandle method, int osr_bci, int comp_level);
392 static bool compilation_is_in_queue(methodHandle method);
393 static int queue_size(int comp_level) {
394 CompileQueue *q = compile_queue(comp_level);
395 return q != NULL ? q->size() : 0;
396 }
397 static void compilation_init();
398 static void init_compiler_thread_log();
399 static nmethod* compile_method(methodHandle method,
400 int osr_bci,
401 int comp_level,
402 methodHandle hot_method,
403 int hot_count,
404 const char* comment, Thread* thread);
405
406 static void compiler_thread_loop();
407 static uint get_compilation_id() { return _compilation_id; }
408
409 // Set _should_block.
410 // Call this from the VM, with Threads_lock held and a safepoint requested.
411 static void set_should_block();
|