1 /* 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_OPTO_MACHNODE_HPP 26 #define SHARE_VM_OPTO_MACHNODE_HPP 27 28 #include "opto/callnode.hpp" 29 #include "opto/matcher.hpp" 30 #include "opto/multnode.hpp" 31 #include "opto/node.hpp" 32 #include "opto/regmask.hpp" 33 34 class BufferBlob; 35 class CodeBuffer; 36 class JVMState; 37 class MachCallDynamicJavaNode; 38 class MachCallJavaNode; 39 class MachCallLeafNode; 40 class MachCallNode; 41 class MachCallRuntimeNode; 42 class MachCallStaticJavaNode; 43 class MachEpilogNode; 44 class MachIfNode; 45 class MachNullCheckNode; 46 class MachOper; 47 class MachProjNode; 48 class MachPrologNode; 49 class MachReturnNode; 50 class MachSafePointNode; 51 class MachSpillCopyNode; 52 class Matcher; 53 class PhaseRegAlloc; 54 class RegMask; 55 class State; 56 57 //---------------------------MachOper------------------------------------------ 58 class MachOper : public ResourceObj { 59 public: 60 // Allocate right next to the MachNodes in the same arena 61 void *operator new( size_t x, Compile* C ) { return C->node_arena()->Amalloc_D(x); } 62 63 // Opcode 64 virtual uint opcode() const = 0; 65 66 // Number of input edges. 67 // Generally at least 1 68 virtual uint num_edges() const { return 1; } 69 // Array of Register masks 70 virtual const RegMask *in_RegMask(int index) const; 71 72 // Methods to output the encoding of the operand 73 74 // Negate conditional branches. Error for non-branch Nodes 75 virtual void negate(); 76 77 // Return the value requested 78 // result register lookup, corresponding to int_format 79 virtual int reg(PhaseRegAlloc *ra_, const Node *node) const; 80 // input register lookup, corresponding to ext_format 81 virtual int reg(PhaseRegAlloc *ra_, const Node *node, int idx) const; 82 83 // helpers for MacroAssembler generation from ADLC 84 Register as_Register(PhaseRegAlloc *ra_, const Node *node) const { 85 return ::as_Register(reg(ra_, node)); 86 } 87 Register as_Register(PhaseRegAlloc *ra_, const Node *node, int idx) const { 88 return ::as_Register(reg(ra_, node, idx)); 89 } 90 FloatRegister as_FloatRegister(PhaseRegAlloc *ra_, const Node *node) const { 91 return ::as_FloatRegister(reg(ra_, node)); 92 } 93 FloatRegister as_FloatRegister(PhaseRegAlloc *ra_, const Node *node, int idx) const { 94 return ::as_FloatRegister(reg(ra_, node, idx)); 95 } 96 97 #if defined(IA32) || defined(AMD64) 98 XMMRegister as_XMMRegister(PhaseRegAlloc *ra_, const Node *node) const { 99 return ::as_XMMRegister(reg(ra_, node)); 100 } 101 XMMRegister as_XMMRegister(PhaseRegAlloc *ra_, const Node *node, int idx) const { 102 return ::as_XMMRegister(reg(ra_, node, idx)); 103 } 104 #endif 105 106 virtual intptr_t constant() const; 107 virtual bool constant_is_oop() const; 108 virtual jdouble constantD() const; 109 virtual jfloat constantF() const; 110 virtual jlong constantL() const; 111 virtual TypeOopPtr *oop() const; 112 virtual int ccode() const; 113 // A zero, default, indicates this value is not needed. 114 // May need to lookup the base register, as done in int_ and ext_format 115 virtual int base (PhaseRegAlloc *ra_, const Node *node, int idx) const; 116 virtual int index(PhaseRegAlloc *ra_, const Node *node, int idx) const; 117 virtual int scale() const; 118 // Parameters needed to support MEMORY_INTERFACE access to stackSlot 119 virtual int disp (PhaseRegAlloc *ra_, const Node *node, int idx) const; 120 // Check for PC-Relative displacement 121 virtual bool disp_is_oop() const; 122 virtual int constant_disp() const; // usu. 0, may return Type::OffsetBot 123 virtual int base_position() const; // base edge position, or -1 124 virtual int index_position() const; // index edge position, or -1 125 126 // Access the TypeKlassPtr of operands with a base==RegI and disp==RegP 127 // Only returns non-null value for i486.ad's indOffset32X 128 virtual const TypePtr *disp_as_type() const { return NULL; } 129 130 // Return the label 131 virtual Label *label() const; 132 133 // Return the method's address 134 virtual intptr_t method() const; 135 136 // Hash and compare over operands are currently identical 137 virtual uint hash() const; 138 virtual uint cmp( const MachOper &oper ) const; 139 140 // Virtual clone, since I do not know how big the MachOper is. 141 virtual MachOper *clone(Compile* C) const = 0; 142 143 // Return ideal Type from simple operands. Fail for complex operands. 144 virtual const Type *type() const; 145 146 // Set an integer offset if we have one, or error otherwise 147 virtual void set_con( jint c0 ) { ShouldNotReachHere(); } 148 149 #ifndef PRODUCT 150 // Return name of operand 151 virtual const char *Name() const { return "???";} 152 153 // Methods to output the text version of the operand 154 virtual void int_format(PhaseRegAlloc *,const MachNode *node, outputStream *st) const = 0; 155 virtual void ext_format(PhaseRegAlloc *,const MachNode *node,int idx, outputStream *st) const=0; 156 157 virtual void dump_spec(outputStream *st) const; // Print per-operand info 158 #endif 159 }; 160 161 //------------------------------MachNode--------------------------------------- 162 // Base type for all machine specific nodes. All node classes generated by the 163 // ADLC inherit from this class. 164 class MachNode : public Node { 165 public: 166 MachNode() : Node((uint)0), _num_opnds(0), _opnds(NULL) { 167 init_class_id(Class_Mach); 168 } 169 // Required boilerplate 170 virtual uint size_of() const { return sizeof(MachNode); } 171 virtual int Opcode() const; // Always equal to MachNode 172 virtual uint rule() const = 0; // Machine-specific opcode 173 // Number of inputs which come before the first operand. 174 // Generally at least 1, to skip the Control input 175 virtual uint oper_input_base() const { return 1; } 176 177 // Copy inputs and operands to new node of instruction. 178 // Called from cisc_version() and short_branch_version(). 179 // !!!! The method's body is defined in ad_<arch>.cpp file. 180 void fill_new_machnode(MachNode *n, Compile* C) const; 181 182 // Return an equivalent instruction using memory for cisc_operand position 183 virtual MachNode *cisc_version(int offset, Compile* C); 184 // Modify this instruction's register mask to use stack version for cisc_operand 185 virtual void use_cisc_RegMask(); 186 187 // Support for short branches 188 virtual MachNode *short_branch_version(Compile* C) { return NULL; } 189 bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; } 190 191 // First index in _in[] corresponding to operand, or -1 if there is none 192 int operand_index(uint operand) const; 193 194 // Register class input is expected in 195 virtual const RegMask &in_RegMask(uint) const; 196 197 // cisc-spillable instructions redefine for use by in_RegMask 198 virtual const RegMask *cisc_RegMask() const { return NULL; } 199 200 // If this instruction is a 2-address instruction, then return the 201 // index of the input which must match the output. Not nessecary 202 // for instructions which bind the input and output register to the 203 // same singleton regiser (e.g., Intel IDIV which binds AX to be 204 // both an input and an output). It is nessecary when the input and 205 // output have choices - but they must use the same choice. 206 virtual uint two_adr( ) const { return 0; } 207 208 // Array of complex operand pointers. Each corresponds to zero or 209 // more leafs. Must be set by MachNode constructor to point to an 210 // internal array of MachOpers. The MachOper array is sized by 211 // specific MachNodes described in the ADL. 212 uint _num_opnds; 213 MachOper **_opnds; 214 uint num_opnds() const { return _num_opnds; } 215 216 // Emit bytes into cbuf 217 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 218 // Size of instruction in bytes 219 virtual uint size(PhaseRegAlloc *ra_) const; 220 // Helper function that computes size by emitting code 221 virtual uint emit_size(PhaseRegAlloc *ra_) const; 222 223 // Return the alignment required (in units of relocInfo::addr_unit()) 224 // for this instruction (must be a power of 2) 225 virtual int alignment_required() const { return 1; } 226 227 // Return the padding (in bytes) to be emitted before this 228 // instruction to properly align it. 229 virtual int compute_padding(int current_offset) const { return 0; } 230 231 // Return number of relocatable values contained in this instruction 232 virtual int reloc() const { return 0; } 233 234 // Hash and compare over operands. Used to do GVN on machine Nodes. 235 virtual uint hash() const; 236 virtual uint cmp( const Node &n ) const; 237 238 // Expand method for MachNode, replaces nodes representing pseudo 239 // instructions with a set of nodes which represent real machine 240 // instructions and compute the same value. 241 virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; } 242 243 // Bottom_type call; value comes from operand0 244 virtual const class Type *bottom_type() const { return _opnds[0]->type(); } 245 virtual uint ideal_reg() const { const Type *t = _opnds[0]->type(); return t == TypeInt::CC ? Op_RegFlags : Matcher::base2reg[t->base()]; } 246 247 // If this is a memory op, return the base pointer and fixed offset. 248 // If there are no such, return NULL. If there are multiple addresses 249 // or the address is indeterminate (rare cases) then return (Node*)-1, 250 // which serves as node bottom. 251 // If the offset is not statically determined, set it to Type::OffsetBot. 252 // This method is free to ignore stack slots if that helps. 253 #define TYPE_PTR_SENTINAL ((const TypePtr*)-1) 254 // Passing TYPE_PTR_SENTINAL as adr_type asks for computation of the adr_type if possible 255 const Node* get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const; 256 257 // Helper for get_base_and_disp: find the base and index input nodes. 258 // Returns the MachOper as determined by memory_operand(), for use, if 259 // needed by the caller. If (MachOper *)-1 is returned, base and index 260 // are set to NodeSentinel. If (MachOper *) NULL is returned, base and 261 // index are set to NULL. 262 const MachOper* memory_inputs(Node* &base, Node* &index) const; 263 264 // Helper for memory_inputs: Which operand carries the necessary info? 265 // By default, returns NULL, which means there is no such operand. 266 // If it returns (MachOper*)-1, this means there are multiple memories. 267 virtual const MachOper* memory_operand() const { return NULL; } 268 269 // Call "get_base_and_disp" to decide which category of memory is used here. 270 virtual const class TypePtr *adr_type() const; 271 272 // Negate conditional branches. Error for non-branch Nodes 273 virtual void negate(); 274 275 // Apply peephole rule(s) to this instruction 276 virtual MachNode *peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ); 277 278 // Top-level ideal Opcode matched 279 virtual int ideal_Opcode() const { return Op_Node; } 280 281 // Set the branch inside jump MachNodes. Error for non-branch Nodes. 282 virtual void label_set( Label* label, uint block_num ); 283 284 // Adds the label for the case 285 virtual void add_case_label( int switch_val, Label* blockLabel); 286 287 // Set the absolute address for methods 288 virtual void method_set( intptr_t addr ); 289 290 // Should we clone rather than spill this instruction? 291 bool rematerialize() const; 292 293 // Get the pipeline info 294 static const Pipeline *pipeline_class(); 295 virtual const Pipeline *pipeline() const; 296 297 #ifndef PRODUCT 298 virtual const char *Name() const = 0; // Machine-specific name 299 virtual void dump_spec(outputStream *st) const; // Print per-node info 300 void dump_format(PhaseRegAlloc *ra, outputStream *st) const; // access to virtual 301 #endif 302 }; 303 304 //------------------------------MachIdealNode---------------------------- 305 // Machine specific versions of nodes that must be defined by user. 306 // These are not converted by matcher from ideal nodes to machine nodes 307 // but are inserted into the code by the compiler. 308 class MachIdealNode : public MachNode { 309 public: 310 MachIdealNode( ) {} 311 312 // Define the following defaults for non-matched machine nodes 313 virtual uint oper_input_base() const { return 0; } 314 virtual uint rule() const { return 9999999; } 315 virtual const class Type *bottom_type() const { return _opnds == NULL ? Type::CONTROL : MachNode::bottom_type(); } 316 }; 317 318 //------------------------------MachTypeNode---------------------------- 319 // Machine Nodes that need to retain a known Type. 320 class MachTypeNode : public MachNode { 321 virtual uint size_of() const { return sizeof(*this); } // Size is bigger 322 public: 323 const Type *_bottom_type; 324 325 virtual const class Type *bottom_type() const { return _bottom_type; } 326 #ifndef PRODUCT 327 virtual void dump_spec(outputStream *st) const; 328 #endif 329 }; 330 331 //------------------------------MachBreakpointNode---------------------------- 332 // Machine breakpoint or interrupt Node 333 class MachBreakpointNode : public MachIdealNode { 334 public: 335 MachBreakpointNode( ) {} 336 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 337 virtual uint size(PhaseRegAlloc *ra_) const; 338 339 #ifndef PRODUCT 340 virtual const char *Name() const { return "Breakpoint"; } 341 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 342 #endif 343 }; 344 345 //------------------------------MachConstantBaseNode-------------------------- 346 // Machine node that represents the base address of the constant table. 347 class MachConstantBaseNode : public MachIdealNode { 348 public: 349 static const RegMask& _out_RegMask; // We need the out_RegMask statically in MachConstantNode::in_RegMask(). 350 351 public: 352 MachConstantBaseNode() : MachIdealNode() { 353 init_class_id(Class_MachConstantBase); 354 } 355 virtual const class Type* bottom_type() const { return TypeRawPtr::NOTNULL; } 356 virtual uint ideal_reg() const { return Op_RegP; } 357 virtual uint oper_input_base() const { return 1; } 358 359 virtual void emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const; 360 virtual uint size(PhaseRegAlloc* ra_) const; 361 virtual bool pinned() const { return UseRDPCForConstantTableBase; } 362 363 static const RegMask& static_out_RegMask() { return _out_RegMask; } 364 virtual const RegMask& out_RegMask() const { return static_out_RegMask(); } 365 366 #ifndef PRODUCT 367 virtual const char* Name() const { return "MachConstantBaseNode"; } 368 virtual void format(PhaseRegAlloc*, outputStream* st) const; 369 #endif 370 }; 371 372 //------------------------------MachConstantNode------------------------------- 373 // Machine node that holds a constant which is stored in the constant table. 374 class MachConstantNode : public MachNode { 375 protected: 376 Compile::Constant _constant; // This node's constant. 377 378 public: 379 MachConstantNode() : MachNode() { 380 init_class_id(Class_MachConstant); 381 } 382 383 virtual void eval_constant(Compile* C) { 384 #ifdef ASSERT 385 tty->print("missing MachConstantNode eval_constant function: "); 386 dump(); 387 #endif 388 ShouldNotCallThis(); 389 } 390 391 virtual const RegMask &in_RegMask(uint idx) const { 392 if (idx == mach_constant_base_node_input()) 393 return MachConstantBaseNode::static_out_RegMask(); 394 return MachNode::in_RegMask(idx); 395 } 396 397 // Input edge of MachConstantBaseNode. 398 uint mach_constant_base_node_input() const { return req() - 1; } 399 400 int constant_offset(); 401 int constant_offset() const { return ((MachConstantNode*) this)->constant_offset(); } 402 }; 403 404 //------------------------------MachUEPNode----------------------------------- 405 // Machine Unvalidated Entry Point Node 406 class MachUEPNode : public MachIdealNode { 407 public: 408 MachUEPNode( ) {} 409 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 410 virtual uint size(PhaseRegAlloc *ra_) const; 411 412 #ifndef PRODUCT 413 virtual const char *Name() const { return "Unvalidated-Entry-Point"; } 414 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 415 #endif 416 }; 417 418 //------------------------------MachPrologNode-------------------------------- 419 // Machine function Prolog Node 420 class MachPrologNode : public MachIdealNode { 421 public: 422 MachPrologNode( ) {} 423 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 424 virtual uint size(PhaseRegAlloc *ra_) const; 425 virtual int reloc() const; 426 427 #ifndef PRODUCT 428 virtual const char *Name() const { return "Prolog"; } 429 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 430 #endif 431 }; 432 433 //------------------------------MachEpilogNode-------------------------------- 434 // Machine function Epilog Node 435 class MachEpilogNode : public MachIdealNode { 436 public: 437 MachEpilogNode(bool do_poll = false) : _do_polling(do_poll) {} 438 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 439 virtual uint size(PhaseRegAlloc *ra_) const; 440 virtual int reloc() const; 441 virtual const Pipeline *pipeline() const; 442 443 private: 444 bool _do_polling; 445 446 public: 447 bool do_polling() const { return _do_polling; } 448 449 // Offset of safepoint from the beginning of the node 450 int safepoint_offset() const; 451 452 #ifndef PRODUCT 453 virtual const char *Name() const { return "Epilog"; } 454 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 455 #endif 456 }; 457 458 //------------------------------MachNopNode----------------------------------- 459 // Machine function Nop Node 460 class MachNopNode : public MachIdealNode { 461 private: 462 int _count; 463 public: 464 MachNopNode( ) : _count(1) {} 465 MachNopNode( int count ) : _count(count) {} 466 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 467 virtual uint size(PhaseRegAlloc *ra_) const; 468 469 virtual const class Type *bottom_type() const { return Type::CONTROL; } 470 471 virtual int ideal_Opcode() const { return Op_Con; } // bogus; see output.cpp 472 virtual const Pipeline *pipeline() const; 473 #ifndef PRODUCT 474 virtual const char *Name() const { return "Nop"; } 475 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 476 virtual void dump_spec(outputStream *st) const { } // No per-operand info 477 #endif 478 }; 479 480 //------------------------------MachSpillCopyNode------------------------------ 481 // Machine SpillCopy Node. Copies 1 or 2 words from any location to any 482 // location (stack or register). 483 class MachSpillCopyNode : public MachIdealNode { 484 const RegMask *_in; // RegMask for input 485 const RegMask *_out; // RegMask for output 486 const Type *_type; 487 public: 488 MachSpillCopyNode( Node *n, const RegMask &in, const RegMask &out ) : 489 MachIdealNode(), _in(&in), _out(&out), _type(n->bottom_type()) { 490 init_class_id(Class_MachSpillCopy); 491 init_flags(Flag_is_Copy); 492 add_req(NULL); 493 add_req(n); 494 } 495 virtual uint size_of() const { return sizeof(*this); } 496 void set_out_RegMask(const RegMask &out) { _out = &out; } 497 void set_in_RegMask(const RegMask &in) { _in = ∈ } 498 virtual const RegMask &out_RegMask() const { return *_out; } 499 virtual const RegMask &in_RegMask(uint) const { return *_in; } 500 virtual const class Type *bottom_type() const { return _type; } 501 virtual uint ideal_reg() const { return Matcher::base2reg[_type->base()]; } 502 virtual uint oper_input_base() const { return 1; } 503 uint implementation( CodeBuffer *cbuf, PhaseRegAlloc *ra_, bool do_size, outputStream* st ) const; 504 505 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 506 virtual uint size(PhaseRegAlloc *ra_) const; 507 508 #ifndef PRODUCT 509 virtual const char *Name() const { return "MachSpillCopy"; } 510 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 511 #endif 512 }; 513 514 //------------------------------MachNullChkNode-------------------------------- 515 // Machine-dependent null-pointer-check Node. Points a real MachNode that is 516 // also some kind of memory op. Turns the indicated MachNode into a 517 // conditional branch with good latency on the ptr-not-null path and awful 518 // latency on the pointer-is-null path. 519 520 class MachNullCheckNode : public MachIdealNode { 521 public: 522 const uint _vidx; // Index of memop being tested 523 MachNullCheckNode( Node *ctrl, Node *memop, uint vidx ) : MachIdealNode(), _vidx(vidx) { 524 init_class_id(Class_MachNullCheck); 525 init_flags(Flag_is_Branch); 526 add_req(ctrl); 527 add_req(memop); 528 } 529 530 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 531 virtual void label_set(Label* label, uint block_num); 532 virtual bool pinned() const { return true; }; 533 virtual void negate() { } 534 virtual const class Type *bottom_type() const { return TypeTuple::IFBOTH; } 535 virtual uint ideal_reg() const { return NotAMachineReg; } 536 virtual const RegMask &in_RegMask(uint) const; 537 virtual const RegMask &out_RegMask() const { return RegMask::Empty; } 538 #ifndef PRODUCT 539 virtual const char *Name() const { return "NullCheck"; } 540 virtual void format( PhaseRegAlloc *, outputStream *st ) const; 541 #endif 542 }; 543 544 //------------------------------MachProjNode---------------------------------- 545 // Machine-dependent Ideal projections (how is that for an oxymoron). Really 546 // just MachNodes made by the Ideal world that replicate simple projections 547 // but with machine-dependent input & output register masks. Generally 548 // produced as part of calling conventions. Normally I make MachNodes as part 549 // of the Matcher process, but the Matcher is ill suited to issues involving 550 // frame handling, so frame handling is all done in the Ideal world with 551 // occasional callbacks to the machine model for important info. 552 class MachProjNode : public ProjNode { 553 public: 554 MachProjNode( Node *multi, uint con, const RegMask &out, uint ideal_reg ) : ProjNode(multi,con), _rout(out), _ideal_reg(ideal_reg) { 555 init_class_id(Class_MachProj); 556 } 557 RegMask _rout; 558 const uint _ideal_reg; 559 enum projType { 560 unmatched_proj = 0, // Projs for Control, I/O, memory not matched 561 fat_proj = 999 // Projs killing many regs, defined by _rout 562 }; 563 virtual int Opcode() const; 564 virtual const Type *bottom_type() const; 565 virtual const TypePtr *adr_type() const; 566 virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; } 567 virtual const RegMask &out_RegMask() const { return _rout; } 568 virtual uint ideal_reg() const { return _ideal_reg; } 569 // Need size_of() for virtual ProjNode::clone() 570 virtual uint size_of() const { return sizeof(MachProjNode); } 571 #ifndef PRODUCT 572 virtual void dump_spec(outputStream *st) const; 573 #endif 574 }; 575 576 //------------------------------MachIfNode------------------------------------- 577 // Machine-specific versions of IfNodes 578 class MachIfNode : public MachNode { 579 virtual uint size_of() const { return sizeof(*this); } // Size is bigger 580 public: 581 float _prob; // Probability branch goes either way 582 float _fcnt; // Frequency counter 583 MachIfNode() : MachNode() { 584 init_class_id(Class_MachIf); 585 } 586 #ifndef PRODUCT 587 virtual void dump_spec(outputStream *st) const; 588 #endif 589 }; 590 591 //------------------------------MachGotoNode----------------------------------- 592 // Machine-specific versions of GotoNodes 593 class MachGotoNode : public MachNode { 594 public: 595 MachGotoNode() : MachNode() { 596 init_class_id(Class_MachGoto); 597 } 598 }; 599 600 //------------------------------MachFastLockNode------------------------------------- 601 // Machine-specific versions of FastLockNodes 602 class MachFastLockNode : public MachNode { 603 virtual uint size_of() const { return sizeof(*this); } // Size is bigger 604 public: 605 BiasedLockingCounters* _counters; 606 607 MachFastLockNode() : MachNode() {} 608 }; 609 610 //------------------------------MachReturnNode-------------------------------- 611 // Machine-specific versions of subroutine returns 612 class MachReturnNode : public MachNode { 613 virtual uint size_of() const; // Size is bigger 614 public: 615 RegMask *_in_rms; // Input register masks, set during allocation 616 ReallocMark _nesting; // assertion check for reallocations 617 const TypePtr* _adr_type; // memory effects of call or return 618 MachReturnNode() : MachNode() { 619 init_class_id(Class_MachReturn); 620 _adr_type = TypePtr::BOTTOM; // the default: all of memory 621 } 622 623 void set_adr_type(const TypePtr* atp) { _adr_type = atp; } 624 625 virtual const RegMask &in_RegMask(uint) const; 626 virtual bool pinned() const { return true; }; 627 virtual const TypePtr *adr_type() const; 628 }; 629 630 //------------------------------MachSafePointNode----------------------------- 631 // Machine-specific versions of safepoints 632 class MachSafePointNode : public MachReturnNode { 633 public: 634 OopMap* _oop_map; // Array of OopMap info (8-bit char) for GC 635 JVMState* _jvms; // Pointer to list of JVM State Objects 636 uint _jvmadj; // Extra delta to jvms indexes (mach. args) 637 OopMap* oop_map() const { return _oop_map; } 638 void set_oop_map(OopMap* om) { _oop_map = om; } 639 640 MachSafePointNode() : MachReturnNode(), _oop_map(NULL), _jvms(NULL), _jvmadj(0) { 641 init_class_id(Class_MachSafePoint); 642 } 643 644 virtual JVMState* jvms() const { return _jvms; } 645 void set_jvms(JVMState* s) { 646 _jvms = s; 647 } 648 virtual const Type *bottom_type() const; 649 650 virtual const RegMask &in_RegMask(uint) const; 651 652 // Functionality from old debug nodes 653 Node *returnadr() const { return in(TypeFunc::ReturnAdr); } 654 Node *frameptr () const { return in(TypeFunc::FramePtr); } 655 656 Node *local(const JVMState* jvms, uint idx) const { 657 assert(verify_jvms(jvms), "jvms must match"); 658 return in(_jvmadj + jvms->locoff() + idx); 659 } 660 Node *stack(const JVMState* jvms, uint idx) const { 661 assert(verify_jvms(jvms), "jvms must match"); 662 return in(_jvmadj + jvms->stkoff() + idx); 663 } 664 Node *monitor_obj(const JVMState* jvms, uint idx) const { 665 assert(verify_jvms(jvms), "jvms must match"); 666 return in(_jvmadj + jvms->monitor_obj_offset(idx)); 667 } 668 Node *monitor_box(const JVMState* jvms, uint idx) const { 669 assert(verify_jvms(jvms), "jvms must match"); 670 return in(_jvmadj + jvms->monitor_box_offset(idx)); 671 } 672 void set_local(const JVMState* jvms, uint idx, Node *c) { 673 assert(verify_jvms(jvms), "jvms must match"); 674 set_req(_jvmadj + jvms->locoff() + idx, c); 675 } 676 void set_stack(const JVMState* jvms, uint idx, Node *c) { 677 assert(verify_jvms(jvms), "jvms must match"); 678 set_req(_jvmadj + jvms->stkoff() + idx, c); 679 } 680 void set_monitor(const JVMState* jvms, uint idx, Node *c) { 681 assert(verify_jvms(jvms), "jvms must match"); 682 set_req(_jvmadj + jvms->monoff() + idx, c); 683 } 684 }; 685 686 //------------------------------MachCallNode---------------------------------- 687 // Machine-specific versions of subroutine calls 688 class MachCallNode : public MachSafePointNode { 689 protected: 690 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 691 virtual uint cmp( const Node &n ) const; 692 virtual uint size_of() const = 0; // Size is bigger 693 public: 694 const TypeFunc *_tf; // Function type 695 address _entry_point; // Address of the method being called 696 float _cnt; // Estimate of number of times called 697 uint _argsize; // Size of argument block on stack 698 699 const TypeFunc* tf() const { return _tf; } 700 const address entry_point() const { return _entry_point; } 701 const float cnt() const { return _cnt; } 702 uint argsize() const { return _argsize; } 703 704 void set_tf(const TypeFunc* tf) { _tf = tf; } 705 void set_entry_point(address p) { _entry_point = p; } 706 void set_cnt(float c) { _cnt = c; } 707 void set_argsize(int s) { _argsize = s; } 708 709 MachCallNode() : MachSafePointNode() { 710 init_class_id(Class_MachCall); 711 } 712 713 virtual const Type *bottom_type() const; 714 virtual bool pinned() const { return false; } 715 virtual const Type *Value( PhaseTransform *phase ) const; 716 virtual const RegMask &in_RegMask(uint) const; 717 virtual int ret_addr_offset() { return 0; } 718 719 bool returns_long() const { return tf()->return_type() == T_LONG; } 720 bool return_value_is_used() const; 721 #ifndef PRODUCT 722 virtual void dump_spec(outputStream *st) const; 723 #endif 724 }; 725 726 //------------------------------MachCallJavaNode------------------------------ 727 // "Base" class for machine-specific versions of subroutine calls 728 class MachCallJavaNode : public MachCallNode { 729 protected: 730 virtual uint cmp( const Node &n ) const; 731 virtual uint size_of() const; // Size is bigger 732 public: 733 ciMethod* _method; // Method being direct called 734 int _bci; // Byte Code index of call byte code 735 bool _optimized_virtual; // Tells if node is a static call or an optimized virtual 736 bool _method_handle_invoke; // Tells if the call has to preserve SP 737 MachCallJavaNode() : MachCallNode() { 738 init_class_id(Class_MachCallJava); 739 } 740 741 virtual const RegMask &in_RegMask(uint) const; 742 743 #ifndef PRODUCT 744 virtual void dump_spec(outputStream *st) const; 745 #endif 746 }; 747 748 //------------------------------MachCallStaticJavaNode------------------------ 749 // Machine-specific versions of monomorphic subroutine calls 750 class MachCallStaticJavaNode : public MachCallJavaNode { 751 virtual uint cmp( const Node &n ) const; 752 virtual uint size_of() const; // Size is bigger 753 public: 754 const char *_name; // Runtime wrapper name 755 MachCallStaticJavaNode() : MachCallJavaNode() { 756 init_class_id(Class_MachCallStaticJava); 757 } 758 759 // If this is an uncommon trap, return the request code, else zero. 760 int uncommon_trap_request() const; 761 762 virtual int ret_addr_offset(); 763 #ifndef PRODUCT 764 virtual void dump_spec(outputStream *st) const; 765 void dump_trap_args(outputStream *st) const; 766 #endif 767 }; 768 769 //------------------------------MachCallDynamicJavaNode------------------------ 770 // Machine-specific versions of possibly megamorphic subroutine calls 771 class MachCallDynamicJavaNode : public MachCallJavaNode { 772 public: 773 int _vtable_index; 774 MachCallDynamicJavaNode() : MachCallJavaNode() { 775 init_class_id(Class_MachCallDynamicJava); 776 DEBUG_ONLY(_vtable_index = -99); // throw an assert if uninitialized 777 } 778 virtual int ret_addr_offset(); 779 #ifndef PRODUCT 780 virtual void dump_spec(outputStream *st) const; 781 #endif 782 }; 783 784 //------------------------------MachCallRuntimeNode---------------------------- 785 // Machine-specific versions of subroutine calls 786 class MachCallRuntimeNode : public MachCallNode { 787 virtual uint cmp( const Node &n ) const; 788 virtual uint size_of() const; // Size is bigger 789 public: 790 const char *_name; // Printable name, if _method is NULL 791 MachCallRuntimeNode() : MachCallNode() { 792 init_class_id(Class_MachCallRuntime); 793 } 794 virtual int ret_addr_offset(); 795 #ifndef PRODUCT 796 virtual void dump_spec(outputStream *st) const; 797 #endif 798 }; 799 800 class MachCallLeafNode: public MachCallRuntimeNode { 801 public: 802 MachCallLeafNode() : MachCallRuntimeNode() { 803 init_class_id(Class_MachCallLeaf); 804 } 805 }; 806 807 //------------------------------MachHaltNode----------------------------------- 808 // Machine-specific versions of halt nodes 809 class MachHaltNode : public MachReturnNode { 810 public: 811 virtual JVMState* jvms() const; 812 }; 813 814 815 //------------------------------MachTempNode----------------------------------- 816 // Node used by the adlc to construct inputs to represent temporary registers 817 class MachTempNode : public MachNode { 818 private: 819 MachOper *_opnd_array[1]; 820 821 public: 822 virtual const RegMask &out_RegMask() const { return *_opnds[0]->in_RegMask(0); } 823 virtual uint rule() const { return 9999999; } 824 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {} 825 826 MachTempNode(MachOper* oper) { 827 init_class_id(Class_MachTemp); 828 _num_opnds = 1; 829 _opnds = _opnd_array; 830 add_req(NULL); 831 _opnds[0] = oper; 832 } 833 virtual uint size_of() const { return sizeof(MachTempNode); } 834 835 #ifndef PRODUCT 836 virtual void format(PhaseRegAlloc *, outputStream *st ) const {} 837 virtual const char *Name() const { return "MachTemp";} 838 #endif 839 }; 840 841 842 843 //------------------------------labelOper-------------------------------------- 844 // Machine-independent version of label operand 845 class labelOper : public MachOper { 846 private: 847 virtual uint num_edges() const { return 0; } 848 public: 849 // Supported for fixed size branches 850 Label* _label; // Label for branch(es) 851 852 uint _block_num; 853 854 labelOper() : _block_num(0), _label(0) {} 855 856 labelOper(Label* label, uint block_num) : _label(label), _block_num(block_num) {} 857 858 labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {} 859 860 virtual MachOper *clone(Compile* C) const; 861 862 virtual Label *label() const { assert(_label != NULL, "need Label"); return _label; } 863 864 virtual uint opcode() const; 865 866 virtual uint hash() const; 867 virtual uint cmp( const MachOper &oper ) const; 868 #ifndef PRODUCT 869 virtual const char *Name() const { return "Label";} 870 871 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const; 872 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); } 873 #endif 874 }; 875 876 877 //------------------------------methodOper-------------------------------------- 878 // Machine-independent version of method operand 879 class methodOper : public MachOper { 880 private: 881 virtual uint num_edges() const { return 0; } 882 public: 883 intptr_t _method; // Address of method 884 methodOper() : _method(0) {} 885 methodOper(intptr_t method) : _method(method) {} 886 887 virtual MachOper *clone(Compile* C) const; 888 889 virtual intptr_t method() const { return _method; } 890 891 virtual uint opcode() const; 892 893 virtual uint hash() const; 894 virtual uint cmp( const MachOper &oper ) const; 895 #ifndef PRODUCT 896 virtual const char *Name() const { return "Method";} 897 898 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const; 899 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); } 900 #endif 901 }; 902 903 #endif // SHARE_VM_OPTO_MACHNODE_HPP