src/share/vm/c1/c1_Instruction.hpp

Sat, 12 Oct 2013 12:12:59 +0200

author
roland
date
Sat, 12 Oct 2013 12:12:59 +0200
changeset 5921
ce0cc25bc5e2
parent 5914
d13d7aba8c12
child 6876
710a3c8b516e
child 7058
2fd0fd493045
permissions
-rw-r--r--

8026054: New type profiling points: type of return values at calls
Summary: x86 interpreter and c1 type profiling for return values at calls
Reviewed-by: kvn, twisti

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

mercurial