1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/callnode.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,814 @@ 1.4 +/* 1.5 + * Copyright 1997-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// Portions of code courtesy of Clifford Click 1.29 + 1.30 +// Optimization - Graph Style 1.31 + 1.32 +class Chaitin; 1.33 +class NamedCounter; 1.34 +class MultiNode; 1.35 +class SafePointNode; 1.36 +class CallNode; 1.37 +class CallJavaNode; 1.38 +class CallStaticJavaNode; 1.39 +class CallDynamicJavaNode; 1.40 +class CallRuntimeNode; 1.41 +class CallLeafNode; 1.42 +class CallLeafNoFPNode; 1.43 +class AllocateNode; 1.44 +class AllocateArrayNode; 1.45 +class LockNode; 1.46 +class UnlockNode; 1.47 +class JVMState; 1.48 +class OopMap; 1.49 +class State; 1.50 +class StartNode; 1.51 +class MachCallNode; 1.52 +class FastLockNode; 1.53 + 1.54 +//------------------------------StartNode-------------------------------------- 1.55 +// The method start node 1.56 +class StartNode : public MultiNode { 1.57 + virtual uint cmp( const Node &n ) const; 1.58 + virtual uint size_of() const; // Size is bigger 1.59 +public: 1.60 + const TypeTuple *_domain; 1.61 + StartNode( Node *root, const TypeTuple *domain ) : MultiNode(2), _domain(domain) { 1.62 + init_class_id(Class_Start); 1.63 + init_flags(Flag_is_block_start); 1.64 + init_req(0,this); 1.65 + init_req(1,root); 1.66 + } 1.67 + virtual int Opcode() const; 1.68 + virtual bool pinned() const { return true; }; 1.69 + virtual const Type *bottom_type() const; 1.70 + virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; } 1.71 + virtual const Type *Value( PhaseTransform *phase ) const; 1.72 + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 1.73 + virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_reg, uint length ) const; 1.74 + virtual const RegMask &in_RegMask(uint) const; 1.75 + virtual Node *match( const ProjNode *proj, const Matcher *m ); 1.76 + virtual uint ideal_reg() const { return 0; } 1.77 +#ifndef PRODUCT 1.78 + virtual void dump_spec(outputStream *st) const; 1.79 +#endif 1.80 +}; 1.81 + 1.82 +//------------------------------StartOSRNode----------------------------------- 1.83 +// The method start node for on stack replacement code 1.84 +class StartOSRNode : public StartNode { 1.85 +public: 1.86 + StartOSRNode( Node *root, const TypeTuple *domain ) : StartNode(root, domain) {} 1.87 + virtual int Opcode() const; 1.88 + static const TypeTuple *osr_domain(); 1.89 +}; 1.90 + 1.91 + 1.92 +//------------------------------ParmNode--------------------------------------- 1.93 +// Incoming parameters 1.94 +class ParmNode : public ProjNode { 1.95 + static const char * const names[TypeFunc::Parms+1]; 1.96 +public: 1.97 + ParmNode( StartNode *src, uint con ) : ProjNode(src,con) {} 1.98 + virtual int Opcode() const; 1.99 + virtual bool is_CFG() const { return (_con == TypeFunc::Control); } 1.100 + virtual uint ideal_reg() const; 1.101 +#ifndef PRODUCT 1.102 + virtual void dump_spec(outputStream *st) const; 1.103 +#endif 1.104 +}; 1.105 + 1.106 + 1.107 +//------------------------------ReturnNode------------------------------------- 1.108 +// Return from subroutine node 1.109 +class ReturnNode : public Node { 1.110 +public: 1.111 + ReturnNode( uint edges, Node *cntrl, Node *i_o, Node *memory, Node *retadr, Node *frameptr ); 1.112 + virtual int Opcode() const; 1.113 + virtual bool is_CFG() const { return true; } 1.114 + virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 1.115 + virtual bool depends_only_on_test() const { return false; } 1.116 + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 1.117 + virtual const Type *Value( PhaseTransform *phase ) const; 1.118 + virtual uint ideal_reg() const { return NotAMachineReg; } 1.119 + virtual uint match_edge(uint idx) const; 1.120 +#ifndef PRODUCT 1.121 + virtual void dump_req() const; 1.122 +#endif 1.123 +}; 1.124 + 1.125 + 1.126 +//------------------------------RethrowNode------------------------------------ 1.127 +// Rethrow of exception at call site. Ends a procedure before rethrowing; 1.128 +// ends the current basic block like a ReturnNode. Restores registers and 1.129 +// unwinds stack. Rethrow happens in the caller's method. 1.130 +class RethrowNode : public Node { 1.131 + public: 1.132 + RethrowNode( Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *ret_adr, Node *exception ); 1.133 + virtual int Opcode() const; 1.134 + virtual bool is_CFG() const { return true; } 1.135 + virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash 1.136 + virtual bool depends_only_on_test() const { return false; } 1.137 + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 1.138 + virtual const Type *Value( PhaseTransform *phase ) const; 1.139 + virtual uint match_edge(uint idx) const; 1.140 + virtual uint ideal_reg() const { return NotAMachineReg; } 1.141 +#ifndef PRODUCT 1.142 + virtual void dump_req() const; 1.143 +#endif 1.144 +}; 1.145 + 1.146 + 1.147 +//------------------------------TailCallNode----------------------------------- 1.148 +// Pop stack frame and jump indirect 1.149 +class TailCallNode : public ReturnNode { 1.150 +public: 1.151 + TailCallNode( Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *retadr, Node *target, Node *moop ) 1.152 + : ReturnNode( TypeFunc::Parms+2, cntrl, i_o, memory, frameptr, retadr ) { 1.153 + init_req(TypeFunc::Parms, target); 1.154 + init_req(TypeFunc::Parms+1, moop); 1.155 + } 1.156 + 1.157 + virtual int Opcode() const; 1.158 + virtual uint match_edge(uint idx) const; 1.159 +}; 1.160 + 1.161 +//------------------------------TailJumpNode----------------------------------- 1.162 +// Pop stack frame and jump indirect 1.163 +class TailJumpNode : public ReturnNode { 1.164 +public: 1.165 + TailJumpNode( Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *target, Node *ex_oop) 1.166 + : ReturnNode(TypeFunc::Parms+2, cntrl, i_o, memory, frameptr, Compile::current()->top()) { 1.167 + init_req(TypeFunc::Parms, target); 1.168 + init_req(TypeFunc::Parms+1, ex_oop); 1.169 + } 1.170 + 1.171 + virtual int Opcode() const; 1.172 + virtual uint match_edge(uint idx) const; 1.173 +}; 1.174 + 1.175 +//-------------------------------JVMState------------------------------------- 1.176 +// A linked list of JVMState nodes captures the whole interpreter state, 1.177 +// plus GC roots, for all active calls at some call site in this compilation 1.178 +// unit. (If there is no inlining, then the list has exactly one link.) 1.179 +// This provides a way to map the optimized program back into the interpreter, 1.180 +// or to let the GC mark the stack. 1.181 +class JVMState : public ResourceObj { 1.182 +private: 1.183 + JVMState* _caller; // List pointer for forming scope chains 1.184 + uint _depth; // One mroe than caller depth, or one. 1.185 + uint _locoff; // Offset to locals in input edge mapping 1.186 + uint _stkoff; // Offset to stack in input edge mapping 1.187 + uint _monoff; // Offset to monitors in input edge mapping 1.188 + uint _endoff; // Offset to end of input edge mapping 1.189 + uint _sp; // Jave Expression Stack Pointer for this state 1.190 + int _bci; // Byte Code Index of this JVM point 1.191 + ciMethod* _method; // Method Pointer 1.192 + SafePointNode* _map; // Map node associated with this scope 1.193 +public: 1.194 + friend class Compile; 1.195 + 1.196 + // Because JVMState objects live over the entire lifetime of the 1.197 + // Compile object, they are allocated into the comp_arena, which 1.198 + // does not get resource marked or reset during the compile process 1.199 + void *operator new( size_t x, Compile* C ) { return C->comp_arena()->Amalloc(x); } 1.200 + void operator delete( void * ) { } // fast deallocation 1.201 + 1.202 + // Create a new JVMState, ready for abstract interpretation. 1.203 + JVMState(ciMethod* method, JVMState* caller); 1.204 + JVMState(int stack_size); // root state; has a null method 1.205 + 1.206 + // Access functions for the JVM 1.207 + uint locoff() const { return _locoff; } 1.208 + uint stkoff() const { return _stkoff; } 1.209 + uint argoff() const { return _stkoff + _sp; } 1.210 + uint monoff() const { return _monoff; } 1.211 + uint endoff() const { return _endoff; } 1.212 + uint oopoff() const { return debug_end(); } 1.213 + 1.214 + int loc_size() const { return _stkoff - _locoff; } 1.215 + int stk_size() const { return _monoff - _stkoff; } 1.216 + int mon_size() const { return _endoff - _monoff; } 1.217 + 1.218 + bool is_loc(uint i) const { return i >= _locoff && i < _stkoff; } 1.219 + bool is_stk(uint i) const { return i >= _stkoff && i < _monoff; } 1.220 + bool is_mon(uint i) const { return i >= _monoff && i < _endoff; } 1.221 + 1.222 + uint sp() const { return _sp; } 1.223 + int bci() const { return _bci; } 1.224 + bool has_method() const { return _method != NULL; } 1.225 + ciMethod* method() const { assert(has_method(), ""); return _method; } 1.226 + JVMState* caller() const { return _caller; } 1.227 + SafePointNode* map() const { return _map; } 1.228 + uint depth() const { return _depth; } 1.229 + uint debug_start() const; // returns locoff of root caller 1.230 + uint debug_end() const; // returns endoff of self 1.231 + uint debug_size() const { return loc_size() + sp() + mon_size(); } 1.232 + uint debug_depth() const; // returns sum of debug_size values at all depths 1.233 + 1.234 + // Returns the JVM state at the desired depth (1 == root). 1.235 + JVMState* of_depth(int d) const; 1.236 + 1.237 + // Tells if two JVM states have the same call chain (depth, methods, & bcis). 1.238 + bool same_calls_as(const JVMState* that) const; 1.239 + 1.240 + // Monitors (monitors are stored as (boxNode, objNode) pairs 1.241 + enum { logMonitorEdges = 1 }; 1.242 + int nof_monitors() const { return mon_size() >> logMonitorEdges; } 1.243 + int monitor_depth() const { return nof_monitors() + (caller() ? caller()->monitor_depth() : 0); } 1.244 + int monitor_box_offset(int idx) const { return monoff() + (idx << logMonitorEdges) + 0; } 1.245 + int monitor_obj_offset(int idx) const { return monoff() + (idx << logMonitorEdges) + 1; } 1.246 + bool is_monitor_box(uint off) const { 1.247 + assert(is_mon(off), "should be called only for monitor edge"); 1.248 + return (0 == bitfield(off - monoff(), 0, logMonitorEdges)); 1.249 + } 1.250 + bool is_monitor_use(uint off) const { return (is_mon(off) 1.251 + && is_monitor_box(off)) 1.252 + || (caller() && caller()->is_monitor_use(off)); } 1.253 + 1.254 + // Initialization functions for the JVM 1.255 + void set_locoff(uint off) { _locoff = off; } 1.256 + void set_stkoff(uint off) { _stkoff = off; } 1.257 + void set_monoff(uint off) { _monoff = off; } 1.258 + void set_endoff(uint off) { _endoff = off; } 1.259 + void set_offsets(uint off) { _locoff = _stkoff = _monoff = _endoff = off; } 1.260 + void set_map(SafePointNode *map) { _map = map; } 1.261 + void set_sp(uint sp) { _sp = sp; } 1.262 + void set_bci(int bci) { _bci = bci; } 1.263 + 1.264 + // Miscellaneous utility functions 1.265 + JVMState* clone_deep(Compile* C) const; // recursively clones caller chain 1.266 + JVMState* clone_shallow(Compile* C) const; // retains uncloned caller 1.267 + 1.268 +#ifndef PRODUCT 1.269 + void format(PhaseRegAlloc *regalloc, const Node *n, outputStream* st) const; 1.270 + void dump_spec(outputStream *st) const; 1.271 + void dump_on(outputStream* st) const; 1.272 + void dump() const { 1.273 + dump_on(tty); 1.274 + } 1.275 +#endif 1.276 +}; 1.277 + 1.278 +//------------------------------SafePointNode---------------------------------- 1.279 +// A SafePointNode is a subclass of a MultiNode for convenience (and 1.280 +// potential code sharing) only - conceptually it is independent of 1.281 +// the Node semantics. 1.282 +class SafePointNode : public MultiNode { 1.283 + virtual uint cmp( const Node &n ) const; 1.284 + virtual uint size_of() const; // Size is bigger 1.285 + 1.286 +public: 1.287 + SafePointNode(uint edges, JVMState* jvms, 1.288 + // A plain safepoint advertises no memory effects (NULL): 1.289 + const TypePtr* adr_type = NULL) 1.290 + : MultiNode( edges ), 1.291 + _jvms(jvms), 1.292 + _oop_map(NULL), 1.293 + _adr_type(adr_type) 1.294 + { 1.295 + init_class_id(Class_SafePoint); 1.296 + } 1.297 + 1.298 + OopMap* _oop_map; // Array of OopMap info (8-bit char) for GC 1.299 + JVMState* const _jvms; // Pointer to list of JVM State objects 1.300 + const TypePtr* _adr_type; // What type of memory does this node produce? 1.301 + 1.302 + // Many calls take *all* of memory as input, 1.303 + // but some produce a limited subset of that memory as output. 1.304 + // The adr_type reports the call's behavior as a store, not a load. 1.305 + 1.306 + virtual JVMState* jvms() const { return _jvms; } 1.307 + void set_jvms(JVMState* s) { 1.308 + *(JVMState**)&_jvms = s; // override const attribute in the accessor 1.309 + } 1.310 + OopMap *oop_map() const { return _oop_map; } 1.311 + void set_oop_map(OopMap *om) { _oop_map = om; } 1.312 + 1.313 + // Functionality from old debug nodes which has changed 1.314 + Node *local(JVMState* jvms, uint idx) const { 1.315 + assert(verify_jvms(jvms), "jvms must match"); 1.316 + return in(jvms->locoff() + idx); 1.317 + } 1.318 + Node *stack(JVMState* jvms, uint idx) const { 1.319 + assert(verify_jvms(jvms), "jvms must match"); 1.320 + return in(jvms->stkoff() + idx); 1.321 + } 1.322 + Node *argument(JVMState* jvms, uint idx) const { 1.323 + assert(verify_jvms(jvms), "jvms must match"); 1.324 + return in(jvms->argoff() + idx); 1.325 + } 1.326 + Node *monitor_box(JVMState* jvms, uint idx) const { 1.327 + assert(verify_jvms(jvms), "jvms must match"); 1.328 + return in(jvms->monitor_box_offset(idx)); 1.329 + } 1.330 + Node *monitor_obj(JVMState* jvms, uint idx) const { 1.331 + assert(verify_jvms(jvms), "jvms must match"); 1.332 + return in(jvms->monitor_obj_offset(idx)); 1.333 + } 1.334 + 1.335 + void set_local(JVMState* jvms, uint idx, Node *c); 1.336 + 1.337 + void set_stack(JVMState* jvms, uint idx, Node *c) { 1.338 + assert(verify_jvms(jvms), "jvms must match"); 1.339 + set_req(jvms->stkoff() + idx, c); 1.340 + } 1.341 + void set_argument(JVMState* jvms, uint idx, Node *c) { 1.342 + assert(verify_jvms(jvms), "jvms must match"); 1.343 + set_req(jvms->argoff() + idx, c); 1.344 + } 1.345 + void ensure_stack(JVMState* jvms, uint stk_size) { 1.346 + assert(verify_jvms(jvms), "jvms must match"); 1.347 + int grow_by = (int)stk_size - (int)jvms->stk_size(); 1.348 + if (grow_by > 0) grow_stack(jvms, grow_by); 1.349 + } 1.350 + void grow_stack(JVMState* jvms, uint grow_by); 1.351 + // Handle monitor stack 1.352 + void push_monitor( const FastLockNode *lock ); 1.353 + void pop_monitor (); 1.354 + Node *peek_monitor_box() const; 1.355 + Node *peek_monitor_obj() const; 1.356 + 1.357 + // Access functions for the JVM 1.358 + Node *control () const { return in(TypeFunc::Control ); } 1.359 + Node *i_o () const { return in(TypeFunc::I_O ); } 1.360 + Node *memory () const { return in(TypeFunc::Memory ); } 1.361 + Node *returnadr() const { return in(TypeFunc::ReturnAdr); } 1.362 + Node *frameptr () const { return in(TypeFunc::FramePtr ); } 1.363 + 1.364 + void set_control ( Node *c ) { set_req(TypeFunc::Control,c); } 1.365 + void set_i_o ( Node *c ) { set_req(TypeFunc::I_O ,c); } 1.366 + void set_memory ( Node *c ) { set_req(TypeFunc::Memory ,c); } 1.367 + 1.368 + MergeMemNode* merged_memory() const { 1.369 + return in(TypeFunc::Memory)->as_MergeMem(); 1.370 + } 1.371 + 1.372 + // The parser marks useless maps as dead when it's done with them: 1.373 + bool is_killed() { return in(TypeFunc::Control) == NULL; } 1.374 + 1.375 + // Exception states bubbling out of subgraphs such as inlined calls 1.376 + // are recorded here. (There might be more than one, hence the "next".) 1.377 + // This feature is used only for safepoints which serve as "maps" 1.378 + // for JVM states during parsing, intrinsic expansion, etc. 1.379 + SafePointNode* next_exception() const; 1.380 + void set_next_exception(SafePointNode* n); 1.381 + bool has_exceptions() const { return next_exception() != NULL; } 1.382 + 1.383 + // Standard Node stuff 1.384 + virtual int Opcode() const; 1.385 + virtual bool pinned() const { return true; } 1.386 + virtual const Type *Value( PhaseTransform *phase ) const; 1.387 + virtual const Type *bottom_type() const { return Type::CONTROL; } 1.388 + virtual const TypePtr *adr_type() const { return _adr_type; } 1.389 + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 1.390 + virtual Node *Identity( PhaseTransform *phase ); 1.391 + virtual uint ideal_reg() const { return 0; } 1.392 + virtual const RegMask &in_RegMask(uint) const; 1.393 + virtual const RegMask &out_RegMask() const; 1.394 + virtual uint match_edge(uint idx) const; 1.395 + 1.396 + static bool needs_polling_address_input(); 1.397 + 1.398 +#ifndef PRODUCT 1.399 + virtual void dump_spec(outputStream *st) const; 1.400 +#endif 1.401 +}; 1.402 + 1.403 +//------------------------------CallNode--------------------------------------- 1.404 +// Call nodes now subsume the function of debug nodes at callsites, so they 1.405 +// contain the functionality of a full scope chain of debug nodes. 1.406 +class CallNode : public SafePointNode { 1.407 +public: 1.408 + const TypeFunc *_tf; // Function type 1.409 + address _entry_point; // Address of method being called 1.410 + float _cnt; // Estimate of number of times called 1.411 + PointsToNode::EscapeState _escape_state; 1.412 + 1.413 + CallNode(const TypeFunc* tf, address addr, const TypePtr* adr_type) 1.414 + : SafePointNode(tf->domain()->cnt(), NULL, adr_type), 1.415 + _tf(tf), 1.416 + _entry_point(addr), 1.417 + _cnt(COUNT_UNKNOWN) 1.418 + { 1.419 + init_class_id(Class_Call); 1.420 + init_flags(Flag_is_Call); 1.421 + _escape_state = PointsToNode::UnknownEscape; 1.422 + } 1.423 + 1.424 + const TypeFunc* tf() const { return _tf; } 1.425 + const address entry_point() const { return _entry_point; } 1.426 + const float cnt() const { return _cnt; } 1.427 + 1.428 + void set_tf(const TypeFunc* tf) { _tf = tf; } 1.429 + void set_entry_point(address p) { _entry_point = p; } 1.430 + void set_cnt(float c) { _cnt = c; } 1.431 + 1.432 + virtual const Type *bottom_type() const; 1.433 + virtual const Type *Value( PhaseTransform *phase ) const; 1.434 + virtual Node *Identity( PhaseTransform *phase ) { return this; } 1.435 + virtual uint cmp( const Node &n ) const; 1.436 + virtual uint size_of() const = 0; 1.437 + virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const; 1.438 + virtual Node *match( const ProjNode *proj, const Matcher *m ); 1.439 + virtual uint ideal_reg() const { return NotAMachineReg; } 1.440 + // Are we guaranteed that this node is a safepoint? Not true for leaf calls and 1.441 + // for some macro nodes whose expansion does not have a safepoint on the fast path. 1.442 + virtual bool guaranteed_safepoint() { return true; } 1.443 + // For macro nodes, the JVMState gets modified during expansion, so when cloning 1.444 + // the node the JVMState must be cloned. 1.445 + virtual void clone_jvms() { } // default is not to clone 1.446 + 1.447 + virtual uint match_edge(uint idx) const; 1.448 + 1.449 +#ifndef PRODUCT 1.450 + virtual void dump_req() const; 1.451 + virtual void dump_spec(outputStream *st) const; 1.452 +#endif 1.453 +}; 1.454 + 1.455 +//------------------------------CallJavaNode----------------------------------- 1.456 +// Make a static or dynamic subroutine call node using Java calling 1.457 +// convention. (The "Java" calling convention is the compiler's calling 1.458 +// convention, as opposed to the interpreter's or that of native C.) 1.459 +class CallJavaNode : public CallNode { 1.460 +protected: 1.461 + virtual uint cmp( const Node &n ) const; 1.462 + virtual uint size_of() const; // Size is bigger 1.463 + 1.464 + bool _optimized_virtual; 1.465 + ciMethod* _method; // Method being direct called 1.466 +public: 1.467 + const int _bci; // Byte Code Index of call byte code 1.468 + CallJavaNode(const TypeFunc* tf , address addr, ciMethod* method, int bci) 1.469 + : CallNode(tf, addr, TypePtr::BOTTOM), 1.470 + _method(method), _bci(bci), _optimized_virtual(false) 1.471 + { 1.472 + init_class_id(Class_CallJava); 1.473 + } 1.474 + 1.475 + virtual int Opcode() const; 1.476 + ciMethod* method() const { return _method; } 1.477 + void set_method(ciMethod *m) { _method = m; } 1.478 + void set_optimized_virtual(bool f) { _optimized_virtual = f; } 1.479 + bool is_optimized_virtual() const { return _optimized_virtual; } 1.480 + 1.481 +#ifndef PRODUCT 1.482 + virtual void dump_spec(outputStream *st) const; 1.483 +#endif 1.484 +}; 1.485 + 1.486 +//------------------------------CallStaticJavaNode----------------------------- 1.487 +// Make a direct subroutine call using Java calling convention (for static 1.488 +// calls and optimized virtual calls, plus calls to wrappers for run-time 1.489 +// routines); generates static stub. 1.490 +class CallStaticJavaNode : public CallJavaNode { 1.491 + virtual uint cmp( const Node &n ) const; 1.492 + virtual uint size_of() const; // Size is bigger 1.493 +public: 1.494 + CallStaticJavaNode(const TypeFunc* tf, address addr, ciMethod* method, int bci) 1.495 + : CallJavaNode(tf, addr, method, bci), _name(NULL) { 1.496 + init_class_id(Class_CallStaticJava); 1.497 + } 1.498 + CallStaticJavaNode(const TypeFunc* tf, address addr, const char* name, int bci, 1.499 + const TypePtr* adr_type) 1.500 + : CallJavaNode(tf, addr, NULL, bci), _name(name) { 1.501 + init_class_id(Class_CallStaticJava); 1.502 + // This node calls a runtime stub, which often has narrow memory effects. 1.503 + _adr_type = adr_type; 1.504 + } 1.505 + const char *_name; // Runtime wrapper name 1.506 + 1.507 + // If this is an uncommon trap, return the request code, else zero. 1.508 + int uncommon_trap_request() const; 1.509 + static int extract_uncommon_trap_request(const Node* call); 1.510 + 1.511 + virtual int Opcode() const; 1.512 +#ifndef PRODUCT 1.513 + virtual void dump_spec(outputStream *st) const; 1.514 +#endif 1.515 +}; 1.516 + 1.517 +//------------------------------CallDynamicJavaNode---------------------------- 1.518 +// Make a dispatched call using Java calling convention. 1.519 +class CallDynamicJavaNode : public CallJavaNode { 1.520 + virtual uint cmp( const Node &n ) const; 1.521 + virtual uint size_of() const; // Size is bigger 1.522 +public: 1.523 + CallDynamicJavaNode( const TypeFunc *tf , address addr, ciMethod* method, int vtable_index, int bci ) : CallJavaNode(tf,addr,method,bci), _vtable_index(vtable_index) { 1.524 + init_class_id(Class_CallDynamicJava); 1.525 + } 1.526 + 1.527 + int _vtable_index; 1.528 + virtual int Opcode() const; 1.529 +#ifndef PRODUCT 1.530 + virtual void dump_spec(outputStream *st) const; 1.531 +#endif 1.532 +}; 1.533 + 1.534 +//------------------------------CallRuntimeNode-------------------------------- 1.535 +// Make a direct subroutine call node into compiled C++ code. 1.536 +class CallRuntimeNode : public CallNode { 1.537 + virtual uint cmp( const Node &n ) const; 1.538 + virtual uint size_of() const; // Size is bigger 1.539 +public: 1.540 + CallRuntimeNode(const TypeFunc* tf, address addr, const char* name, 1.541 + const TypePtr* adr_type) 1.542 + : CallNode(tf, addr, adr_type), 1.543 + _name(name) 1.544 + { 1.545 + init_class_id(Class_CallRuntime); 1.546 + } 1.547 + 1.548 + const char *_name; // Printable name, if _method is NULL 1.549 + virtual int Opcode() const; 1.550 + virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const; 1.551 + 1.552 +#ifndef PRODUCT 1.553 + virtual void dump_spec(outputStream *st) const; 1.554 +#endif 1.555 +}; 1.556 + 1.557 +//------------------------------CallLeafNode----------------------------------- 1.558 +// Make a direct subroutine call node into compiled C++ code, without 1.559 +// safepoints 1.560 +class CallLeafNode : public CallRuntimeNode { 1.561 +public: 1.562 + CallLeafNode(const TypeFunc* tf, address addr, const char* name, 1.563 + const TypePtr* adr_type) 1.564 + : CallRuntimeNode(tf, addr, name, adr_type) 1.565 + { 1.566 + init_class_id(Class_CallLeaf); 1.567 + } 1.568 + virtual int Opcode() const; 1.569 + virtual bool guaranteed_safepoint() { return false; } 1.570 +#ifndef PRODUCT 1.571 + virtual void dump_spec(outputStream *st) const; 1.572 +#endif 1.573 +}; 1.574 + 1.575 +//------------------------------CallLeafNoFPNode------------------------------- 1.576 +// CallLeafNode, not using floating point or using it in the same manner as 1.577 +// the generated code 1.578 +class CallLeafNoFPNode : public CallLeafNode { 1.579 +public: 1.580 + CallLeafNoFPNode(const TypeFunc* tf, address addr, const char* name, 1.581 + const TypePtr* adr_type) 1.582 + : CallLeafNode(tf, addr, name, adr_type) 1.583 + { 1.584 + } 1.585 + virtual int Opcode() const; 1.586 +}; 1.587 + 1.588 + 1.589 +//------------------------------Allocate--------------------------------------- 1.590 +// High-level memory allocation 1.591 +// 1.592 +// AllocateNode and AllocateArrayNode are subclasses of CallNode because they will 1.593 +// get expanded into a code sequence containing a call. Unlike other CallNodes, 1.594 +// they have 2 memory projections and 2 i_o projections (which are distinguished by 1.595 +// the _is_io_use flag in the projection.) This is needed when expanding the node in 1.596 +// order to differentiate the uses of the projection on the normal control path from 1.597 +// those on the exception return path. 1.598 +// 1.599 +class AllocateNode : public CallNode { 1.600 +public: 1.601 + enum { 1.602 + // Output: 1.603 + RawAddress = TypeFunc::Parms, // the newly-allocated raw address 1.604 + // Inputs: 1.605 + AllocSize = TypeFunc::Parms, // size (in bytes) of the new object 1.606 + KlassNode, // type (maybe dynamic) of the obj. 1.607 + InitialTest, // slow-path test (may be constant) 1.608 + ALength, // array length (or TOP if none) 1.609 + ParmLimit 1.610 + }; 1.611 + 1.612 + static const TypeFunc* alloc_type() { 1.613 + const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms); 1.614 + fields[AllocSize] = TypeInt::POS; 1.615 + fields[KlassNode] = TypeInstPtr::NOTNULL; 1.616 + fields[InitialTest] = TypeInt::BOOL; 1.617 + fields[ALength] = TypeInt::INT; // length (can be a bad length) 1.618 + 1.619 + const TypeTuple *domain = TypeTuple::make(ParmLimit, fields); 1.620 + 1.621 + // create result type (range) 1.622 + fields = TypeTuple::fields(1); 1.623 + fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop 1.624 + 1.625 + const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 1.626 + 1.627 + return TypeFunc::make(domain, range); 1.628 + } 1.629 + 1.630 + virtual uint size_of() const; // Size is bigger 1.631 + AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio, 1.632 + Node *size, Node *klass_node, Node *initial_test); 1.633 + // Expansion modifies the JVMState, so we need to clone it 1.634 + virtual void clone_jvms() { 1.635 + set_jvms(jvms()->clone_deep(Compile::current())); 1.636 + } 1.637 + virtual int Opcode() const; 1.638 + virtual uint ideal_reg() const { return Op_RegP; } 1.639 + virtual bool guaranteed_safepoint() { return false; } 1.640 + 1.641 + // Pattern-match a possible usage of AllocateNode. 1.642 + // Return null if no allocation is recognized. 1.643 + // The operand is the pointer produced by the (possible) allocation. 1.644 + // It must be a projection of the Allocate or its subsequent CastPP. 1.645 + // (Note: This function is defined in file graphKit.cpp, near 1.646 + // GraphKit::new_instance/new_array, whose output it recognizes.) 1.647 + // The 'ptr' may not have an offset unless the 'offset' argument is given. 1.648 + static AllocateNode* Ideal_allocation(Node* ptr, PhaseTransform* phase); 1.649 + 1.650 + // Fancy version which uses AddPNode::Ideal_base_and_offset to strip 1.651 + // an offset, which is reported back to the caller. 1.652 + // (Note: AllocateNode::Ideal_allocation is defined in graphKit.cpp.) 1.653 + static AllocateNode* Ideal_allocation(Node* ptr, PhaseTransform* phase, 1.654 + intptr_t& offset); 1.655 + 1.656 + // Dig the klass operand out of a (possible) allocation site. 1.657 + static Node* Ideal_klass(Node* ptr, PhaseTransform* phase) { 1.658 + AllocateNode* allo = Ideal_allocation(ptr, phase); 1.659 + return (allo == NULL) ? NULL : allo->in(KlassNode); 1.660 + } 1.661 + 1.662 + // Conservatively small estimate of offset of first non-header byte. 1.663 + int minimum_header_size() { 1.664 + return is_AllocateArray() ? sizeof(arrayOopDesc) : sizeof(oopDesc); 1.665 + } 1.666 + 1.667 + // Return the corresponding initialization barrier (or null if none). 1.668 + // Walks out edges to find it... 1.669 + // (Note: Both InitializeNode::allocation and AllocateNode::initialization 1.670 + // are defined in graphKit.cpp, which sets up the bidirectional relation.) 1.671 + InitializeNode* initialization(); 1.672 + 1.673 + // Convenience for initialization->maybe_set_complete(phase) 1.674 + bool maybe_set_complete(PhaseGVN* phase); 1.675 +}; 1.676 + 1.677 +//------------------------------AllocateArray--------------------------------- 1.678 +// 1.679 +// High-level array allocation 1.680 +// 1.681 +class AllocateArrayNode : public AllocateNode { 1.682 +public: 1.683 + AllocateArrayNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio, 1.684 + Node* size, Node* klass_node, Node* initial_test, 1.685 + Node* count_val 1.686 + ) 1.687 + : AllocateNode(C, atype, ctrl, mem, abio, size, klass_node, 1.688 + initial_test) 1.689 + { 1.690 + init_class_id(Class_AllocateArray); 1.691 + set_req(AllocateNode::ALength, count_val); 1.692 + } 1.693 + virtual int Opcode() const; 1.694 + virtual uint size_of() const; // Size is bigger 1.695 + 1.696 + // Pattern-match a possible usage of AllocateArrayNode. 1.697 + // Return null if no allocation is recognized. 1.698 + static AllocateArrayNode* Ideal_array_allocation(Node* ptr, PhaseTransform* phase) { 1.699 + AllocateNode* allo = Ideal_allocation(ptr, phase); 1.700 + return (allo == NULL || !allo->is_AllocateArray()) 1.701 + ? NULL : allo->as_AllocateArray(); 1.702 + } 1.703 + 1.704 + // Dig the length operand out of a (possible) array allocation site. 1.705 + static Node* Ideal_length(Node* ptr, PhaseTransform* phase) { 1.706 + AllocateArrayNode* allo = Ideal_array_allocation(ptr, phase); 1.707 + return (allo == NULL) ? NULL : allo->in(AllocateNode::ALength); 1.708 + } 1.709 +}; 1.710 + 1.711 +//------------------------------AbstractLockNode----------------------------------- 1.712 +class AbstractLockNode: public CallNode { 1.713 +private: 1.714 + bool _eliminate; // indicates this lock can be safely eliminated 1.715 +#ifndef PRODUCT 1.716 + NamedCounter* _counter; 1.717 +#endif 1.718 + 1.719 +protected: 1.720 + // helper functions for lock elimination 1.721 + // 1.722 + 1.723 + bool find_matching_unlock(const Node* ctrl, LockNode* lock, 1.724 + GrowableArray<AbstractLockNode*> &lock_ops); 1.725 + bool find_lock_and_unlock_through_if(Node* node, LockNode* lock, 1.726 + GrowableArray<AbstractLockNode*> &lock_ops); 1.727 + bool find_unlocks_for_region(const RegionNode* region, LockNode* lock, 1.728 + GrowableArray<AbstractLockNode*> &lock_ops); 1.729 + LockNode *find_matching_lock(UnlockNode* unlock); 1.730 + 1.731 + 1.732 +public: 1.733 + AbstractLockNode(const TypeFunc *tf) 1.734 + : CallNode(tf, NULL, TypeRawPtr::BOTTOM), 1.735 + _eliminate(false) 1.736 + { 1.737 +#ifndef PRODUCT 1.738 + _counter = NULL; 1.739 +#endif 1.740 + } 1.741 + virtual int Opcode() const = 0; 1.742 + Node * obj_node() const {return in(TypeFunc::Parms + 0); } 1.743 + Node * box_node() const {return in(TypeFunc::Parms + 1); } 1.744 + Node * fastlock_node() const {return in(TypeFunc::Parms + 2); } 1.745 + const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;} 1.746 + 1.747 + virtual uint size_of() const { return sizeof(*this); } 1.748 + 1.749 + bool is_eliminated() {return _eliminate; } 1.750 + // mark node as eliminated and update the counter if there is one 1.751 + void set_eliminated(); 1.752 + 1.753 +#ifndef PRODUCT 1.754 + void create_lock_counter(JVMState* s); 1.755 + NamedCounter* counter() const { return _counter; } 1.756 +#endif 1.757 +}; 1.758 + 1.759 +//------------------------------Lock--------------------------------------- 1.760 +// High-level lock operation 1.761 +// 1.762 +// This is a subclass of CallNode because it is a macro node which gets expanded 1.763 +// into a code sequence containing a call. This node takes 3 "parameters": 1.764 +// 0 - object to lock 1.765 +// 1 - a BoxLockNode 1.766 +// 2 - a FastLockNode 1.767 +// 1.768 +class LockNode : public AbstractLockNode { 1.769 +public: 1.770 + 1.771 + static const TypeFunc *lock_type() { 1.772 + // create input type (domain) 1.773 + const Type **fields = TypeTuple::fields(3); 1.774 + fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 1.775 + fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock 1.776 + fields[TypeFunc::Parms+2] = TypeInt::BOOL; // FastLock 1.777 + const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3,fields); 1.778 + 1.779 + // create result type (range) 1.780 + fields = TypeTuple::fields(0); 1.781 + 1.782 + const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 1.783 + 1.784 + return TypeFunc::make(domain,range); 1.785 + } 1.786 + 1.787 + virtual int Opcode() const; 1.788 + virtual uint size_of() const; // Size is bigger 1.789 + LockNode(Compile* C, const TypeFunc *tf) : AbstractLockNode( tf ) { 1.790 + init_class_id(Class_Lock); 1.791 + init_flags(Flag_is_macro); 1.792 + C->add_macro_node(this); 1.793 + } 1.794 + virtual bool guaranteed_safepoint() { return false; } 1.795 + 1.796 + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 1.797 + // Expansion modifies the JVMState, so we need to clone it 1.798 + virtual void clone_jvms() { 1.799 + set_jvms(jvms()->clone_deep(Compile::current())); 1.800 + } 1.801 +}; 1.802 + 1.803 +//------------------------------Unlock--------------------------------------- 1.804 +// High-level unlock operation 1.805 +class UnlockNode : public AbstractLockNode { 1.806 +public: 1.807 + virtual int Opcode() const; 1.808 + virtual uint size_of() const; // Size is bigger 1.809 + UnlockNode(Compile* C, const TypeFunc *tf) : AbstractLockNode( tf ) { 1.810 + init_class_id(Class_Unlock); 1.811 + init_flags(Flag_is_macro); 1.812 + C->add_macro_node(this); 1.813 + } 1.814 + virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 1.815 + // unlock is never a safepoint 1.816 + virtual bool guaranteed_safepoint() { return false; } 1.817 +};