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