callnode.hpp revision 113
7d32c065c7bb56f281651ae3dd2888f32ce4f1d9Bob Halley * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
2f072c2982861ec2e86e97f8a3ed199fe45c1f70Michael Graff * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * This code is free software; you can redistribute it and/or modify it
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * under the terms of the GNU General Public License version 2 only, as
2f072c2982861ec2e86e97f8a3ed199fe45c1f70Michael Graff * published by the Free Software Foundation.
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * This code is distributed in the hope that it will be useful, but WITHOUT
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * version 2 for more details (a copy is included in the LICENSE file that
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * accompanied this code).
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * You should have received a copy of the GNU General Public License version
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * 2 along with this work; if not, write to the Free Software Foundation,
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * CA 95054 USA or visit www.sun.com if you need additional information or
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews * have any questions.
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff// Portions of code courtesy of Clifford Click
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// Optimization - Graph Style
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews//------------------------------StartNode--------------------------------------
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// The method start node
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual uint size_of() const; // Size is bigger
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews StartNode( Node *root, const TypeTuple *domain ) : MultiNode(2), _domain(domain) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson virtual int Opcode() const;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson virtual bool pinned() const { return true; };
0e8cf9a887c70f96ac448b06c069d90b830215ccMark Andrews virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; }
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual const Type *Value( PhaseTransform *phase ) const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_reg, uint length ) const;
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson virtual Node *match( const ProjNode *proj, const Matcher *m );
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual void dump_spec(outputStream *st) const;
722cc17289e2bacad75cf16a7170485853f66274David Lawrence//------------------------------StartOSRNode-----------------------------------
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// The method start node for on stack replacement code
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews StartOSRNode( Node *root, const TypeTuple *domain ) : StartNode(root, domain) {}
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual int Opcode() const;
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews//------------------------------ParmNode---------------------------------------
54c26ab21c61c6d6b1e484bb88dc3ac263845d17Mark Andrews// Incoming parameters
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews static const char * const names[TypeFunc::Parms+1];
fad44a20eede1bbc66716241dede225500c91caaAndreas Gustafsson ParmNode( StartNode *src, uint con ) : ProjNode(src,con) {
5fc7ba3e1ac5d72239e9971e0f469dd5796738f9Andreas Gustafsson virtual int Opcode() const;
fad44a20eede1bbc66716241dede225500c91caaAndreas Gustafsson virtual bool is_CFG() const { return (_con == TypeFunc::Control); }
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual void dump_spec(outputStream *st) const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews//------------------------------ReturnNode-------------------------------------
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// Return from subroutine node
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews ReturnNode( uint edges, Node *cntrl, Node *i_o, Node *memory, Node *retadr, Node *frameptr );
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual int Opcode() const;
d981ca645597116d227a48bf37cc5edc061c854dBob Halley virtual bool is_CFG() const { return true; }
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual bool depends_only_on_test() const { return false; }
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual const Type *Value( PhaseTransform *phase ) const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual uint ideal_reg() const { return NotAMachineReg; }
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual void dump_req() const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews//------------------------------RethrowNode------------------------------------
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// Rethrow of exception at call site. Ends a procedure before rethrowing;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// ends the current basic block like a ReturnNode. Restores registers and
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// unwinds stack. Rethrow happens in the caller's method.
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews RethrowNode( Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *ret_adr, Node *exception );
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual int Opcode() const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual bool is_CFG() const { return true; }
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual bool depends_only_on_test() const { return false; }
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halley virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual const Type *Value( PhaseTransform *phase ) const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual uint ideal_reg() const { return NotAMachineReg; }
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual void dump_req() const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews//------------------------------TailCallNode-----------------------------------
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// Pop stack frame and jump indirect
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff TailCallNode( Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *retadr, Node *target, Node *moop )
d981ca645597116d227a48bf37cc5edc061c854dBob Halley : ReturnNode( TypeFunc::Parms+2, cntrl, i_o, memory, frameptr, retadr ) {
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual int Opcode() const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews//------------------------------TailJumpNode-----------------------------------
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// Pop stack frame and jump indirect
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews TailJumpNode( Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *target, Node *ex_oop)
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff : ReturnNode(TypeFunc::Parms+2, cntrl, i_o, memory, frameptr, Compile::current()->top()) {
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews virtual int Opcode() const;
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews//-------------------------------JVMState-------------------------------------
12a12d8ab469ba71e8593a71c28d91d4b25d5863Mark Andrews// A linked list of JVMState nodes captures the whole interpreter state,
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews// plus GC roots, for all active calls at some call site in this compilation
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halley// unit. (If there is no inlining, then the list has exactly one link.)
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews// This provides a way to map the optimized program back into the interpreter,
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews// or to let the GC mark the stack.
d981ca645597116d227a48bf37cc5edc061c854dBob Halley JVMState* _caller; // List pointer for forming scope chains
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff uint _depth; // One mroe than caller depth, or one.
d981ca645597116d227a48bf37cc5edc061c854dBob Halley uint _locoff; // Offset to locals in input edge mapping
d981ca645597116d227a48bf37cc5edc061c854dBob Halley uint _stkoff; // Offset to stack in input edge mapping
d981ca645597116d227a48bf37cc5edc061c854dBob Halley uint _monoff; // Offset to monitors in input edge mapping
d981ca645597116d227a48bf37cc5edc061c854dBob Halley uint _scloff; // Offset to fields of scalar objs in input edge mapping
d981ca645597116d227a48bf37cc5edc061c854dBob Halley uint _endoff; // Offset to end of input edge mapping
d981ca645597116d227a48bf37cc5edc061c854dBob Halley uint _sp; // Jave Expression Stack Pointer for this state
d981ca645597116d227a48bf37cc5edc061c854dBob Halley SafePointNode* _map; // Map node associated with this scope
d981ca645597116d227a48bf37cc5edc061c854dBob Halley friend class Compile;
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley // Because JVMState objects live over the entire lifetime of the
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley // Compile object, they are allocated into the comp_arena, which
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley // does not get resource marked or reset during the compile process
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley void *operator new( size_t x, Compile* C ) { return C->comp_arena()->Amalloc(x); }
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley void operator delete( void * ) { } // fast deallocation
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley // Create a new JVMState, ready for abstract interpretation.
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley JVMState(int stack_size); // root state; has a null method
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews // Access functions for the JVM
#ifndef PRODUCT
void dump() const {
void pop_monitor ();
virtual int Opcode() const;
virtual bool pinned() const { return true; }
static bool needs_polling_address_input();
#ifndef PRODUCT
#ifdef ASSERT
virtual int Opcode() const;
#ifndef PRODUCT
virtual bool guaranteed_safepoint() { return true; }
#ifndef PRODUCT
virtual void dump_req() const;
bool _optimized_virtual;
virtual int Opcode() const;
#ifndef PRODUCT
int uncommon_trap_request() const;
virtual int Opcode() const;
#ifndef PRODUCT
CallDynamicJavaNode( const TypeFunc *tf , address addr, ciMethod* method, int vtable_index, int bci ) : CallJavaNode(tf,addr,method,bci), _vtable_index(vtable_index) {
int _vtable_index;
virtual int Opcode() const;
#ifndef PRODUCT
virtual int Opcode() const;
#ifndef PRODUCT
virtual int Opcode() const;
virtual bool guaranteed_safepoint() { return false; }
#ifndef PRODUCT
virtual int Opcode() const;
virtual void clone_jvms() {
virtual int Opcode() const;
virtual bool guaranteed_safepoint() { return false; }
// (Note: This function is defined in file graphKit.cpp, near
// GraphKit::new_instance/new_array, whose output it recognizes.)
// (Note: AllocateNode::Ideal_allocation is defined in graphKit.cpp.)
int minimum_header_size() {
// are defined in graphKit.cpp, which sets up the bidirectional relation.)
virtual int Opcode() const;
#ifndef PRODUCT
_eliminate(false)
#ifndef PRODUCT
virtual int Opcode() const = 0;
void set_eliminated();
#ifndef PRODUCT
virtual int Opcode() const;
C->add_macro_node(this);
virtual bool guaranteed_safepoint() { return false; }
virtual void clone_jvms() {
virtual int Opcode() const;
C->add_macro_node(this);
virtual bool guaranteed_safepoint() { return false; }