/* * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
class NamedCounter; class MultiNode; class SafePointNode; class CallNode; class CallJavaNode; class CallStaticJavaNode; class CallDynamicJavaNode; class CallRuntimeNode; class CallLeafNode; class CallLeafNoFPNode; class CallLeafVectorNode; class AllocateNode; class AllocateArrayNode; class AbstractLockNode; class LockNode; class UnlockNode; class FastLockNode;
//-------------------------------JVMState------------------------------------- // A linked list of JVMState nodes captures the whole interpreter state, // plus GC roots, for all active calls at some call site in this compilation // unit. (If there is no inlining, then the list has exactly one link.) // This provides a way to map the optimized program back into the interpreter, // or to let the GC mark the stack. class JVMState : public ResourceObj { friendclass VMStructs; public: typedefenum {
Reexecute_Undefined = -1, // not defined -- will be translated into false later
Reexecute_False = 0, // false -- do not reexecute
Reexecute_True = 1 // true -- reexecute the bytecode
} ReexecuteState; //Reexecute State
private:
JVMState* _caller; // List pointer for forming scope chains
uint _depth; // One more than caller depth, or one.
uint _locoff; // Offset to locals in input edge mapping
uint _stkoff; // Offset to stack in input edge mapping
uint _monoff; // Offset to monitors in input edge mapping
uint _scloff; // Offset to fields of scalar objs in input edge mapping
uint _endoff; // Offset to end of input edge mapping
uint _sp; // Java Expression Stack Pointer for this state int _bci; // Byte Code Index of this JVM point
ReexecuteState _reexecute; // Whether this bytecode need to be re-executed
ciMethod* _method; // Method Pointer
SafePointNode* _map; // Map node associated with this scope public: friendclass Compile; friendclass PreserveReexecuteState;
// Because JVMState objects live over the entire lifetime of the // Compile object, they are allocated into the comp_arena, which // does not get resource marked or reset during the compile process void *operatornew( size_t x, Compile* C ) throw() { return C->comp_arena()->Amalloc(x); } voidoperatordelete( void * ) { } // fast deallocation
// Create a new JVMState, ready for abstract interpretation.
JVMState(ciMethod* method, JVMState* caller);
JVMState(int stack_size); // root state; has a null method
//------------------------------SafePointNode---------------------------------- // A SafePointNode is a subclass of a MultiNode for convenience (and // potential code sharing) only - conceptually it is independent of // the Node semantics. class SafePointNode : public MultiNode { friend JVMState; friendclass GraphKit; friendclass VMStructs;
protected:
JVMState* const _jvms; // Pointer to list of JVM State objects // Many calls take *all* of memory as input, // but some produce a limited subset of that memory as output. // The adr_type reports the call's behavior as a store, not a load. const TypePtr* _adr_type; // What type of memory does this node produce?
ReplacedNodes _replaced_nodes; // During parsing: list of pair of nodes from calls to GraphKit::replace_in_map() bool _has_ea_local_in_scope; // NoEscape or ArgEscape objects in JVM States
void set_jvms(JVMState* s) {
assert(s != nullptr, "assign NULL value to _jvms");
*(JVMState**)&_jvms = s; // override const attribute in the accessor
} public:
SafePointNode(uint edges, JVMState* jvms, // A plain safepoint advertises no memory effects (NULL): const TypePtr* adr_type = NULL)
: MultiNode( edges ),
_jvms(jvms),
_adr_type(adr_type),
_has_ea_local_in_scope(false)
{
init_class_id(Class_SafePoint);
}
JVMState* jvms() const { return _jvms; } virtualbool needs_deep_clone_jvms(Compile* C) { returnfalse; } void clone_jvms(Compile* C) { if (jvms() != NULL) { if (needs_deep_clone_jvms(C)) {
set_jvms(jvms()->clone_deep(C));
jvms()->set_map_deep(this);
} else {
jvms()->clone_shallow(C)->bind_map(this);
}
}
}
private: void verify_input(JVMState* jvms, uint idx) const {
assert(verify_jvms(jvms), "jvms must match");
Node* n = in(idx);
assert((!n->bottom_type()->isa_long() && !n->bottom_type()->isa_double()) ||
in(idx + 1)->is_top(), "2nd half of long/double");
}
// The parser marks useless maps as dead when it's done with them: bool is_killed() { return in(TypeFunc::Control) == NULL; }
// Exception states bubbling out of subgraphs such as inlined calls // are recorded here. (There might be more than one, hence the "next".) // This feature is used only for safepoints which serve as "maps" // for JVM states during parsing, intrinsic expansion, etc.
SafePointNode* next_exception() const; void set_next_exception(SafePointNode* n); bool has_exceptions() const { return next_exception() != NULL; }
// Helper methods to operate on replaced nodes
ReplacedNodes replaced_nodes() const { return _replaced_nodes;
}
//------------------------------SafePointScalarObjectNode---------------------- // A SafePointScalarObjectNode represents the state of a scalarized object // at a safepoint.
class SafePointScalarObjectNode: public TypeNode {
uint _first_index; // First input edge relative index of a SafePoint node where // states of the scalarized object fields are collected. // It is relative to the last (youngest) jvms->_scloff.
uint _n_fields; // Number of non-static fields of the scalarized object.
DEBUG_ONLY(Node* _alloc;)
// Assumes that "this" is an argument to a safepoint node "s", and that // "new_call" is being created to correspond to "s". But the difference // between the start index of the jvmstates of "new_call" and "s" is // "jvms_adj". Produce and return a SafePointScalarObjectNode that // corresponds appropriately to "this" in "new_call". Assumes that // "sosn_map" is a map, specific to the translation of "s" to "new_call", // mapping old SafePointScalarObjectNodes to new, to avoid multiple copies.
SafePointScalarObjectNode* clone(Dict* sosn_map, bool& new_node) const;
// Simple container for the outgoing projections of a call. Useful // for serious surgery on calls. class CallProjections : public StackObj { public:
Node* fallthrough_proj;
Node* fallthrough_catchproj;
Node* fallthrough_memproj;
Node* fallthrough_ioproj;
Node* catchall_catchproj;
Node* catchall_memproj;
Node* catchall_ioproj;
Node* resproj;
Node* exobj;
};
class CallGenerator;
//------------------------------CallNode--------------------------------------- // Call nodes now subsume the function of debug nodes at callsites, so they // contain the functionality of a full scope chain of debug nodes. class CallNode : public SafePointNode { friendclass VMStructs;
public: const TypeFunc* _tf; // Function type
address _entry_point; // Address of method being called float _cnt; // Estimate of number of times called
CallGenerator* _generator; // corresponding CallGenerator for some late inline calls constchar* _name; // Printable name, if _method is NULL
virtualconst Type* bottom_type() const; virtualconst Type* Value(PhaseGVN* phase) const; virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); virtual Node* Identity(PhaseGVN* phase) { returnthis; } virtualbool cmp(const Node &n) const; virtual uint size_of() const = 0; virtualvoid calling_convention(BasicType* sig_bt, VMRegPair* parm_regs, uint argcnt) const; virtual Node* match(const ProjNode* proj, const Matcher* m); virtual uint ideal_reg() const { return NotAMachineReg; } // Are we guaranteed that this node is a safepoint? Not true for leaf calls and // for some macro nodes whose expansion does not have a safepoint on the fast path. virtualbool guaranteed_safepoint() { returntrue; } // For macro nodes, the JVMState gets modified during expansion. If calls // use MachConstantBase, it gets modified during matching. So when cloning // the node the JVMState must be deep cloned. Default is to shallow clone. virtualbool needs_deep_clone_jvms(Compile* C) { return C->needs_deep_clone_jvms(); }
// Returns true if the call may modify n virtualbool may_modify(const TypeOopPtr* t_oop, PhaseTransform* phase); // Does this node have a use of n other than in debug information? bool has_non_debug_use(Node* n); // Returns the unique CheckCastPP of a call // or result projection is there are several CheckCastPP // or returns NULL if there is no one.
Node* result_cast(); // Does this node returns pointer? bool returns_pointer() const { const TypeTuple* r = tf()->range(); return (r->cnt() > TypeFunc::Parms &&
r->field_at(TypeFunc::Parms)->isa_ptr());
}
// Collect all the interesting edges from a call for use in // replacing the call by something else. Used by macro expansion // and the late inlining support. void extract_projections(CallProjections* projs, bool separate_io_proj, bool do_asserts = true);
#ifndef PRODUCT virtualvoid dump_req(outputStream* st = tty, DumpConfig* dc = nullptr) const; virtualvoid dump_spec(outputStream* st) const; #endif
};
//------------------------------CallJavaNode----------------------------------- // Make a static or dynamic subroutine call node using Java calling // convention. (The "Java" calling convention is the compiler's calling // convention, as opposed to the interpreter's or that of native C.) class CallJavaNode : public CallNode { friendclass VMStructs; protected: virtualbool cmp( const Node &n ) const; virtual uint size_of() const; // Size is bigger
bool _optimized_virtual; bool _method_handle_invoke; bool _override_symbolic_info; // Override symbolic call site info from bytecode
ciMethod* _method; // Method being direct called bool _arg_escape; // ArgEscape in parameter list public:
CallJavaNode(const TypeFunc* tf , address addr, ciMethod* method)
: CallNode(tf, addr, TypePtr::BOTTOM),
_optimized_virtual(false),
_method_handle_invoke(false),
_override_symbolic_info(false),
_method(method),
_arg_escape(false)
{
init_class_id(Class_CallJava);
}
//------------------------------CallStaticJavaNode----------------------------- // Make a direct subroutine call using Java calling convention (for static // calls and optimized virtual calls, plus calls to wrappers for run-time // routines); generates static stub. class CallStaticJavaNode : public CallJavaNode { virtualbool cmp( const Node &n ) const; virtual uint size_of() const; // Size is bigger public:
CallStaticJavaNode(Compile* C, const TypeFunc* tf, address addr, ciMethod* method)
: CallJavaNode(tf, addr, method) {
init_class_id(Class_CallStaticJava); if (C->eliminate_boxing() && (method != NULL) && method->is_boxing_method()) {
init_flags(Flag_is_macro);
C->add_macro_node(this);
}
}
CallStaticJavaNode(const TypeFunc* tf, address addr, constchar* name, const TypePtr* adr_type)
: CallJavaNode(tf, addr, NULL) {
init_class_id(Class_CallStaticJava); // This node calls a runtime stub, which often has narrow memory effects.
_adr_type = adr_type;
_name = name;
}
// If this is an uncommon trap, return the request code, else zero. int uncommon_trap_request() const; staticint extract_uncommon_trap_request(const Node* call);
bool is_boxing_method() const { return is_macro() && (method() != NULL) && method()->is_boxing_method();
} // Late inlining modifies the JVMState, so we need to deep clone it // when the call node is cloned (because it is macro node). virtualbool needs_deep_clone_jvms(Compile* C) { return is_boxing_method() || CallNode::needs_deep_clone_jvms(C);
}
//------------------------------CallDynamicJavaNode---------------------------- // Make a dispatched call using Java calling convention. class CallDynamicJavaNode : public CallJavaNode { virtualbool cmp( const Node &n ) const; virtual uint size_of() const; // Size is bigger public:
CallDynamicJavaNode(const TypeFunc* tf , address addr, ciMethod* method, int vtable_index)
: CallJavaNode(tf,addr,method), _vtable_index(vtable_index) {
init_class_id(Class_CallDynamicJava);
}
// Late inlining modifies the JVMState, so we need to deep clone it // when the call node is cloned. virtualbool needs_deep_clone_jvms(Compile* C) { return IncrementalInlineVirtual || CallNode::needs_deep_clone_jvms(C);
}
//------------------------------CallLeafNode----------------------------------- // Make a direct subroutine call node into compiled C++ code, without // safepoints class CallLeafNode : public CallRuntimeNode { public:
CallLeafNode(const TypeFunc* tf, address addr, constchar* name, const TypePtr* adr_type)
: CallRuntimeNode(tf, addr, name, adr_type)
{
init_class_id(Class_CallLeaf);
} virtualint Opcode() const; virtualbool guaranteed_safepoint() { returnfalse; } #ifndef PRODUCT virtualvoid dump_spec(outputStream *st) const; #endif
};
//------------------------------CallLeafNoFPNode------------------------------- // CallLeafNode, not using floating point or using it in the same manner as // the generated code class CallLeafNoFPNode : public CallLeafNode { public:
CallLeafNoFPNode(const TypeFunc* tf, address addr, constchar* name, const TypePtr* adr_type)
: CallLeafNode(tf, addr, name, adr_type)
{
init_class_id(Class_CallLeafNoFP);
} virtualint Opcode() const;
};
//------------------------------Allocate--------------------------------------- // High-level memory allocation // // AllocateNode and AllocateArrayNode are subclasses of CallNode because they will // get expanded into a code sequence containing a call. Unlike other CallNodes, // they have 2 memory projections and 2 i_o projections (which are distinguished by // the _is_io_use flag in the projection.) This is needed when expanding the node in // order to differentiate the uses of the projection on the normal control path from // those on the exception return path. // class AllocateNode : public CallNode { public: enum { // Output:
RawAddress = TypeFunc::Parms, // the newly-allocated raw address // Inputs:
AllocSize = TypeFunc::Parms, // size (in bytes) of the new object
KlassNode, // type (maybe dynamic) of the obj.
InitialTest, // slow-path test (may be constant)
ALength, // array length (or TOP if none)
ValidLengthTest,
ParmLimit
};
// Result of Escape Analysis bool _is_scalar_replaceable; bool _is_non_escaping; // True when MemBar for new is redundant with MemBar at initialzer exit bool _is_allocation_MemBar_redundant;
virtual uint size_of() const; // Size is bigger
AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio,
Node *size, Node *klass_node, Node *initial_test); // Expansion modifies the JVMState, so we need to deep clone it virtualbool needs_deep_clone_jvms(Compile* C) { returntrue; } virtualint Opcode() const; virtual uint ideal_reg() const { return Op_RegP; } virtualbool guaranteed_safepoint() { returnfalse; }
// allocations do not modify their arguments virtualbool may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) { returnfalse;}
// Pattern-match a possible usage of AllocateNode. // Return null if no allocation is recognized. // The operand is the pointer produced by the (possible) allocation. // It must be a projection of the Allocate or its subsequent CastPP. // (Note: This function is defined in file graphKit.cpp, near // GraphKit::new_instance/new_array, whose output it recognizes.) // The 'ptr' may not have an offset unless the 'offset' argument is given. static AllocateNode* Ideal_allocation(Node* ptr, PhaseTransform* phase);
// Fancy version which uses AddPNode::Ideal_base_and_offset to strip // an offset, which is reported back to the caller. // (Note: AllocateNode::Ideal_allocation is defined in graphKit.cpp.) static AllocateNode* Ideal_allocation(Node* ptr, PhaseTransform* phase,
intptr_t& offset);
// Dig the klass operand out of a (possible) allocation site. static Node* Ideal_klass(Node* ptr, PhaseTransform* phase) {
AllocateNode* allo = Ideal_allocation(ptr, phase); return (allo == NULL) ? NULL : allo->in(KlassNode);
}
// Conservatively small estimate of offset of first non-header byte. int minimum_header_size() { return is_AllocateArray() ? arrayOopDesc::base_offset_in_bytes(T_BYTE) :
instanceOopDesc::base_offset_in_bytes();
}
// Return the corresponding initialization barrier (or null if none). // Walks out edges to find it... // (Note: Both InitializeNode::allocation and AllocateNode::initialization // are defined in graphKit.cpp, which sets up the bidirectional relation.)
InitializeNode* initialization();
// Convenience for initialization->maybe_set_complete(phase) bool maybe_set_complete(PhaseGVN* phase);
// Return true if allocation doesn't escape thread, its escape state // needs be noEscape or ArgEscape. InitializeNode._does_not_escape // is true when its allocation's escape state is noEscape or // ArgEscape. In case allocation's InitializeNode is NULL, check // AlllocateNode._is_non_escaping flag. // AlllocateNode._is_non_escaping is true when its escape state is // noEscape. bool does_not_escape_thread() {
InitializeNode* init = NULL; return _is_non_escaping || (((init = initialization()) != NULL) && init->does_not_escape());
}
// If object doesn't escape in <.init> method and there is memory barrier // inserted at exit of its <.init>, memory barrier for new is not necessary. // Inovke this method when MemBar at exit of initializer and post-dominate // allocation node. void compute_MemBar_redundancy(ciMethod* initializer); bool is_allocation_MemBar_redundant() { return _is_allocation_MemBar_redundant; }
// Dig the length operand out of a array allocation site.
Node* Ideal_length() { return in(AllocateNode::ALength);
}
// Dig the length operand out of a array allocation site and narrow the // type with a CastII, if necesssary
Node* make_ideal_length(const TypeOopPtr* ary_type, PhaseTransform *phase, bool can_create = true);
// Pattern-match a possible usage of AllocateArrayNode. // Return null if no allocation is recognized. static AllocateArrayNode* Ideal_array_allocation(Node* ptr, PhaseTransform* phase) {
AllocateNode* allo = Ideal_allocation(ptr, phase); return (allo == NULL || !allo->is_AllocateArray())
? NULL : allo->as_AllocateArray();
}
};
//------------------------------AbstractLockNode----------------------------------- class AbstractLockNode: public CallNode { private: enum {
Regular = 0, // Normal lock
NonEscObj, // Lock is used for non escaping object
Coarsened, // Lock was coarsened
Nested // Nested lock
} _kind;
staticconstchar* _kind_names[Nested+1];
#ifndef PRODUCT
NamedCounter* _counter; #endif
protected: // helper functions for lock elimination //
//------------------------------Lock--------------------------------------- // High-level lock operation // // This is a subclass of CallNode because it is a macro node which gets expanded // into a code sequence containing a call. This node takes 3 "parameters": // 0 - object to lock // 1 - a BoxLockNode // 2 - a FastLockNode // class LockNode : public AbstractLockNode { public:
staticconst TypeFunc *lock_type() { // create input type (domain) const Type **fields = TypeTuple::fields(3);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
fields[TypeFunc::Parms+2] = TypeInt::BOOL; // FastLock const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3,fields);
// create result type (range)
fields = TypeTuple::fields(0);
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); // Expansion modifies the JVMState, so we need to deep clone it virtualbool needs_deep_clone_jvms(Compile* C) { returntrue; }
bool is_nested_lock_region(); // Is this Lock nested? bool is_nested_lock_region(Compile * c); // Why isn't this Lock nested?
};
//------------------------------Unlock--------------------------------------- // High-level unlock operation class UnlockNode : public AbstractLockNode { private: #ifdef ASSERT
JVMState* const _dbg_jvms; // Pointer to list of JVM State objects #endif public: virtualint Opcode() const; virtual uint size_of() const; // Size is bigger
UnlockNode(Compile* C, const TypeFunc *tf) : AbstractLockNode( tf ) #ifdef ASSERT
, _dbg_jvms(NULL) #endif
{
init_class_id(Class_Unlock);
init_flags(Flag_is_macro);
C->add_macro_node(this);
} virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); // unlock is never a safepoint virtualbool guaranteed_safepoint() { returnfalse; } #ifdef ASSERT void set_dbg_jvms(JVMState* s) {
*(JVMState**)&_dbg_jvms = s; // override const attribute in the accessor
}
JVMState* dbg_jvms() const { return _dbg_jvms; } #else
JVMState* dbg_jvms() const { return NULL; } #endif
}; #endif// SHARE_OPTO_CALLNODE_HPP
Messung V0.5
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.