comparison src/share/vm/opto/doCall.cpp @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 89152779163c dda2ae6f9557
children 7848fc12602b
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
1 /* 1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
54 } 54 }
55 CompileTask::print_inline_indent(depth, out); 55 CompileTask::print_inline_indent(depth, out);
56 out->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count); 56 out->print(" \\-> TypeProfile (%d/%d counts) = ", receiver_count, site_count);
57 stringStream ss; 57 stringStream ss;
58 prof_klass->name()->print_symbol_on(&ss); 58 prof_klass->name()->print_symbol_on(&ss);
59 out->print(ss.as_string()); 59 out->print("%s", ss.as_string());
60 out->cr(); 60 out->cr();
61 } 61 }
62 } 62 }
63 63
64 CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool call_does_dispatch, 64 CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool call_does_dispatch,
159 // This is the number of times we expect the call code to be used. 159 // This is the number of times we expect the call code to be used.
160 float expected_uses = past_uses; 160 float expected_uses = past_uses;
161 161
162 // Try inlining a bytecoded method: 162 // Try inlining a bytecoded method:
163 if (!call_does_dispatch) { 163 if (!call_does_dispatch) {
164 InlineTree* ilt; 164 InlineTree* ilt = InlineTree::find_subtree_from_root(this->ilt(), jvms->caller(), jvms->method());
165 if (UseOldInlining) {
166 ilt = InlineTree::find_subtree_from_root(this->ilt(), jvms->caller(), jvms->method());
167 } else {
168 // Make a disembodied, stateless ILT.
169 // TO DO: When UseOldInlining is removed, copy the ILT code elsewhere.
170 float site_invoke_ratio = prof_factor;
171 // Note: ilt is for the root of this parse, not the present call site.
172 ilt = new InlineTree(this, jvms->method(), jvms->caller(), site_invoke_ratio, MaxInlineLevel);
173 }
174 WarmCallInfo scratch_ci; 165 WarmCallInfo scratch_ci;
175 if (!UseOldInlining)
176 scratch_ci.init(jvms, callee, profile, prof_factor);
177 bool should_delay = false; 166 bool should_delay = false;
178 WarmCallInfo* ci = ilt->ok_to_inline(callee, jvms, profile, &scratch_ci, should_delay); 167 WarmCallInfo* ci = ilt->ok_to_inline(callee, jvms, profile, &scratch_ci, should_delay);
179 assert(ci != &scratch_ci, "do not let this pointer escape"); 168 assert(ci != &scratch_ci, "do not let this pointer escape");
180 bool allow_inline = (ci != NULL && !ci->is_cold()); 169 bool allow_inline = (ci != NULL && !ci->is_cold());
181 bool require_inline = (allow_inline && ci->is_hot()); 170 bool require_inline = (allow_inline && ci->is_hot());
259 } 248 }
260 } 249 }
261 CallGenerator* miss_cg; 250 CallGenerator* miss_cg;
262 Deoptimization::DeoptReason reason = morphism == 2 ? 251 Deoptimization::DeoptReason reason = morphism == 2 ?
263 Deoptimization::Reason_bimorphic : 252 Deoptimization::Reason_bimorphic :
264 Deoptimization::Reason_class_check; 253 (speculative_receiver_type == NULL ? Deoptimization::Reason_class_check : Deoptimization::Reason_speculate_class_check);
265 if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) && 254 if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) &&
266 !too_many_traps(jvms->method(), jvms->bci(), reason) 255 !too_many_traps(jvms->method(), jvms->bci(), reason)
267 ) { 256 ) {
268 // Generate uncommon trap for class check failure path 257 // Generate uncommon trap for class check failure path
269 // in case of monomorphic or bimorphic virtual call site. 258 // in case of monomorphic or bimorphic virtual call site.
367 } 356 }
368 357
369 bool Compile::should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms) { 358 bool Compile::should_delay_boxing_inlining(ciMethod* call_method, JVMState* jvms) {
370 if (eliminate_boxing() && call_method->is_boxing_method()) { 359 if (eliminate_boxing() && call_method->is_boxing_method()) {
371 set_has_boxed_value(true); 360 set_has_boxed_value(true);
372 return true; 361 return aggressive_unboxing();
373 } 362 }
374 return false; 363 return false;
375 } 364 }
376 365
377 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link 366 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
469 ciKlass* speculative_receiver_type = NULL; 458 ciKlass* speculative_receiver_type = NULL;
470 if (is_virtual_or_interface) { 459 if (is_virtual_or_interface) {
471 Node* receiver_node = stack(sp() - nargs); 460 Node* receiver_node = stack(sp() - nargs);
472 const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr(); 461 const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr();
473 // call_does_dispatch and vtable_index are out-parameters. They might be changed. 462 // call_does_dispatch and vtable_index are out-parameters. They might be changed.
474 callee = C->optimize_virtual_call(method(), bci(), klass, orig_callee, receiver_type, 463 // For arrays, klass below is Object. When vtable calls are used,
475 is_virtual, 464 // resolving the call with Object would allow an illegal call to
465 // finalize() on an array. We use holder instead: illegal calls to
466 // finalize() won't be compiled as vtable calls (IC call
467 // resolution will catch the illegal call) and the few legal calls
468 // on array types won't be either.
469 callee = C->optimize_virtual_call(method(), bci(), klass, holder, orig_callee,
470 receiver_type, is_virtual,
476 call_does_dispatch, vtable_index); // out-parameters 471 call_does_dispatch, vtable_index); // out-parameters
477 speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL; 472 speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL;
478 } 473 }
479 474
480 // Note: It's OK to try to inline a virtual call. 475 // Note: It's OK to try to inline a virtual call.
946 } 941 }
947 #endif //PRODUCT 942 #endif //PRODUCT
948 943
949 944
950 ciMethod* Compile::optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass, 945 ciMethod* Compile::optimize_virtual_call(ciMethod* caller, int bci, ciInstanceKlass* klass,
951 ciMethod* callee, const TypeOopPtr* receiver_type, 946 ciKlass* holder, ciMethod* callee,
952 bool is_virtual, 947 const TypeOopPtr* receiver_type, bool is_virtual,
953 bool& call_does_dispatch, int& vtable_index) { 948 bool& call_does_dispatch, int& vtable_index) {
954 // Set default values for out-parameters. 949 // Set default values for out-parameters.
955 call_does_dispatch = true; 950 call_does_dispatch = true;
956 vtable_index = Method::invalid_vtable_index; 951 vtable_index = Method::invalid_vtable_index;
957 952
962 if (optimized_virtual_method != NULL) { 957 if (optimized_virtual_method != NULL) {
963 callee = optimized_virtual_method; 958 callee = optimized_virtual_method;
964 call_does_dispatch = false; 959 call_does_dispatch = false;
965 } else if (!UseInlineCaches && is_virtual && callee->is_loaded()) { 960 } else if (!UseInlineCaches && is_virtual && callee->is_loaded()) {
966 // We can make a vtable call at this site 961 // We can make a vtable call at this site
967 vtable_index = callee->resolve_vtable_index(caller->holder(), klass); 962 vtable_index = callee->resolve_vtable_index(caller->holder(), holder);
968 } 963 }
969 return callee; 964 return callee;
970 } 965 }
971 966
972 // Identify possible target method and inlining style 967 // Identify possible target method and inlining style
985 // Attempt to improve the receiver 980 // Attempt to improve the receiver
986 bool actual_receiver_is_exact = false; 981 bool actual_receiver_is_exact = false;
987 ciInstanceKlass* actual_receiver = klass; 982 ciInstanceKlass* actual_receiver = klass;
988 if (receiver_type != NULL) { 983 if (receiver_type != NULL) {
989 // Array methods are all inherited from Object, and are monomorphic. 984 // Array methods are all inherited from Object, and are monomorphic.
985 // finalize() call on array is not allowed.
990 if (receiver_type->isa_aryptr() && 986 if (receiver_type->isa_aryptr() &&
991 callee->holder() == env()->Object_klass()) { 987 callee->holder() == env()->Object_klass() &&
988 callee->name() != ciSymbol::finalize_method_name()) {
992 return callee; 989 return callee;
993 } 990 }
994 991
995 // All other interesting cases are instance klasses. 992 // All other interesting cases are instance klasses.
996 if (!receiver_type->isa_instptr()) { 993 if (!receiver_type->isa_instptr()) {