Mercurial > hg > graal-jvmci-8
annotate src/share/vm/c1/c1_Instruction.hpp @ 1791:3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
Summary: Added profiling of instanceof and aastore.
Reviewed-by: kvn, jrose, never
author | iveresov |
---|---|
date | Mon, 13 Sep 2010 12:10:49 -0700 |
parents | d5d065957597 |
children | f02a8bbe6ed4 |
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; | |
1783 | 101 class ProfileInvoke; |
0 | 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; | |
1783 | 198 virtual void do_ProfileInvoke (ProfileInvoke* x) = 0; |
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 | |
1791
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
909 ciMethod* _profiled_method; |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
910 int _profiled_bci; |
0 | 911 public: |
912 // creation | |
913 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* lock_stack) | |
914 : AccessIndexed(array, index, length, elt_type, lock_stack) | |
1791
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
915 , _value(value), _profiled_method(NULL), _profiled_bci(0) |
0 | 916 { |
917 set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object())); | |
918 set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object())); | |
919 ASSERT_VALUES | |
920 pin(); | |
921 } | |
922 | |
923 // accessors | |
924 Value value() const { return _value; } | |
925 IRScope* scope() const; // the state's scope | |
926 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } | |
927 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); } | |
1791
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
928 // Helpers for methodDataOop profiling |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
929 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
930 void set_profiled_method(ciMethod* method) { _profiled_method = method; } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
931 void set_profiled_bci(int bci) { _profiled_bci = bci; } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
932 bool should_profile() const { return check_flag(ProfileMDOFlag); } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
933 ciMethod* profiled_method() const { return _profiled_method; } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
934 int profiled_bci() const { return _profiled_bci; } |
0 | 935 // generic |
1584 | 936 virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); } |
0 | 937 }; |
938 | |
939 | |
940 LEAF(NegateOp, Instruction) | |
941 private: | |
942 Value _x; | |
943 | |
944 public: | |
945 // creation | |
946 NegateOp(Value x) : Instruction(x->type()->base()), _x(x) { | |
947 ASSERT_VALUES | |
948 } | |
949 | |
950 // accessors | |
951 Value x() const { return _x; } | |
952 | |
953 // generic | |
1584 | 954 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); } |
0 | 955 }; |
956 | |
957 | |
958 BASE(Op2, Instruction) | |
959 private: | |
960 Bytecodes::Code _op; | |
961 Value _x; | |
962 Value _y; | |
963 | |
964 public: | |
965 // creation | |
966 Op2(ValueType* type, Bytecodes::Code op, Value x, Value y) : Instruction(type), _op(op), _x(x), _y(y) { | |
967 ASSERT_VALUES | |
968 } | |
969 | |
970 // accessors | |
971 Bytecodes::Code op() const { return _op; } | |
972 Value x() const { return _x; } | |
973 Value y() const { return _y; } | |
974 | |
975 // manipulators | |
976 void swap_operands() { | |
977 assert(is_commutative(), "operation must be commutative"); | |
978 Value t = _x; _x = _y; _y = t; | |
979 } | |
980 | |
981 // generic | |
982 virtual bool is_commutative() const { return false; } | |
1584 | 983 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); f->visit(&_y); } |
0 | 984 }; |
985 | |
986 | |
987 LEAF(ArithmeticOp, Op2) | |
988 private: | |
989 ValueStack* _lock_stack; // used only for division operations | |
990 public: | |
991 // creation | |
992 ArithmeticOp(Bytecodes::Code op, Value x, Value y, bool is_strictfp, ValueStack* lock_stack) | |
993 : Op2(x->type()->meet(y->type()), op, x, y) | |
994 , _lock_stack(lock_stack) { | |
995 set_flag(IsStrictfpFlag, is_strictfp); | |
996 if (can_trap()) pin(); | |
997 } | |
998 | |
999 // accessors | |
1000 ValueStack* lock_stack() const { return _lock_stack; } | |
1001 bool is_strictfp() const { return check_flag(IsStrictfpFlag); } | |
1002 | |
1003 // setters | |
1004 void set_lock_stack(ValueStack* l) { _lock_stack = l; } | |
1005 | |
1006 // generic | |
1007 virtual bool is_commutative() const; | |
1008 virtual bool can_trap() const; | |
1584 | 1009 virtual void other_values_do(ValueVisitor* f); |
0 | 1010 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) |
1011 }; | |
1012 | |
1013 | |
1014 LEAF(ShiftOp, Op2) | |
1015 public: | |
1016 // creation | |
1017 ShiftOp(Bytecodes::Code op, Value x, Value s) : Op2(x->type()->base(), op, x, s) {} | |
1018 | |
1019 // generic | |
1020 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) | |
1021 }; | |
1022 | |
1023 | |
1024 LEAF(LogicOp, Op2) | |
1025 public: | |
1026 // creation | |
1027 LogicOp(Bytecodes::Code op, Value x, Value y) : Op2(x->type()->meet(y->type()), op, x, y) {} | |
1028 | |
1029 // generic | |
1030 virtual bool is_commutative() const; | |
1031 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) | |
1032 }; | |
1033 | |
1034 | |
1035 LEAF(CompareOp, Op2) | |
1036 private: | |
1037 ValueStack* _state_before; // for deoptimization, when canonicalizing | |
1038 public: | |
1039 // creation | |
1040 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before) | |
1041 : Op2(intType, op, x, y) | |
1042 , _state_before(state_before) | |
1043 {} | |
1044 | |
1045 // accessors | |
1046 ValueStack* state_before() const { return _state_before; } | |
1047 | |
1048 // generic | |
1049 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) | |
1584 | 1050 virtual void other_values_do(ValueVisitor* f); |
0 | 1051 }; |
1052 | |
1053 | |
1054 LEAF(IfOp, Op2) | |
1055 private: | |
1056 Value _tval; | |
1057 Value _fval; | |
1058 | |
1059 public: | |
1060 // creation | |
1061 IfOp(Value x, Condition cond, Value y, Value tval, Value fval) | |
1062 : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y) | |
1063 , _tval(tval) | |
1064 , _fval(fval) | |
1065 { | |
1066 ASSERT_VALUES | |
1067 assert(tval->type()->tag() == fval->type()->tag(), "types must match"); | |
1068 } | |
1069 | |
1070 // accessors | |
1071 virtual bool is_commutative() const; | |
1072 Bytecodes::Code op() const { ShouldNotCallThis(); return Bytecodes::_illegal; } | |
1073 Condition cond() const { return (Condition)Op2::op(); } | |
1074 Value tval() const { return _tval; } | |
1075 Value fval() const { return _fval; } | |
1076 | |
1077 // generic | |
1584 | 1078 virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); } |
0 | 1079 }; |
1080 | |
1081 | |
1082 LEAF(Convert, Instruction) | |
1083 private: | |
1084 Bytecodes::Code _op; | |
1085 Value _value; | |
1086 | |
1087 public: | |
1088 // creation | |
1089 Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) { | |
1090 ASSERT_VALUES | |
1091 } | |
1092 | |
1093 // accessors | |
1094 Bytecodes::Code op() const { return _op; } | |
1095 Value value() const { return _value; } | |
1096 | |
1097 // generic | |
1584 | 1098 virtual void input_values_do(ValueVisitor* f) { f->visit(&_value); } |
0 | 1099 HASHING2(Convert, true, op(), value()->subst()) |
1100 }; | |
1101 | |
1102 | |
1103 LEAF(NullCheck, Instruction) | |
1104 private: | |
1105 Value _obj; | |
1106 ValueStack* _lock_stack; | |
1107 | |
1108 public: | |
1109 // creation | |
1110 NullCheck(Value obj, ValueStack* lock_stack) : Instruction(obj->type()->base()), _obj(obj), _lock_stack(lock_stack) { | |
1111 ASSERT_VALUES | |
1112 set_can_trap(true); | |
1113 assert(_obj->type()->is_object(), "null check must be applied to objects only"); | |
1114 pin(Instruction::PinExplicitNullCheck); | |
1115 } | |
1116 | |
1117 // accessors | |
1118 Value obj() const { return _obj; } | |
1119 ValueStack* lock_stack() const { return _lock_stack; } | |
1120 | |
1121 // setters | |
1122 void set_lock_stack(ValueStack* l) { _lock_stack = l; } | |
1123 void set_can_trap(bool can_trap) { set_flag(CanTrapFlag, can_trap); } | |
1124 | |
1125 // generic | |
1126 virtual bool can_trap() const { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ } | |
1584 | 1127 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } |
1128 virtual void other_values_do(ValueVisitor* f); | |
0 | 1129 HASHING1(NullCheck, true, obj()->subst()) |
1130 }; | |
1131 | |
1132 | |
1133 BASE(StateSplit, Instruction) | |
1134 private: | |
1135 ValueStack* _state; | |
1136 | |
1137 protected: | |
1138 static void substitute(BlockList& list, BlockBegin* old_block, BlockBegin* new_block); | |
1139 | |
1140 public: | |
1141 // creation | |
1142 StateSplit(ValueType* type) : Instruction(type), _state(NULL) { | |
1143 pin(PinStateSplitConstructor); | |
1144 } | |
1145 | |
1146 // accessors | |
1147 ValueStack* state() const { return _state; } | |
1148 IRScope* scope() const; // the state's scope | |
1149 | |
1150 // manipulation | |
1151 void set_state(ValueStack* state) { _state = state; } | |
1152 | |
1153 // generic | |
1584 | 1154 virtual void input_values_do(ValueVisitor* f) { /* no values */ } |
1155 virtual void state_values_do(ValueVisitor* f); | |
0 | 1156 }; |
1157 | |
1158 | |
1159 LEAF(Invoke, StateSplit) | |
1160 private: | |
1295 | 1161 Bytecodes::Code _code; |
1162 Value _recv; | |
1163 Values* _args; | |
1164 BasicTypeList* _signature; | |
1165 int _vtable_index; | |
1166 ciMethod* _target; | |
1167 ValueStack* _state_before; // Required for deoptimization. | |
0 | 1168 |
1169 public: | |
1170 // creation | |
1171 Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args, | |
1295 | 1172 int vtable_index, ciMethod* target, ValueStack* state_before); |
0 | 1173 |
1174 // accessors | |
1175 Bytecodes::Code code() const { return _code; } | |
1176 Value receiver() const { return _recv; } | |
1177 bool has_receiver() const { return receiver() != NULL; } | |
1178 int number_of_arguments() const { return _args->length(); } | |
1179 Value argument_at(int i) const { return _args->at(i); } | |
1180 int vtable_index() const { return _vtable_index; } | |
1181 BasicTypeList* signature() const { return _signature; } | |
1182 ciMethod* target() const { return _target; } | |
1295 | 1183 ValueStack* state_before() const { return _state_before; } |
0 | 1184 |
1185 // Returns false if target is not loaded | |
1186 bool target_is_final() const { return check_flag(TargetIsFinalFlag); } | |
1187 bool target_is_loaded() const { return check_flag(TargetIsLoadedFlag); } | |
1188 // Returns false if target is not loaded | |
1189 bool target_is_strictfp() const { return check_flag(TargetIsStrictfpFlag); } | |
1190 | |
1295 | 1191 // JSR 292 support |
1192 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } | |
1193 | |
0 | 1194 // generic |
1195 virtual bool can_trap() const { return true; } | |
1584 | 1196 virtual void input_values_do(ValueVisitor* f) { |
0 | 1197 StateSplit::input_values_do(f); |
1584 | 1198 if (has_receiver()) f->visit(&_recv); |
1199 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); | |
0 | 1200 } |
1584 | 1201 virtual void state_values_do(ValueVisitor *f); |
0 | 1202 }; |
1203 | |
1204 | |
1205 LEAF(NewInstance, StateSplit) | |
1206 private: | |
1207 ciInstanceKlass* _klass; | |
1208 | |
1209 public: | |
1210 // creation | |
1211 NewInstance(ciInstanceKlass* klass) : StateSplit(instanceType), _klass(klass) {} | |
1212 | |
1213 // accessors | |
1214 ciInstanceKlass* klass() const { return _klass; } | |
1215 | |
1216 // generic | |
1217 virtual bool can_trap() const { return true; } | |
1218 ciType* exact_type() const; | |
1219 }; | |
1220 | |
1221 | |
1222 BASE(NewArray, StateSplit) | |
1223 private: | |
1224 Value _length; | |
1225 ValueStack* _state_before; | |
1226 | |
1227 public: | |
1228 // creation | |
1229 NewArray(Value length, ValueStack* state_before) : StateSplit(objectType), _length(length), _state_before(state_before) { | |
1230 // Do not ASSERT_VALUES since length is NULL for NewMultiArray | |
1231 } | |
1232 | |
1233 // accessors | |
1234 ValueStack* state_before() const { return _state_before; } | |
1235 Value length() const { return _length; } | |
1236 | |
1237 // generic | |
1238 virtual bool can_trap() const { return true; } | |
1584 | 1239 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); } |
1240 virtual void other_values_do(ValueVisitor* f); | |
0 | 1241 }; |
1242 | |
1243 | |
1244 LEAF(NewTypeArray, NewArray) | |
1245 private: | |
1246 BasicType _elt_type; | |
1247 | |
1248 public: | |
1249 // creation | |
1250 NewTypeArray(Value length, BasicType elt_type) : NewArray(length, NULL), _elt_type(elt_type) {} | |
1251 | |
1252 // accessors | |
1253 BasicType elt_type() const { return _elt_type; } | |
1254 ciType* exact_type() const; | |
1255 }; | |
1256 | |
1257 | |
1258 LEAF(NewObjectArray, NewArray) | |
1259 private: | |
1260 ciKlass* _klass; | |
1261 | |
1262 public: | |
1263 // creation | |
1264 NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {} | |
1265 | |
1266 // accessors | |
1267 ciKlass* klass() const { return _klass; } | |
1268 ciType* exact_type() const; | |
1269 }; | |
1270 | |
1271 | |
1272 LEAF(NewMultiArray, NewArray) | |
1273 private: | |
1274 ciKlass* _klass; | |
1275 Values* _dims; | |
1276 | |
1277 public: | |
1278 // creation | |
1279 NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(NULL, state_before), _klass(klass), _dims(dims) { | |
1280 ASSERT_VALUES | |
1281 } | |
1282 | |
1283 // accessors | |
1284 ciKlass* klass() const { return _klass; } | |
1285 Values* dims() const { return _dims; } | |
1286 int rank() const { return dims()->length(); } | |
1287 | |
1288 // generic | |
1584 | 1289 virtual void input_values_do(ValueVisitor* f) { |
0 | 1290 // NOTE: we do not call NewArray::input_values_do since "length" |
1291 // is meaningless for a multi-dimensional array; passing the | |
1292 // zeroth element down to NewArray as its length is a bad idea | |
1293 // since there will be a copy in the "dims" array which doesn't | |
1294 // get updated, and the value must not be traversed twice. Was bug | |
1295 // - kbr 4/10/2001 | |
1296 StateSplit::input_values_do(f); | |
1584 | 1297 for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i)); |
0 | 1298 } |
1299 }; | |
1300 | |
1301 | |
1302 BASE(TypeCheck, StateSplit) | |
1303 private: | |
1304 ciKlass* _klass; | |
1305 Value _obj; | |
1306 ValueStack* _state_before; | |
1307 | |
1791
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1308 ciMethod* _profiled_method; |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1309 int _profiled_bci; |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1310 |
0 | 1311 public: |
1312 // creation | |
1791
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1313 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before) |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1314 : StateSplit(type), _klass(klass), _obj(obj), _state_before(state_before), |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1315 _profiled_method(NULL), _profiled_bci(0) { |
0 | 1316 ASSERT_VALUES |
1317 set_direct_compare(false); | |
1318 } | |
1319 | |
1320 // accessors | |
1321 ValueStack* state_before() const { return _state_before; } | |
1322 ciKlass* klass() const { return _klass; } | |
1323 Value obj() const { return _obj; } | |
1324 bool is_loaded() const { return klass() != NULL; } | |
1325 bool direct_compare() const { return check_flag(DirectCompareFlag); } | |
1326 | |
1327 // manipulation | |
1328 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); } | |
1329 | |
1330 // generic | |
1331 virtual bool can_trap() const { return true; } | |
1584 | 1332 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } |
1333 virtual void other_values_do(ValueVisitor* f); | |
1791
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1334 |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1335 // Helpers for methodDataOop profiling |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1336 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1337 void set_profiled_method(ciMethod* method) { _profiled_method = method; } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1338 void set_profiled_bci(int bci) { _profiled_bci = bci; } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1339 bool should_profile() const { return check_flag(ProfileMDOFlag); } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1340 ciMethod* profiled_method() const { return _profiled_method; } |
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1341 int profiled_bci() const { return _profiled_bci; } |
0 | 1342 }; |
1343 | |
1344 | |
1345 LEAF(CheckCast, TypeCheck) | |
1346 public: | |
1347 // creation | |
1348 CheckCast(ciKlass* klass, Value obj, ValueStack* state_before) | |
1791
3a294e483abc
6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents:
1783
diff
changeset
|
1349 : TypeCheck(klass, obj, objectType, state_before) {} |
0 | 1350 |
1351 void set_incompatible_class_change_check() { | |
1352 set_flag(ThrowIncompatibleClassChangeErrorFlag, true); | |
1353 } | |
1354 bool is_incompatible_class_change_check() const { | |
1355 return check_flag(ThrowIncompatibleClassChangeErrorFlag); | |
1356 } | |
1357 | |
1358 ciType* declared_type() const; | |
1359 ciType* exact_type() const; | |
1360 }; | |
1361 | |
1362 | |
1363 LEAF(InstanceOf, TypeCheck) | |
1364 public: | |
1365 // creation | |
1366 InstanceOf(ciKlass* klass, Value obj, ValueStack* state_before) : TypeCheck(klass, obj, intType, state_before) {} | |
1367 }; | |
1368 | |
1369 | |
1370 BASE(AccessMonitor, StateSplit) | |
1371 private: | |
1372 Value _obj; | |
1373 int _monitor_no; | |
1374 | |
1375 public: | |
1376 // creation | |
1377 AccessMonitor(Value obj, int monitor_no) | |
1378 : StateSplit(illegalType) | |
1379 , _obj(obj) | |
1380 , _monitor_no(monitor_no) | |
1381 { | |
1382 set_needs_null_check(true); | |
1383 ASSERT_VALUES | |
1384 } | |
1385 | |
1386 // accessors | |
1387 Value obj() const { return _obj; } | |
1388 int monitor_no() const { return _monitor_no; } | |
1389 | |
1390 // generic | |
1584 | 1391 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } |
0 | 1392 }; |
1393 | |
1394 | |
1395 LEAF(MonitorEnter, AccessMonitor) | |
1396 private: | |
1397 ValueStack* _lock_stack_before; | |
1398 | |
1399 public: | |
1400 // creation | |
1401 MonitorEnter(Value obj, int monitor_no, ValueStack* lock_stack_before) | |
1402 : AccessMonitor(obj, monitor_no) | |
1403 , _lock_stack_before(lock_stack_before) | |
1404 { | |
1405 ASSERT_VALUES | |
1406 } | |
1407 | |
1408 // accessors | |
1409 ValueStack* lock_stack_before() const { return _lock_stack_before; } | |
1584 | 1410 virtual void state_values_do(ValueVisitor* f); |
0 | 1411 |
1412 // generic | |
1413 virtual bool can_trap() const { return true; } | |
1414 }; | |
1415 | |
1416 | |
1417 LEAF(MonitorExit, AccessMonitor) | |
1418 public: | |
1419 // creation | |
1420 MonitorExit(Value obj, int monitor_no) : AccessMonitor(obj, monitor_no) {} | |
1421 }; | |
1422 | |
1423 | |
1424 LEAF(Intrinsic, StateSplit) | |
1425 private: | |
1426 vmIntrinsics::ID _id; | |
1427 Values* _args; | |
1428 ValueStack* _lock_stack; | |
1429 Value _recv; | |
1430 | |
1431 public: | |
1432 // preserves_state can be set to true for Intrinsics | |
1433 // which are guaranteed to preserve register state across any slow | |
1434 // cases; setting it to true does not mean that the Intrinsic can | |
1435 // not trap, only that if we continue execution in the same basic | |
1436 // block after the Intrinsic, all of the registers are intact. This | |
1437 // allows load elimination and common expression elimination to be | |
1438 // performed across the Intrinsic. The default value is false. | |
1439 Intrinsic(ValueType* type, | |
1440 vmIntrinsics::ID id, | |
1441 Values* args, | |
1442 bool has_receiver, | |
1443 ValueStack* lock_stack, | |
1444 bool preserves_state, | |
1445 bool cantrap = true) | |
1446 : StateSplit(type) | |
1447 , _id(id) | |
1448 , _args(args) | |
1449 , _lock_stack(lock_stack) | |
1450 , _recv(NULL) | |
1451 { | |
1452 assert(args != NULL, "args must exist"); | |
1453 ASSERT_VALUES | |
1454 set_flag(PreservesStateFlag, preserves_state); | |
1455 set_flag(CanTrapFlag, cantrap); | |
1456 if (has_receiver) { | |
1457 _recv = argument_at(0); | |
1458 } | |
1459 set_needs_null_check(has_receiver); | |
1460 | |
1461 // some intrinsics can't trap, so don't force them to be pinned | |
1462 if (!can_trap()) { | |
1463 unpin(PinStateSplitConstructor); | |
1464 } | |
1465 } | |
1466 | |
1467 // accessors | |
1468 vmIntrinsics::ID id() const { return _id; } | |
1469 int number_of_arguments() const { return _args->length(); } | |
1470 Value argument_at(int i) const { return _args->at(i); } | |
1471 ValueStack* lock_stack() const { return _lock_stack; } | |
1472 | |
1473 bool has_receiver() const { return (_recv != NULL); } | |
1474 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } | |
1475 bool preserves_state() const { return check_flag(PreservesStateFlag); } | |
1476 | |
1477 // generic | |
1478 virtual bool can_trap() const { return check_flag(CanTrapFlag); } | |
1584 | 1479 virtual void input_values_do(ValueVisitor* f) { |
0 | 1480 StateSplit::input_values_do(f); |
1584 | 1481 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); |
0 | 1482 } |
1584 | 1483 virtual void state_values_do(ValueVisitor* f); |
0 | 1484 |
1485 }; | |
1486 | |
1487 | |
1488 class LIR_List; | |
1489 | |
1490 LEAF(BlockBegin, StateSplit) | |
1491 private: | |
1492 int _block_id; // the unique block id | |
1493 int _depth_first_number; // number of this block in a depth-first ordering | |
1494 int _linear_scan_number; // number of this block in linear-scan ordering | |
1495 int _loop_depth; // the loop nesting level of this block | |
1496 int _loop_index; // number of the innermost loop of this block | |
1497 int _flags; // the flags associated with this block | |
1498 | |
1499 // fields used by BlockListBuilder | |
1500 int _total_preds; // number of predecessors found by BlockListBuilder | |
1501 BitMap _stores_to_locals; // bit is set when a local variable is stored in the block | |
1502 | |
1503 // SSA specific fields: (factor out later) | |
1504 BlockList _successors; // the successors of this block | |
1505 BlockList _predecessors; // the predecessors of this block | |
1506 BlockBegin* _dominator; // the dominator of this block | |
1507 // SSA specific ends | |
1508 BlockEnd* _end; // the last instruction of this block | |
1509 BlockList _exception_handlers; // the exception handlers potentially invoked by this block | |
1510 ValueStackStack* _exception_states; // only for xhandler entries: states of all instructions that have an edge to this xhandler | |
1511 int _exception_handler_pco; // if this block is the start of an exception handler, | |
1512 // this records the PC offset in the assembly code of the | |
1513 // first instruction in this block | |
1514 Label _label; // the label associated with this block | |
1515 LIR_List* _lir; // the low level intermediate representation for this block | |
1516 | |
1517 BitMap _live_in; // set of live LIR_Opr registers at entry to this block | |
1518 BitMap _live_out; // set of live LIR_Opr registers at exit from this block | |
1519 BitMap _live_gen; // set of registers used before any redefinition in this block | |
1520 BitMap _live_kill; // set of registers defined in this block | |
1521 | |
1522 BitMap _fpu_register_usage; | |
1523 intArray* _fpu_stack_state; // For x86 FPU code generation with UseLinearScan | |
1524 int _first_lir_instruction_id; // ID of first LIR instruction in this block | |
1525 int _last_lir_instruction_id; // ID of last LIR instruction in this block | |
1526 | |
1527 void iterate_preorder (boolArray& mark, BlockClosure* closure); | |
1528 void iterate_postorder(boolArray& mark, BlockClosure* closure); | |
1529 | |
1530 friend class SuxAndWeightAdjuster; | |
1531 | |
1532 public: | |
1584 | 1533 void* operator new(size_t size) { |
1534 Compilation* c = Compilation::current(); | |
1535 void* res = c->arena()->Amalloc(size); | |
1536 ((BlockBegin*)res)->_id = c->get_next_id(); | |
1537 ((BlockBegin*)res)->_block_id = c->get_next_block_id(); | |
1538 return res; | |
1539 } | |
1540 | |
0 | 1541 // initialization/counting |
1584 | 1542 static int number_of_blocks() { |
1543 return Compilation::current()->number_of_blocks(); | |
1544 } | |
0 | 1545 |
1546 // creation | |
1547 BlockBegin(int bci) | |
1548 : StateSplit(illegalType) | |
1549 , _depth_first_number(-1) | |
1550 , _linear_scan_number(-1) | |
1551 , _loop_depth(0) | |
1552 , _flags(0) | |
1553 , _dominator(NULL) | |
1554 , _end(NULL) | |
1555 , _predecessors(2) | |
1556 , _successors(2) | |
1557 , _exception_handlers(1) | |
1558 , _exception_states(NULL) | |
1559 , _exception_handler_pco(-1) | |
1560 , _lir(NULL) | |
1561 , _loop_index(-1) | |
1562 , _live_in() | |
1563 , _live_out() | |
1564 , _live_gen() | |
1565 , _live_kill() | |
1566 , _fpu_register_usage() | |
1567 , _fpu_stack_state(NULL) | |
1568 , _first_lir_instruction_id(-1) | |
1569 , _last_lir_instruction_id(-1) | |
1570 , _total_preds(0) | |
1571 , _stores_to_locals() | |
1572 { | |
1573 set_bci(bci); | |
1574 } | |
1575 | |
1576 // accessors | |
1577 int block_id() const { return _block_id; } | |
1578 BlockList* successors() { return &_successors; } | |
1579 BlockBegin* dominator() const { return _dominator; } | |
1580 int loop_depth() const { return _loop_depth; } | |
1581 int depth_first_number() const { return _depth_first_number; } | |
1582 int linear_scan_number() const { return _linear_scan_number; } | |
1583 BlockEnd* end() const { return _end; } | |
1584 Label* label() { return &_label; } | |
1585 LIR_List* lir() const { return _lir; } | |
1586 int exception_handler_pco() const { return _exception_handler_pco; } | |
1587 BitMap& live_in() { return _live_in; } | |
1588 BitMap& live_out() { return _live_out; } | |
1589 BitMap& live_gen() { return _live_gen; } | |
1590 BitMap& live_kill() { return _live_kill; } | |
1591 BitMap& fpu_register_usage() { return _fpu_register_usage; } | |
1592 intArray* fpu_stack_state() const { return _fpu_stack_state; } | |
1593 int first_lir_instruction_id() const { return _first_lir_instruction_id; } | |
1594 int last_lir_instruction_id() const { return _last_lir_instruction_id; } | |
1595 int total_preds() const { return _total_preds; } | |
1596 BitMap& stores_to_locals() { return _stores_to_locals; } | |
1597 | |
1598 // manipulation | |
1599 void set_bci(int bci) { Instruction::set_bci(bci); } | |
1600 void set_dominator(BlockBegin* dom) { _dominator = dom; } | |
1601 void set_loop_depth(int d) { _loop_depth = d; } | |
1602 void set_depth_first_number(int dfn) { _depth_first_number = dfn; } | |
1603 void set_linear_scan_number(int lsn) { _linear_scan_number = lsn; } | |
1604 void set_end(BlockEnd* end); | |
1605 void disconnect_from_graph(); | |
1606 static void disconnect_edge(BlockBegin* from, BlockBegin* to); | |
1607 BlockBegin* insert_block_between(BlockBegin* sux); | |
1608 void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux); | |
1609 void set_lir(LIR_List* lir) { _lir = lir; } | |
1610 void set_exception_handler_pco(int pco) { _exception_handler_pco = pco; } | |
1611 void set_live_in (BitMap map) { _live_in = map; } | |
1612 void set_live_out (BitMap map) { _live_out = map; } | |
1613 void set_live_gen (BitMap map) { _live_gen = map; } | |
1614 void set_live_kill (BitMap map) { _live_kill = map; } | |
1615 void set_fpu_register_usage(BitMap map) { _fpu_register_usage = map; } | |
1616 void set_fpu_stack_state(intArray* state) { _fpu_stack_state = state; } | |
1617 void set_first_lir_instruction_id(int id) { _first_lir_instruction_id = id; } | |
1618 void set_last_lir_instruction_id(int id) { _last_lir_instruction_id = id; } | |
1619 void increment_total_preds(int n = 1) { _total_preds += n; } | |
1620 void init_stores_to_locals(int locals_count) { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); } | |
1621 | |
1622 // generic | |
1584 | 1623 virtual void state_values_do(ValueVisitor* f); |
0 | 1624 |
1625 // successors and predecessors | |
1626 int number_of_sux() const; | |
1627 BlockBegin* sux_at(int i) const; | |
1628 void add_successor(BlockBegin* sux); | |
1629 void remove_successor(BlockBegin* pred); | |
1630 bool is_successor(BlockBegin* sux) const { return _successors.contains(sux); } | |
1631 | |
1632 void add_predecessor(BlockBegin* pred); | |
1633 void remove_predecessor(BlockBegin* pred); | |
1634 bool is_predecessor(BlockBegin* pred) const { return _predecessors.contains(pred); } | |
1635 int number_of_preds() const { return _predecessors.length(); } | |
1636 BlockBegin* pred_at(int i) const { return _predecessors[i]; } | |
1637 | |
1638 // exception handlers potentially invoked by this block | |
1639 void add_exception_handler(BlockBegin* b); | |
1640 bool is_exception_handler(BlockBegin* b) const { return _exception_handlers.contains(b); } | |
1641 int number_of_exception_handlers() const { return _exception_handlers.length(); } | |
1642 BlockBegin* exception_handler_at(int i) const { return _exception_handlers.at(i); } | |
1643 | |
1644 // states of the instructions that have an edge to this exception handler | |
1645 int number_of_exception_states() { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states == NULL ? 0 : _exception_states->length(); } | |
1646 ValueStack* exception_state_at(int idx) const { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states->at(idx); } | |
1647 int add_exception_state(ValueStack* state); | |
1648 | |
1649 // flags | |
1650 enum Flag { | |
1651 no_flag = 0, | |
1652 std_entry_flag = 1 << 0, | |
1653 osr_entry_flag = 1 << 1, | |
1654 exception_entry_flag = 1 << 2, | |
1655 subroutine_entry_flag = 1 << 3, | |
1656 backward_branch_target_flag = 1 << 4, | |
1657 is_on_work_list_flag = 1 << 5, | |
1658 was_visited_flag = 1 << 6, | |
1378
9f5b60a14736
6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents:
1295
diff
changeset
|
1659 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
|
1660 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
|
1661 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
|
1662 linear_scan_loop_end_flag = 1 << 10 // set during loop-detection for LinearScan |
0 | 1663 }; |
1664 | |
1665 void set(Flag f) { _flags |= f; } | |
1666 void clear(Flag f) { _flags &= ~f; } | |
1667 bool is_set(Flag f) const { return (_flags & f) != 0; } | |
1668 bool is_entry_block() const { | |
1669 const int entry_mask = std_entry_flag | osr_entry_flag | exception_entry_flag; | |
1670 return (_flags & entry_mask) != 0; | |
1671 } | |
1672 | |
1673 // iteration | |
1674 void iterate_preorder (BlockClosure* closure); | |
1675 void iterate_postorder (BlockClosure* closure); | |
1676 | |
1584 | 1677 void block_values_do(ValueVisitor* f); |
0 | 1678 |
1679 // loops | |
1680 void set_loop_index(int ix) { _loop_index = ix; } | |
1681 int loop_index() const { return _loop_index; } | |
1682 | |
1683 // merging | |
1684 bool try_merge(ValueStack* state); // try to merge states at block begin | |
1685 void merge(ValueStack* state) { bool b = try_merge(state); assert(b, "merge failed"); } | |
1686 | |
1687 // debugging | |
1688 void print_block() PRODUCT_RETURN; | |
1689 void print_block(InstructionPrinter& ip, bool live_only = false) PRODUCT_RETURN; | |
1690 }; | |
1691 | |
1692 | |
1693 BASE(BlockEnd, StateSplit) | |
1694 private: | |
1695 BlockBegin* _begin; | |
1696 BlockList* _sux; | |
1697 ValueStack* _state_before; | |
1698 | |
1699 protected: | |
1700 BlockList* sux() const { return _sux; } | |
1701 | |
1702 void set_sux(BlockList* sux) { | |
1703 #ifdef ASSERT | |
1704 assert(sux != NULL, "sux must exist"); | |
1705 for (int i = sux->length() - 1; i >= 0; i--) assert(sux->at(i) != NULL, "sux must exist"); | |
1706 #endif | |
1707 _sux = sux; | |
1708 } | |
1709 | |
1710 public: | |
1711 // creation | |
1712 BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint) | |
1713 : StateSplit(type) | |
1714 , _begin(NULL) | |
1715 , _sux(NULL) | |
1716 , _state_before(state_before) { | |
1717 set_flag(IsSafepointFlag, is_safepoint); | |
1718 } | |
1719 | |
1720 // accessors | |
1721 ValueStack* state_before() const { return _state_before; } | |
1722 bool is_safepoint() const { return check_flag(IsSafepointFlag); } | |
1723 BlockBegin* begin() const { return _begin; } | |
1724 | |
1725 // manipulation | |
1726 void set_begin(BlockBegin* begin); | |
1727 | |
1728 // generic | |
1584 | 1729 virtual void other_values_do(ValueVisitor* f); |
0 | 1730 |
1731 // successors | |
1732 int number_of_sux() const { return _sux != NULL ? _sux->length() : 0; } | |
1733 BlockBegin* sux_at(int i) const { return _sux->at(i); } | |
1734 BlockBegin* default_sux() const { return sux_at(number_of_sux() - 1); } | |
1735 BlockBegin** addr_sux_at(int i) const { return _sux->adr_at(i); } | |
1736 int sux_index(BlockBegin* sux) const { return _sux->find(sux); } | |
1737 void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux); | |
1738 }; | |
1739 | |
1740 | |
1741 LEAF(Goto, BlockEnd) | |
1742 public: | |
1783 | 1743 enum Direction { |
1744 none, // Just a regular goto | |
1745 taken, not_taken // Goto produced from If | |
1746 }; | |
1747 private: | |
1748 ciMethod* _profiled_method; | |
1749 int _profiled_bci; | |
1750 Direction _direction; | |
1751 public: | |
0 | 1752 // creation |
1783 | 1753 Goto(BlockBegin* sux, ValueStack* state_before, bool is_safepoint = false) |
1754 : BlockEnd(illegalType, state_before, is_safepoint) | |
1755 , _direction(none) | |
1756 , _profiled_method(NULL) | |
1757 , _profiled_bci(0) { | |
0 | 1758 BlockList* s = new BlockList(1); |
1759 s->append(sux); | |
1760 set_sux(s); | |
1761 } | |
1762 | |
1783 | 1763 Goto(BlockBegin* sux, bool is_safepoint) : BlockEnd(illegalType, NULL, is_safepoint) |
1764 , _direction(none) | |
1765 , _profiled_method(NULL) | |
1766 , _profiled_bci(0) { | |
0 | 1767 BlockList* s = new BlockList(1); |
1768 s->append(sux); | |
1769 set_sux(s); | |
1770 } | |
1771 | |
1783 | 1772 bool should_profile() const { return check_flag(ProfileMDOFlag); } |
1773 ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches | |
1774 int profiled_bci() const { return _profiled_bci; } | |
1775 Direction direction() const { return _direction; } | |
1776 | |
1777 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } | |
1778 void set_profiled_method(ciMethod* method) { _profiled_method = method; } | |
1779 void set_profiled_bci(int bci) { _profiled_bci = bci; } | |
1780 void set_direction(Direction d) { _direction = d; } | |
0 | 1781 }; |
1782 | |
1783 | |
1784 LEAF(If, BlockEnd) | |
1785 private: | |
1786 Value _x; | |
1787 Condition _cond; | |
1788 Value _y; | |
1789 ciMethod* _profiled_method; | |
1790 int _profiled_bci; // Canonicalizer may alter bci of If node | |
1783 | 1791 bool _swapped; // Is the order reversed with respect to the original If in the |
1792 // bytecode stream? | |
0 | 1793 public: |
1794 // creation | |
1795 // unordered_is_true is valid for float/double compares only | |
1796 If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint) | |
1797 : BlockEnd(illegalType, state_before, is_safepoint) | |
1798 , _x(x) | |
1799 , _cond(cond) | |
1800 , _y(y) | |
1801 , _profiled_method(NULL) | |
1802 , _profiled_bci(0) | |
1783 | 1803 , _swapped(false) |
0 | 1804 { |
1805 ASSERT_VALUES | |
1806 set_flag(UnorderedIsTrueFlag, unordered_is_true); | |
1807 assert(x->type()->tag() == y->type()->tag(), "types must match"); | |
1808 BlockList* s = new BlockList(2); | |
1809 s->append(tsux); | |
1810 s->append(fsux); | |
1811 set_sux(s); | |
1812 } | |
1813 | |
1814 // accessors | |
1815 Value x() const { return _x; } | |
1816 Condition cond() const { return _cond; } | |
1817 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); } | |
1818 Value y() const { return _y; } | |
1819 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); } | |
1820 BlockBegin* tsux() const { return sux_for(true); } | |
1821 BlockBegin* fsux() const { return sux_for(false); } | |
1822 BlockBegin* usux() const { return sux_for(unordered_is_true()); } | |
1823 bool should_profile() const { return check_flag(ProfileMDOFlag); } | |
1824 ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches | |
1783 | 1825 int profiled_bci() const { return _profiled_bci; } // set for profiled branches and tiered |
1826 bool is_swapped() const { return _swapped; } | |
0 | 1827 |
1828 // manipulation | |
1829 void swap_operands() { | |
1830 Value t = _x; _x = _y; _y = t; | |
1831 _cond = mirror(_cond); | |
1832 } | |
1833 | |
1834 void swap_sux() { | |
1835 assert(number_of_sux() == 2, "wrong number of successors"); | |
1836 BlockList* s = sux(); | |
1837 BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); | |
1838 _cond = negate(_cond); | |
1839 set_flag(UnorderedIsTrueFlag, !check_flag(UnorderedIsTrueFlag)); | |
1840 } | |
1841 | |
1842 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } | |
1843 void set_profiled_method(ciMethod* method) { _profiled_method = method; } | |
1844 void set_profiled_bci(int bci) { _profiled_bci = bci; } | |
1783 | 1845 void set_swapped(bool value) { _swapped = value; } |
0 | 1846 // generic |
1584 | 1847 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); } |
0 | 1848 }; |
1849 | |
1850 | |
1851 LEAF(IfInstanceOf, BlockEnd) | |
1852 private: | |
1853 ciKlass* _klass; | |
1854 Value _obj; | |
1855 bool _test_is_instance; // jump if instance | |
1856 int _instanceof_bci; | |
1857 | |
1858 public: | |
1859 IfInstanceOf(ciKlass* klass, Value obj, bool test_is_instance, int instanceof_bci, BlockBegin* tsux, BlockBegin* fsux) | |
1860 : BlockEnd(illegalType, NULL, false) // temporary set to false | |
1861 , _klass(klass) | |
1862 , _obj(obj) | |
1863 , _test_is_instance(test_is_instance) | |
1864 , _instanceof_bci(instanceof_bci) | |
1865 { | |
1866 ASSERT_VALUES | |
1867 assert(instanceof_bci >= 0, "illegal bci"); | |
1868 BlockList* s = new BlockList(2); | |
1869 s->append(tsux); | |
1870 s->append(fsux); | |
1871 set_sux(s); | |
1872 } | |
1873 | |
1874 // accessors | |
1875 // | |
1876 // Note 1: If test_is_instance() is true, IfInstanceOf tests if obj *is* an | |
1877 // instance of klass; otherwise it tests if it is *not* and instance | |
1878 // of klass. | |
1879 // | |
1880 // Note 2: IfInstanceOf instructions are created by combining an InstanceOf | |
1881 // and an If instruction. The IfInstanceOf bci() corresponds to the | |
1882 // bci that the If would have had; the (this->) instanceof_bci() is | |
1883 // the bci of the original InstanceOf instruction. | |
1884 ciKlass* klass() const { return _klass; } | |
1885 Value obj() const { return _obj; } | |
1886 int instanceof_bci() const { return _instanceof_bci; } | |
1887 bool test_is_instance() const { return _test_is_instance; } | |
1888 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); } | |
1889 BlockBegin* tsux() const { return sux_for(true); } | |
1890 BlockBegin* fsux() const { return sux_for(false); } | |
1891 | |
1892 // manipulation | |
1893 void swap_sux() { | |
1894 assert(number_of_sux() == 2, "wrong number of successors"); | |
1895 BlockList* s = sux(); | |
1896 BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); | |
1897 _test_is_instance = !_test_is_instance; | |
1898 } | |
1899 | |
1900 // generic | |
1584 | 1901 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_obj); } |
0 | 1902 }; |
1903 | |
1904 | |
1905 BASE(Switch, BlockEnd) | |
1906 private: | |
1907 Value _tag; | |
1908 | |
1909 public: | |
1910 // creation | |
1911 Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint) | |
1912 : BlockEnd(illegalType, state_before, is_safepoint) | |
1913 , _tag(tag) { | |
1914 ASSERT_VALUES | |
1915 set_sux(sux); | |
1916 } | |
1917 | |
1918 // accessors | |
1919 Value tag() const { return _tag; } | |
1920 int length() const { return number_of_sux() - 1; } | |
1921 | |
1922 // generic | |
1584 | 1923 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_tag); } |
0 | 1924 }; |
1925 | |
1926 | |
1927 LEAF(TableSwitch, Switch) | |
1928 private: | |
1929 int _lo_key; | |
1930 | |
1931 public: | |
1932 // creation | |
1933 TableSwitch(Value tag, BlockList* sux, int lo_key, ValueStack* state_before, bool is_safepoint) | |
1934 : Switch(tag, sux, state_before, is_safepoint) | |
1935 , _lo_key(lo_key) {} | |
1936 | |
1937 // accessors | |
1938 int lo_key() const { return _lo_key; } | |
1939 int hi_key() const { return _lo_key + length() - 1; } | |
1940 }; | |
1941 | |
1942 | |
1943 LEAF(LookupSwitch, Switch) | |
1944 private: | |
1945 intArray* _keys; | |
1946 | |
1947 public: | |
1948 // creation | |
1949 LookupSwitch(Value tag, BlockList* sux, intArray* keys, ValueStack* state_before, bool is_safepoint) | |
1950 : Switch(tag, sux, state_before, is_safepoint) | |
1951 , _keys(keys) { | |
1952 assert(keys != NULL, "keys must exist"); | |
1953 assert(keys->length() == length(), "sux & keys have incompatible lengths"); | |
1954 } | |
1955 | |
1956 // accessors | |
1957 int key_at(int i) const { return _keys->at(i); } | |
1958 }; | |
1959 | |
1960 | |
1961 LEAF(Return, BlockEnd) | |
1962 private: | |
1963 Value _result; | |
1964 | |
1965 public: | |
1966 // creation | |
1967 Return(Value result) : | |
1968 BlockEnd(result == NULL ? voidType : result->type()->base(), NULL, true), | |
1969 _result(result) {} | |
1970 | |
1971 // accessors | |
1972 Value result() const { return _result; } | |
1973 bool has_result() const { return result() != NULL; } | |
1974 | |
1975 // generic | |
1584 | 1976 virtual void input_values_do(ValueVisitor* f) { |
0 | 1977 BlockEnd::input_values_do(f); |
1584 | 1978 if (has_result()) f->visit(&_result); |
0 | 1979 } |
1980 }; | |
1981 | |
1982 | |
1983 LEAF(Throw, BlockEnd) | |
1984 private: | |
1985 Value _exception; | |
1986 | |
1987 public: | |
1988 // creation | |
1989 Throw(Value exception, ValueStack* state_before) : BlockEnd(illegalType, state_before, true), _exception(exception) { | |
1990 ASSERT_VALUES | |
1991 } | |
1992 | |
1993 // accessors | |
1994 Value exception() const { return _exception; } | |
1995 | |
1996 // generic | |
1997 virtual bool can_trap() const { return true; } | |
1584 | 1998 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_exception); } |
1999 virtual void state_values_do(ValueVisitor* f); | |
0 | 2000 }; |
2001 | |
2002 | |
2003 LEAF(Base, BlockEnd) | |
2004 public: | |
2005 // creation | |
2006 Base(BlockBegin* std_entry, BlockBegin* osr_entry) : BlockEnd(illegalType, NULL, false) { | |
2007 assert(std_entry->is_set(BlockBegin::std_entry_flag), "std entry must be flagged"); | |
2008 assert(osr_entry == NULL || osr_entry->is_set(BlockBegin::osr_entry_flag), "osr entry must be flagged"); | |
2009 BlockList* s = new BlockList(2); | |
2010 if (osr_entry != NULL) s->append(osr_entry); | |
2011 s->append(std_entry); // must be default sux! | |
2012 set_sux(s); | |
2013 } | |
2014 | |
2015 // accessors | |
2016 BlockBegin* std_entry() const { return default_sux(); } | |
2017 BlockBegin* osr_entry() const { return number_of_sux() < 2 ? NULL : sux_at(0); } | |
2018 }; | |
2019 | |
2020 | |
2021 LEAF(OsrEntry, Instruction) | |
2022 public: | |
2023 // creation | |
2024 #ifdef _LP64 | |
2025 OsrEntry() : Instruction(longType, false) { pin(); } | |
2026 #else | |
2027 OsrEntry() : Instruction(intType, false) { pin(); } | |
2028 #endif | |
2029 | |
2030 // generic | |
1584 | 2031 virtual void input_values_do(ValueVisitor* f) { } |
0 | 2032 }; |
2033 | |
2034 | |
2035 // Models the incoming exception at a catch site | |
2036 LEAF(ExceptionObject, Instruction) | |
2037 public: | |
2038 // creation | |
2039 ExceptionObject() : Instruction(objectType, false) { | |
2040 pin(); | |
2041 } | |
2042 | |
2043 // generic | |
1584 | 2044 virtual void input_values_do(ValueVisitor* f) { } |
0 | 2045 }; |
2046 | |
2047 | |
2048 // Models needed rounding for floating-point values on Intel. | |
2049 // Currently only used to represent rounding of double-precision | |
2050 // values stored into local variables, but could be used to model | |
2051 // intermediate rounding of single-precision values as well. | |
2052 LEAF(RoundFP, Instruction) | |
2053 private: | |
2054 Value _input; // floating-point value to be rounded | |
2055 | |
2056 public: | |
2057 RoundFP(Value input) | |
2058 : Instruction(input->type()) // Note: should not be used for constants | |
2059 , _input(input) | |
2060 { | |
2061 ASSERT_VALUES | |
2062 } | |
2063 | |
2064 // accessors | |
2065 Value input() const { return _input; } | |
2066 | |
2067 // generic | |
1584 | 2068 virtual void input_values_do(ValueVisitor* f) { f->visit(&_input); } |
0 | 2069 }; |
2070 | |
2071 | |
2072 BASE(UnsafeOp, Instruction) | |
2073 private: | |
2074 BasicType _basic_type; // ValueType can not express byte-sized integers | |
2075 | |
2076 protected: | |
2077 // creation | |
2078 UnsafeOp(BasicType basic_type, bool is_put) | |
2079 : Instruction(is_put ? voidType : as_ValueType(basic_type)) | |
2080 , _basic_type(basic_type) | |
2081 { | |
2082 //Note: Unsafe ops are not not guaranteed to throw NPE. | |
2083 // Convservatively, Unsafe operations must be pinned though we could be | |
2084 // looser about this if we wanted to.. | |
2085 pin(); | |
2086 } | |
2087 | |
2088 public: | |
2089 // accessors | |
2090 BasicType basic_type() { return _basic_type; } | |
2091 | |
2092 // generic | |
1584 | 2093 virtual void input_values_do(ValueVisitor* f) { } |
2094 virtual void other_values_do(ValueVisitor* f) { } | |
0 | 2095 }; |
2096 | |
2097 | |
2098 BASE(UnsafeRawOp, UnsafeOp) | |
2099 private: | |
2100 Value _base; // Base address (a Java long) | |
2101 Value _index; // Index if computed by optimizer; initialized to NULL | |
2102 int _log2_scale; // Scale factor: 0, 1, 2, or 3. | |
2103 // Indicates log2 of number of bytes (1, 2, 4, or 8) | |
2104 // to scale index by. | |
2105 | |
2106 protected: | |
2107 UnsafeRawOp(BasicType basic_type, Value addr, bool is_put) | |
2108 : UnsafeOp(basic_type, is_put) | |
2109 , _base(addr) | |
2110 , _index(NULL) | |
2111 , _log2_scale(0) | |
2112 { | |
2113 // Can not use ASSERT_VALUES because index may be NULL | |
2114 assert(addr != NULL && addr->type()->is_long(), "just checking"); | |
2115 } | |
2116 | |
2117 UnsafeRawOp(BasicType basic_type, Value base, Value index, int log2_scale, bool is_put) | |
2118 : UnsafeOp(basic_type, is_put) | |
2119 , _base(base) | |
2120 , _index(index) | |
2121 , _log2_scale(log2_scale) | |
2122 { | |
2123 } | |
2124 | |
2125 public: | |
2126 // accessors | |
2127 Value base() { return _base; } | |
2128 Value index() { return _index; } | |
2129 bool has_index() { return (_index != NULL); } | |
2130 int log2_scale() { return _log2_scale; } | |
2131 | |
2132 // setters | |
2133 void set_base (Value base) { _base = base; } | |
2134 void set_index(Value index) { _index = index; } | |
2135 void set_log2_scale(int log2_scale) { _log2_scale = log2_scale; } | |
2136 | |
2137 // generic | |
1584 | 2138 virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); |
2139 f->visit(&_base); | |
2140 if (has_index()) f->visit(&_index); } | |
0 | 2141 }; |
2142 | |
2143 | |
2144 LEAF(UnsafeGetRaw, UnsafeRawOp) | |
2145 private: | |
2146 bool _may_be_unaligned; // For OSREntry | |
2147 | |
2148 public: | |
2149 UnsafeGetRaw(BasicType basic_type, Value addr, bool may_be_unaligned) | |
2150 : UnsafeRawOp(basic_type, addr, false) { | |
2151 _may_be_unaligned = may_be_unaligned; | |
2152 } | |
2153 | |
2154 UnsafeGetRaw(BasicType basic_type, Value base, Value index, int log2_scale, bool may_be_unaligned) | |
2155 : UnsafeRawOp(basic_type, base, index, log2_scale, false) { | |
2156 _may_be_unaligned = may_be_unaligned; | |
2157 } | |
2158 | |
2159 bool may_be_unaligned() { return _may_be_unaligned; } | |
2160 }; | |
2161 | |
2162 | |
2163 LEAF(UnsafePutRaw, UnsafeRawOp) | |
2164 private: | |
2165 Value _value; // Value to be stored | |
2166 | |
2167 public: | |
2168 UnsafePutRaw(BasicType basic_type, Value addr, Value value) | |
2169 : UnsafeRawOp(basic_type, addr, true) | |
2170 , _value(value) | |
2171 { | |
2172 assert(value != NULL, "just checking"); | |
2173 ASSERT_VALUES | |
2174 } | |
2175 | |
2176 UnsafePutRaw(BasicType basic_type, Value base, Value index, int log2_scale, Value value) | |
2177 : UnsafeRawOp(basic_type, base, index, log2_scale, true) | |
2178 , _value(value) | |
2179 { | |
2180 assert(value != NULL, "just checking"); | |
2181 ASSERT_VALUES | |
2182 } | |
2183 | |
2184 // accessors | |
2185 Value value() { return _value; } | |
2186 | |
2187 // generic | |
1584 | 2188 virtual void input_values_do(ValueVisitor* f) { UnsafeRawOp::input_values_do(f); |
2189 f->visit(&_value); } | |
0 | 2190 }; |
2191 | |
2192 | |
2193 BASE(UnsafeObjectOp, UnsafeOp) | |
2194 private: | |
2195 Value _object; // Object to be fetched from or mutated | |
2196 Value _offset; // Offset within object | |
2197 bool _is_volatile; // true if volatile - dl/JSR166 | |
2198 public: | |
2199 UnsafeObjectOp(BasicType basic_type, Value object, Value offset, bool is_put, bool is_volatile) | |
2200 : UnsafeOp(basic_type, is_put), _object(object), _offset(offset), _is_volatile(is_volatile) | |
2201 { | |
2202 } | |
2203 | |
2204 // accessors | |
2205 Value object() { return _object; } | |
2206 Value offset() { return _offset; } | |
2207 bool is_volatile() { return _is_volatile; } | |
2208 // generic | |
1584 | 2209 virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); |
2210 f->visit(&_object); | |
2211 f->visit(&_offset); } | |
0 | 2212 }; |
2213 | |
2214 | |
2215 LEAF(UnsafeGetObject, UnsafeObjectOp) | |
2216 public: | |
2217 UnsafeGetObject(BasicType basic_type, Value object, Value offset, bool is_volatile) | |
2218 : UnsafeObjectOp(basic_type, object, offset, false, is_volatile) | |
2219 { | |
2220 ASSERT_VALUES | |
2221 } | |
2222 }; | |
2223 | |
2224 | |
2225 LEAF(UnsafePutObject, UnsafeObjectOp) | |
2226 private: | |
2227 Value _value; // Value to be stored | |
2228 public: | |
2229 UnsafePutObject(BasicType basic_type, Value object, Value offset, Value value, bool is_volatile) | |
2230 : UnsafeObjectOp(basic_type, object, offset, true, is_volatile) | |
2231 , _value(value) | |
2232 { | |
2233 ASSERT_VALUES | |
2234 } | |
2235 | |
2236 // accessors | |
2237 Value value() { return _value; } | |
2238 | |
2239 // generic | |
1584 | 2240 virtual void input_values_do(ValueVisitor* f) { UnsafeObjectOp::input_values_do(f); |
2241 f->visit(&_value); } | |
0 | 2242 }; |
2243 | |
2244 | |
2245 BASE(UnsafePrefetch, UnsafeObjectOp) | |
2246 public: | |
2247 UnsafePrefetch(Value object, Value offset) | |
2248 : UnsafeObjectOp(T_VOID, object, offset, false, false) | |
2249 { | |
2250 } | |
2251 }; | |
2252 | |
2253 | |
2254 LEAF(UnsafePrefetchRead, UnsafePrefetch) | |
2255 public: | |
2256 UnsafePrefetchRead(Value object, Value offset) | |
2257 : UnsafePrefetch(object, offset) | |
2258 { | |
2259 ASSERT_VALUES | |
2260 } | |
2261 }; | |
2262 | |
2263 | |
2264 LEAF(UnsafePrefetchWrite, UnsafePrefetch) | |
2265 public: | |
2266 UnsafePrefetchWrite(Value object, Value offset) | |
2267 : UnsafePrefetch(object, offset) | |
2268 { | |
2269 ASSERT_VALUES | |
2270 } | |
2271 }; | |
2272 | |
2273 LEAF(ProfileCall, Instruction) | |
2274 private: | |
2275 ciMethod* _method; | |
2276 int _bci_of_invoke; | |
2277 Value _recv; | |
2278 ciKlass* _known_holder; | |
2279 | |
2280 public: | |
2281 ProfileCall(ciMethod* method, int bci, Value recv, ciKlass* known_holder) | |
2282 : Instruction(voidType) | |
2283 , _method(method) | |
2284 , _bci_of_invoke(bci) | |
2285 , _recv(recv) | |
2286 , _known_holder(known_holder) | |
2287 { | |
2288 // The ProfileCall has side-effects and must occur precisely where located | |
2289 pin(); | |
2290 } | |
2291 | |
2292 ciMethod* method() { return _method; } | |
2293 int bci_of_invoke() { return _bci_of_invoke; } | |
2294 Value recv() { return _recv; } | |
2295 ciKlass* known_holder() { return _known_holder; } | |
2296 | |
1584 | 2297 virtual void input_values_do(ValueVisitor* f) { if (_recv != NULL) f->visit(&_recv); } |
0 | 2298 }; |
2299 | |
1783 | 2300 // Use to trip invocation counter of an inlined method |
0 | 2301 |
1783 | 2302 LEAF(ProfileInvoke, Instruction) |
0 | 2303 private: |
1783 | 2304 ciMethod* _inlinee; |
2305 ValueStack* _state; | |
2306 int _bci_of_invoke; | |
0 | 2307 |
2308 public: | |
1783 | 2309 ProfileInvoke(ciMethod* inlinee, ValueStack* state, int bci) |
0 | 2310 : Instruction(voidType) |
1783 | 2311 , _inlinee(inlinee) |
2312 , _bci_of_invoke(bci) | |
2313 , _state(state) | |
0 | 2314 { |
1783 | 2315 // The ProfileInvoke has side-effects and must occur precisely where located QQQ??? |
0 | 2316 pin(); |
2317 } | |
2318 | |
1783 | 2319 ciMethod* inlinee() { return _inlinee; } |
2320 ValueStack* state() { return _state; } | |
2321 int bci_of_invoke() { return _bci_of_invoke; } | |
2322 virtual void input_values_do(ValueVisitor*) {} | |
2323 virtual void state_values_do(ValueVisitor*); | |
0 | 2324 }; |
2325 | |
2326 class BlockPair: public CompilationResourceObj { | |
2327 private: | |
2328 BlockBegin* _from; | |
2329 BlockBegin* _to; | |
2330 public: | |
2331 BlockPair(BlockBegin* from, BlockBegin* to): _from(from), _to(to) {} | |
2332 BlockBegin* from() const { return _from; } | |
2333 BlockBegin* to() const { return _to; } | |
2334 bool is_same(BlockBegin* from, BlockBegin* to) const { return _from == from && _to == to; } | |
2335 bool is_same(BlockPair* p) const { return _from == p->from() && _to == p->to(); } | |
2336 void set_to(BlockBegin* b) { _to = b; } | |
2337 void set_from(BlockBegin* b) { _from = b; } | |
2338 }; | |
2339 | |
2340 | |
2341 define_array(BlockPairArray, BlockPair*) | |
2342 define_stack(BlockPairList, BlockPairArray) | |
2343 | |
2344 | |
2345 inline int BlockBegin::number_of_sux() const { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); } | |
2346 inline BlockBegin* BlockBegin::sux_at(int i) const { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch"); return _successors.at(i); } | |
2347 inline void BlockBegin::add_successor(BlockBegin* sux) { assert(_end == NULL, "Would create mismatch with successors of BlockEnd"); _successors.append(sux); } | |
2348 | |
2349 #undef ASSERT_VALUES |