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