annotate src/share/vm/opto/parseHelper.cpp @ 10278:6f3fd5150b67

6934604: enable parts of EliminateAutoBox by default Summary: Resurrected autobox elimination code and enabled part of it by default. Reviewed-by: roland, twisti
author kvn
date Wed, 08 May 2013 15:08:01 -0700
parents aeaca88565e6
children c775af091fe9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1206
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1206
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1206
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
26 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
27 #include "compiler/compileLog.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
28 #include "oops/objArrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
29 #include "opto/addnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
30 #include "opto/memnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
31 #include "opto/mulnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
32 #include "opto/parse.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
33 #include "opto/rootnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
34 #include "opto/runtime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1746
diff changeset
35 #include "runtime/sharedRuntime.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //------------------------------make_dtrace_method_entry_exit ----------------
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Dtrace -- record entry or exit of a method if compiled with dtrace support
a61af66fc99e Initial load
duke
parents:
diff changeset
39 void GraphKit::make_dtrace_method_entry_exit(ciMethod* method, bool is_entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 const TypeFunc *call_type = OptoRuntime::dtrace_method_entry_exit_Type();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 address call_address = is_entry ? CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry) :
a61af66fc99e Initial load
duke
parents:
diff changeset
42 CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 const char *call_name = is_entry ? "dtrace_method_entry" : "dtrace_method_exit";
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Get base of thread-local storage area
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
46 Node* thread = _gvn.transform( new (C) ThreadLocalNode() );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Get method
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
49 const TypePtr* method_type = TypeMetadataPtr::make(method);
164
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
50 Node *method_node = _gvn.transform( ConNode::make(C, method_type) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // For some reason, this call reads only raw memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 make_runtime_call(RC_LEAF | RC_NARROW_MEM,
a61af66fc99e Initial load
duke
parents:
diff changeset
57 call_type, call_address,
a61af66fc99e Initial load
duke
parents:
diff changeset
58 call_name, raw_adr_type,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 thread, method_node);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
64 //------------------------------do_checkcast-----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void Parse::do_checkcast() {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 bool will_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 ciKlass* klass = iter().get_klass(will_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 Node *obj = peek();
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Throw uncommon trap if class is not loaded or the value we are casting
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // _from_ is not loaded, and value is not null. If the value _is_ NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // then the checkcast does nothing.
4823
9a28ddfc1f4a 7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents: 4771
diff changeset
74 const TypeOopPtr *tp = _gvn.type(obj)->isa_oopptr();
9a28ddfc1f4a 7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents: 4771
diff changeset
75 if (!will_link || (tp && tp->klass() && !tp->klass()->is_loaded())) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (C->log() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 if (!will_link) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 C->log()->elem("assert_null reason='checkcast' klass='%d'",
a61af66fc99e Initial load
duke
parents:
diff changeset
79 C->log()->identify(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
4823
9a28ddfc1f4a 7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents: 4771
diff changeset
81 if (tp && tp->klass() && !tp->klass()->is_loaded()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // %%% Cannot happen?
a61af66fc99e Initial load
duke
parents:
diff changeset
83 C->log()->elem("assert_null reason='checkcast source' klass='%d'",
a61af66fc99e Initial load
duke
parents:
diff changeset
84 C->log()->identify(tp->klass()));
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
7194
beebba0acc11 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 6831
diff changeset
87 null_assert(obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if (!stopped()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 profile_null_checkcast();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Node *res = gen_checkcast(obj, makecon(TypeKlassPtr::make(klass)) );
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Pop from stack AFTER gen_checkcast because it can uncommon trap and
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // the debug info has to be correct.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
100 push(res);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 //------------------------------do_instanceof----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void Parse::do_instanceof() {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 if (stopped()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // We would like to return false if class is not loaded, emitting a
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // dependency, but Java requires instanceof to load its operand.
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Throw uncommon trap if class is not loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
111 bool will_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 ciKlass* klass = iter().get_klass(will_link);
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (!will_link) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (C->log() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 C->log()->elem("assert_null reason='instanceof' klass='%d'",
a61af66fc99e Initial load
duke
parents:
diff changeset
117 C->log()->identify(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
7194
beebba0acc11 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 6831
diff changeset
119 null_assert(peek());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
120 assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (!stopped()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // The object is now known to be null.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Shortcut the effect of gen_instanceof and return "false" directly.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 pop(); // pop the null
a61af66fc99e Initial load
duke
parents:
diff changeset
125 push(_gvn.intcon(0)); // push false answer
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Push the bool result back on stack
1746
4b29a725c43c 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 1645
diff changeset
131 Node* res = gen_instanceof(peek(), makecon(TypeKlassPtr::make(klass)));
4b29a725c43c 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 1645
diff changeset
132
4b29a725c43c 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 1645
diff changeset
133 // Pop from stack AFTER gen_instanceof because it can uncommon trap.
4b29a725c43c 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 1645
diff changeset
134 pop();
4b29a725c43c 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 1645
diff changeset
135 push(res);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 //------------------------------array_store_check------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // pull array from stack and check that the store is valid
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void Parse::array_store_check() {
a61af66fc99e Initial load
duke
parents:
diff changeset
141
7194
beebba0acc11 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 6831
diff changeset
142 // Shorthand access to array store elements without popping them.
beebba0acc11 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 6831
diff changeset
143 Node *obj = peek(0);
beebba0acc11 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 6831
diff changeset
144 Node *idx = peek(1);
beebba0acc11 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 6831
diff changeset
145 Node *ary = peek(2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (_gvn.type(obj) == TypePtr::NULL_PTR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // There's never a type check on null values.
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // This cutout lets us avoid the uncommon_trap(Reason_array_check)
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // below, which turns into a performance liability if the
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // gen_checkcast folds up completely.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Extract the array klass type
a61af66fc99e Initial load
duke
parents:
diff changeset
156 int klass_offset = oopDesc::klass_offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 Node* p = basic_plus_adr( ary, ary, klass_offset );
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // p's type is array-of-OOPS plus klass_offset
164
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
159 Node* array_klass = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Get the array klass
a61af66fc99e Initial load
duke
parents:
diff changeset
161 const TypeKlassPtr *tak = _gvn.type(array_klass)->is_klassptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // array_klass's type is generally INexact array-of-oop. Heroically
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // cast the array klass to EXACT array and uncommon-trap if the cast
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // fails.
a61af66fc99e Initial load
duke
parents:
diff changeset
166 bool always_see_exact_class = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 if (MonomorphicArrayCheck
a61af66fc99e Initial load
duke
parents:
diff changeset
168 && !too_many_traps(Deoptimization::Reason_array_check)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 always_see_exact_class = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // (If no MDO at all, hope for the best, until a trap actually occurs.)
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Is the array klass is exactly its defined type?
a61af66fc99e Initial load
duke
parents:
diff changeset
174 if (always_see_exact_class && !tak->klass_is_exact()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // Make a constant out of the inexact array klass
a61af66fc99e Initial load
duke
parents:
diff changeset
176 const TypeKlassPtr *extak = tak->cast_to_exactness(true)->is_klassptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 Node* con = makecon(extak);
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
178 Node* cmp = _gvn.transform(new (C) CmpPNode( array_klass, con ));
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
179 Node* bol = _gvn.transform(new (C) BoolNode( cmp, BoolTest::eq ));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Node* ctrl= control();
a61af66fc99e Initial load
duke
parents:
diff changeset
181 { BuildCutout unless(this, bol, PROB_MAX);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 uncommon_trap(Deoptimization::Reason_array_check,
a61af66fc99e Initial load
duke
parents:
diff changeset
183 Deoptimization::Action_maybe_recompile,
a61af66fc99e Initial load
duke
parents:
diff changeset
184 tak->klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (stopped()) { // MUST uncommon-trap?
a61af66fc99e Initial load
duke
parents:
diff changeset
187 set_control(ctrl); // Then Don't Do It, just fall into the normal checking
a61af66fc99e Initial load
duke
parents:
diff changeset
188 } else { // Cast array klass to exactness:
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // Use the exact constant value we know it is.
a61af66fc99e Initial load
duke
parents:
diff changeset
190 replace_in_map(array_klass,con);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 CompileLog* log = C->log();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (log != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 log->elem("cast_up reason='monomorphic_array' from='%d' to='(exact)'",
a61af66fc99e Initial load
duke
parents:
diff changeset
194 log->identify(tak->klass()));
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 array_klass = con; // Use cast value moving forward
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // Come here for polymorphic array klasses
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // Extract the array element class
6831
d8ce2825b193 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 6804
diff changeset
203 int element_klass_offset = in_bytes(ObjArrayKlass::element_klass_offset());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
204 Node *p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset);
164
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
205 Node *a_e_klass = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p2, tak) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // Check (the hard way) and throw if not a subklass.
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Result is ignored, we just need the CFG effects.
a61af66fc99e Initial load
duke
parents:
diff changeset
209 gen_checkcast( obj, a_e_klass );
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
213 void Parse::emit_guard_for_new(ciInstanceKlass* klass) {
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
214 // Emit guarded new
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
215 // if (klass->_init_thread != current_thread ||
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
216 // klass->_init_state != being_initialized)
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
217 // uncommon_trap
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
218 Node* cur_thread = _gvn.transform( new (C) ThreadLocalNode() );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
219 Node* merge = new (C) RegionNode(3);
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
220 _gvn.set_type(merge, Type::CONTROL);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
221 Node* kls = makecon(TypeKlassPtr::make(klass));
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
222
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
223 Node* init_thread_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_thread_offset()));
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
224 Node* adr_node = basic_plus_adr(kls, kls, init_thread_offset);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
225 Node* init_thread = make_load(NULL, adr_node, TypeRawPtr::BOTTOM, T_ADDRESS);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
226 Node *tst = Bool( CmpP( init_thread, cur_thread), BoolTest::eq);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
227 IfNode* iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
228 set_control(IfTrue(iff));
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
229 merge->set_req(1, IfFalse(iff));
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
230
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
231 Node* init_state_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_state_offset()));
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
232 adr_node = basic_plus_adr(kls, kls, init_state_offset);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
233 // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler
4739
52b5d32fbfaf 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 1972
diff changeset
234 // can generate code to load it as unsigned byte.
52b5d32fbfaf 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 1972
diff changeset
235 Node* init_state = make_load(NULL, adr_node, TypeInt::UBYTE, T_BOOLEAN);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
236 Node* being_init = _gvn.intcon(InstanceKlass::being_initialized);
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
237 tst = Bool( CmpI( init_state, being_init), BoolTest::eq);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
238 iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
239 set_control(IfTrue(iff));
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
240 merge->set_req(2, IfFalse(iff));
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
241
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
242 PreserveJVMState pjvms(this);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
243 record_for_igvn(merge);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
244 set_control(merge);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
245
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
246 uncommon_trap(Deoptimization::Reason_uninitialized,
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
247 Deoptimization::Action_reinterpret,
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
248 klass);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
249 }
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
250
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
251
0
a61af66fc99e Initial load
duke
parents:
diff changeset
252 //------------------------------do_new-----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
253 void Parse::do_new() {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 bool will_link;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 ciInstanceKlass* klass = iter().get_klass(will_link)->as_instance_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
258 assert(will_link, "_new: typeflow responsibility");
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // Should initialize, or throw an InstantiationError?
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
261 if (!klass->is_initialized() && !klass->is_being_initialized() ||
0
a61af66fc99e Initial load
duke
parents:
diff changeset
262 klass->is_abstract() || klass->is_interface() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
263 klass->name() == ciSymbol::java_lang_Class() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
264 iter().is_unresolved_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 uncommon_trap(Deoptimization::Reason_uninitialized,
a61af66fc99e Initial load
duke
parents:
diff changeset
266 Deoptimization::Action_reinterpret,
a61af66fc99e Initial load
duke
parents:
diff changeset
267 klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
270 if (klass->is_being_initialized()) {
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
271 emit_guard_for_new(klass);
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1552
diff changeset
272 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 Node* kls = makecon(TypeKlassPtr::make(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
275 Node* obj = new_instance(kls);
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // Push resultant oop onto stack
a61af66fc99e Initial load
duke
parents:
diff changeset
278 push(obj);
1080
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
279
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
280 // Keep track of whether opportunities exist for StringBuilder
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
281 // optimizations.
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
282 if (OptimizeStringConcat &&
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
283 (klass == C->env()->StringBuilder_klass() ||
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
284 klass == C->env()->StringBuffer_klass())) {
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
285 C->set_has_stringbuilder(true);
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 844
diff changeset
286 }
10278
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 10105
diff changeset
287
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 10105
diff changeset
288 // Keep track of boxed values for EliminateAutoBox optimizations.
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 10105
diff changeset
289 if (C->eliminate_boxing() && klass->is_box_klass()) {
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 10105
diff changeset
290 C->set_has_boxed_value(true);
6f3fd5150b67 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 10105
diff changeset
291 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
295 //------------------------------dump_map_adr_mem-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // Debug dump of the mapping from address types to MergeMemNode indices.
a61af66fc99e Initial load
duke
parents:
diff changeset
297 void Parse::dump_map_adr_mem() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 tty->print_cr("--- Mapping from address types to memory Nodes ---");
a61af66fc99e Initial load
duke
parents:
diff changeset
299 MergeMemNode *mem = map() == NULL ? NULL : (map()->memory()->is_MergeMem() ?
a61af66fc99e Initial load
duke
parents:
diff changeset
300 map()->memory()->as_MergeMem() : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 for (uint i = 0; i < (uint)C->num_alias_types(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 C->alias_type(i)->print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 tty->print("\t");
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // Node mapping, if any
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if (mem && i < mem->req() && mem->in(i) && mem->in(i) != mem->empty_memory()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 mem->in(i)->dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
307 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
317 //
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // parser methods for profiling
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 //----------------------test_counter_against_threshold ------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
322 void Parse::test_counter_against_threshold(Node* cnt, int limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // Test the counter against the limit and uncommon trap if greater.
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // This code is largely copied from the range check code in
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // array_addressing()
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // Test invocation count vs threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
329 Node *threshold = makecon(TypeInt::make(limit));
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
330 Node *chk = _gvn.transform( new (C) CmpUNode( cnt, threshold) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
331 BoolTest::mask btest = BoolTest::lt;
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
332 Node *tst = _gvn.transform( new (C) BoolNode( chk, btest) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // Branch to failure if threshold exceeded
a61af66fc99e Initial load
duke
parents:
diff changeset
334 { BuildCutout unless(this, tst, PROB_ALWAYS);
a61af66fc99e Initial load
duke
parents:
diff changeset
335 uncommon_trap(Deoptimization::Reason_age,
a61af66fc99e Initial load
duke
parents:
diff changeset
336 Deoptimization::Action_maybe_recompile);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 //----------------------increment_and_test_invocation_counter-------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
341 void Parse::increment_and_test_invocation_counter(int limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 if (!count_invocations()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
343
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
344 // Get the Method* node.
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
345 ciMethod* m = method();
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
346 address counters_adr = m->ensure_method_counters();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
347
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
348 Node* ctrl = control();
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
349 const TypePtr* adr_type = TypeRawPtr::make(counters_adr);
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
350 Node *counters_node = makecon(adr_type);
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
351 Node* adr_iic_node = basic_plus_adr(counters_node, counters_node,
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
352 MethodCounters::interpreter_invocation_counter_offset_in_bytes());
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
353 Node* cnt = make_load(ctrl, adr_iic_node, TypeInt::INT, T_INT, adr_type);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 test_counter_against_threshold(cnt, limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // Add one to the counter and store
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
358 Node* incr = _gvn.transform(new (C) AddINode(cnt, _gvn.intcon(1)));
10105
aeaca88565e6 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 7194
diff changeset
359 store_to_memory( ctrl, adr_iic_node, incr, T_INT, adr_type );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 //----------------------------method_data_addressing---------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
363 Node* Parse::method_data_addressing(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, Node* idx, uint stride) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
364 // Get offset within MethodData* of the data array
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
365 ByteSize data_offset = MethodData::data_offset();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // Get cell offset of the ProfileData within data array
a61af66fc99e Initial load
duke
parents:
diff changeset
368 int cell_offset = md->dp_to_di(data->dp());
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // Add in counter_offset, the # of bytes into the ProfileData of counter or flag
a61af66fc99e Initial load
duke
parents:
diff changeset
371 int offset = in_bytes(data_offset) + cell_offset + in_bytes(counter_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
372
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 4823
diff changeset
373 const TypePtr* adr_type = TypeMetadataPtr::make(md);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
374 Node* mdo = makecon(adr_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 Node* ptr = basic_plus_adr(mdo, mdo, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 if (stride != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
378 Node* str = _gvn.MakeConX(stride);
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
379 Node* scale = _gvn.transform( new (C) MulXNode( idx, str ) );
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
380 ptr = _gvn.transform( new (C) AddPNode( mdo, ptr, scale ) );
0
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 return ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 //--------------------------increment_md_counter_at----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
387 void Parse::increment_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, Node* idx, uint stride) {
a61af66fc99e Initial load
duke
parents:
diff changeset
388 Node* adr_node = method_data_addressing(md, data, counter_offset, idx, stride);
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390 const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
391 Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type);
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
392 Node* incr = _gvn.transform(new (C) AddINode(cnt, _gvn.intcon(DataLayout::counter_increment)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
393 store_to_memory(NULL, adr_node, incr, T_INT, adr_type );
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396 //--------------------------test_for_osr_md_counter_at-------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
397 void Parse::test_for_osr_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, int limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 Node* adr_node = method_data_addressing(md, data, counter_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
401 Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 test_counter_against_threshold(cnt, limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 //-------------------------------set_md_flag_at--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
407 void Parse::set_md_flag_at(ciMethodData* md, ciProfileData* data, int flag_constant) {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 Node* adr_node = method_data_addressing(md, data, DataLayout::flags_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
411 Node* flags = make_load(NULL, adr_node, TypeInt::BYTE, T_BYTE, adr_type);
6804
e626685e9f6c 7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents: 6725
diff changeset
412 Node* incr = _gvn.transform(new (C) OrINode(flags, _gvn.intcon(flag_constant)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
413 store_to_memory(NULL, adr_node, incr, T_BYTE, adr_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 //----------------------------profile_taken_branch-----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
417 void Parse::profile_taken_branch(int target_bci, bool force_update) {
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // This is a potential osr_site if we have a backedge.
a61af66fc99e Initial load
duke
parents:
diff changeset
419 int cur_bci = bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
420 bool osr_site =
a61af66fc99e Initial load
duke
parents:
diff changeset
421 (target_bci <= cur_bci) && count_invocations() && UseOnStackReplacement;
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // If we are going to OSR, restart at the target bytecode.
a61af66fc99e Initial load
duke
parents:
diff changeset
424 set_bci(target_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 // To do: factor out the the limit calculations below. These duplicate
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // the similar limit calculations in the interpreter.
a61af66fc99e Initial load
duke
parents:
diff changeset
428
a61af66fc99e Initial load
duke
parents:
diff changeset
429 if (method_data_update() || force_update) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 assert(md != NULL, "expected valid ciMethodData");
a61af66fc99e Initial load
duke
parents:
diff changeset
432 ciProfileData* data = md->bci_to_data(cur_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 assert(data->is_JumpData(), "need JumpData for taken branch");
a61af66fc99e Initial load
duke
parents:
diff changeset
434 increment_md_counter_at(md, data, JumpData::taken_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 // In the new tiered system this is all we need to do. In the old
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // (c2 based) tiered sytem we must do the code below.
a61af66fc99e Initial load
duke
parents:
diff changeset
439 #ifndef TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
440 if (method_data_update()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
442 if (osr_site) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 ciProfileData* data = md->bci_to_data(cur_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
444 int limit = (CompileThreshold
a61af66fc99e Initial load
duke
parents:
diff changeset
445 * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
a61af66fc99e Initial load
duke
parents:
diff changeset
446 test_for_osr_md_counter_at(md, data, JumpData::taken_offset(), limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // With method data update off, use the invocation counter to trigger an
a61af66fc99e Initial load
duke
parents:
diff changeset
450 // OSR compilation, as done in the interpreter.
a61af66fc99e Initial load
duke
parents:
diff changeset
451 if (osr_site) {
a61af66fc99e Initial load
duke
parents:
diff changeset
452 int limit = (CompileThreshold * OnStackReplacePercentage) / 100;
a61af66fc99e Initial load
duke
parents:
diff changeset
453 increment_and_test_invocation_counter(limit);
a61af66fc99e Initial load
duke
parents:
diff changeset
454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456 #endif // TIERED
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // Restore the original bytecode.
a61af66fc99e Initial load
duke
parents:
diff changeset
459 set_bci(cur_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 //--------------------------profile_not_taken_branch---------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
463 void Parse::profile_not_taken_branch(bool force_update) {
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 if (method_data_update() || force_update) {
a61af66fc99e Initial load
duke
parents:
diff changeset
466 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
467 assert(md != NULL, "expected valid ciMethodData");
a61af66fc99e Initial load
duke
parents:
diff changeset
468 ciProfileData* data = md->bci_to_data(bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
469 assert(data->is_BranchData(), "need BranchData for not taken branch");
a61af66fc99e Initial load
duke
parents:
diff changeset
470 increment_md_counter_at(md, data, BranchData::not_taken_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 }
a61af66fc99e Initial load
duke
parents:
diff changeset
474
a61af66fc99e Initial load
duke
parents:
diff changeset
475 //---------------------------------profile_call--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
476 void Parse::profile_call(Node* receiver) {
a61af66fc99e Initial load
duke
parents:
diff changeset
477 if (!method_data_update()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 switch (bc()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 case Bytecodes::_invokevirtual:
a61af66fc99e Initial load
duke
parents:
diff changeset
481 case Bytecodes::_invokeinterface:
a61af66fc99e Initial load
duke
parents:
diff changeset
482 profile_receiver_type(receiver);
a61af66fc99e Initial load
duke
parents:
diff changeset
483 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
484 case Bytecodes::_invokestatic:
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 196
diff changeset
485 case Bytecodes::_invokedynamic:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
486 case Bytecodes::_invokespecial:
1206
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1080
diff changeset
487 profile_generic_call();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
488 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
489 default: fatal("unexpected call bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
491 }
a61af66fc99e Initial load
duke
parents:
diff changeset
492
a61af66fc99e Initial load
duke
parents:
diff changeset
493 //------------------------------profile_generic_call---------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
494 void Parse::profile_generic_call() {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 assert(method_data_update(), "must be generating profile code");
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
498 assert(md != NULL, "expected valid ciMethodData");
a61af66fc99e Initial load
duke
parents:
diff changeset
499 ciProfileData* data = md->bci_to_data(bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
500 assert(data->is_CounterData(), "need CounterData for not taken branch");
a61af66fc99e Initial load
duke
parents:
diff changeset
501 increment_md_counter_at(md, data, CounterData::count_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 //-----------------------------profile_receiver_type---------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
505 void Parse::profile_receiver_type(Node* receiver) {
a61af66fc99e Initial load
duke
parents:
diff changeset
506 assert(method_data_update(), "must be generating profile code");
a61af66fc99e Initial load
duke
parents:
diff changeset
507
a61af66fc99e Initial load
duke
parents:
diff changeset
508 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
509 assert(md != NULL, "expected valid ciMethodData");
a61af66fc99e Initial load
duke
parents:
diff changeset
510 ciProfileData* data = md->bci_to_data(bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
511 assert(data->is_ReceiverTypeData(), "need ReceiverTypeData here");
1206
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1080
diff changeset
512
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1080
diff changeset
513 // Skip if we aren't tracking receivers
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1080
diff changeset
514 if (TypeProfileWidth < 1) {
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1080
diff changeset
515 increment_md_counter_at(md, data, CounterData::count_offset());
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1080
diff changeset
516 return;
87684f1a88b5 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 1080
diff changeset
517 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
518 ciReceiverTypeData* rdata = (ciReceiverTypeData*)data->as_ReceiverTypeData();
a61af66fc99e Initial load
duke
parents:
diff changeset
519
a61af66fc99e Initial load
duke
parents:
diff changeset
520 Node* method_data = method_data_addressing(md, rdata, in_ByteSize(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
521
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // Using an adr_type of TypePtr::BOTTOM to work around anti-dep problems.
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // A better solution might be to use TypeRawPtr::BOTTOM with RC_NARROW_MEM.
a61af66fc99e Initial load
duke
parents:
diff changeset
524 make_runtime_call(RC_LEAF, OptoRuntime::profile_receiver_type_Type(),
a61af66fc99e Initial load
duke
parents:
diff changeset
525 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
526 OptoRuntime::profile_receiver_type_C),
a61af66fc99e Initial load
duke
parents:
diff changeset
527 "profile_receiver_type_C",
a61af66fc99e Initial load
duke
parents:
diff changeset
528 TypePtr::BOTTOM,
a61af66fc99e Initial load
duke
parents:
diff changeset
529 method_data, receiver);
a61af66fc99e Initial load
duke
parents:
diff changeset
530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 //---------------------------------profile_ret---------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
533 void Parse::profile_ret(int target_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 if (!method_data_update()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
535
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // Skip if we aren't tracking ret targets
a61af66fc99e Initial load
duke
parents:
diff changeset
537 if (TypeProfileWidth < 1) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
538
a61af66fc99e Initial load
duke
parents:
diff changeset
539 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
540 assert(md != NULL, "expected valid ciMethodData");
a61af66fc99e Initial load
duke
parents:
diff changeset
541 ciProfileData* data = md->bci_to_data(bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
542 assert(data->is_RetData(), "need RetData for ret");
a61af66fc99e Initial load
duke
parents:
diff changeset
543 ciRetData* ret_data = (ciRetData*)data->as_RetData();
a61af66fc99e Initial load
duke
parents:
diff changeset
544
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // Look for the target_bci is already in the table
a61af66fc99e Initial load
duke
parents:
diff changeset
546 uint row;
a61af66fc99e Initial load
duke
parents:
diff changeset
547 bool table_full = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
548 for (row = 0; row < ret_data->row_limit(); row++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
549 int key = ret_data->bci(row);
a61af66fc99e Initial load
duke
parents:
diff changeset
550 table_full &= (key != RetData::no_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
551 if (key == target_bci) break;
a61af66fc99e Initial load
duke
parents:
diff changeset
552 }
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 if (row >= ret_data->row_limit()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
555 // The target_bci was not found in the table.
a61af66fc99e Initial load
duke
parents:
diff changeset
556 if (!table_full) {
a61af66fc99e Initial load
duke
parents:
diff changeset
557 // XXX: Make slow call to update RetData
a61af66fc99e Initial load
duke
parents:
diff changeset
558 }
a61af66fc99e Initial load
duke
parents:
diff changeset
559 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
561
a61af66fc99e Initial load
duke
parents:
diff changeset
562 // the target_bci is already in the table
a61af66fc99e Initial load
duke
parents:
diff changeset
563 increment_md_counter_at(md, data, RetData::bci_count_offset(row));
a61af66fc99e Initial load
duke
parents:
diff changeset
564 }
a61af66fc99e Initial load
duke
parents:
diff changeset
565
a61af66fc99e Initial load
duke
parents:
diff changeset
566 //--------------------------profile_null_checkcast----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
567 void Parse::profile_null_checkcast() {
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // Set the null-seen flag, done in conjunction with the usual null check. We
a61af66fc99e Initial load
duke
parents:
diff changeset
569 // never unset the flag, so this is a one-way switch.
a61af66fc99e Initial load
duke
parents:
diff changeset
570 if (!method_data_update()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
573 assert(md != NULL, "expected valid ciMethodData");
a61af66fc99e Initial load
duke
parents:
diff changeset
574 ciProfileData* data = md->bci_to_data(bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
575 assert(data->is_BitData(), "need BitData for checkcast");
a61af66fc99e Initial load
duke
parents:
diff changeset
576 set_md_flag_at(md, data, BitData::null_seen_byte_constant());
a61af66fc99e Initial load
duke
parents:
diff changeset
577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
578
a61af66fc99e Initial load
duke
parents:
diff changeset
579 //-----------------------------profile_switch_case-----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
580 void Parse::profile_switch_case(int table_index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
581 if (!method_data_update()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
582
a61af66fc99e Initial load
duke
parents:
diff changeset
583 ciMethodData* md = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
584 assert(md != NULL, "expected valid ciMethodData");
a61af66fc99e Initial load
duke
parents:
diff changeset
585
a61af66fc99e Initial load
duke
parents:
diff changeset
586 ciProfileData* data = md->bci_to_data(bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
587 assert(data->is_MultiBranchData(), "need MultiBranchData for switch case");
a61af66fc99e Initial load
duke
parents:
diff changeset
588 if (table_index >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
589 increment_md_counter_at(md, data, MultiBranchData::case_count_offset(table_index));
a61af66fc99e Initial load
duke
parents:
diff changeset
590 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
591 increment_md_counter_at(md, data, MultiBranchData::default_count_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
593 }