1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/machnode.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,969 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_OPTO_MACHNODE_HPP 1.29 +#define SHARE_VM_OPTO_MACHNODE_HPP 1.30 + 1.31 +#include "opto/callnode.hpp" 1.32 +#include "opto/matcher.hpp" 1.33 +#include "opto/multnode.hpp" 1.34 +#include "opto/node.hpp" 1.35 +#include "opto/regmask.hpp" 1.36 + 1.37 +class BiasedLockingCounters; 1.38 +class BufferBlob; 1.39 +class CodeBuffer; 1.40 +class JVMState; 1.41 +class MachCallDynamicJavaNode; 1.42 +class MachCallJavaNode; 1.43 +class MachCallLeafNode; 1.44 +class MachCallNode; 1.45 +class MachCallRuntimeNode; 1.46 +class MachCallStaticJavaNode; 1.47 +class MachEpilogNode; 1.48 +class MachIfNode; 1.49 +class MachNullCheckNode; 1.50 +class MachOper; 1.51 +class MachProjNode; 1.52 +class MachPrologNode; 1.53 +class MachReturnNode; 1.54 +class MachSafePointNode; 1.55 +class MachSpillCopyNode; 1.56 +class Matcher; 1.57 +class PhaseRegAlloc; 1.58 +class RegMask; 1.59 +class RTMLockingCounters; 1.60 +class State; 1.61 + 1.62 +//---------------------------MachOper------------------------------------------ 1.63 +class MachOper : public ResourceObj { 1.64 +public: 1.65 + // Allocate right next to the MachNodes in the same arena 1.66 + void *operator new( size_t x, Compile* C ) throw() { return C->node_arena()->Amalloc_D(x); } 1.67 + 1.68 + // Opcode 1.69 + virtual uint opcode() const = 0; 1.70 + 1.71 + // Number of input edges. 1.72 + // Generally at least 1 1.73 + virtual uint num_edges() const { return 1; } 1.74 + // Array of Register masks 1.75 + virtual const RegMask *in_RegMask(int index) const; 1.76 + 1.77 + // Methods to output the encoding of the operand 1.78 + 1.79 + // Negate conditional branches. Error for non-branch Nodes 1.80 + virtual void negate(); 1.81 + 1.82 + // Return the value requested 1.83 + // result register lookup, corresponding to int_format 1.84 + virtual int reg(PhaseRegAlloc *ra_, const Node *node) const; 1.85 + // input register lookup, corresponding to ext_format 1.86 + virtual int reg(PhaseRegAlloc *ra_, const Node *node, int idx) const; 1.87 + 1.88 + // helpers for MacroAssembler generation from ADLC 1.89 + Register as_Register(PhaseRegAlloc *ra_, const Node *node) const { 1.90 + return ::as_Register(reg(ra_, node)); 1.91 + } 1.92 + Register as_Register(PhaseRegAlloc *ra_, const Node *node, int idx) const { 1.93 + return ::as_Register(reg(ra_, node, idx)); 1.94 + } 1.95 + FloatRegister as_FloatRegister(PhaseRegAlloc *ra_, const Node *node) const { 1.96 + return ::as_FloatRegister(reg(ra_, node)); 1.97 + } 1.98 + FloatRegister as_FloatRegister(PhaseRegAlloc *ra_, const Node *node, int idx) const { 1.99 + return ::as_FloatRegister(reg(ra_, node, idx)); 1.100 + } 1.101 + 1.102 +#if defined(IA32) || defined(AMD64) 1.103 + XMMRegister as_XMMRegister(PhaseRegAlloc *ra_, const Node *node) const { 1.104 + return ::as_XMMRegister(reg(ra_, node)); 1.105 + } 1.106 + XMMRegister as_XMMRegister(PhaseRegAlloc *ra_, const Node *node, int idx) const { 1.107 + return ::as_XMMRegister(reg(ra_, node, idx)); 1.108 + } 1.109 +#endif 1.110 + // CondRegister reg converter 1.111 +#if defined(PPC64) 1.112 + ConditionRegister as_ConditionRegister(PhaseRegAlloc *ra_, const Node *node) const { 1.113 + return ::as_ConditionRegister(reg(ra_, node)); 1.114 + } 1.115 + ConditionRegister as_ConditionRegister(PhaseRegAlloc *ra_, const Node *node, int idx) const { 1.116 + return ::as_ConditionRegister(reg(ra_, node, idx)); 1.117 + } 1.118 +#endif 1.119 + 1.120 + virtual intptr_t constant() const; 1.121 + virtual relocInfo::relocType constant_reloc() const; 1.122 + virtual jdouble constantD() const; 1.123 + virtual jfloat constantF() const; 1.124 + virtual jlong constantL() const; 1.125 + virtual TypeOopPtr *oop() const; 1.126 + virtual int ccode() const; 1.127 + // A zero, default, indicates this value is not needed. 1.128 + // May need to lookup the base register, as done in int_ and ext_format 1.129 + virtual int base (PhaseRegAlloc *ra_, const Node *node, int idx) const; 1.130 + virtual int index(PhaseRegAlloc *ra_, const Node *node, int idx) const; 1.131 + virtual int scale() const; 1.132 + // Parameters needed to support MEMORY_INTERFACE access to stackSlot 1.133 + virtual int disp (PhaseRegAlloc *ra_, const Node *node, int idx) const; 1.134 + // Check for PC-Relative displacement 1.135 + virtual relocInfo::relocType disp_reloc() const; 1.136 + virtual int constant_disp() const; // usu. 0, may return Type::OffsetBot 1.137 + virtual int base_position() const; // base edge position, or -1 1.138 + virtual int index_position() const; // index edge position, or -1 1.139 + 1.140 + // Access the TypeKlassPtr of operands with a base==RegI and disp==RegP 1.141 + // Only returns non-null value for i486.ad's indOffset32X 1.142 + virtual const TypePtr *disp_as_type() const { return NULL; } 1.143 + 1.144 + // Return the label 1.145 + virtual Label *label() const; 1.146 + 1.147 + // Return the method's address 1.148 + virtual intptr_t method() const; 1.149 + 1.150 + // Hash and compare over operands are currently identical 1.151 + virtual uint hash() const; 1.152 + virtual uint cmp( const MachOper &oper ) const; 1.153 + 1.154 + // Virtual clone, since I do not know how big the MachOper is. 1.155 + virtual MachOper *clone(Compile* C) const = 0; 1.156 + 1.157 + // Return ideal Type from simple operands. Fail for complex operands. 1.158 + virtual const Type *type() const; 1.159 + 1.160 + // Set an integer offset if we have one, or error otherwise 1.161 + virtual void set_con( jint c0 ) { ShouldNotReachHere(); } 1.162 + 1.163 +#ifndef PRODUCT 1.164 + // Return name of operand 1.165 + virtual const char *Name() const { return "???";} 1.166 + 1.167 + // Methods to output the text version of the operand 1.168 + virtual void int_format(PhaseRegAlloc *,const MachNode *node, outputStream *st) const = 0; 1.169 + virtual void ext_format(PhaseRegAlloc *,const MachNode *node,int idx, outputStream *st) const=0; 1.170 + 1.171 + virtual void dump_spec(outputStream *st) const; // Print per-operand info 1.172 + 1.173 + // Check whether o is a valid oper. 1.174 + static bool notAnOper(const MachOper *o) { 1.175 + if (o == NULL) return true; 1.176 + if (((intptr_t)o & 1) != 0) return true; 1.177 + if (*(address*)o == badAddress) return true; // kill by Node::destruct 1.178 + return false; 1.179 + } 1.180 +#endif // !PRODUCT 1.181 +}; 1.182 + 1.183 +//------------------------------MachNode--------------------------------------- 1.184 +// Base type for all machine specific nodes. All node classes generated by the 1.185 +// ADLC inherit from this class. 1.186 +class MachNode : public Node { 1.187 +public: 1.188 + MachNode() : Node((uint)0), _num_opnds(0), _opnds(NULL) { 1.189 + init_class_id(Class_Mach); 1.190 + } 1.191 + // Required boilerplate 1.192 + virtual uint size_of() const { return sizeof(MachNode); } 1.193 + virtual int Opcode() const; // Always equal to MachNode 1.194 + virtual uint rule() const = 0; // Machine-specific opcode 1.195 + // Number of inputs which come before the first operand. 1.196 + // Generally at least 1, to skip the Control input 1.197 + virtual uint oper_input_base() const { return 1; } 1.198 + // Position of constant base node in node's inputs. -1 if 1.199 + // no constant base node input. 1.200 + virtual uint mach_constant_base_node_input() const { return (uint)-1; } 1.201 + 1.202 + // Copy inputs and operands to new node of instruction. 1.203 + // Called from cisc_version() and short_branch_version(). 1.204 + // !!!! The method's body is defined in ad_<arch>.cpp file. 1.205 + void fill_new_machnode(MachNode *n, Compile* C) const; 1.206 + 1.207 + // Return an equivalent instruction using memory for cisc_operand position 1.208 + virtual MachNode *cisc_version(int offset, Compile* C); 1.209 + // Modify this instruction's register mask to use stack version for cisc_operand 1.210 + virtual void use_cisc_RegMask(); 1.211 + 1.212 + // Support for short branches 1.213 + bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; } 1.214 + 1.215 + // Avoid back to back some instructions on some CPUs. 1.216 + enum AvoidBackToBackFlag { AVOID_NONE = 0, 1.217 + AVOID_BEFORE = Flag_avoid_back_to_back_before, 1.218 + AVOID_AFTER = Flag_avoid_back_to_back_after, 1.219 + AVOID_BEFORE_AND_AFTER = AVOID_BEFORE | AVOID_AFTER }; 1.220 + 1.221 + bool avoid_back_to_back(AvoidBackToBackFlag flag_value) const { 1.222 + return (flags() & flag_value) == flag_value; 1.223 + } 1.224 + 1.225 + // instruction implemented with a call 1.226 + bool has_call() const { return (flags() & Flag_has_call) != 0; } 1.227 + 1.228 + // First index in _in[] corresponding to operand, or -1 if there is none 1.229 + int operand_index(uint operand) const; 1.230 + int operand_index(const MachOper *oper) const; 1.231 + 1.232 + // Register class input is expected in 1.233 + virtual const RegMask &in_RegMask(uint) const; 1.234 + 1.235 + // cisc-spillable instructions redefine for use by in_RegMask 1.236 + virtual const RegMask *cisc_RegMask() const { return NULL; } 1.237 + 1.238 + // If this instruction is a 2-address instruction, then return the 1.239 + // index of the input which must match the output. Not nessecary 1.240 + // for instructions which bind the input and output register to the 1.241 + // same singleton regiser (e.g., Intel IDIV which binds AX to be 1.242 + // both an input and an output). It is nessecary when the input and 1.243 + // output have choices - but they must use the same choice. 1.244 + virtual uint two_adr( ) const { return 0; } 1.245 + 1.246 + // Array of complex operand pointers. Each corresponds to zero or 1.247 + // more leafs. Must be set by MachNode constructor to point to an 1.248 + // internal array of MachOpers. The MachOper array is sized by 1.249 + // specific MachNodes described in the ADL. 1.250 + uint _num_opnds; 1.251 + MachOper **_opnds; 1.252 + uint num_opnds() const { return _num_opnds; } 1.253 + 1.254 + // Emit bytes into cbuf 1.255 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.256 + // Expand node after register allocation. 1.257 + // Node is replaced by several nodes in the postalloc expand phase. 1.258 + // Corresponding methods are generated for nodes if they specify 1.259 + // postalloc_expand. See block.cpp for more documentation. 1.260 + virtual bool requires_postalloc_expand() const { return false; } 1.261 + virtual void postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_); 1.262 + // Size of instruction in bytes 1.263 + virtual uint size(PhaseRegAlloc *ra_) const; 1.264 + // Helper function that computes size by emitting code 1.265 + virtual uint emit_size(PhaseRegAlloc *ra_) const; 1.266 + 1.267 + // Return the alignment required (in units of relocInfo::addr_unit()) 1.268 + // for this instruction (must be a power of 2) 1.269 + virtual int alignment_required() const { return 1; } 1.270 + 1.271 + // Return the padding (in bytes) to be emitted before this 1.272 + // instruction to properly align it. 1.273 + virtual int compute_padding(int current_offset) const { return 0; } 1.274 + 1.275 + // Return number of relocatable values contained in this instruction 1.276 + virtual int reloc() const { return 0; } 1.277 + 1.278 + // Return number of words used for double constants in this instruction 1.279 + virtual int ins_num_consts() const { return 0; } 1.280 + 1.281 + // Hash and compare over operands. Used to do GVN on machine Nodes. 1.282 + virtual uint hash() const; 1.283 + virtual uint cmp( const Node &n ) const; 1.284 + 1.285 + // Expand method for MachNode, replaces nodes representing pseudo 1.286 + // instructions with a set of nodes which represent real machine 1.287 + // instructions and compute the same value. 1.288 + virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; } 1.289 + 1.290 + // Bottom_type call; value comes from operand0 1.291 + virtual const class Type *bottom_type() const { return _opnds[0]->type(); } 1.292 + virtual uint ideal_reg() const { const Type *t = _opnds[0]->type(); return t == TypeInt::CC ? Op_RegFlags : t->ideal_reg(); } 1.293 + 1.294 + // If this is a memory op, return the base pointer and fixed offset. 1.295 + // If there are no such, return NULL. If there are multiple addresses 1.296 + // or the address is indeterminate (rare cases) then return (Node*)-1, 1.297 + // which serves as node bottom. 1.298 + // If the offset is not statically determined, set it to Type::OffsetBot. 1.299 + // This method is free to ignore stack slots if that helps. 1.300 + #define TYPE_PTR_SENTINAL ((const TypePtr*)-1) 1.301 + // Passing TYPE_PTR_SENTINAL as adr_type asks for computation of the adr_type if possible 1.302 + const Node* get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const; 1.303 + 1.304 + // Helper for get_base_and_disp: find the base and index input nodes. 1.305 + // Returns the MachOper as determined by memory_operand(), for use, if 1.306 + // needed by the caller. If (MachOper *)-1 is returned, base and index 1.307 + // are set to NodeSentinel. If (MachOper *) NULL is returned, base and 1.308 + // index are set to NULL. 1.309 + const MachOper* memory_inputs(Node* &base, Node* &index) const; 1.310 + 1.311 + // Helper for memory_inputs: Which operand carries the necessary info? 1.312 + // By default, returns NULL, which means there is no such operand. 1.313 + // If it returns (MachOper*)-1, this means there are multiple memories. 1.314 + virtual const MachOper* memory_operand() const { return NULL; } 1.315 + 1.316 + // Call "get_base_and_disp" to decide which category of memory is used here. 1.317 + virtual const class TypePtr *adr_type() const; 1.318 + 1.319 + // Apply peephole rule(s) to this instruction 1.320 + virtual MachNode *peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ); 1.321 + 1.322 + // Top-level ideal Opcode matched 1.323 + virtual int ideal_Opcode() const { return Op_Node; } 1.324 + 1.325 + // Adds the label for the case 1.326 + virtual void add_case_label( int switch_val, Label* blockLabel); 1.327 + 1.328 + // Set the absolute address for methods 1.329 + virtual void method_set( intptr_t addr ); 1.330 + 1.331 + // Should we clone rather than spill this instruction? 1.332 + bool rematerialize() const; 1.333 + 1.334 + // Get the pipeline info 1.335 + static const Pipeline *pipeline_class(); 1.336 + virtual const Pipeline *pipeline() const; 1.337 + 1.338 + // Returns true if this node is a check that can be implemented with a trap. 1.339 + virtual bool is_TrapBasedCheckNode() const { return false; } 1.340 + 1.341 +#ifndef PRODUCT 1.342 + virtual const char *Name() const = 0; // Machine-specific name 1.343 + virtual void dump_spec(outputStream *st) const; // Print per-node info 1.344 + void dump_format(PhaseRegAlloc *ra, outputStream *st) const; // access to virtual 1.345 +#endif 1.346 +}; 1.347 + 1.348 +//------------------------------MachIdealNode---------------------------- 1.349 +// Machine specific versions of nodes that must be defined by user. 1.350 +// These are not converted by matcher from ideal nodes to machine nodes 1.351 +// but are inserted into the code by the compiler. 1.352 +class MachIdealNode : public MachNode { 1.353 +public: 1.354 + MachIdealNode( ) {} 1.355 + 1.356 + // Define the following defaults for non-matched machine nodes 1.357 + virtual uint oper_input_base() const { return 0; } 1.358 + virtual uint rule() const { return 9999999; } 1.359 + virtual const class Type *bottom_type() const { return _opnds == NULL ? Type::CONTROL : MachNode::bottom_type(); } 1.360 +}; 1.361 + 1.362 +//------------------------------MachTypeNode---------------------------- 1.363 +// Machine Nodes that need to retain a known Type. 1.364 +class MachTypeNode : public MachNode { 1.365 + virtual uint size_of() const { return sizeof(*this); } // Size is bigger 1.366 +public: 1.367 + MachTypeNode( ) {} 1.368 + const Type *_bottom_type; 1.369 + 1.370 + virtual const class Type *bottom_type() const { return _bottom_type; } 1.371 +#ifndef PRODUCT 1.372 + virtual void dump_spec(outputStream *st) const; 1.373 +#endif 1.374 +}; 1.375 + 1.376 +//------------------------------MachBreakpointNode---------------------------- 1.377 +// Machine breakpoint or interrupt Node 1.378 +class MachBreakpointNode : public MachIdealNode { 1.379 +public: 1.380 + MachBreakpointNode( ) {} 1.381 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.382 + virtual uint size(PhaseRegAlloc *ra_) const; 1.383 + 1.384 +#ifndef PRODUCT 1.385 + virtual const char *Name() const { return "Breakpoint"; } 1.386 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.387 +#endif 1.388 +}; 1.389 + 1.390 +//------------------------------MachConstantBaseNode-------------------------- 1.391 +// Machine node that represents the base address of the constant table. 1.392 +class MachConstantBaseNode : public MachIdealNode { 1.393 +public: 1.394 + static const RegMask& _out_RegMask; // We need the out_RegMask statically in MachConstantNode::in_RegMask(). 1.395 + 1.396 +public: 1.397 + MachConstantBaseNode() : MachIdealNode() { 1.398 + init_class_id(Class_MachConstantBase); 1.399 + } 1.400 + virtual const class Type* bottom_type() const { return TypeRawPtr::NOTNULL; } 1.401 + virtual uint ideal_reg() const { return Op_RegP; } 1.402 + virtual uint oper_input_base() const { return 1; } 1.403 + 1.404 + virtual bool requires_postalloc_expand() const; 1.405 + virtual void postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_); 1.406 + 1.407 + virtual void emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const; 1.408 + virtual uint size(PhaseRegAlloc* ra_) const; 1.409 + virtual bool pinned() const { return UseRDPCForConstantTableBase; } 1.410 + 1.411 + static const RegMask& static_out_RegMask() { return _out_RegMask; } 1.412 + virtual const RegMask& out_RegMask() const { return static_out_RegMask(); } 1.413 + 1.414 +#ifndef PRODUCT 1.415 + virtual const char* Name() const { return "MachConstantBaseNode"; } 1.416 + virtual void format(PhaseRegAlloc*, outputStream* st) const; 1.417 +#endif 1.418 +}; 1.419 + 1.420 +//------------------------------MachConstantNode------------------------------- 1.421 +// Machine node that holds a constant which is stored in the constant table. 1.422 +class MachConstantNode : public MachTypeNode { 1.423 +protected: 1.424 + Compile::Constant _constant; // This node's constant. 1.425 + 1.426 +public: 1.427 + MachConstantNode() : MachTypeNode() { 1.428 + init_class_id(Class_MachConstant); 1.429 + } 1.430 + 1.431 + virtual void eval_constant(Compile* C) { 1.432 +#ifdef ASSERT 1.433 + tty->print("missing MachConstantNode eval_constant function: "); 1.434 + dump(); 1.435 +#endif 1.436 + ShouldNotCallThis(); 1.437 + } 1.438 + 1.439 + virtual const RegMask &in_RegMask(uint idx) const { 1.440 + if (idx == mach_constant_base_node_input()) 1.441 + return MachConstantBaseNode::static_out_RegMask(); 1.442 + return MachNode::in_RegMask(idx); 1.443 + } 1.444 + 1.445 + // Input edge of MachConstantBaseNode. 1.446 + virtual uint mach_constant_base_node_input() const { return req() - 1; } 1.447 + 1.448 + int constant_offset(); 1.449 + int constant_offset() const { return ((MachConstantNode*) this)->constant_offset(); } 1.450 + // Unchecked version to avoid assertions in debug output. 1.451 + int constant_offset_unchecked() const; 1.452 +}; 1.453 + 1.454 +//------------------------------MachUEPNode----------------------------------- 1.455 +// Machine Unvalidated Entry Point Node 1.456 +class MachUEPNode : public MachIdealNode { 1.457 +public: 1.458 + MachUEPNode( ) {} 1.459 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.460 + virtual uint size(PhaseRegAlloc *ra_) const; 1.461 + 1.462 +#ifndef PRODUCT 1.463 + virtual const char *Name() const { return "Unvalidated-Entry-Point"; } 1.464 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.465 +#endif 1.466 +}; 1.467 + 1.468 +//------------------------------MachPrologNode-------------------------------- 1.469 +// Machine function Prolog Node 1.470 +class MachPrologNode : public MachIdealNode { 1.471 +public: 1.472 + MachPrologNode( ) {} 1.473 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.474 + virtual uint size(PhaseRegAlloc *ra_) const; 1.475 + virtual int reloc() const; 1.476 + 1.477 +#ifndef PRODUCT 1.478 + virtual const char *Name() const { return "Prolog"; } 1.479 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.480 +#endif 1.481 +}; 1.482 + 1.483 +//------------------------------MachEpilogNode-------------------------------- 1.484 +// Machine function Epilog Node 1.485 +class MachEpilogNode : public MachIdealNode { 1.486 +public: 1.487 + MachEpilogNode(bool do_poll = false) : _do_polling(do_poll) {} 1.488 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.489 + virtual uint size(PhaseRegAlloc *ra_) const; 1.490 + virtual int reloc() const; 1.491 + virtual const Pipeline *pipeline() const; 1.492 + 1.493 +private: 1.494 + bool _do_polling; 1.495 + 1.496 +public: 1.497 + bool do_polling() const { return _do_polling; } 1.498 + 1.499 + // Offset of safepoint from the beginning of the node 1.500 + int safepoint_offset() const; 1.501 + 1.502 +#ifndef PRODUCT 1.503 + virtual const char *Name() const { return "Epilog"; } 1.504 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.505 +#endif 1.506 +}; 1.507 + 1.508 +//------------------------------MachNopNode----------------------------------- 1.509 +// Machine function Nop Node 1.510 +class MachNopNode : public MachIdealNode { 1.511 +private: 1.512 + int _count; 1.513 +public: 1.514 + MachNopNode( ) : _count(1) {} 1.515 + MachNopNode( int count ) : _count(count) {} 1.516 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.517 + virtual uint size(PhaseRegAlloc *ra_) const; 1.518 + 1.519 + virtual const class Type *bottom_type() const { return Type::CONTROL; } 1.520 + 1.521 + virtual int ideal_Opcode() const { return Op_Con; } // bogus; see output.cpp 1.522 + virtual const Pipeline *pipeline() const; 1.523 +#ifndef PRODUCT 1.524 + virtual const char *Name() const { return "Nop"; } 1.525 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.526 + virtual void dump_spec(outputStream *st) const { } // No per-operand info 1.527 +#endif 1.528 +}; 1.529 + 1.530 +//------------------------------MachSpillCopyNode------------------------------ 1.531 +// Machine SpillCopy Node. Copies 1 or 2 words from any location to any 1.532 +// location (stack or register). 1.533 +class MachSpillCopyNode : public MachIdealNode { 1.534 + const RegMask *_in; // RegMask for input 1.535 + const RegMask *_out; // RegMask for output 1.536 + const Type *_type; 1.537 +public: 1.538 + MachSpillCopyNode( Node *n, const RegMask &in, const RegMask &out ) : 1.539 + MachIdealNode(), _in(&in), _out(&out), _type(n->bottom_type()) { 1.540 + init_class_id(Class_MachSpillCopy); 1.541 + init_flags(Flag_is_Copy); 1.542 + add_req(NULL); 1.543 + add_req(n); 1.544 + } 1.545 + virtual uint size_of() const { return sizeof(*this); } 1.546 + void set_out_RegMask(const RegMask &out) { _out = &out; } 1.547 + void set_in_RegMask(const RegMask &in) { _in = ∈ } 1.548 + virtual const RegMask &out_RegMask() const { return *_out; } 1.549 + virtual const RegMask &in_RegMask(uint) const { return *_in; } 1.550 + virtual const class Type *bottom_type() const { return _type; } 1.551 + virtual uint ideal_reg() const { return _type->ideal_reg(); } 1.552 + virtual uint oper_input_base() const { return 1; } 1.553 + uint implementation( CodeBuffer *cbuf, PhaseRegAlloc *ra_, bool do_size, outputStream* st ) const; 1.554 + 1.555 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.556 + virtual uint size(PhaseRegAlloc *ra_) const; 1.557 + 1.558 +#ifndef PRODUCT 1.559 + virtual const char *Name() const { return "MachSpillCopy"; } 1.560 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.561 +#endif 1.562 +}; 1.563 + 1.564 +//------------------------------MachBranchNode-------------------------------- 1.565 +// Abstract machine branch Node 1.566 +class MachBranchNode : public MachIdealNode { 1.567 +public: 1.568 + MachBranchNode() : MachIdealNode() { 1.569 + init_class_id(Class_MachBranch); 1.570 + } 1.571 + virtual void label_set(Label* label, uint block_num) = 0; 1.572 + virtual void save_label(Label** label, uint* block_num) = 0; 1.573 + 1.574 + // Support for short branches 1.575 + virtual MachNode *short_branch_version(Compile* C) { return NULL; } 1.576 + 1.577 + virtual bool pinned() const { return true; }; 1.578 +}; 1.579 + 1.580 +//------------------------------MachNullChkNode-------------------------------- 1.581 +// Machine-dependent null-pointer-check Node. Points a real MachNode that is 1.582 +// also some kind of memory op. Turns the indicated MachNode into a 1.583 +// conditional branch with good latency on the ptr-not-null path and awful 1.584 +// latency on the pointer-is-null path. 1.585 + 1.586 +class MachNullCheckNode : public MachBranchNode { 1.587 +public: 1.588 + const uint _vidx; // Index of memop being tested 1.589 + MachNullCheckNode( Node *ctrl, Node *memop, uint vidx ) : MachBranchNode(), _vidx(vidx) { 1.590 + init_class_id(Class_MachNullCheck); 1.591 + add_req(ctrl); 1.592 + add_req(memop); 1.593 + } 1.594 + virtual uint size_of() const { return sizeof(*this); } 1.595 + 1.596 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; 1.597 + virtual void label_set(Label* label, uint block_num); 1.598 + virtual void save_label(Label** label, uint* block_num); 1.599 + virtual void negate() { } 1.600 + virtual const class Type *bottom_type() const { return TypeTuple::IFBOTH; } 1.601 + virtual uint ideal_reg() const { return NotAMachineReg; } 1.602 + virtual const RegMask &in_RegMask(uint) const; 1.603 + virtual const RegMask &out_RegMask() const { return RegMask::Empty; } 1.604 +#ifndef PRODUCT 1.605 + virtual const char *Name() const { return "NullCheck"; } 1.606 + virtual void format( PhaseRegAlloc *, outputStream *st ) const; 1.607 +#endif 1.608 +}; 1.609 + 1.610 +//------------------------------MachProjNode---------------------------------- 1.611 +// Machine-dependent Ideal projections (how is that for an oxymoron). Really 1.612 +// just MachNodes made by the Ideal world that replicate simple projections 1.613 +// but with machine-dependent input & output register masks. Generally 1.614 +// produced as part of calling conventions. Normally I make MachNodes as part 1.615 +// of the Matcher process, but the Matcher is ill suited to issues involving 1.616 +// frame handling, so frame handling is all done in the Ideal world with 1.617 +// occasional callbacks to the machine model for important info. 1.618 +class MachProjNode : public ProjNode { 1.619 +public: 1.620 + MachProjNode( Node *multi, uint con, const RegMask &out, uint ideal_reg ) : ProjNode(multi,con), _rout(out), _ideal_reg(ideal_reg) { 1.621 + init_class_id(Class_MachProj); 1.622 + } 1.623 + RegMask _rout; 1.624 + const uint _ideal_reg; 1.625 + enum projType { 1.626 + unmatched_proj = 0, // Projs for Control, I/O, memory not matched 1.627 + fat_proj = 999 // Projs killing many regs, defined by _rout 1.628 + }; 1.629 + virtual int Opcode() const; 1.630 + virtual const Type *bottom_type() const; 1.631 + virtual const TypePtr *adr_type() const; 1.632 + virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; } 1.633 + virtual const RegMask &out_RegMask() const { return _rout; } 1.634 + virtual uint ideal_reg() const { return _ideal_reg; } 1.635 + // Need size_of() for virtual ProjNode::clone() 1.636 + virtual uint size_of() const { return sizeof(MachProjNode); } 1.637 +#ifndef PRODUCT 1.638 + virtual void dump_spec(outputStream *st) const; 1.639 +#endif 1.640 +}; 1.641 + 1.642 +//------------------------------MachIfNode------------------------------------- 1.643 +// Machine-specific versions of IfNodes 1.644 +class MachIfNode : public MachBranchNode { 1.645 + virtual uint size_of() const { return sizeof(*this); } // Size is bigger 1.646 +public: 1.647 + float _prob; // Probability branch goes either way 1.648 + float _fcnt; // Frequency counter 1.649 + MachIfNode() : MachBranchNode() { 1.650 + init_class_id(Class_MachIf); 1.651 + } 1.652 + // Negate conditional branches. 1.653 + virtual void negate() = 0; 1.654 +#ifndef PRODUCT 1.655 + virtual void dump_spec(outputStream *st) const; 1.656 +#endif 1.657 +}; 1.658 + 1.659 +//------------------------------MachGotoNode----------------------------------- 1.660 +// Machine-specific versions of GotoNodes 1.661 +class MachGotoNode : public MachBranchNode { 1.662 +public: 1.663 + MachGotoNode() : MachBranchNode() { 1.664 + init_class_id(Class_MachGoto); 1.665 + } 1.666 +}; 1.667 + 1.668 +//------------------------------MachFastLockNode------------------------------------- 1.669 +// Machine-specific versions of FastLockNodes 1.670 +class MachFastLockNode : public MachNode { 1.671 + virtual uint size_of() const { return sizeof(*this); } // Size is bigger 1.672 +public: 1.673 + BiasedLockingCounters* _counters; 1.674 + RTMLockingCounters* _rtm_counters; // RTM lock counters for inflated locks 1.675 + RTMLockingCounters* _stack_rtm_counters; // RTM lock counters for stack locks 1.676 + MachFastLockNode() : MachNode() {} 1.677 +}; 1.678 + 1.679 +//------------------------------MachReturnNode-------------------------------- 1.680 +// Machine-specific versions of subroutine returns 1.681 +class MachReturnNode : public MachNode { 1.682 + virtual uint size_of() const; // Size is bigger 1.683 +public: 1.684 + RegMask *_in_rms; // Input register masks, set during allocation 1.685 + ReallocMark _nesting; // assertion check for reallocations 1.686 + const TypePtr* _adr_type; // memory effects of call or return 1.687 + MachReturnNode() : MachNode() { 1.688 + init_class_id(Class_MachReturn); 1.689 + _adr_type = TypePtr::BOTTOM; // the default: all of memory 1.690 + } 1.691 + 1.692 + void set_adr_type(const TypePtr* atp) { _adr_type = atp; } 1.693 + 1.694 + virtual const RegMask &in_RegMask(uint) const; 1.695 + virtual bool pinned() const { return true; }; 1.696 + virtual const TypePtr *adr_type() const; 1.697 +}; 1.698 + 1.699 +//------------------------------MachSafePointNode----------------------------- 1.700 +// Machine-specific versions of safepoints 1.701 +class MachSafePointNode : public MachReturnNode { 1.702 +public: 1.703 + OopMap* _oop_map; // Array of OopMap info (8-bit char) for GC 1.704 + JVMState* _jvms; // Pointer to list of JVM State Objects 1.705 + uint _jvmadj; // Extra delta to jvms indexes (mach. args) 1.706 + OopMap* oop_map() const { return _oop_map; } 1.707 + void set_oop_map(OopMap* om) { _oop_map = om; } 1.708 + 1.709 + MachSafePointNode() : MachReturnNode(), _oop_map(NULL), _jvms(NULL), _jvmadj(0) { 1.710 + init_class_id(Class_MachSafePoint); 1.711 + } 1.712 + 1.713 + virtual JVMState* jvms() const { return _jvms; } 1.714 + void set_jvms(JVMState* s) { 1.715 + _jvms = s; 1.716 + } 1.717 + virtual const Type *bottom_type() const; 1.718 + 1.719 + virtual const RegMask &in_RegMask(uint) const; 1.720 + 1.721 + // Functionality from old debug nodes 1.722 + Node *returnadr() const { return in(TypeFunc::ReturnAdr); } 1.723 + Node *frameptr () const { return in(TypeFunc::FramePtr); } 1.724 + 1.725 + Node *local(const JVMState* jvms, uint idx) const { 1.726 + assert(verify_jvms(jvms), "jvms must match"); 1.727 + return in(_jvmadj + jvms->locoff() + idx); 1.728 + } 1.729 + Node *stack(const JVMState* jvms, uint idx) const { 1.730 + assert(verify_jvms(jvms), "jvms must match"); 1.731 + return in(_jvmadj + jvms->stkoff() + idx); 1.732 + } 1.733 + Node *monitor_obj(const JVMState* jvms, uint idx) const { 1.734 + assert(verify_jvms(jvms), "jvms must match"); 1.735 + return in(_jvmadj + jvms->monitor_obj_offset(idx)); 1.736 + } 1.737 + Node *monitor_box(const JVMState* jvms, uint idx) const { 1.738 + assert(verify_jvms(jvms), "jvms must match"); 1.739 + return in(_jvmadj + jvms->monitor_box_offset(idx)); 1.740 + } 1.741 + void set_local(const JVMState* jvms, uint idx, Node *c) { 1.742 + assert(verify_jvms(jvms), "jvms must match"); 1.743 + set_req(_jvmadj + jvms->locoff() + idx, c); 1.744 + } 1.745 + void set_stack(const JVMState* jvms, uint idx, Node *c) { 1.746 + assert(verify_jvms(jvms), "jvms must match"); 1.747 + set_req(_jvmadj + jvms->stkoff() + idx, c); 1.748 + } 1.749 + void set_monitor(const JVMState* jvms, uint idx, Node *c) { 1.750 + assert(verify_jvms(jvms), "jvms must match"); 1.751 + set_req(_jvmadj + jvms->monoff() + idx, c); 1.752 + } 1.753 +}; 1.754 + 1.755 +//------------------------------MachCallNode---------------------------------- 1.756 +// Machine-specific versions of subroutine calls 1.757 +class MachCallNode : public MachSafePointNode { 1.758 +protected: 1.759 + virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 1.760 + virtual uint cmp( const Node &n ) const; 1.761 + virtual uint size_of() const = 0; // Size is bigger 1.762 +public: 1.763 + const TypeFunc *_tf; // Function type 1.764 + address _entry_point; // Address of the method being called 1.765 + float _cnt; // Estimate of number of times called 1.766 + uint _argsize; // Size of argument block on stack 1.767 + 1.768 + const TypeFunc* tf() const { return _tf; } 1.769 + const address entry_point() const { return _entry_point; } 1.770 + const float cnt() const { return _cnt; } 1.771 + uint argsize() const { return _argsize; } 1.772 + 1.773 + void set_tf(const TypeFunc* tf) { _tf = tf; } 1.774 + void set_entry_point(address p) { _entry_point = p; } 1.775 + void set_cnt(float c) { _cnt = c; } 1.776 + void set_argsize(int s) { _argsize = s; } 1.777 + 1.778 + MachCallNode() : MachSafePointNode() { 1.779 + init_class_id(Class_MachCall); 1.780 + } 1.781 + 1.782 + virtual const Type *bottom_type() const; 1.783 + virtual bool pinned() const { return false; } 1.784 + virtual const Type *Value( PhaseTransform *phase ) const; 1.785 + virtual const RegMask &in_RegMask(uint) const; 1.786 + virtual int ret_addr_offset() { return 0; } 1.787 + 1.788 + bool returns_long() const { return tf()->return_type() == T_LONG; } 1.789 + bool return_value_is_used() const; 1.790 +#ifndef PRODUCT 1.791 + virtual void dump_spec(outputStream *st) const; 1.792 +#endif 1.793 +}; 1.794 + 1.795 +//------------------------------MachCallJavaNode------------------------------ 1.796 +// "Base" class for machine-specific versions of subroutine calls 1.797 +class MachCallJavaNode : public MachCallNode { 1.798 +protected: 1.799 + virtual uint cmp( const Node &n ) const; 1.800 + virtual uint size_of() const; // Size is bigger 1.801 +public: 1.802 + ciMethod* _method; // Method being direct called 1.803 + int _bci; // Byte Code index of call byte code 1.804 + bool _optimized_virtual; // Tells if node is a static call or an optimized virtual 1.805 + bool _method_handle_invoke; // Tells if the call has to preserve SP 1.806 + MachCallJavaNode() : MachCallNode() { 1.807 + init_class_id(Class_MachCallJava); 1.808 + } 1.809 + 1.810 + virtual const RegMask &in_RegMask(uint) const; 1.811 + 1.812 +#ifndef PRODUCT 1.813 + virtual void dump_spec(outputStream *st) const; 1.814 +#endif 1.815 +}; 1.816 + 1.817 +//------------------------------MachCallStaticJavaNode------------------------ 1.818 +// Machine-specific versions of monomorphic subroutine calls 1.819 +class MachCallStaticJavaNode : public MachCallJavaNode { 1.820 + virtual uint cmp( const Node &n ) const; 1.821 + virtual uint size_of() const; // Size is bigger 1.822 +public: 1.823 + const char *_name; // Runtime wrapper name 1.824 + MachCallStaticJavaNode() : MachCallJavaNode() { 1.825 + init_class_id(Class_MachCallStaticJava); 1.826 + } 1.827 + 1.828 + // If this is an uncommon trap, return the request code, else zero. 1.829 + int uncommon_trap_request() const; 1.830 + 1.831 + virtual int ret_addr_offset(); 1.832 +#ifndef PRODUCT 1.833 + virtual void dump_spec(outputStream *st) const; 1.834 + void dump_trap_args(outputStream *st) const; 1.835 +#endif 1.836 +}; 1.837 + 1.838 +//------------------------------MachCallDynamicJavaNode------------------------ 1.839 +// Machine-specific versions of possibly megamorphic subroutine calls 1.840 +class MachCallDynamicJavaNode : public MachCallJavaNode { 1.841 +public: 1.842 + int _vtable_index; 1.843 + MachCallDynamicJavaNode() : MachCallJavaNode() { 1.844 + init_class_id(Class_MachCallDynamicJava); 1.845 + DEBUG_ONLY(_vtable_index = -99); // throw an assert if uninitialized 1.846 + } 1.847 + virtual int ret_addr_offset(); 1.848 +#ifndef PRODUCT 1.849 + virtual void dump_spec(outputStream *st) const; 1.850 +#endif 1.851 +}; 1.852 + 1.853 +//------------------------------MachCallRuntimeNode---------------------------- 1.854 +// Machine-specific versions of subroutine calls 1.855 +class MachCallRuntimeNode : public MachCallNode { 1.856 + virtual uint cmp( const Node &n ) const; 1.857 + virtual uint size_of() const; // Size is bigger 1.858 +public: 1.859 + const char *_name; // Printable name, if _method is NULL 1.860 + MachCallRuntimeNode() : MachCallNode() { 1.861 + init_class_id(Class_MachCallRuntime); 1.862 + } 1.863 + virtual int ret_addr_offset(); 1.864 +#ifndef PRODUCT 1.865 + virtual void dump_spec(outputStream *st) const; 1.866 +#endif 1.867 +}; 1.868 + 1.869 +class MachCallLeafNode: public MachCallRuntimeNode { 1.870 +public: 1.871 + MachCallLeafNode() : MachCallRuntimeNode() { 1.872 + init_class_id(Class_MachCallLeaf); 1.873 + } 1.874 +}; 1.875 + 1.876 +//------------------------------MachHaltNode----------------------------------- 1.877 +// Machine-specific versions of halt nodes 1.878 +class MachHaltNode : public MachReturnNode { 1.879 +public: 1.880 + virtual JVMState* jvms() const; 1.881 +}; 1.882 + 1.883 + 1.884 +//------------------------------MachTempNode----------------------------------- 1.885 +// Node used by the adlc to construct inputs to represent temporary registers 1.886 +class MachTempNode : public MachNode { 1.887 +private: 1.888 + MachOper *_opnd_array[1]; 1.889 + 1.890 +public: 1.891 + virtual const RegMask &out_RegMask() const { return *_opnds[0]->in_RegMask(0); } 1.892 + virtual uint rule() const { return 9999999; } 1.893 + virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {} 1.894 + 1.895 + MachTempNode(MachOper* oper) { 1.896 + init_class_id(Class_MachTemp); 1.897 + _num_opnds = 1; 1.898 + _opnds = _opnd_array; 1.899 + add_req(NULL); 1.900 + _opnds[0] = oper; 1.901 + } 1.902 + virtual uint size_of() const { return sizeof(MachTempNode); } 1.903 + 1.904 +#ifndef PRODUCT 1.905 + virtual void format(PhaseRegAlloc *, outputStream *st ) const {} 1.906 + virtual const char *Name() const { return "MachTemp";} 1.907 +#endif 1.908 +}; 1.909 + 1.910 + 1.911 + 1.912 +//------------------------------labelOper-------------------------------------- 1.913 +// Machine-independent version of label operand 1.914 +class labelOper : public MachOper { 1.915 +private: 1.916 + virtual uint num_edges() const { return 0; } 1.917 +public: 1.918 + // Supported for fixed size branches 1.919 + Label* _label; // Label for branch(es) 1.920 + 1.921 + uint _block_num; 1.922 + 1.923 + labelOper() : _block_num(0), _label(0) {} 1.924 + 1.925 + labelOper(Label* label, uint block_num) : _label(label), _block_num(block_num) {} 1.926 + 1.927 + labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {} 1.928 + 1.929 + virtual MachOper *clone(Compile* C) const; 1.930 + 1.931 + virtual Label *label() const { assert(_label != NULL, "need Label"); return _label; } 1.932 + 1.933 + virtual uint opcode() const; 1.934 + 1.935 + virtual uint hash() const; 1.936 + virtual uint cmp( const MachOper &oper ) const; 1.937 +#ifndef PRODUCT 1.938 + virtual const char *Name() const { return "Label";} 1.939 + 1.940 + virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const; 1.941 + virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); } 1.942 +#endif 1.943 +}; 1.944 + 1.945 + 1.946 +//------------------------------methodOper-------------------------------------- 1.947 +// Machine-independent version of method operand 1.948 +class methodOper : public MachOper { 1.949 +private: 1.950 + virtual uint num_edges() const { return 0; } 1.951 +public: 1.952 + intptr_t _method; // Address of method 1.953 + methodOper() : _method(0) {} 1.954 + methodOper(intptr_t method) : _method(method) {} 1.955 + 1.956 + virtual MachOper *clone(Compile* C) const; 1.957 + 1.958 + virtual intptr_t method() const { return _method; } 1.959 + 1.960 + virtual uint opcode() const; 1.961 + 1.962 + virtual uint hash() const; 1.963 + virtual uint cmp( const MachOper &oper ) const; 1.964 +#ifndef PRODUCT 1.965 + virtual const char *Name() const { return "Method";} 1.966 + 1.967 + virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const; 1.968 + virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); } 1.969 +#endif 1.970 +}; 1.971 + 1.972 +#endif // SHARE_VM_OPTO_MACHNODE_HPP