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