1 /*
2 * Copyright (c) 1998, 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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "ci/ciReplay.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "classfile/vmSymbols.hpp"
29 #include "compiler/compileBroker.hpp"
30 #include "compiler/compileLog.hpp"
31 #include "interpreter/linkResolver.hpp"
32 #include "oops/objArrayKlass.hpp"
33 #include "opto/callGenerator.hpp"
34 #include "opto/parse.hpp"
35 #include "runtime/handles.inline.hpp"
36 #include "utilities/events.hpp"
37
38 //=============================================================================
39 //------------------------------InlineTree-------------------------------------
40 InlineTree::InlineTree(Compile* c,
41 const InlineTree *caller_tree, ciMethod* callee,
42 JVMState* caller_jvms, int caller_bci,
43 float site_invoke_ratio, int max_inline_level) :
44 C(c),
45 _caller_jvms(caller_jvms),
46 _caller_tree((InlineTree*) caller_tree),
47 _method(callee),
48 _site_invoke_ratio(site_invoke_ratio),
49 _max_inline_level(max_inline_level),
50 _count_inline_bcs(method()->code_size_for_inlining()),
51 _subtrees(c->comp_arena(), 2, 0, NULL),
52 _msg(NULL)
53 {
54 #ifndef PRODUCT
55 _count_inlines = 0;
56 _forced_inline = false;
467 // Try to do constant pool resolution if running Xcomp
468 if( !caller_method->check_call(index, call_bc == Bytecodes::_invokestatic) ) {
469 return false;
470 }
471 }
472 }
473 return true;
474 }
475
476 //------------------------------check_can_parse--------------------------------
477 const char* InlineTree::check_can_parse(ciMethod* callee) {
478 // Certain methods cannot be parsed at all:
479 if ( callee->is_native()) return "native method";
480 if ( callee->is_abstract()) return "abstract method";
481 if (!callee->can_be_compiled()) return "not compilable (disabled)";
482 if (!callee->has_balanced_monitors()) return "not compilable (unbalanced monitors)";
483 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)";
484 return NULL;
485 }
486
487 //------------------------------print_inlining---------------------------------
488 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
489 ciMethod* caller_method, bool success) const {
490 const char* inline_msg = msg();
491 assert(inline_msg != NULL, "just checking");
492 if (C->log() != NULL) {
493 if (success) {
494 C->log()->inline_success(inline_msg);
495 } else {
496 C->log()->inline_fail(inline_msg);
497 }
498 }
499 CompileTask::print_inlining_ul(callee_method, inline_level(),
500 caller_bci, inline_msg);
501 if (C->print_inlining()) {
502 C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
503 if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
504 if (Verbose && callee_method) {
505 const InlineTree *top = this;
506 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
507 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
508 }
509 }
510 #if INCLUDE_TRACE
511 EventCompilerInlining event;
512 if (event.should_commit()) {
513 event.set_compileId(C->compile_id());
514 event.set_message(inline_msg);
515 event.set_succeeded(success);
516 event.set_bci(caller_bci);
517 event.set_caller(caller_method->get_Method());
518 event.set_callee(callee_method->to_trace_struct());
519 event.commit();
520 }
521 #endif // INCLUDE_TRACE
522 }
523
524 //------------------------------ok_to_inline-----------------------------------
525 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
526 assert(callee_method != NULL, "caller checks for optimized virtual!");
527 assert(!should_delay, "should be initialized to false");
528 #ifdef ASSERT
529 // Make sure the incoming jvms has the same information content as me.
530 // This means that we can eventually make this whole class AllStatic.
531 if (jvms->caller() == NULL) {
532 assert(_caller_jvms == NULL, "redundant instance state");
533 } else {
534 assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
535 }
536 assert(_method == jvms->method(), "redundant instance state");
537 #endif
538 int caller_bci = jvms->bci();
539 ciMethod* caller_method = jvms->method();
540
541 // Do some initial checks.
|
1 /*
2 * Copyright (c) 1998, 2017, 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 "ci/ciReplay.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "classfile/vmSymbols.hpp"
29 #include "compiler/compileBroker.hpp"
30 #include "compiler/compileLog.hpp"
31 #include "interpreter/linkResolver.hpp"
32 #include "oops/objArrayKlass.hpp"
33 #include "opto/callGenerator.hpp"
34 #include "opto/parse.hpp"
35 #include "runtime/handles.inline.hpp"
36 #include "utilities/events.hpp"
37 #if INCLUDE_TRACE
38 #include "trace/tracing.hpp"
39 #include "tracefiles/traceEventClasses.hpp"
40 #endif
41
42 //=============================================================================
43 //------------------------------InlineTree-------------------------------------
44 InlineTree::InlineTree(Compile* c,
45 const InlineTree *caller_tree, ciMethod* callee,
46 JVMState* caller_jvms, int caller_bci,
47 float site_invoke_ratio, int max_inline_level) :
48 C(c),
49 _caller_jvms(caller_jvms),
50 _caller_tree((InlineTree*) caller_tree),
51 _method(callee),
52 _site_invoke_ratio(site_invoke_ratio),
53 _max_inline_level(max_inline_level),
54 _count_inline_bcs(method()->code_size_for_inlining()),
55 _subtrees(c->comp_arena(), 2, 0, NULL),
56 _msg(NULL)
57 {
58 #ifndef PRODUCT
59 _count_inlines = 0;
60 _forced_inline = false;
471 // Try to do constant pool resolution if running Xcomp
472 if( !caller_method->check_call(index, call_bc == Bytecodes::_invokestatic) ) {
473 return false;
474 }
475 }
476 }
477 return true;
478 }
479
480 //------------------------------check_can_parse--------------------------------
481 const char* InlineTree::check_can_parse(ciMethod* callee) {
482 // Certain methods cannot be parsed at all:
483 if ( callee->is_native()) return "native method";
484 if ( callee->is_abstract()) return "abstract method";
485 if (!callee->can_be_compiled()) return "not compilable (disabled)";
486 if (!callee->has_balanced_monitors()) return "not compilable (unbalanced monitors)";
487 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)";
488 return NULL;
489 }
490
491 #if INCLUDE_TRACE
492 static void post_inlining_event(int compile_id,
493 const char* msg,
494 bool success,
495 int bci,
496 ciMethod* caller,
497 ciMethod* callee) {
498 assert(caller != NULL, "invariant");
499 assert(callee != NULL, "invariant");
500
501 EventCompilerInlining event;
502 if (event.should_commit()) {
503 TraceStructCalleeMethod callee_struct;
504 callee_struct.set_type(callee->holder()->name()->as_utf8());
505 callee_struct.set_name(callee->name()->as_utf8());
506 callee_struct.set_descriptor(callee->signature()->as_symbol()->as_utf8());
507 event.set_compileId(compile_id);
508 event.set_message(msg);
509 event.set_succeeded(success);
510 event.set_bci(bci);
511 event.set_caller(caller->get_Method());
512 event.set_callee(callee_struct);
513 event.commit();
514 }
515 }
516 #endif // INCLUDE_TRACE
517
518 //------------------------------print_inlining---------------------------------
519 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
520 ciMethod* caller_method, bool success) const {
521 const char* inline_msg = msg();
522 assert(inline_msg != NULL, "just checking");
523 if (C->log() != NULL) {
524 if (success) {
525 C->log()->inline_success(inline_msg);
526 } else {
527 C->log()->inline_fail(inline_msg);
528 }
529 }
530 CompileTask::print_inlining_ul(callee_method, inline_level(),
531 caller_bci, inline_msg);
532 if (C->print_inlining()) {
533 C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
534 if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
535 if (Verbose && callee_method) {
536 const InlineTree *top = this;
537 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
538 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
539 }
540 }
541 TRACE_ONLY(post_inlining_event(C->compile_id(),
542 inline_msg,
543 success,
544 caller_bci,
545 caller_method,
546 callee_method);)
547 }
548
549 //------------------------------ok_to_inline-----------------------------------
550 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
551 assert(callee_method != NULL, "caller checks for optimized virtual!");
552 assert(!should_delay, "should be initialized to false");
553 #ifdef ASSERT
554 // Make sure the incoming jvms has the same information content as me.
555 // This means that we can eventually make this whole class AllStatic.
556 if (jvms->caller() == NULL) {
557 assert(_caller_jvms == NULL, "redundant instance state");
558 } else {
559 assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
560 }
561 assert(_method == jvms->method(), "redundant instance state");
562 #endif
563 int caller_bci = jvms->bci();
564 ciMethod* caller_method = jvms->method();
565
566 // Do some initial checks.
|