Mercurial > hg > truffle
annotate src/share/vm/c1/c1_Instruction.hpp @ 1604:b918d354830a
6960865: ldc of unloaded class throws an assert in ciTypeFlow
Summary: Support java_mirror for unloaded klasses, arrays as well as instances. Simplify ciTypeFlow by removing unused path.
Reviewed-by: kvn
author | jrose |
---|---|
date | Sat, 12 Jun 2010 22:53:43 -0700 |
parents | b812ff5abc73 |
children | d5d065957597 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1378
diff
changeset
|
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1378
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1378
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:
1378
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // Predefined classes | |
26 class ciField; | |
27 class ValueStack; | |
28 class InstructionPrinter; | |
29 class IRScope; | |
30 class LIR_OprDesc; | |
31 typedef LIR_OprDesc* LIR_Opr; | |
32 | |
33 | |
34 // Instruction class hierarchy | |
35 // | |
36 // All leaf classes in the class hierarchy are concrete classes | |
37 // (i.e., are instantiated). All other classes are abstract and | |
38 // serve factoring. | |
39 | |
40 class Instruction; | |
41 class HiWord; | |
42 class Phi; | |
43 class Local; | |
44 class Constant; | |
45 class AccessField; | |
46 class LoadField; | |
47 class StoreField; | |
48 class AccessArray; | |
49 class ArrayLength; | |
50 class AccessIndexed; | |
51 class LoadIndexed; | |
52 class StoreIndexed; | |
53 class NegateOp; | |
54 class Op2; | |
55 class ArithmeticOp; | |
56 class ShiftOp; | |
57 class LogicOp; | |
58 class CompareOp; | |
59 class IfOp; | |
60 class Convert; | |
61 class NullCheck; | |
62 class OsrEntry; | |
63 class ExceptionObject; | |
64 class StateSplit; | |
65 class Invoke; | |
66 class NewInstance; | |
67 class NewArray; | |
68 class NewTypeArray; | |
69 class NewObjectArray; | |
70 class NewMultiArray; | |
71 class TypeCheck; | |
72 class CheckCast; | |
73 class InstanceOf; | |
74 class AccessMonitor; | |
75 class MonitorEnter; | |
76 class MonitorExit; | |
77 class Intrinsic; | |
78 class BlockBegin; | |
79 class BlockEnd; | |
80 class Goto; | |
81 class If; | |
82 class IfInstanceOf; | |
83 class Switch; | |
84 class TableSwitch; | |
85 class LookupSwitch; | |
86 class Return; | |
87 class Throw; | |
88 class Base; | |
89 class RoundFP; | |
90 class UnsafeOp; | |
91 class UnsafeRawOp; | |
92 class UnsafeGetRaw; | |
93 class UnsafePutRaw; | |
94 class UnsafeObjectOp; | |
95 class UnsafeGetObject; | |
96 class UnsafePutObject; | |
97 class UnsafePrefetch; | |
98 class UnsafePrefetchRead; | |
99 class UnsafePrefetchWrite; | |
100 class ProfileCall; | |
101 class ProfileCounter; | |
102 | |
103 // A Value is a reference to the instruction creating the value | |
104 typedef Instruction* Value; | |
105 define_array(ValueArray, Value) | |
106 define_stack(Values, ValueArray) | |
107 | |
108 define_array(ValueStackArray, ValueStack*) | |
109 define_stack(ValueStackStack, ValueStackArray) | |
110 | |
111 // BlockClosure is the base class for block traversal/iteration. | |
112 | |
113 class BlockClosure: public CompilationResourceObj { | |
114 public: | |
115 virtual void block_do(BlockBegin* block) = 0; | |
116 }; | |
117 | |
118 | |
1584 | 119 // A simple closure class for visiting the values of an Instruction |
120 class ValueVisitor: public StackObj { | |
121 public: | |
122 virtual void visit(Value* v) = 0; | |
123 }; | |
124 | |
125 | |
0 | 126 // Some array and list classes |
127 define_array(BlockBeginArray, BlockBegin*) | |
128 define_stack(_BlockList, BlockBeginArray) | |
129 | |
130 class BlockList: public _BlockList { | |
131 public: | |
132 BlockList(): _BlockList() {} | |
133 BlockList(const int size): _BlockList(size) {} | |
134 BlockList(const int size, BlockBegin* init): _BlockList(size, init) {} | |
135 | |
136 void iterate_forward(BlockClosure* closure); | |
137 void iterate_backward(BlockClosure* closure); | |
138 void blocks_do(void f(BlockBegin*)); | |
1584 | 139 void values_do(ValueVisitor* f); |
0 | 140 void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN; |
141 }; | |
142 | |
143 | |
144 // InstructionVisitors provide type-based dispatch for instructions. | |
145 // For each concrete Instruction class X, a virtual function do_X is | |
146 // provided. Functionality that needs to be implemented for all classes | |
147 // (e.g., printing, code generation) is factored out into a specialised | |
148 // visitor instead of added to the Instruction classes itself. | |
149 | |
150 class InstructionVisitor: public StackObj { | |
151 public: | |
152 void do_HiWord (HiWord* x) { ShouldNotReachHere(); } | |
153 virtual void do_Phi (Phi* x) = 0; | |
154 virtual void do_Local (Local* x) = 0; | |
155 virtual void do_Constant (Constant* x) = 0; | |
156 virtual void do_LoadField (LoadField* x) = 0; | |
157 virtual void do_StoreField (StoreField* x) = 0; | |
158 virtual void do_ArrayLength (ArrayLength* x) = 0; | |
159 virtual void do_LoadIndexed (LoadIndexed* x) = 0; | |
160 virtual void do_StoreIndexed (StoreIndexed* x) = 0; | |
161 virtual void do_NegateOp (NegateOp* x) = 0; | |
162 virtual void do_ArithmeticOp (ArithmeticOp* x) = 0; | |
163 virtual void do_ShiftOp (ShiftOp* x) = 0; | |
164 virtual void do_LogicOp (LogicOp* x) = 0; | |
165 virtual void do_CompareOp (CompareOp* x) = 0; | |
166 virtual void do_IfOp (IfOp* x) = 0; | |
167 virtual void do_Convert (Convert* x) = 0; | |
168 virtual void do_NullCheck (NullCheck* x) = 0; | |
169 virtual void do_Invoke (Invoke* x) = 0; | |
170 virtual void do_NewInstance (NewInstance* x) = 0; | |
171 virtual void do_NewTypeArray (NewTypeArray* x) = 0; | |
172 virtual void do_NewObjectArray (NewObjectArray* x) = 0; | |
173 virtual void do_NewMultiArray (NewMultiArray* x) = 0; | |
174 virtual void do_CheckCast (CheckCast* x) = 0; | |
175 virtual void do_InstanceOf (InstanceOf* x) = 0; | |
176 virtual void do_MonitorEnter (MonitorEnter* x) = 0; | |
177 virtual void do_MonitorExit (MonitorExit* x) = 0; | |
178 virtual void do_Intrinsic (Intrinsic* x) = 0; | |
179 virtual void do_BlockBegin (BlockBegin* x) = 0; | |
180 virtual void do_Goto (Goto* x) = 0; | |
181 virtual void do_If (If* x) = 0; | |
182 virtual void do_IfInstanceOf (IfInstanceOf* x) = 0; | |
183 virtual void do_TableSwitch (TableSwitch* x) = 0; | |
184 virtual void do_LookupSwitch (LookupSwitch* x) = 0; | |
185 virtual void do_Return (Return* x) = 0; | |
186 virtual void do_Throw (Throw* x) = 0; | |
187 virtual void do_Base (Base* x) = 0; | |
188 virtual void do_OsrEntry (OsrEntry* x) = 0; | |
189 virtual void do_ExceptionObject(ExceptionObject* x) = 0; | |
190 virtual void do_RoundFP (RoundFP* x) = 0; | |
191 virtual void do_UnsafeGetRaw (UnsafeGetRaw* x) = 0; | |
192 virtual void do_UnsafePutRaw (UnsafePutRaw* x) = 0; | |
193 virtual void do_UnsafeGetObject(UnsafeGetObject* x) = 0; | |
194 virtual void do_UnsafePutObject(UnsafePutObject* x) = 0; | |
195 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x) = 0; | |
196 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) = 0; | |
197 virtual void do_ProfileCall (ProfileCall* x) = 0; | |
198 virtual void do_ProfileCounter (ProfileCounter* x) = 0; | |
199 }; | |
200 | |
201 | |
202 // Hashing support | |
203 // | |
204 // Note: This hash functions affect the performance | |
205 // of ValueMap - make changes carefully! | |
206 | |
207 #define HASH1(x1 ) ((intx)(x1)) | |
208 #define HASH2(x1, x2 ) ((HASH1(x1 ) << 7) ^ HASH1(x2)) | |
209 #define HASH3(x1, x2, x3 ) ((HASH2(x1, x2 ) << 7) ^ HASH1(x3)) | |
210 #define HASH4(x1, x2, x3, x4) ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4)) | |
211 | |
212 | |
213 // The following macros are used to implement instruction-specific hashing. | |
214 // By default, each instruction implements hash() and is_equal(Value), used | |
215 // for value numbering/common subexpression elimination. The default imple- | |
216 // mentation disables value numbering. Each instruction which can be value- | |
217 // numbered, should define corresponding hash() and is_equal(Value) functions | |
218 // via the macros below. The f arguments specify all the values/op codes, etc. | |
219 // that need to be identical for two instructions to be identical. | |
220 // | |
221 // Note: The default implementation of hash() returns 0 in order to indicate | |
222 // that the instruction should not be considered for value numbering. | |
223 // The currently used hash functions do not guarantee that never a 0 | |
224 // is produced. While this is still correct, it may be a performance | |
225 // bug (no value numbering for that node). However, this situation is | |
226 // so unlikely, that we are not going to handle it specially. | |
227 | |
228 #define HASHING1(class_name, enabled, f1) \ | |
229 virtual intx hash() const { \ | |
230 return (enabled) ? HASH2(name(), f1) : 0; \ | |
231 } \ | |
232 virtual bool is_equal(Value v) const { \ | |
233 if (!(enabled) ) return false; \ | |
234 class_name* _v = v->as_##class_name(); \ | |
235 if (_v == NULL ) return false; \ | |
236 if (f1 != _v->f1) return false; \ | |
237 return true; \ | |
238 } \ | |
239 | |
240 | |
241 #define HASHING2(class_name, enabled, f1, f2) \ | |
242 virtual intx hash() const { \ | |
243 return (enabled) ? HASH3(name(), f1, f2) : 0; \ | |
244 } \ | |
245 virtual bool is_equal(Value v) const { \ | |
246 if (!(enabled) ) return false; \ | |
247 class_name* _v = v->as_##class_name(); \ | |
248 if (_v == NULL ) return false; \ | |
249 if (f1 != _v->f1) return false; \ | |
250 if (f2 != _v->f2) return false; \ | |
251 return true; \ | |
252 } \ | |
253 | |
254 | |
255 #define HASHING3(class_name, enabled, f1, f2, f3) \ | |
256 virtual intx hash() const { \ | |
257 return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \ | |
258 } \ | |
259 virtual bool is_equal(Value v) const { \ | |
260 if (!(enabled) ) return false; \ | |
261 class_name* _v = v->as_##class_name(); \ | |
262 if (_v == NULL ) return false; \ | |
263 if (f1 != _v->f1) return false; \ | |
264 if (f2 != _v->f2) return false; \ | |
265 if (f3 != _v->f3) return false; \ | |
266 return true; \ | |
267 } \ | |
268 | |
269 | |
270 // The mother of all instructions... | |
271 | |
272 class Instruction: public CompilationResourceObj { | |
273 private: | |
274 int _id; // the unique instruction id | |
275 int _bci; // the instruction bci | |
276 int _use_count; // the number of instructions refering to this value (w/o prev/next); only roots can have use count = 0 or > 1 | |
277 int _pin_state; // set of PinReason describing the reason for pinning | |
278 ValueType* _type; // the instruction value type | |
279 Instruction* _next; // the next instruction if any (NULL for BlockEnd instructions) | |
280 Instruction* _subst; // the substitution instruction if any | |
281 LIR_Opr _operand; // LIR specific information | |
282 unsigned int _flags; // Flag bits | |
283 | |
284 XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction | |
285 | |
286 #ifdef ASSERT | |
287 HiWord* _hi_word; | |
288 #endif | |
289 | |
290 friend class UseCountComputer; | |
1584 | 291 friend class BlockBegin; |
0 | 292 |
293 protected: | |
294 void set_bci(int bci) { assert(bci == SynchronizationEntryBCI || bci >= 0, "illegal bci"); _bci = bci; } | |
295 void set_type(ValueType* type) { | |
296 assert(type != NULL, "type must exist"); | |
297 _type = type; | |
298 } | |
299 | |
300 public: | |
1584 | 301 void* operator new(size_t size) { |
302 Compilation* c = Compilation::current(); | |
303 void* res = c->arena()->Amalloc(size); | |
304 ((Instruction*)res)->_id = c->get_next_id(); | |
305 return res; | |
306 } | |
307 | |
0 | 308 enum InstructionFlag { |
309 NeedsNullCheckFlag = 0, | |
310 CanTrapFlag, | |
311 DirectCompareFlag, | |
312 IsEliminatedFlag, | |
313 IsInitializedFlag, | |
314 IsLoadedFlag, | |
315 IsSafepointFlag, | |
316 IsStaticFlag, | |
317 IsStrictfpFlag, | |
318 NeedsStoreCheckFlag, | |
319 NeedsWriteBarrierFlag, | |
320 PreservesStateFlag, | |
321 TargetIsFinalFlag, | |
322 TargetIsLoadedFlag, | |
323 TargetIsStrictfpFlag, | |
324 UnorderedIsTrueFlag, | |
325 NeedsPatchingFlag, | |
326 ThrowIncompatibleClassChangeErrorFlag, | |
327 ProfileMDOFlag, | |
328 InstructionLastFlag | |
329 }; | |
330 | |
331 public: | |
332 bool check_flag(InstructionFlag id) const { return (_flags & (1 << id)) != 0; } | |
333 void set_flag(InstructionFlag id, bool f) { _flags = f ? (_flags | (1 << id)) : (_flags & ~(1 << id)); }; | |
334 | |
335 // 'globally' used condition values | |
336 enum Condition { | |
337 eql, neq, lss, leq, gtr, geq | |
338 }; | |
339 | |
340 // Instructions may be pinned for many reasons and under certain conditions | |
341 // with enough knowledge it's possible to safely unpin them. | |
342 enum PinReason { | |
343 PinUnknown = 1 << 0 | |
344 , PinExplicitNullCheck = 1 << 3 | |
345 , PinStackForStateSplit= 1 << 12 | |
346 , PinStateSplitConstructor= 1 << 13 | |
347 , PinGlobalValueNumbering= 1 << 14 | |
348 }; | |
349 | |
350 static Condition mirror(Condition cond); | |
351 static Condition negate(Condition cond); | |
352 | |
353 // initialization | |
1584 | 354 static int number_of_instructions() { |
355 return Compilation::current()->number_of_instructions(); | |
356 } | |
0 | 357 |
358 // creation | |
359 Instruction(ValueType* type, bool type_is_constant = false, bool create_hi = true) | |
1584 | 360 : _bci(-99) |
0 | 361 , _use_count(0) |
362 , _pin_state(0) | |
363 , _type(type) | |
364 , _next(NULL) | |
365 , _subst(NULL) | |
366 , _flags(0) | |
367 , _operand(LIR_OprFact::illegalOpr) | |
368 , _exception_handlers(NULL) | |
369 #ifdef ASSERT | |
370 , _hi_word(NULL) | |
371 #endif | |
372 { | |
373 assert(type != NULL && (!type->is_constant() || type_is_constant), "type must exist"); | |
374 #ifdef ASSERT | |
375 if (create_hi && type->is_double_word()) { | |
376 create_hi_word(); | |
377 } | |
378 #endif | |
379 } | |
380 | |
381 // accessors | |
382 int id() const { return _id; } | |
383 int bci() const { return _bci; } | |
384 int use_count() const { return _use_count; } | |
385 int pin_state() const { return _pin_state; } | |
386 bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; } | |
387 ValueType* type() const { return _type; } | |
388 Instruction* prev(BlockBegin* block); // use carefully, expensive operation | |
389 Instruction* next() const { return _next; } | |
390 bool has_subst() const { return _subst != NULL; } | |
391 Instruction* subst() { return _subst == NULL ? this : _subst->subst(); } | |
392 LIR_Opr operand() const { return _operand; } | |
393 | |
394 void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); } | |
395 bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); } | |
396 | |
397 bool has_uses() const { return use_count() > 0; } | |
398 bool is_root() const { return is_pinned() || use_count() > 1; } | |
399 XHandlers* exception_handlers() const { return _exception_handlers; } | |
400 | |
401 // manipulation | |
402 void pin(PinReason reason) { _pin_state |= reason; } | |
403 void pin() { _pin_state |= PinUnknown; } | |
404 // DANGEROUS: only used by EliminateStores | |
405 void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; } | |
406 virtual void set_lock_stack(ValueStack* l) { /* do nothing*/ } | |
407 virtual ValueStack* lock_stack() const { return NULL; } | |
408 | |
409 Instruction* set_next(Instruction* next, int bci) { | |
410 if (next != NULL) { | |
411 assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next"); | |
412 assert(next->as_Phi() == NULL && next->as_Local() == NULL, "shouldn't link these instructions into list"); | |
413 next->set_bci(bci); | |
414 } | |
415 _next = next; | |
416 return next; | |
417 } | |
418 | |
419 void set_subst(Instruction* subst) { | |
420 assert(subst == NULL || | |
421 type()->base() == subst->type()->base() || | |
422 subst->type()->base() == illegalType, "type can't change"); | |
423 _subst = subst; | |
424 } | |
425 void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; } | |
426 | |
427 #ifdef ASSERT | |
428 // HiWord is used for debugging and is allocated early to avoid | |
429 // allocation at inconvenient points | |
430 HiWord* hi_word() { return _hi_word; } | |
431 void create_hi_word(); | |
432 #endif | |
433 | |
434 | |
435 // machine-specifics | |
436 void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; } | |
437 void clear_operand() { _operand = LIR_OprFact::illegalOpr; } | |
438 | |
439 // generic | |
440 virtual Instruction* as_Instruction() { return this; } // to satisfy HASHING1 macro | |
441 virtual HiWord* as_HiWord() { return NULL; } | |
442 virtual Phi* as_Phi() { return NULL; } | |
443 virtual Local* as_Local() { return NULL; } | |
444 virtual Constant* as_Constant() { return NULL; } | |
445 virtual AccessField* as_AccessField() { return NULL; } | |
446 virtual LoadField* as_LoadField() { return NULL; } | |
447 virtual StoreField* as_StoreField() { return NULL; } | |
448 virtual AccessArray* as_AccessArray() { return NULL; } | |
449 virtual ArrayLength* as_ArrayLength() { return NULL; } | |
450 virtual AccessIndexed* as_AccessIndexed() { return NULL; } | |
451 virtual LoadIndexed* as_LoadIndexed() { return NULL; } | |
452 virtual StoreIndexed* as_StoreIndexed() { return NULL; } | |
453 virtual NegateOp* as_NegateOp() { return NULL; } | |
454 virtual Op2* as_Op2() { return NULL; } | |
455 virtual ArithmeticOp* as_ArithmeticOp() { return NULL; } | |
456 virtual ShiftOp* as_ShiftOp() { return NULL; } | |
457 virtual LogicOp* as_LogicOp() { return NULL; } | |
458 virtual CompareOp* as_CompareOp() { return NULL; } | |
459 virtual IfOp* as_IfOp() { return NULL; } | |
460 virtual Convert* as_Convert() { return NULL; } | |
461 virtual NullCheck* as_NullCheck() { return NULL; } | |
462 virtual OsrEntry* as_OsrEntry() { return NULL; } | |
463 virtual StateSplit* as_StateSplit() { return NULL; } | |
464 virtual Invoke* as_Invoke() { return NULL; } | |
465 virtual NewInstance* as_NewInstance() { return NULL; } | |
466 virtual NewArray* as_NewArray() { return NULL; } | |
467 virtual NewTypeArray* as_NewTypeArray() { return NULL; } | |
468 virtual NewObjectArray* as_NewObjectArray() { return NULL; } | |
469 virtual NewMultiArray* as_NewMultiArray() { return NULL; } | |
470 virtual TypeCheck* as_TypeCheck() { return NULL; } | |
471 virtual CheckCast* as_CheckCast() { return NULL; } | |
472 virtual InstanceOf* as_InstanceOf() { return NULL; } | |
473 virtual AccessMonitor* as_AccessMonitor() { return NULL; } | |
474 virtual MonitorEnter* as_MonitorEnter() { return NULL; } | |
475 virtual MonitorExit* as_MonitorExit() { return NULL; } | |
476 virtual Intrinsic* as_Intrinsic() { return NULL; } | |
477 virtual BlockBegin* as_BlockBegin() { return NULL; } | |
478 virtual BlockEnd* as_BlockEnd() { return NULL; } | |
479 virtual Goto* as_Goto() { return NULL; } | |
480 virtual If* as_If() { return NULL; } | |
481 virtual IfInstanceOf* as_IfInstanceOf() { return NULL; } | |
482 virtual TableSwitch* as_TableSwitch() { return NULL; } | |
483 virtual LookupSwitch* as_LookupSwitch() { return NULL; } | |
484 virtual Return* as_Return() { return NULL; } | |
485 virtual Throw* as_Throw() { return NULL; } | |
486 virtual Base* as_Base() { return NULL; } | |
487 virtual RoundFP* as_RoundFP() { return NULL; } | |
488 virtual ExceptionObject* as_ExceptionObject() { return NULL; } | |
489 virtual UnsafeOp* as_UnsafeOp() { return NULL; } | |
490 | |
491 virtual void visit(InstructionVisitor* v) = 0; | |
492 | |
493 virtual bool can_trap() const { return false; } | |
494 | |
1584 | 495 virtual void input_values_do(ValueVisitor* f) = 0; |
496 virtual void state_values_do(ValueVisitor* f) { /* usually no state - override on demand */ } | |
497 virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ } | |
498 void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); } | |
0 | 499 |
500 virtual ciType* exact_type() const { return NULL; } | |
501 virtual ciType* declared_type() const { return NULL; } | |
502 | |
503 // hashing | |
504 virtual const char* name() const = 0; | |
505 HASHING1(Instruction, false, id()) // hashing disabled by default | |
506 | |
507 // debugging | |
508 void print() PRODUCT_RETURN; | |
509 void print_line() PRODUCT_RETURN; | |
510 void print(InstructionPrinter& ip) PRODUCT_RETURN; | |
511 }; | |
512 | |
513 | |
514 // The following macros are used to define base (i.e., non-leaf) | |
515 // and leaf instruction classes. They define class-name related | |
516 // generic functionality in one place. | |
517 | |
518 #define BASE(class_name, super_class_name) \ | |
519 class class_name: public super_class_name { \ | |
520 public: \ | |
521 virtual class_name* as_##class_name() { return this; } \ | |
522 | |
523 | |
524 #define LEAF(class_name, super_class_name) \ | |
525 BASE(class_name, super_class_name) \ | |
526 public: \ | |
527 virtual const char* name() const { return #class_name; } \ | |
528 virtual void visit(InstructionVisitor* v) { v->do_##class_name(this); } \ | |
529 | |
530 | |
531 // Debugging support | |
532 | |
1584 | 533 |
0 | 534 #ifdef ASSERT |
1584 | 535 class AssertValues: public ValueVisitor { |
536 void visit(Value* x) { assert((*x) != NULL, "value must exist"); } | |
537 }; | |
538 #define ASSERT_VALUES { AssertValues assert_value; values_do(&assert_value); } | |
0 | 539 #else |
540 #define ASSERT_VALUES | |
541 #endif // ASSERT | |
542 | |
543 | |
544 // A HiWord occupies the 'high word' of a 2-word | |
545 // expression stack entry. Hi & lo words must be | |
546 // paired on the expression stack (otherwise the | |
547 // bytecode sequence is illegal). Note that 'hi' | |
548 // refers to the IR expression stack format and | |
549 // does *not* imply a machine word ordering. No | |
550 // HiWords are used in optimized mode for speed, | |
551 // but NULL pointers are used instead. | |
552 | |
553 LEAF(HiWord, Instruction) | |
554 private: | |
555 Value _lo_word; | |
556 | |
557 public: | |
558 // creation | |
559 HiWord(Value lo_word) | |
560 : Instruction(illegalType, false, false), | |
561 _lo_word(lo_word) { | |
562 // hi-words are also allowed for illegal lo-words | |
563 assert(lo_word->type()->is_double_word() || lo_word->type()->is_illegal(), | |
564 "HiWord must be used for 2-word values only"); | |
565 } | |
566 | |
567 // accessors | |
568 Value lo_word() const { return _lo_word->subst(); } | |
569 | |
570 // for invalidating of HiWords | |
571 void make_illegal() { set_type(illegalType); } | |
572 | |
573 // generic | |
1584 | 574 virtual void input_values_do(ValueVisitor* f) { ShouldNotReachHere(); } |
0 | 575 }; |
576 | |
577 | |
578 // A Phi is a phi function in the sense of SSA form. It stands for | |
579 // the value of a local variable at the beginning of a join block. | |
580 // A Phi consists of n operands, one for every incoming branch. | |
581 | |
582 LEAF(Phi, Instruction) | |
583 private: | |
584 BlockBegin* _block; // the block to which the phi function belongs | |
585 int _pf_flags; // the flags of the phi function | |
586 int _index; // to value on operand stack (index < 0) or to local | |
587 public: | |
588 // creation | |
589 Phi(ValueType* type, BlockBegin* b, int index) | |
590 : Instruction(type->base()) | |
591 , _pf_flags(0) | |
592 , _block(b) | |
593 , _index(index) | |
594 { | |
595 if (type->is_illegal()) { | |
596 make_illegal(); | |
597 } | |
598 } | |
599 | |
600 // flags | |
601 enum Flag { | |
602 no_flag = 0, | |
603 visited = 1 << 0, | |
604 cannot_simplify = 1 << 1 | |
605 }; | |
606 | |
607 // accessors | |
608 bool is_local() const { return _index >= 0; } | |
609 bool is_on_stack() const { return !is_local(); } | |
610 int local_index() const { assert(is_local(), ""); return _index; } | |
611 int stack_index() const { assert(is_on_stack(), ""); return -(_index+1); } | |
612 | |
613 Value operand_at(int i) const; | |
614 int operand_count() const; | |
615 | |
616 BlockBegin* block() const { return _block; } | |
617 | |
618 void set(Flag f) { _pf_flags |= f; } | |
619 void clear(Flag f) { _pf_flags &= ~f; } | |
620 bool is_set(Flag f) const { return (_pf_flags & f) != 0; } | |
621 | |
622 // Invalidates phis corresponding to merges of locals of two different types | |
623 // (these should never be referenced, otherwise the bytecodes are illegal) | |
624 void make_illegal() { | |
625 set(cannot_simplify); | |
626 set_type(illegalType); | |
627 } | |
628 | |
629 bool is_illegal() const { | |
630 return type()->is_illegal(); | |
631 } | |
632 | |
633 // generic | |
1584 | 634 virtual void input_values_do(ValueVisitor* f) { |
0 | 635 } |
636 }; | |
637 | |
638 | |
639 // A local is a placeholder for an incoming argument to a function call. | |
640 LEAF(Local, Instruction) | |
641 private: | |
642 int _java_index; // the local index within the method to which the local belongs | |
643 public: | |
644 // creation | |
645 Local(ValueType* type, int index) | |
646 : Instruction(type) | |
647 , _java_index(index) | |
648 {} | |
649 | |
650 // accessors | |
651 int java_index() const { return _java_index; } | |
652 | |
653 // generic | |
1584 | 654 virtual void input_values_do(ValueVisitor* f) { /* no values */ } |
0 | 655 }; |
656 | |
657 | |
658 LEAF(Constant, Instruction) | |
659 ValueStack* _state; | |
660 | |
661 public: | |
662 // creation | |
663 Constant(ValueType* type): | |
664 Instruction(type, true) | |
665 , _state(NULL) { | |
666 assert(type->is_constant(), "must be a constant"); | |
667 } | |
668 | |
669 Constant(ValueType* type, ValueStack* state): | |
670 Instruction(type, true) | |
671 , _state(state) { | |
672 assert(state != NULL, "only used for constants which need patching"); | |
673 assert(type->is_constant(), "must be a constant"); | |
674 // since it's patching it needs to be pinned | |
675 pin(); | |
676 } | |
677 | |
678 ValueStack* state() const { return _state; } | |
679 | |
680 // generic | |
681 virtual bool can_trap() const { return state() != NULL; } | |
1584 | 682 virtual void input_values_do(ValueVisitor* f) { /* no values */ } |
683 virtual void other_values_do(ValueVisitor* f); | |
0 | 684 |
685 virtual intx hash() const; | |
686 virtual bool is_equal(Value v) const; | |
687 | |
688 virtual BlockBegin* compare(Instruction::Condition condition, Value right, | |
689 BlockBegin* true_sux, BlockBegin* false_sux); | |
690 }; | |
691 | |
692 | |
693 BASE(AccessField, Instruction) | |
694 private: | |
695 Value _obj; | |
696 int _offset; | |
697 ciField* _field; | |
698 ValueStack* _state_before; // state is set only for unloaded or uninitialized fields | |
699 ValueStack* _lock_stack; // contains lock and scope information | |
700 NullCheck* _explicit_null_check; // For explicit null check elimination | |
701 | |
702 public: | |
703 // creation | |
704 AccessField(Value obj, int offset, ciField* field, bool is_static, ValueStack* lock_stack, | |
705 ValueStack* state_before, bool is_loaded, bool is_initialized) | |
706 : Instruction(as_ValueType(field->type()->basic_type())) | |
707 , _obj(obj) | |
708 , _offset(offset) | |
709 , _field(field) | |
710 , _lock_stack(lock_stack) | |
711 , _state_before(state_before) | |
712 , _explicit_null_check(NULL) | |
713 { | |
714 set_needs_null_check(!is_static); | |
715 set_flag(IsLoadedFlag, is_loaded); | |
716 set_flag(IsInitializedFlag, is_initialized); | |
717 set_flag(IsStaticFlag, is_static); | |
718 ASSERT_VALUES | |
719 if (!is_loaded || (PatchALot && !field->is_volatile())) { | |
720 // need to patch if the holder wasn't loaded or we're testing | |
721 // using PatchALot. Don't allow PatchALot for fields which are | |
722 // known to be volatile they aren't patchable. | |
723 set_flag(NeedsPatchingFlag, true); | |
724 } | |
725 // pin of all instructions with memory access | |
726 pin(); | |
727 } | |
728 | |
729 // accessors | |
730 Value obj() const { return _obj; } | |
731 int offset() const { return _offset; } | |
732 ciField* field() const { return _field; } | |
733 BasicType field_type() const { return _field->type()->basic_type(); } | |
734 bool is_static() const { return check_flag(IsStaticFlag); } | |
735 bool is_loaded() const { return check_flag(IsLoadedFlag); } | |
736 bool is_initialized() const { return check_flag(IsInitializedFlag); } | |
737 ValueStack* state_before() const { return _state_before; } | |
738 ValueStack* lock_stack() const { return _lock_stack; } | |
739 NullCheck* explicit_null_check() const { return _explicit_null_check; } | |
740 bool needs_patching() const { return check_flag(NeedsPatchingFlag); } | |
741 | |
742 // manipulation | |
743 void set_lock_stack(ValueStack* l) { _lock_stack = l; } | |
744 // Under certain circumstances, if a previous NullCheck instruction | |
745 // proved the target object non-null, we can eliminate the explicit | |
746 // null check and do an implicit one, simply specifying the debug | |
747 // information from the NullCheck. This field should only be consulted | |
748 // if needs_null_check() is true. | |
749 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } | |
750 | |
751 // generic | |
752 virtual bool can_trap() const { return needs_null_check() || needs_patching(); } | |
1584 | 753 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } |
754 virtual void other_values_do(ValueVisitor* f); | |
0 | 755 }; |
756 | |
757 | |
758 LEAF(LoadField, AccessField) | |
759 public: | |
760 // creation | |
761 LoadField(Value obj, int offset, ciField* field, bool is_static, ValueStack* lock_stack, | |
762 ValueStack* state_before, bool is_loaded, bool is_initialized) | |
763 : AccessField(obj, offset, field, is_static, lock_stack, state_before, is_loaded, is_initialized) | |
764 {} | |
765 | |
766 ciType* declared_type() const; | |
767 ciType* exact_type() const; | |
768 | |
769 // generic | |
770 HASHING2(LoadField, is_loaded() && !field()->is_volatile(), obj()->subst(), offset()) // cannot be eliminated if not yet loaded or if volatile | |
771 }; | |
772 | |
773 | |
774 LEAF(StoreField, AccessField) | |
775 private: | |
776 Value _value; | |
777 | |
778 public: | |
779 // creation | |
780 StoreField(Value obj, int offset, ciField* field, Value value, bool is_static, ValueStack* lock_stack, | |
781 ValueStack* state_before, bool is_loaded, bool is_initialized) | |
782 : AccessField(obj, offset, field, is_static, lock_stack, state_before, is_loaded, is_initialized) | |
783 , _value(value) | |
784 { | |
785 set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object()); | |
786 ASSERT_VALUES | |
787 pin(); | |
788 } | |
789 | |
790 // accessors | |
791 Value value() const { return _value; } | |
792 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } | |
793 | |
794 // generic | |
1584 | 795 virtual void input_values_do(ValueVisitor* f) { AccessField::input_values_do(f); f->visit(&_value); } |
0 | 796 }; |
797 | |
798 | |
799 BASE(AccessArray, Instruction) | |
800 private: | |
801 Value _array; | |
802 ValueStack* _lock_stack; | |
803 | |
804 public: | |
805 // creation | |
806 AccessArray(ValueType* type, Value array, ValueStack* lock_stack) | |
807 : Instruction(type) | |
808 , _array(array) | |
809 , _lock_stack(lock_stack) { | |
810 set_needs_null_check(true); | |
811 ASSERT_VALUES | |
812 pin(); // instruction with side effect (null exception or range check throwing) | |
813 } | |
814 | |
815 Value array() const { return _array; } | |
816 ValueStack* lock_stack() const { return _lock_stack; } | |
817 | |
818 // setters | |
819 void set_lock_stack(ValueStack* l) { _lock_stack = l; } | |
820 | |
821 // generic | |
822 virtual bool can_trap() const { return needs_null_check(); } | |
1584 | 823 virtual void input_values_do(ValueVisitor* f) { f->visit(&_array); } |
824 virtual void other_values_do(ValueVisitor* f); | |
0 | 825 }; |
826 | |
827 | |
828 LEAF(ArrayLength, AccessArray) | |
829 private: | |
830 NullCheck* _explicit_null_check; // For explicit null check elimination | |
831 | |
832 public: | |
833 // creation | |
834 ArrayLength(Value array, ValueStack* lock_stack) | |
835 : AccessArray(intType, array, lock_stack) | |
836 , _explicit_null_check(NULL) {} | |
837 | |
838 // accessors | |
839 NullCheck* explicit_null_check() const { return _explicit_null_check; } | |
840 | |
841 // setters | |
842 // See LoadField::set_explicit_null_check for documentation | |
843 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } | |
844 | |
845 // generic | |
846 HASHING1(ArrayLength, true, array()->subst()) | |
847 }; | |
848 | |
849 | |
850 BASE(AccessIndexed, AccessArray) | |
851 private: | |
852 Value _index; | |
853 Value _length; | |
854 BasicType _elt_type; | |
855 | |
856 public: | |
857 // creation | |
858 AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* lock_stack) | |
859 : AccessArray(as_ValueType(elt_type), array, lock_stack) | |
860 , _index(index) | |
861 , _length(length) | |
862 , _elt_type(elt_type) | |
863 { | |
864 ASSERT_VALUES | |
865 } | |
866 | |
867 // accessors | |
868 Value index() const { return _index; } | |
869 Value length() const { return _length; } | |
870 BasicType elt_type() const { return _elt_type; } | |
871 | |
872 // perform elimination of range checks involving constants | |
873 bool compute_needs_range_check(); | |
874 | |
875 // generic | |
1584 | 876 virtual void input_values_do(ValueVisitor* f) { AccessArray::input_values_do(f); f->visit(&_index); if (_length != NULL) f->visit(&_length); } |
0 | 877 }; |
878 | |
879 | |
880 LEAF(LoadIndexed, AccessIndexed) | |
881 private: | |
882 NullCheck* _explicit_null_check; // For explicit null check elimination | |
883 | |
884 public: | |
885 // creation | |
886 LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* lock_stack) | |
887 : AccessIndexed(array, index, length, elt_type, lock_stack) | |
888 , _explicit_null_check(NULL) {} | |
889 | |
890 // accessors | |
891 NullCheck* explicit_null_check() const { return _explicit_null_check; } | |
892 | |
893 // setters | |
894 // See LoadField::set_explicit_null_check for documentation | |
895 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } | |
896 | |
897 ciType* exact_type() const; | |
898 ciType* declared_type() const; | |
899 | |
900 // generic | |
901 HASHING2(LoadIndexed, true, array()->subst(), index()->subst()) | |
902 }; | |
903 | |
904 | |
905 LEAF(StoreIndexed, AccessIndexed) | |
906 private: | |
907 Value _value; | |
908 | |
909 public: | |
910 // creation | |
911 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* lock_stack) | |
912 : AccessIndexed(array, index, length, elt_type, lock_stack) | |
913 , _value(value) | |
914 { | |
915 set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object())); | |
916 set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object())); | |
917 ASSERT_VALUES | |
918 pin(); | |
919 } | |
920 | |
921 // accessors | |
922 Value value() const { return _value; } | |
923 IRScope* scope() const; // the state's scope | |
924 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } | |
925 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); } | |
926 | |
927 // generic | |
1584 | 928 virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); } |
0 | 929 }; |
930 | |
931 | |
932 LEAF(NegateOp, Instruction) | |
933 private: | |
934 Value _x; | |
935 | |
936 public: | |
937 // creation | |
938 NegateOp(Value x) : Instruction(x->type()->base()), _x(x) { | |
939 ASSERT_VALUES | |
940 } | |
941 | |
942 // accessors | |
943 Value x() const { return _x; } | |
944 | |
945 // generic | |
1584 | 946 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); } |
0 | 947 }; |
948 | |
949 | |
950 BASE(Op2, Instruction) | |
951 private: | |
952 Bytecodes::Code _op; | |
953 Value _x; | |
954 Value _y; | |
955 | |
956 public: | |
957 // creation | |
958 Op2(ValueType* type, Bytecodes::Code op, Value x, Value y) : Instruction(type), _op(op), _x(x), _y(y) { | |
959 ASSERT_VALUES | |
960 } | |
961 | |
962 // accessors | |
963 Bytecodes::Code op() const { return _op; } | |
964 Value x() const { return _x; } | |
965 Value y() const { return _y; } | |
966 | |
967 // manipulators | |
968 void swap_operands() { | |
969 assert(is_commutative(), "operation must be commutative"); | |
970 Value t = _x; _x = _y; _y = t; | |
971 } | |
972 | |
973 // generic | |
974 virtual bool is_commutative() const { return false; } | |
1584 | 975 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); f->visit(&_y); } |
0 | 976 }; |
977 | |
978 | |
979 LEAF(ArithmeticOp, Op2) | |
980 private: | |
981 ValueStack* _lock_stack; // used only for division operations | |
982 public: | |
983 // creation | |
984 ArithmeticOp(Bytecodes::Code op, Value x, Value y, bool is_strictfp, ValueStack* lock_stack) | |
985 : Op2(x->type()->meet(y->type()), op, x, y) | |
986 , _lock_stack(lock_stack) { | |
987 set_flag(IsStrictfpFlag, is_strictfp); | |
988 if (can_trap()) pin(); | |
989 } | |
990 | |
991 // accessors | |
992 ValueStack* lock_stack() const { return _lock_stack; } | |
993 bool is_strictfp() const { return check_flag(IsStrictfpFlag); } | |
994 | |
995 // setters | |
996 void set_lock_stack(ValueStack* l) { _lock_stack = l; } | |
997 | |
998 // generic | |
999 virtual bool is_commutative() const; | |
1000 virtual bool can_trap() const; | |
1584 | 1001 virtual void other_values_do(ValueVisitor* f); |
0 | 1002 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) |
1003 }; | |
1004 | |
1005 | |
1006 LEAF(ShiftOp, Op2) | |
1007 public: | |
1008 // creation | |
1009 ShiftOp(Bytecodes::Code op, Value x, Value s) : Op2(x->type()->base(), op, x, s) {} | |
1010 | |
1011 // generic | |
1012 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) | |
1013 }; | |
1014 | |
1015 | |
1016 LEAF(LogicOp, Op2) | |
1017 public: | |
1018 // creation | |
1019 LogicOp(Bytecodes::Code op, Value x, Value y) : Op2(x->type()->meet(y->type()), op, x, y) {} | |
1020 | |
1021 // generic | |
1022 virtual bool is_commutative() const; | |
1023 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) | |
1024 }; | |
1025 | |
1026 | |
1027 LEAF(CompareOp, Op2) | |
1028 private: | |
1029 ValueStack* _state_before; // for deoptimization, when canonicalizing | |
1030 public: | |
1031 // creation | |
1032 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before) | |
1033 : Op2(intType, op, x, y) | |
1034 , _state_before(state_before) | |
1035 {} | |
1036 | |
1037 // accessors | |
1038 ValueStack* state_before() const { return _state_before; } | |
1039 | |
1040 // generic | |
1041 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) | |
1584 | 1042 virtual void other_values_do(ValueVisitor* f); |
0 | 1043 }; |
1044 | |
1045 | |
1046 LEAF(IfOp, Op2) | |
1047 private: | |
1048 Value _tval; | |
1049 Value _fval; | |
1050 | |
1051 public: | |
1052 // creation | |
1053 IfOp(Value x, Condition cond, Value y, Value tval, Value fval) | |
1054 : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y) | |
1055 , _tval(tval) | |
1056 , _fval(fval) | |
1057 { | |
1058 ASSERT_VALUES | |
1059 assert(tval->type()->tag() == fval->type()->tag(), "types must match"); | |
1060 } | |
1061 | |
1062 // accessors | |
1063 virtual bool is_commutative() const; | |
1064 Bytecodes::Code op() const { ShouldNotCallThis(); return Bytecodes::_illegal; } | |
1065 Condition cond() const { return (Condition)Op2::op(); } | |
1066 Value tval() const { return _tval; } | |
1067 Value fval() const { return _fval; } | |
1068 | |
1069 // generic | |
1584 | 1070 virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); } |
0 | 1071 }; |
1072 | |
1073 | |
1074 LEAF(Convert, Instruction) | |
1075 private: | |
1076 Bytecodes::Code _op; | |
1077 Value _value; | |
1078 | |
1079 public: | |
1080 // creation | |
1081 Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) { | |
1082 ASSERT_VALUES | |
1083 } | |
1084 | |
1085 // accessors | |
1086 Bytecodes::Code op() const { return _op; } | |
1087 Value value() const { return _value; } | |
1088 | |
1089 // generic | |
1584 | 1090 virtual void input_values_do(ValueVisitor* f) { f->visit(&_value); } |
0 | 1091 HASHING2(Convert, true, op(), value()->subst()) |
1092 }; | |
1093 | |
1094 | |
1095 LEAF(NullCheck, Instruction) | |
1096 private: | |
1097 Value _obj; | |
1098 ValueStack* _lock_stack; | |
1099 | |
1100 public: | |
1101 // creation | |
1102 NullCheck(Value obj, ValueStack* lock_stack) : Instruction(obj->type()->base()), _obj(obj), _lock_stack(lock_stack) { | |
1103 ASSERT_VALUES | |
1104 set_can_trap(true); | |
1105 assert(_obj->type()->is_object(), "null check must be applied to objects only"); | |
1106 pin(Instruction::PinExplicitNullCheck); | |
1107 } | |
1108 | |
1109 // accessors | |
1110 Value obj() const { return _obj; } | |
1111 ValueStack* lock_stack() const { return _lock_stack; } | |
1112 | |
1113 // setters | |
1114 void set_lock_stack(ValueStack* l) { _lock_stack = l; } | |
1115 void set_can_trap(bool can_trap) { set_flag(CanTrapFlag, can_trap); } | |
1116 | |
1117 // generic | |
1118 virtual bool can_trap() const { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ } | |
1584 | 1119 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } |
1120 virtual void other_values_do(ValueVisitor* f); | |
0 | 1121 HASHING1(NullCheck, true, obj()->subst()) |
1122 }; | |
1123 | |
1124 | |
1125 BASE(StateSplit, Instruction) | |
1126 private: | |
1127 ValueStack* _state; | |
1128 | |
1129 protected: | |
1130 static void substitute(BlockList& list, BlockBegin* old_block, BlockBegin* new_block); | |
1131 | |
1132 public: | |
1133 // creation | |
1134 StateSplit(ValueType* type) : Instruction(type), _state(NULL) { | |
1135 pin(PinStateSplitConstructor); | |
1136 } | |
1137 | |
1138 // accessors | |
1139 ValueStack* state() const { return _state; } | |
1140 IRScope* scope() const; // the state's scope | |
1141 | |
1142 // manipulation | |
1143 void set_state(ValueStack* state) { _state = state; } | |
1144 | |
1145 // generic | |
1584 | 1146 virtual void input_values_do(ValueVisitor* f) { /* no values */ } |
1147 virtual void state_values_do(ValueVisitor* f); | |
0 | 1148 }; |
1149 | |
1150 | |
1151 LEAF(Invoke, StateSplit) | |
1152 private: | |
1295 | 1153 Bytecodes::Code _code; |
1154 Value _recv; | |
1155 Values* _args; | |
1156 BasicTypeList* _signature; | |
1157 int _vtable_index; | |
1158 ciMethod* _target; | |
1159 ValueStack* _state_before; // Required for deoptimization. | |
0 | 1160 |
1161 public: | |
1162 // creation | |
1163 Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args, | |
1295 | 1164 int vtable_index, ciMethod* target, ValueStack* state_before); |
0 | 1165 |
1166 // accessors | |
1167 Bytecodes::Code code() const { return _code; } | |
1168 Value receiver() const { return _recv; } | |
1169 bool has_receiver() const { return receiver() != NULL; } | |
1170 int number_of_arguments() const { return _args->length(); } | |
1171 Value argument_at(int i) const { return _args->at(i); } | |
1172 int vtable_index() const { return _vtable_index; } | |
1173 BasicTypeList* signature() const { return _signature; } | |
1174 ciMethod* target() const { return _target; } | |
1295 | 1175 ValueStack* state_before() const { return _state_before; } |
0 | 1176 |
1177 // Returns false if target is not loaded | |
1178 bool target_is_final() const { return check_flag(TargetIsFinalFlag); } | |
1179 bool target_is_loaded() const { return check_flag(TargetIsLoadedFlag); } | |
1180 // Returns false if target is not loaded | |
1181 bool target_is_strictfp() const { return check_flag(TargetIsStrictfpFlag); } | |
1182 | |
1295 | 1183 // JSR 292 support |
1184 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } | |
1185 | |
0 | 1186 // generic |
1187 virtual bool can_trap() const { return true; } | |
1584 | 1188 virtual void input_values_do(ValueVisitor* f) { |
0 | 1189 StateSplit::input_values_do(f); |
1584 | 1190 if (has_receiver()) f->visit(&_recv); |
1191 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); | |
0 | 1192 } |
1584 | 1193 virtual void state_values_do(ValueVisitor *f); |
0 | 1194 }; |
1195 | |
1196 | |
1197 LEAF(NewInstance, StateSplit) | |
1198 private: | |
1199 ciInstanceKlass* _klass; | |
1200 | |
1201 public: | |
1202 // creation | |
1203 NewInstance(ciInstanceKlass* klass) : StateSplit(instanceType), _klass(klass) {} | |
1204 | |
1205 // accessors | |
1206 ciInstanceKlass* klass() const { return _klass; } | |
1207 | |
1208 // generic | |
1209 virtual bool can_trap() const { return true; } | |
1210 ciType* exact_type() const; | |
1211 }; | |
1212 | |
1213 | |
1214 BASE(NewArray, StateSplit) | |
1215 private: | |
1216 Value _length; | |
1217 ValueStack* _state_before; | |
1218 | |
1219 public: | |
1220 // creation | |
1221 NewArray(Value length, ValueStack* state_before) : StateSplit(objectType), _length(length), _state_before(state_before) { | |
1222 // Do not ASSERT_VALUES since length is NULL for NewMultiArray | |
1223 } | |
1224 | |
1225 // accessors | |
1226 ValueStack* state_before() const { return _state_before; } | |
1227 Value length() const { return _length; } | |
1228 | |
1229 // generic | |
1230 virtual bool can_trap() const { return true; } | |
1584 | 1231 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); } |
1232 virtual void other_values_do(ValueVisitor* f); | |
0 | 1233 }; |
1234 | |
1235 | |
1236 LEAF(NewTypeArray, NewArray) | |
1237 private: | |
1238 BasicType _elt_type; | |
1239 | |
1240 public: | |
1241 // creation | |
1242 NewTypeArray(Value length, BasicType elt_type) : NewArray(length, NULL), _elt_type(elt_type) {} | |
1243 | |
1244 // accessors | |
1245 BasicType elt_type() const { return _elt_type; } | |
1246 ciType* exact_type() const; | |
1247 }; | |
1248 | |
1249 | |
1250 LEAF(NewObjectArray, NewArray) | |
1251 private: | |
1252 ciKlass* _klass; | |
1253 | |
1254 public: | |
1255 // creation | |
1256 NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {} | |
1257 | |
1258 // accessors | |
1259 ciKlass* klass() const { return _klass; } | |
1260 ciType* exact_type() const; | |
1261 }; | |
1262 | |
1263 | |
1264 LEAF(NewMultiArray, NewArray) | |
1265 private: | |
1266 ciKlass* _klass; | |
1267 Values* _dims; | |
1268 | |
1269 public: | |
1270 // creation | |
1271 NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(NULL, state_before), _klass(klass), _dims(dims) { | |
1272 ASSERT_VALUES | |
1273 } | |
1274 | |
1275 // accessors | |
1276 ciKlass* klass() const { return _klass; } | |
1277 Values* dims() const { return _dims; } | |
1278 int rank() const { return dims()->length(); } | |
1279 | |
1280 // generic | |
1584 | 1281 virtual void input_values_do(ValueVisitor* f) { |
0 | 1282 // NOTE: we do not call NewArray::input_values_do since "length" |
1283 // is meaningless for a multi-dimensional array; passing the | |
1284 // zeroth element down to NewArray as its length is a bad idea | |
1285 // since there will be a copy in the "dims" array which doesn't | |
1286 // get updated, and the value must not be traversed twice. Was bug | |
1287 // - kbr 4/10/2001 | |
1288 StateSplit::input_values_do(f); | |
1584 | 1289 for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i)); |
0 | 1290 } |
1291 }; | |
1292 | |
1293 | |
1294 BASE(TypeCheck, StateSplit) | |
1295 private: | |
1296 ciKlass* _klass; | |
1297 Value _obj; | |
1298 ValueStack* _state_before; | |
1299 | |
1300 public: | |
1301 // creation | |
1302 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before) : StateSplit(type), _klass(klass), _obj(obj), _state_before(state_before) { | |
1303 ASSERT_VALUES | |
1304 set_direct_compare(false); | |
1305 } | |
1306 | |
1307 // accessors | |
1308 ValueStack* state_before() const { return _state_before; } | |
1309 ciKlass* klass() const { return _klass; } | |
1310 Value obj() const { return _obj; } | |
1311 bool is_loaded() const { return klass() != NULL; } | |
1312 bool direct_compare() const { return check_flag(DirectCompareFlag); } | |
1313 | |
1314 // manipulation | |
1315 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); } | |
1316 | |
1317 // generic | |
1318 virtual bool can_trap() const { return true; } | |
1584 | 1319 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } |
1320 virtual void other_values_do(ValueVisitor* f); | |
0 | 1321 }; |
1322 | |
1323 | |
1324 LEAF(CheckCast, TypeCheck) | |
1325 private: | |
1326 ciMethod* _profiled_method; | |
1327 int _profiled_bci; | |
1328 | |
1329 public: | |
1330 // creation | |
1331 CheckCast(ciKlass* klass, Value obj, ValueStack* state_before) | |
1332 : TypeCheck(klass, obj, objectType, state_before) | |
1333 , _profiled_method(NULL) | |
1334 , _profiled_bci(0) {} | |
1335 | |
1336 void set_incompatible_class_change_check() { | |
1337 set_flag(ThrowIncompatibleClassChangeErrorFlag, true); | |
1338 } | |
1339 bool is_incompatible_class_change_check() const { | |
1340 return check_flag(ThrowIncompatibleClassChangeErrorFlag); | |
1341 } | |
1342 | |
1343 // Helpers for methodDataOop profiling | |
1344 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } | |
1345 void set_profiled_method(ciMethod* method) { _profiled_method = method; } | |
1346 void set_profiled_bci(int bci) { _profiled_bci = bci; } | |
1347 bool should_profile() const { return check_flag(ProfileMDOFlag); } | |
1348 ciMethod* profiled_method() const { return _profiled_method; } | |
1349 int profiled_bci() const { return _profiled_bci; } | |
1350 | |
1351 ciType* declared_type() const; | |
1352 ciType* exact_type() const; | |
1353 | |
1354 }; | |
1355 | |
1356 | |
1357 LEAF(InstanceOf, TypeCheck) | |
1358 public: | |
1359 // creation | |
1360 InstanceOf(ciKlass* klass, Value obj, ValueStack* state_before) : TypeCheck(klass, obj, intType, state_before) {} | |
1361 }; | |
1362 | |
1363 | |
1364 BASE(AccessMonitor, StateSplit) | |
1365 private: | |
1366 Value _obj; | |
1367 int _monitor_no; | |
1368 | |
1369 public: | |
1370 // creation | |
1371 AccessMonitor(Value obj, int monitor_no) | |
1372 : StateSplit(illegalType) | |
1373 , _obj(obj) | |
1374 , _monitor_no(monitor_no) | |
1375 { | |
1376 set_needs_null_check(true); | |
1377 ASSERT_VALUES | |
1378 } | |
1379 | |
1380 // accessors | |
1381 Value obj() const { return _obj; } | |
1382 int monitor_no() const { return _monitor_no; } | |
1383 | |
1384 // generic | |
1584 | 1385 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } |
0 | 1386 }; |
1387 | |
1388 | |
1389 LEAF(MonitorEnter, AccessMonitor) | |
1390 private: | |
1391 ValueStack* _lock_stack_before; | |
1392 | |
1393 public: | |
1394 // creation | |
1395 MonitorEnter(Value obj, int monitor_no, ValueStack* lock_stack_before) | |
1396 : AccessMonitor(obj, monitor_no) | |
1397 , _lock_stack_before(lock_stack_before) | |
1398 { | |
1399 ASSERT_VALUES | |
1400 } | |
1401 | |
1402 // accessors | |
1403 ValueStack* lock_stack_before() const { return _lock_stack_before; } | |
1584 | 1404 virtual void state_values_do(ValueVisitor* f); |
0 | 1405 |
1406 // generic | |
1407 virtual bool can_trap() const { return true; } | |
1408 }; | |
1409 | |
1410 | |
1411 LEAF(MonitorExit, AccessMonitor) | |
1412 public: | |
1413 // creation | |
1414 MonitorExit(Value obj, int monitor_no) : AccessMonitor(obj, monitor_no) {} | |
1415 }; | |
1416 | |
1417 | |
1418 LEAF(Intrinsic, StateSplit) | |
1419 private: | |
1420 vmIntrinsics::ID _id; | |
1421 Values* _args; | |
1422 ValueStack* _lock_stack; | |
1423 Value _recv; | |
1424 | |
1425 public: | |
1426 // preserves_state can be set to true for Intrinsics | |
1427 // which are guaranteed to preserve register state across any slow | |
1428 // cases; setting it to true does not mean that the Intrinsic can | |
1429 // not trap, only that if we continue execution in the same basic | |
1430 // block after the Intrinsic, all of the registers are intact. This | |
1431 // allows load elimination and common expression elimination to be | |
1432 // performed across the Intrinsic. The default value is false. | |
1433 Intrinsic(ValueType* type, | |
1434 vmIntrinsics::ID id, | |
1435 Values* args, | |
1436 bool has_receiver, | |
1437 ValueStack* lock_stack, | |
1438 bool preserves_state, | |
1439 bool cantrap = true) | |
1440 : StateSplit(type) | |
1441 , _id(id) | |
1442 , _args(args) | |
1443 , _lock_stack(lock_stack) | |
1444 , _recv(NULL) | |
1445 { | |
1446 assert(args != NULL, "args must exist"); | |
1447 ASSERT_VALUES | |
1448 set_flag(PreservesStateFlag, preserves_state); | |
1449 set_flag(CanTrapFlag, cantrap); | |
1450 if (has_receiver) { | |
1451 _recv = argument_at(0); | |
1452 } | |
1453 set_needs_null_check(has_receiver); | |
1454 | |
1455 // some intrinsics can't trap, so don't force them to be pinned | |
1456 if (!can_trap()) { | |
1457 unpin(PinStateSplitConstructor); | |
1458 } | |
1459 } | |
1460 | |
1461 // accessors | |
1462 vmIntrinsics::ID id() const { return _id; } | |
1463 int number_of_arguments() const { return _args->length(); } | |
1464 Value argument_at(int i) const { return _args->at(i); } | |
1465 ValueStack* lock_stack() const { return _lock_stack; } | |
1466 | |
1467 bool has_receiver() const { return (_recv != NULL); } | |
1468 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } | |
1469 bool preserves_state() const { return check_flag(PreservesStateFlag); } | |
1470 | |
1471 // generic | |
1472 virtual bool can_trap() const { return check_flag(CanTrapFlag); } | |
1584 | 1473 virtual void input_values_do(ValueVisitor* f) { |
0 | 1474 StateSplit::input_values_do(f); |
1584 | 1475 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); |
0 | 1476 } |
1584 | 1477 virtual void state_values_do(ValueVisitor* f); |
0 | 1478 |
1479 }; | |
1480 | |
1481 | |
1482 class LIR_List; | |
1483 | |
1484 LEAF(BlockBegin, StateSplit) | |
1485 private: | |
1486 int _block_id; // the unique block id | |
1487 int _depth_first_number; // number of this block in a depth-first ordering | |
1488 int _linear_scan_number; // number of this block in linear-scan ordering | |
1489 int _loop_depth; // the loop nesting level of this block | |
1490 int _loop_index; // number of the innermost loop of this block | |
1491 int _flags; // the flags associated with this block | |
1492 | |
1493 // fields used by BlockListBuilder | |
1494 int _total_preds; // number of predecessors found by BlockListBuilder | |
1495 BitMap _stores_to_locals; // bit is set when a local variable is stored in the block | |
1496 | |
1497 // SSA specific fields: (factor out later) | |
1498 BlockList _successors; // the successors of this block | |
1499 BlockList _predecessors; // the predecessors of this block | |
1500 BlockBegin* _dominator; // the dominator of this block | |
1501 // SSA specific ends | |
1502 BlockEnd* _end; // the last instruction of this block | |
1503 BlockList _exception_handlers; // the exception handlers potentially invoked by this block | |
1504 ValueStackStack* _exception_states; // only for xhandler entries: states of all instructions that have an edge to this xhandler | |
1505 int _exception_handler_pco; // if this block is the start of an exception handler, | |
1506 // this records the PC offset in the assembly code of the | |
1507 // first instruction in this block | |
1508 Label _label; // the label associated with this block | |
1509 LIR_List* _lir; // the low level intermediate representation for this block | |
1510 | |
1511 BitMap _live_in; // set of live LIR_Opr registers at entry to this block | |
1512 BitMap _live_out; // set of live LIR_Opr registers at exit from this block | |
1513 BitMap _live_gen; // set of registers used before any redefinition in this block | |
1514 BitMap _live_kill; // set of registers defined in this block | |
1515 | |
1516 BitMap _fpu_register_usage; | |
1517 intArray* _fpu_stack_state; // For x86 FPU code generation with UseLinearScan | |
1518 int _first_lir_instruction_id; // ID of first LIR instruction in this block | |
1519 int _last_lir_instruction_id; // ID of last LIR instruction in this block | |
1520 | |
1521 void iterate_preorder (boolArray& mark, BlockClosure* closure); | |
1522 void iterate_postorder(boolArray& mark, BlockClosure* closure); | |
1523 | |
1524 friend class SuxAndWeightAdjuster; | |
1525 | |
1526 public: | |
1584 | 1527 void* operator new(size_t size) { |
1528 Compilation* c = Compilation::current(); | |
1529 void* res = c->arena()->Amalloc(size); | |
1530 ((BlockBegin*)res)->_id = c->get_next_id(); | |
1531 ((BlockBegin*)res)->_block_id = c->get_next_block_id(); | |
1532 return res; | |
1533 } | |
1534 | |
0 | 1535 // initialization/counting |
1584 | 1536 static int number_of_blocks() { |
1537 return Compilation::current()->number_of_blocks(); | |
1538 } | |
0 | 1539 |
1540 // creation | |
1541 BlockBegin(int bci) | |
1542 : StateSplit(illegalType) | |
1543 , _depth_first_number(-1) | |
1544 , _linear_scan_number(-1) | |
1545 , _loop_depth(0) | |
1546 , _flags(0) | |
1547 , _dominator(NULL) | |
1548 , _end(NULL) | |
1549 , _predecessors(2) | |
1550 , _successors(2) | |
1551 , _exception_handlers(1) | |
1552 , _exception_states(NULL) | |
1553 , _exception_handler_pco(-1) | |
1554 , _lir(NULL) | |
1555 , _loop_index(-1) | |
1556 , _live_in() | |
1557 , _live_out() | |
1558 , _live_gen() | |
1559 , _live_kill() | |
1560 , _fpu_register_usage() | |
1561 , _fpu_stack_state(NULL) | |
1562 , _first_lir_instruction_id(-1) | |
1563 , _last_lir_instruction_id(-1) | |
1564 , _total_preds(0) | |
1565 , _stores_to_locals() | |
1566 { | |
1567 set_bci(bci); | |
1568 } | |
1569 | |
1570 // accessors | |
1571 int block_id() const { return _block_id; } | |
1572 BlockList* successors() { return &_successors; } | |
1573 BlockBegin* dominator() const { return _dominator; } | |
1574 int loop_depth() const { return _loop_depth; } | |
1575 int depth_first_number() const { return _depth_first_number; } | |
1576 int linear_scan_number() const { return _linear_scan_number; } | |
1577 BlockEnd* end() const { return _end; } | |
1578 Label* label() { return &_label; } | |
1579 LIR_List* lir() const { return _lir; } | |
1580 int exception_handler_pco() const { return _exception_handler_pco; } | |
1581 BitMap& live_in() { return _live_in; } | |
1582 BitMap& live_out() { return _live_out; } | |
1583 BitMap& live_gen() { return _live_gen; } | |
1584 BitMap& live_kill() { return _live_kill; } | |
1585 BitMap& fpu_register_usage() { return _fpu_register_usage; } | |
1586 intArray* fpu_stack_state() const { return _fpu_stack_state; } | |
1587 int first_lir_instruction_id() const { return _first_lir_instruction_id; } | |
1588 int last_lir_instruction_id() const { return _last_lir_instruction_id; } | |
1589 int total_preds() const { return _total_preds; } | |
1590 BitMap& stores_to_locals() { return _stores_to_locals; } | |
1591 | |
1592 // manipulation | |
1593 void set_bci(int bci) { Instruction::set_bci(bci); } | |
1594 void set_dominator(BlockBegin* dom) { _dominator = dom; } | |
1595 void set_loop_depth(int d) { _loop_depth = d; } | |
1596 void set_depth_first_number(int dfn) { _depth_first_number = dfn; } | |
1597 void set_linear_scan_number(int lsn) { _linear_scan_number = lsn; } | |
1598 void set_end(BlockEnd* end); | |
1599 void disconnect_from_graph(); | |
1600 static void disconnect_edge(BlockBegin* from, BlockBegin* to); | |
1601 BlockBegin* insert_block_between(BlockBegin* sux); | |
1602 void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux); | |
1603 void set_lir(LIR_List* lir) { _lir = lir; } | |
1604 void set_exception_handler_pco(int pco) { _exception_handler_pco = pco; } | |
1605 void set_live_in (BitMap map) { _live_in = map; } | |
1606 void set_live_out (BitMap map) { _live_out = map; } | |
1607 void set_live_gen (BitMap map) { _live_gen = map; } | |
1608 void set_live_kill (BitMap map) { _live_kill = map; } | |
1609 void set_fpu_register_usage(BitMap map) { _fpu_register_usage = map; } | |
1610 void set_fpu_stack_state(intArray* state) { _fpu_stack_state = state; } | |
1611 void set_first_lir_instruction_id(int id) { _first_lir_instruction_id = id; } | |
1612 void set_last_lir_instruction_id(int id) { _last_lir_instruction_id = id; } | |
1613 void increment_total_preds(int n = 1) { _total_preds += n; } | |
1614 void init_stores_to_locals(int locals_count) { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); } | |
1615 | |
1616 // generic | |
1584 | 1617 virtual void state_values_do(ValueVisitor* f); |
0 | 1618 |
1619 // successors and predecessors | |
1620 int number_of_sux() const; | |
1621 BlockBegin* sux_at(int i) const; | |
1622 void add_successor(BlockBegin* sux); | |
1623 void remove_successor(BlockBegin* pred); | |
1624 bool is_successor(BlockBegin* sux) const { return _successors.contains(sux); } | |
1625 | |
1626 void add_predecessor(BlockBegin* pred); | |
1627 void remove_predecessor(BlockBegin* pred); | |
1628 bool is_predecessor(BlockBegin* pred) const { return _predecessors.contains(pred); } | |
1629 int number_of_preds() const { return _predecessors.length(); } | |
1630 BlockBegin* pred_at(int i) const { return _predecessors[i]; } | |
1631 | |
1632 // exception handlers potentially invoked by this block | |
1633 void add_exception_handler(BlockBegin* b); | |
1634 bool is_exception_handler(BlockBegin* b) const { return _exception_handlers.contains(b); } | |
1635 int number_of_exception_handlers() const { return _exception_handlers.length(); } | |
1636 BlockBegin* exception_handler_at(int i) const { return _exception_handlers.at(i); } | |
1637 | |
1638 // states of the instructions that have an edge to this exception handler | |
1639 int number_of_exception_states() { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states == NULL ? 0 : _exception_states->length(); } | |
1640 ValueStack* exception_state_at(int idx) const { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states->at(idx); } | |
1641 int add_exception_state(ValueStack* state); | |
1642 | |
1643 // flags | |
1644 enum Flag { | |
1645 no_flag = 0, | |
1646 std_entry_flag = 1 << 0, | |
1647 osr_entry_flag = 1 << 1, | |
1648 exception_entry_flag = 1 << 2, | |
1649 subroutine_entry_flag = 1 << 3, | |
1650 backward_branch_target_flag = 1 << 4, | |
1651 is_on_work_list_flag = 1 << 5, | |
1652 was_visited_flag = 1 << 6, | |
1378
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1295
diff
changeset
|
1653 parser_loop_header_flag = 1 << 7, // set by parser to identify blocks where phi functions can not be created on demand |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1295
diff
changeset
|
1654 critical_edge_split_flag = 1 << 8, // set for all blocks that are introduced when critical edges are split |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1295
diff
changeset
|
1655 linear_scan_loop_header_flag = 1 << 9, // set during loop-detection for LinearScan |
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1295
diff
changeset
|
1656 linear_scan_loop_end_flag = 1 << 10 // set during loop-detection for LinearScan |
0 | 1657 }; |
1658 | |
1659 void set(Flag f) { _flags |= f; } | |
1660 void clear(Flag f) { _flags &= ~f; } | |
1661 bool is_set(Flag f) const { return (_flags & f) != 0; } | |
1662 bool is_entry_block() const { | |
1663 const int entry_mask = std_entry_flag | osr_entry_flag | exception_entry_flag; | |
1664 return (_flags & entry_mask) != 0; | |
1665 } | |
1666 | |
1667 // iteration | |
1668 void iterate_preorder (BlockClosure* closure); | |
1669 void iterate_postorder (BlockClosure* closure); | |
1670 | |
1584 | 1671 void block_values_do(ValueVisitor* f); |
0 | 1672 |
1673 // loops | |
1674 void set_loop_index(int ix) { _loop_index = ix; } | |
1675 int loop_index() const { return _loop_index; } | |
1676 | |
1677 // merging | |
1678 bool try_merge(ValueStack* state); // try to merge states at block begin | |
1679 void merge(ValueStack* state) { bool b = try_merge(state); assert(b, "merge failed"); } | |
1680 | |
1681 // debugging | |
1682 void print_block() PRODUCT_RETURN; | |
1683 void print_block(InstructionPrinter& ip, bool live_only = false) PRODUCT_RETURN; | |
1684 }; | |
1685 | |
1686 | |
1687 BASE(BlockEnd, StateSplit) | |
1688 private: | |
1689 BlockBegin* _begin; | |
1690 BlockList* _sux; | |
1691 ValueStack* _state_before; | |
1692 | |
1693 protected: | |
1694 BlockList* sux() const { return _sux; } | |
1695 | |
1696 void set_sux(BlockList* sux) { | |
1697 #ifdef ASSERT | |
1698 assert(sux != NULL, "sux must exist"); | |
1699 for (int i = sux->length() - 1; i >= 0; i--) assert(sux->at(i) != NULL, "sux must exist"); | |
1700 #endif | |
1701 _sux = sux; | |
1702 } | |
1703 | |
1704 public: | |
1705 // creation | |
1706 BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint) | |
1707 : StateSplit(type) | |
1708 , _begin(NULL) | |
1709 , _sux(NULL) | |
1710 , _state_before(state_before) { | |
1711 set_flag(IsSafepointFlag, is_safepoint); | |
1712 } | |
1713 | |
1714 // accessors | |
1715 ValueStack* state_before() const { return _state_before; } | |
1716 bool is_safepoint() const { return check_flag(IsSafepointFlag); } | |
1717 BlockBegin* begin() const { return _begin; } | |
1718 | |
1719 // manipulation | |
1720 void set_begin(BlockBegin* begin); | |
1721 | |
1722 // generic | |
1584 | 1723 virtual void other_values_do(ValueVisitor* f); |
0 | 1724 |
1725 // successors | |
1726 int number_of_sux() const { return _sux != NULL ? _sux->length() : 0; } | |
1727 BlockBegin* sux_at(int i) const { return _sux->at(i); } | |
1728 BlockBegin* default_sux() const { return sux_at(number_of_sux() - 1); } | |
1729 BlockBegin** addr_sux_at(int i) const { return _sux->adr_at(i); } | |
1730 int sux_index(BlockBegin* sux) const { return _sux->find(sux); } | |
1731 void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux); | |
1732 }; | |
1733 | |
1734 | |
1735 LEAF(Goto, BlockEnd) | |
1736 public: | |
1737 // creation | |
1738 Goto(BlockBegin* sux, ValueStack* state_before, bool is_safepoint = false) : BlockEnd(illegalType, state_before, is_safepoint) { | |
1739 BlockList* s = new BlockList(1); | |
1740 s->append(sux); | |
1741 set_sux(s); | |
1742 } | |
1743 | |
1744 Goto(BlockBegin* sux, bool is_safepoint) : BlockEnd(illegalType, NULL, is_safepoint) { | |
1745 BlockList* s = new BlockList(1); | |
1746 s->append(sux); | |
1747 set_sux(s); | |
1748 } | |
1749 | |
1750 }; | |
1751 | |
1752 | |
1753 LEAF(If, BlockEnd) | |
1754 private: | |
1755 Value _x; | |
1756 Condition _cond; | |
1757 Value _y; | |
1758 ciMethod* _profiled_method; | |
1759 int _profiled_bci; // Canonicalizer may alter bci of If node | |
1760 public: | |
1761 // creation | |
1762 // unordered_is_true is valid for float/double compares only | |
1763 If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint) | |
1764 : BlockEnd(illegalType, state_before, is_safepoint) | |
1765 , _x(x) | |
1766 , _cond(cond) | |
1767 , _y(y) | |
1768 , _profiled_method(NULL) | |
1769 , _profiled_bci(0) | |
1770 { | |
1771 ASSERT_VALUES | |
1772 set_flag(UnorderedIsTrueFlag, unordered_is_true); | |
1773 assert(x->type()->tag() == y->type()->tag(), "types must match"); | |
1774 BlockList* s = new BlockList(2); | |
1775 s->append(tsux); | |
1776 s->append(fsux); | |
1777 set_sux(s); | |
1778 } | |
1779 | |
1780 // accessors | |
1781 Value x() const { return _x; } | |
1782 Condition cond() const { return _cond; } | |
1783 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); } | |
1784 Value y() const { return _y; } | |
1785 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); } | |
1786 BlockBegin* tsux() const { return sux_for(true); } | |
1787 BlockBegin* fsux() const { return sux_for(false); } | |
1788 BlockBegin* usux() const { return sux_for(unordered_is_true()); } | |
1789 bool should_profile() const { return check_flag(ProfileMDOFlag); } | |
1790 ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches | |
1791 int profiled_bci() const { return _profiled_bci; } // set only for profiled branches | |
1792 | |
1793 // manipulation | |
1794 void swap_operands() { | |
1795 Value t = _x; _x = _y; _y = t; | |
1796 _cond = mirror(_cond); | |
1797 } | |
1798 | |
1799 void swap_sux() { | |
1800 assert(number_of_sux() == 2, "wrong number of successors"); | |
1801 BlockList* s = sux(); | |
1802 BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); | |
1803 _cond = negate(_cond); | |
1804 set_flag(UnorderedIsTrueFlag, !check_flag(UnorderedIsTrueFlag)); | |
1805 } | |
1806 | |
1807 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } | |
1808 void set_profiled_method(ciMethod* method) { _profiled_method = method; } | |
1809 void set_profiled_bci(int bci) { _profiled_bci = bci; } | |
1810 | |
1811 // generic | |
1584 | 1812 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); } |
0 | 1813 }; |
1814 | |
1815 | |
1816 LEAF(IfInstanceOf, BlockEnd) | |
1817 private: | |
1818 ciKlass* _klass; | |
1819 Value _obj; | |
1820 bool _test_is_instance; // jump if instance | |
1821 int _instanceof_bci; | |
1822 | |
1823 public: | |
1824 IfInstanceOf(ciKlass* klass, Value obj, bool test_is_instance, int instanceof_bci, BlockBegin* tsux, BlockBegin* fsux) | |
1825 : BlockEnd(illegalType, NULL, false) // temporary set to false | |
1826 , _klass(klass) | |
1827 , _obj(obj) | |
1828 , _test_is_instance(test_is_instance) | |
1829 , _instanceof_bci(instanceof_bci) | |
1830 { | |
1831 ASSERT_VALUES | |
1832 assert(instanceof_bci >= 0, "illegal bci"); | |
1833 BlockList* s = new BlockList(2); | |
1834 s->append(tsux); | |
1835 s->append(fsux); | |
1836 set_sux(s); | |
1837 } | |
1838 | |
1839 // accessors | |
1840 // | |
1841 // Note 1: If test_is_instance() is true, IfInstanceOf tests if obj *is* an | |
1842 // instance of klass; otherwise it tests if it is *not* and instance | |
1843 // of klass. | |
1844 // | |
1845 // Note 2: IfInstanceOf instructions are created by combining an InstanceOf | |
1846 // and an If instruction. The IfInstanceOf bci() corresponds to the | |
1847 // bci that the If would have had; the (this->) instanceof_bci() is | |
1848 // the bci of the original InstanceOf instruction. | |
1849 ciKlass* klass() const { return _klass; } | |
1850 Value obj() const { return _obj; } | |
1851 int instanceof_bci() const { return _instanceof_bci; } | |
1852 bool test_is_instance() const { return _test_is_instance; } | |
1853 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); } | |
1854 BlockBegin* tsux() const { return sux_for(true); } | |
1855 BlockBegin* fsux() const { return sux_for(false); } | |
1856 | |
1857 // manipulation | |
1858 void swap_sux() { | |
1859 assert(number_of_sux() == 2, "wrong number of successors"); | |
1860 BlockList* s = sux(); | |
1861 BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); | |
1862 _test_is_instance = !_test_is_instance; | |
1863 } | |
1864 | |
1865 // generic | |
1584 | 1866 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_obj); } |
0 | 1867 }; |
1868 | |
1869 | |
1870 BASE(Switch, BlockEnd) | |
1871 private: | |
1872 Value _tag; | |
1873 | |
1874 public: | |
1875 // creation | |
1876 Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint) | |
1877 : BlockEnd(illegalType, state_before, is_safepoint) | |
1878 , _tag(tag) { | |
1879 ASSERT_VALUES | |
1880 set_sux(sux); | |
1881 } | |
1882 | |
1883 // accessors | |
1884 Value tag() const { return _tag; } | |
1885 int length() const { return number_of_sux() - 1; } | |
1886 | |
1887 // generic | |
1584 | 1888 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_tag); } |
0 | 1889 }; |
1890 | |
1891 | |
1892 LEAF(TableSwitch, Switch) | |
1893 private: | |
1894 int _lo_key; | |
1895 | |
1896 public: | |
1897 // creation | |
1898 TableSwitch(Value tag, BlockList* sux, int lo_key, ValueStack* state_before, bool is_safepoint) | |
1899 : Switch(tag, sux, state_before, is_safepoint) | |
1900 , _lo_key(lo_key) {} | |
1901 | |
1902 // accessors | |
1903 int lo_key() const { return _lo_key; } | |
1904 int hi_key() const { return _lo_key + length() - 1; } | |
1905 }; | |
1906 | |
1907 | |
1908 LEAF(LookupSwitch, Switch) | |
1909 private: | |
1910 intArray* _keys; | |
1911 | |
1912 public: | |
1913 // creation | |
1914 LookupSwitch(Value tag, BlockList* sux, intArray* keys, ValueStack* state_before, bool is_safepoint) | |
1915 : Switch(tag, sux, state_before, is_safepoint) | |
1916 , _keys(keys) { | |
1917 assert(keys != NULL, "keys must exist"); | |
1918 assert(keys->length() == length(), "sux & keys have incompatible lengths"); | |
1919 } | |
1920 | |
1921 // accessors | |
1922 int key_at(int i) const { return _keys->at(i); } | |
1923 }; | |
1924 | |
1925 | |
1926 LEAF(Return, BlockEnd) | |
1927 private: | |
1928 Value _result; | |
1929 | |
1930 public: | |
1931 // creation | |
1932 Return(Value result) : | |
1933 BlockEnd(result == NULL ? voidType : result->type()->base(), NULL, true), | |
1934 _result(result) {} | |
1935 | |
1936 // accessors | |
1937 Value result() const { return _result; } | |
1938 bool has_result() const { return result() != NULL; } | |
1939 | |
1940 // generic | |
1584 | 1941 virtual void input_values_do(ValueVisitor* f) { |
0 | 1942 BlockEnd::input_values_do(f); |
1584 | 1943 if (has_result()) f->visit(&_result); |
0 | 1944 } |
1945 }; | |
1946 | |
1947 | |
1948 LEAF(Throw, BlockEnd) | |
1949 private: | |
1950 Value _exception; | |
1951 | |
1952 public: | |
1953 // creation | |
1954 Throw(Value exception, ValueStack* state_before) : BlockEnd(illegalType, state_before, true), _exception(exception) { | |
1955 ASSERT_VALUES | |
1956 } | |
1957 | |
1958 // accessors | |
1959 Value exception() const { return _exception; } | |
1960 | |
1961 // generic | |
1962 virtual bool can_trap() const { return true; } | |
1584 | 1963 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_exception); } |
1964 virtual void state_values_do(ValueVisitor* f); | |
0 | 1965 }; |
1966 | |
1967 | |
1968 LEAF(Base, BlockEnd) | |
1969 public: | |
1970 // creation | |
1971 Base(BlockBegin* std_entry, BlockBegin* osr_entry) : BlockEnd(illegalType, NULL, false) { | |
1972 assert(std_entry->is_set(BlockBegin::std_entry_flag), "std entry must be flagged"); | |
1973 assert(osr_entry == NULL || osr_entry->is_set(BlockBegin::osr_entry_flag), "osr entry must be flagged"); | |
1974 BlockList* s = new BlockList(2); | |
1975 if (osr_entry != NULL) s->append(osr_entry); | |
1976 s->append(std_entry); // must be default sux! | |
1977 set_sux(s); | |
1978 } | |
1979 | |
1980 // accessors | |
1981 BlockBegin* std_entry() const { return default_sux(); } | |
1982 BlockBegin* osr_entry() const { return number_of_sux() < 2 ? NULL : sux_at(0); } | |
1983 }; | |
1984 | |
1985 | |
1986 LEAF(OsrEntry, Instruction) | |
1987 public: | |
1988 // creation | |
1989 #ifdef _LP64 | |
1990 OsrEntry() : Instruction(longType, false) { pin(); } | |
1991 #else | |
1992 OsrEntry() : Instruction(intType, false) { pin(); } | |
1993 #endif | |
1994 | |
1995 // generic | |
1584 | 1996 virtual void input_values_do(ValueVisitor* f) { } |
0 | 1997 }; |
1998 | |
1999 | |
2000 // Models the incoming exception at a catch site | |
2001 LEAF(ExceptionObject, Instruction) | |
2002 public: | |
2003 // creation | |
2004 ExceptionObject() : Instruction(objectType, false) { | |
2005 pin(); | |
2006 } | |
2007 | |
2008 // generic | |
1584 | 2009 virtual void input_values_do(ValueVisitor* f) { } |
0 | 2010 }; |
2011 | |
2012 | |
2013 // Models needed rounding for floating-point values on Intel. | |
2014 // Currently only used to represent rounding of double-precision | |
2015 // values stored into local variables, but could be used to model | |
2016 // intermediate rounding of single-precision values as well. | |
2017 LEAF(RoundFP, Instruction) | |
2018 private: | |
2019 Value _input; // floating-point value to be rounded | |
2020 | |
2021 public: | |
2022 RoundFP(Value input) | |
2023 : Instruction(input->type()) // Note: should not be used for constants | |
2024 , _input(input) | |
2025 { | |
2026 ASSERT_VALUES | |
2027 } | |
2028 | |
2029 // accessors | |
2030 Value input() const { return _input; } | |
2031 | |
2032 // generic | |
1584 | 2033 virtual void input_values_do(ValueVisitor* f) { f->visit(&_input); } |
0 | 2034 }; |
2035 | |
2036 | |
2037 BASE(UnsafeOp, Instruction) | |
2038 private: | |
2039 BasicType _basic_type; // ValueType can not express byte-sized integers | |
2040 | |
2041 protected: | |
2042 // creation | |
2043 UnsafeOp(BasicType basic_type, bool is_put) | |
2044 : Instruction(is_put ? voidType : as_ValueType(basic_type)) | |
2045 , _basic_type(basic_type) | |
2046 { | |
2047 //Note: Unsafe ops are not not guaranteed to throw NPE. | |
2048 // Convservatively, Unsafe operations must be pinned though we could be | |
2049 // looser about this if we wanted to.. | |
2050 pin(); | |
2051 } | |
2052 | |
2053 public: | |
2054 // accessors | |
2055 BasicType basic_type() { return _basic_type; } | |
2056 | |
2057 // generic | |
1584 | 2058 virtual void input_values_do(ValueVisitor* f) { } |
2059 virtual void other_values_do(ValueVisitor* f) { } | |
0 | 2060 }; |
2061 | |
2062 | |
2063 BASE(UnsafeRawOp, UnsafeOp) | |
2064 private: | |
2065 Value _base; // Base address (a Java long) | |
2066 Value _index; // Index if computed by optimizer; initialized to NULL | |
2067 int _log2_scale; // Scale factor: 0, 1, 2, or 3. | |
2068 // Indicates log2 of number of bytes (1, 2, 4, or 8) | |
2069 // to scale index by. | |
2070 | |
2071 protected: | |
2072 UnsafeRawOp(BasicType basic_type, Value addr, bool is_put) | |
2073 : UnsafeOp(basic_type, is_put) | |
2074 , _base(addr) | |
2075 , _index(NULL) | |
2076 , _log2_scale(0) | |
2077 { | |
2078 // Can not use ASSERT_VALUES because index may be NULL | |
2079 assert(addr != NULL && addr->type()->is_long(), "just checking"); | |
2080 } | |
2081 | |
2082 UnsafeRawOp(BasicType basic_type, Value base, Value index, int log2_scale, bool is_put) | |
2083 : UnsafeOp(basic_type, is_put) | |
2084 , _base(base) | |
2085 , _index(index) | |
2086 , _log2_scale(log2_scale) | |
2087 { | |
2088 } | |
2089 | |
2090 public: | |
2091 // accessors | |
2092 Value base() { return _base; } | |
2093 Value index() { return _index; } | |
2094 bool has_index() { return (_index != NULL); } | |
2095 int log2_scale() { return _log2_scale; } | |
2096 | |
2097 // setters | |
2098 void set_base (Value base) { _base = base; } | |
2099 void set_index(Value index) { _index = index; } | |
2100 void set_log2_scale(int log2_scale) { _log2_scale = log2_scale; } | |
2101 | |
2102 // generic | |
1584 | 2103 virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); |
2104 f->visit(&_base); | |
2105 if (has_index()) f->visit(&_index); } | |
0 | 2106 }; |
2107 | |
2108 | |
2109 LEAF(UnsafeGetRaw, UnsafeRawOp) | |
2110 private: | |
2111 bool _may_be_unaligned; // For OSREntry | |
2112 | |
2113 public: | |
2114 UnsafeGetRaw(BasicType basic_type, Value addr, bool may_be_unaligned) | |
2115 : UnsafeRawOp(basic_type, addr, false) { | |
2116 _may_be_unaligned = may_be_unaligned; | |
2117 } | |
2118 | |
2119 UnsafeGetRaw(BasicType basic_type, Value base, Value index, int log2_scale, bool may_be_unaligned) | |
2120 : UnsafeRawOp(basic_type, base, index, log2_scale, false) { | |
2121 _may_be_unaligned = may_be_unaligned; | |
2122 } | |
2123 | |
2124 bool may_be_unaligned() { return _may_be_unaligned; } | |
2125 }; | |
2126 | |
2127 | |
2128 LEAF(UnsafePutRaw, UnsafeRawOp) | |
2129 private: | |
2130 Value _value; // Value to be stored | |
2131 | |
2132 public: | |
2133 UnsafePutRaw(BasicType basic_type, Value addr, Value value) | |
2134 : UnsafeRawOp(basic_type, addr, true) | |
2135 , _value(value) | |
2136 { | |
2137 assert(value != NULL, "just checking"); | |
2138 ASSERT_VALUES | |
2139 } | |
2140 | |
2141 UnsafePutRaw(BasicType basic_type, Value base, Value index, int log2_scale, Value value) | |
2142 : UnsafeRawOp(basic_type, base, index, log2_scale, true) | |
2143 , _value(value) | |
2144 { | |
2145 assert(value != NULL, "just checking"); | |
2146 ASSERT_VALUES | |
2147 } | |
2148 | |
2149 // accessors | |
2150 Value value() { return _value; } | |
2151 | |
2152 // generic | |
1584 | 2153 virtual void input_values_do(ValueVisitor* f) { UnsafeRawOp::input_values_do(f); |
2154 f->visit(&_value); } | |
0 | 2155 }; |
2156 | |
2157 | |
2158 BASE(UnsafeObjectOp, UnsafeOp) | |
2159 private: | |
2160 Value _object; // Object to be fetched from or mutated | |
2161 Value _offset; // Offset within object | |
2162 bool _is_volatile; // true if volatile - dl/JSR166 | |
2163 public: | |
2164 UnsafeObjectOp(BasicType basic_type, Value object, Value offset, bool is_put, bool is_volatile) | |
2165 : UnsafeOp(basic_type, is_put), _object(object), _offset(offset), _is_volatile(is_volatile) | |
2166 { | |
2167 } | |
2168 | |
2169 // accessors | |
2170 Value object() { return _object; } | |
2171 Value offset() { return _offset; } | |
2172 bool is_volatile() { return _is_volatile; } | |
2173 // generic | |
1584 | 2174 virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); |
2175 f->visit(&_object); | |
2176 f->visit(&_offset); } | |
0 | 2177 }; |
2178 | |
2179 | |
2180 LEAF(UnsafeGetObject, UnsafeObjectOp) | |
2181 public: | |
2182 UnsafeGetObject(BasicType basic_type, Value object, Value offset, bool is_volatile) | |
2183 : UnsafeObjectOp(basic_type, object, offset, false, is_volatile) | |
2184 { | |
2185 ASSERT_VALUES | |
2186 } | |
2187 }; | |
2188 | |
2189 | |
2190 LEAF(UnsafePutObject, UnsafeObjectOp) | |
2191 private: | |
2192 Value _value; // Value to be stored | |
2193 public: | |
2194 UnsafePutObject(BasicType basic_type, Value object, Value offset, Value value, bool is_volatile) | |
2195 : UnsafeObjectOp(basic_type, object, offset, true, is_volatile) | |
2196 , _value(value) | |
2197 { | |
2198 ASSERT_VALUES | |
2199 } | |
2200 | |
2201 // accessors | |
2202 Value value() { return _value; } | |
2203 | |
2204 // generic | |
1584 | 2205 virtual void input_values_do(ValueVisitor* f) { UnsafeObjectOp::input_values_do(f); |
2206 f->visit(&_value); } | |
0 | 2207 }; |
2208 | |
2209 | |
2210 BASE(UnsafePrefetch, UnsafeObjectOp) | |
2211 public: | |
2212 UnsafePrefetch(Value object, Value offset) | |
2213 : UnsafeObjectOp(T_VOID, object, offset, false, false) | |
2214 { | |
2215 } | |
2216 }; | |
2217 | |
2218 | |
2219 LEAF(UnsafePrefetchRead, UnsafePrefetch) | |
2220 public: | |
2221 UnsafePrefetchRead(Value object, Value offset) | |
2222 : UnsafePrefetch(object, offset) | |
2223 { | |
2224 ASSERT_VALUES | |
2225 } | |
2226 }; | |
2227 | |
2228 | |
2229 LEAF(UnsafePrefetchWrite, UnsafePrefetch) | |
2230 public: | |
2231 UnsafePrefetchWrite(Value object, Value offset) | |
2232 : UnsafePrefetch(object, offset) | |
2233 { | |
2234 ASSERT_VALUES | |
2235 } | |
2236 }; | |
2237 | |
2238 | |
2239 LEAF(ProfileCall, Instruction) | |
2240 private: | |
2241 ciMethod* _method; | |
2242 int _bci_of_invoke; | |
2243 Value _recv; | |
2244 ciKlass* _known_holder; | |
2245 | |
2246 public: | |
2247 ProfileCall(ciMethod* method, int bci, Value recv, ciKlass* known_holder) | |
2248 : Instruction(voidType) | |
2249 , _method(method) | |
2250 , _bci_of_invoke(bci) | |
2251 , _recv(recv) | |
2252 , _known_holder(known_holder) | |
2253 { | |
2254 // The ProfileCall has side-effects and must occur precisely where located | |
2255 pin(); | |
2256 } | |
2257 | |
2258 ciMethod* method() { return _method; } | |
2259 int bci_of_invoke() { return _bci_of_invoke; } | |
2260 Value recv() { return _recv; } | |
2261 ciKlass* known_holder() { return _known_holder; } | |
2262 | |
1584 | 2263 virtual void input_values_do(ValueVisitor* f) { if (_recv != NULL) f->visit(&_recv); } |
0 | 2264 }; |
2265 | |
2266 | |
2267 // | |
2268 // Simple node representing a counter update generally used for updating MDOs | |
2269 // | |
2270 LEAF(ProfileCounter, Instruction) | |
2271 private: | |
2272 Value _mdo; | |
2273 int _offset; | |
2274 int _increment; | |
2275 | |
2276 public: | |
2277 ProfileCounter(Value mdo, int offset, int increment = 1) | |
2278 : Instruction(voidType) | |
2279 , _mdo(mdo) | |
2280 , _offset(offset) | |
2281 , _increment(increment) | |
2282 { | |
2283 // The ProfileCounter has side-effects and must occur precisely where located | |
2284 pin(); | |
2285 } | |
2286 | |
2287 Value mdo() { return _mdo; } | |
2288 int offset() { return _offset; } | |
2289 int increment() { return _increment; } | |
2290 | |
1584 | 2291 virtual void input_values_do(ValueVisitor* f) { f->visit(&_mdo); } |
0 | 2292 }; |
2293 | |
2294 | |
2295 class BlockPair: public CompilationResourceObj { | |
2296 private: | |
2297 BlockBegin* _from; | |
2298 BlockBegin* _to; | |
2299 public: | |
2300 BlockPair(BlockBegin* from, BlockBegin* to): _from(from), _to(to) {} | |
2301 BlockBegin* from() const { return _from; } | |
2302 BlockBegin* to() const { return _to; } | |
2303 bool is_same(BlockBegin* from, BlockBegin* to) const { return _from == from && _to == to; } | |
2304 bool is_same(BlockPair* p) const { return _from == p->from() && _to == p->to(); } | |
2305 void set_to(BlockBegin* b) { _to = b; } | |
2306 void set_from(BlockBegin* b) { _from = b; } | |
2307 }; | |
2308 | |
2309 | |
2310 define_array(BlockPairArray, BlockPair*) | |
2311 define_stack(BlockPairList, BlockPairArray) | |
2312 | |
2313 | |
2314 inline int BlockBegin::number_of_sux() const { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); } | |
2315 inline BlockBegin* BlockBegin::sux_at(int i) const { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch"); return _successors.at(i); } | |
2316 inline void BlockBegin::add_successor(BlockBegin* sux) { assert(_end == NULL, "Would create mismatch with successors of BlockEnd"); _successors.append(sux); } | |
2317 | |
2318 #undef ASSERT_VALUES |