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