macro.cpp revision 63
0N/A/*
0N/A * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A *
0N/A */
0N/A
0N/A#include "incls/_precompiled.incl"
0N/A#include "incls/_macro.cpp.incl"
0N/A
0N/A
0N/A//
0N/A// Replace any references to "oldref" in inputs to "use" with "newref".
0N/A// Returns the number of replacements made.
0N/A//
0N/Aint PhaseMacroExpand::replace_input(Node *use, Node *oldref, Node *newref) {
0N/A int nreplacements = 0;
0N/A uint req = use->req();
0N/A for (uint j = 0; j < use->len(); j++) {
0N/A Node *uin = use->in(j);
0N/A if (uin == oldref) {
0N/A if (j < req)
0N/A use->set_req(j, newref);
0N/A else
0N/A use->set_prec(j, newref);
0N/A nreplacements++;
0N/A } else if (j >= req && uin == NULL) {
0N/A break;
0N/A }
0N/A }
0N/A return nreplacements;
0N/A}
0N/A
0N/Avoid PhaseMacroExpand::copy_call_debug_info(CallNode *oldcall, CallNode * newcall) {
0N/A // Copy debug information and adjust JVMState information
0N/A uint old_dbg_start = oldcall->tf()->domain()->cnt();
0N/A uint new_dbg_start = newcall->tf()->domain()->cnt();
0N/A int jvms_adj = new_dbg_start - old_dbg_start;
0N/A assert (new_dbg_start == newcall->req(), "argument count mismatch");
63N/A
63N/A Dict* sosn_map = new Dict(cmpkey,hashkey);
0N/A for (uint i = old_dbg_start; i < oldcall->req(); i++) {
63N/A Node* old_in = oldcall->in(i);
63N/A // Clone old SafePointScalarObjectNodes, adjusting their field contents.
63N/A if (old_in->is_SafePointScalarObject()) {
63N/A SafePointScalarObjectNode* old_sosn = old_in->as_SafePointScalarObject();
63N/A uint old_unique = C->unique();
63N/A Node* new_in = old_sosn->clone(jvms_adj, sosn_map);
63N/A if (old_unique != C->unique()) {
63N/A new_in = transform_later(new_in); // Register new node.
63N/A }
63N/A old_in = new_in;
63N/A }
63N/A newcall->add_req(old_in);
0N/A }
63N/A
0N/A newcall->set_jvms(oldcall->jvms());
0N/A for (JVMState *jvms = newcall->jvms(); jvms != NULL; jvms = jvms->caller()) {
0N/A jvms->set_map(newcall);
0N/A jvms->set_locoff(jvms->locoff()+jvms_adj);
0N/A jvms->set_stkoff(jvms->stkoff()+jvms_adj);
0N/A jvms->set_monoff(jvms->monoff()+jvms_adj);
63N/A jvms->set_scloff(jvms->scloff()+jvms_adj);
0N/A jvms->set_endoff(jvms->endoff()+jvms_adj);
0N/A }
0N/A}
0N/A
0N/ANode* PhaseMacroExpand::opt_iff(Node* region, Node* iff) {
0N/A IfNode *opt_iff = transform_later(iff)->as_If();
0N/A
0N/A // Fast path taken; set region slot 2
0N/A Node *fast_taken = transform_later( new (C, 1) IfFalseNode(opt_iff) );
0N/A region->init_req(2,fast_taken); // Capture fast-control
0N/A
0N/A // Fast path not-taken, i.e. slow path
0N/A Node *slow_taken = transform_later( new (C, 1) IfTrueNode(opt_iff) );
0N/A return slow_taken;
0N/A}
0N/A
0N/A//--------------------copy_predefined_input_for_runtime_call--------------------
0N/Avoid PhaseMacroExpand::copy_predefined_input_for_runtime_call(Node * ctrl, CallNode* oldcall, CallNode* call) {
0N/A // Set fixed predefined input arguments
0N/A call->init_req( TypeFunc::Control, ctrl );
0N/A call->init_req( TypeFunc::I_O , oldcall->in( TypeFunc::I_O) );
0N/A call->init_req( TypeFunc::Memory , oldcall->in( TypeFunc::Memory ) ); // ?????
0N/A call->init_req( TypeFunc::ReturnAdr, oldcall->in( TypeFunc::ReturnAdr ) );
0N/A call->init_req( TypeFunc::FramePtr, oldcall->in( TypeFunc::FramePtr ) );
0N/A}
0N/A
0N/A//------------------------------make_slow_call---------------------------------
0N/ACallNode* PhaseMacroExpand::make_slow_call(CallNode *oldcall, const TypeFunc* slow_call_type, address slow_call, const char* leaf_name, Node* slow_path, Node* parm0, Node* parm1) {
0N/A
0N/A // Slow-path call
0N/A int size = slow_call_type->domain()->cnt();
0N/A CallNode *call = leaf_name
0N/A ? (CallNode*)new (C, size) CallLeafNode ( slow_call_type, slow_call, leaf_name, TypeRawPtr::BOTTOM )
0N/A : (CallNode*)new (C, size) CallStaticJavaNode( slow_call_type, slow_call, OptoRuntime::stub_name(slow_call), oldcall->jvms()->bci(), TypeRawPtr::BOTTOM );
0N/A
0N/A // Slow path call has no side-effects, uses few values
0N/A copy_predefined_input_for_runtime_call(slow_path, oldcall, call );
0N/A if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0);
0N/A if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1);
0N/A copy_call_debug_info(oldcall, call);
0N/A call->set_cnt(PROB_UNLIKELY_MAG(4)); // Same effect as RC_UNCOMMON.
0N/A _igvn.hash_delete(oldcall);
0N/A _igvn.subsume_node(oldcall, call);
0N/A transform_later(call);
0N/A
0N/A return call;
0N/A}
0N/A
0N/Avoid PhaseMacroExpand::extract_call_projections(CallNode *call) {
0N/A _fallthroughproj = NULL;
0N/A _fallthroughcatchproj = NULL;
0N/A _ioproj_fallthrough = NULL;
0N/A _ioproj_catchall = NULL;
0N/A _catchallcatchproj = NULL;
0N/A _memproj_fallthrough = NULL;
0N/A _memproj_catchall = NULL;
0N/A _resproj = NULL;
0N/A for (DUIterator_Fast imax, i = call->fast_outs(imax); i < imax; i++) {
0N/A ProjNode *pn = call->fast_out(i)->as_Proj();
0N/A switch (pn->_con) {
0N/A case TypeFunc::Control:
0N/A {
0N/A // For Control (fallthrough) and I_O (catch_all_index) we have CatchProj -> Catch -> Proj
0N/A _fallthroughproj = pn;
0N/A DUIterator_Fast jmax, j = pn->fast_outs(jmax);
0N/A const Node *cn = pn->fast_out(j);
0N/A if (cn->is_Catch()) {
0N/A ProjNode *cpn = NULL;
0N/A for (DUIterator_Fast kmax, k = cn->fast_outs(kmax); k < kmax; k++) {
0N/A cpn = cn->fast_out(k)->as_Proj();
0N/A assert(cpn->is_CatchProj(), "must be a CatchProjNode");
0N/A if (cpn->_con == CatchProjNode::fall_through_index)
0N/A _fallthroughcatchproj = cpn;
0N/A else {
0N/A assert(cpn->_con == CatchProjNode::catch_all_index, "must be correct index.");
0N/A _catchallcatchproj = cpn;
0N/A }
0N/A }
0N/A }
0N/A break;
0N/A }
0N/A case TypeFunc::I_O:
0N/A if (pn->_is_io_use)
0N/A _ioproj_catchall = pn;
0N/A else
0N/A _ioproj_fallthrough = pn;
0N/A break;
0N/A case TypeFunc::Memory:
0N/A if (pn->_is_io_use)
0N/A _memproj_catchall = pn;
0N/A else
0N/A _memproj_fallthrough = pn;
0N/A break;
0N/A case TypeFunc::Parms:
0N/A _resproj = pn;
0N/A break;
0N/A default:
0N/A assert(false, "unexpected projection from allocation node.");
0N/A }
0N/A }
0N/A
0N/A}
0N/A
0N/A
0N/A//---------------------------set_eden_pointers-------------------------
0N/Avoid PhaseMacroExpand::set_eden_pointers(Node* &eden_top_adr, Node* &eden_end_adr) {
0N/A if (UseTLAB) { // Private allocation: load from TLS
0N/A Node* thread = transform_later(new (C, 1) ThreadLocalNode());
0N/A int tlab_top_offset = in_bytes(JavaThread::tlab_top_offset());
0N/A int tlab_end_offset = in_bytes(JavaThread::tlab_end_offset());
0N/A eden_top_adr = basic_plus_adr(top()/*not oop*/, thread, tlab_top_offset);
0N/A eden_end_adr = basic_plus_adr(top()/*not oop*/, thread, tlab_end_offset);
0N/A } else { // Shared allocation: load from globals
0N/A CollectedHeap* ch = Universe::heap();
0N/A address top_adr = (address)ch->top_addr();
0N/A address end_adr = (address)ch->end_addr();
0N/A eden_top_adr = makecon(TypeRawPtr::make(top_adr));
0N/A eden_end_adr = basic_plus_adr(eden_top_adr, end_adr - top_adr);
0N/A }
0N/A}
0N/A
0N/A
0N/ANode* PhaseMacroExpand::make_load(Node* ctl, Node* mem, Node* base, int offset, const Type* value_type, BasicType bt) {
0N/A Node* adr = basic_plus_adr(base, offset);
0N/A const TypePtr* adr_type = TypeRawPtr::BOTTOM;
0N/A Node* value = LoadNode::make(C, ctl, mem, adr, adr_type, value_type, bt);
0N/A transform_later(value);
0N/A return value;
0N/A}
0N/A
0N/A
0N/ANode* PhaseMacroExpand::make_store(Node* ctl, Node* mem, Node* base, int offset, Node* value, BasicType bt) {
0N/A Node* adr = basic_plus_adr(base, offset);
0N/A mem = StoreNode::make(C, ctl, mem, adr, NULL, value, bt);
0N/A transform_later(mem);
0N/A return mem;
0N/A}
0N/A
0N/A//=============================================================================
0N/A//
0N/A// A L L O C A T I O N
0N/A//
0N/A// Allocation attempts to be fast in the case of frequent small objects.
0N/A// It breaks down like this:
0N/A//
0N/A// 1) Size in doublewords is computed. This is a constant for objects and
0N/A// variable for most arrays. Doubleword units are used to avoid size
0N/A// overflow of huge doubleword arrays. We need doublewords in the end for
0N/A// rounding.
0N/A//
0N/A// 2) Size is checked for being 'too large'. Too-large allocations will go
0N/A// the slow path into the VM. The slow path can throw any required
0N/A// exceptions, and does all the special checks for very large arrays. The
0N/A// size test can constant-fold away for objects. For objects with
0N/A// finalizers it constant-folds the otherway: you always go slow with
0N/A// finalizers.
0N/A//
0N/A// 3) If NOT using TLABs, this is the contended loop-back point.
0N/A// Load-Locked the heap top. If using TLABs normal-load the heap top.
0N/A//
0N/A// 4) Check that heap top + size*8 < max. If we fail go the slow ` route.
0N/A// NOTE: "top+size*8" cannot wrap the 4Gig line! Here's why: for largish
0N/A// "size*8" we always enter the VM, where "largish" is a constant picked small
0N/A// enough that there's always space between the eden max and 4Gig (old space is
0N/A// there so it's quite large) and large enough that the cost of entering the VM
0N/A// is dwarfed by the cost to initialize the space.
0N/A//
0N/A// 5) If NOT using TLABs, Store-Conditional the adjusted heap top back
0N/A// down. If contended, repeat at step 3. If using TLABs normal-store
0N/A// adjusted heap top back down; there is no contention.
0N/A//
0N/A// 6) If !ZeroTLAB then Bulk-clear the object/array. Fill in klass & mark
0N/A// fields.
0N/A//
0N/A// 7) Merge with the slow-path; cast the raw memory pointer to the correct
0N/A// oop flavor.
0N/A//
0N/A//=============================================================================
0N/A// FastAllocateSizeLimit value is in DOUBLEWORDS.
0N/A// Allocations bigger than this always go the slow route.
0N/A// This value must be small enough that allocation attempts that need to
0N/A// trigger exceptions go the slow route. Also, it must be small enough so
0N/A// that heap_top + size_in_bytes does not wrap around the 4Gig limit.
0N/A//=============================================================================j//
0N/A// %%% Here is an old comment from parseHelper.cpp; is it outdated?
0N/A// The allocator will coalesce int->oop copies away. See comment in
0N/A// coalesce.cpp about how this works. It depends critically on the exact
0N/A// code shape produced here, so if you are changing this code shape
0N/A// make sure the GC info for the heap-top is correct in and around the
0N/A// slow-path call.
0N/A//
0N/A
0N/Avoid PhaseMacroExpand::expand_allocate_common(
0N/A AllocateNode* alloc, // allocation node to be expanded
0N/A Node* length, // array length for an array allocation
0N/A const TypeFunc* slow_call_type, // Type of slow call
0N/A address slow_call_address // Address of slow call
0N/A )
0N/A{
0N/A
0N/A Node* ctrl = alloc->in(TypeFunc::Control);
0N/A Node* mem = alloc->in(TypeFunc::Memory);
0N/A Node* i_o = alloc->in(TypeFunc::I_O);
0N/A Node* size_in_bytes = alloc->in(AllocateNode::AllocSize);
0N/A Node* klass_node = alloc->in(AllocateNode::KlassNode);
0N/A Node* initial_slow_test = alloc->in(AllocateNode::InitialTest);
0N/A
0N/A Node* eden_top_adr;
0N/A Node* eden_end_adr;
0N/A set_eden_pointers(eden_top_adr, eden_end_adr);
0N/A
0N/A uint raw_idx = C->get_alias_index(TypeRawPtr::BOTTOM);
0N/A assert(ctrl != NULL, "must have control");
0N/A
0N/A // Load Eden::end. Loop invariant and hoisted.
0N/A //
0N/A // Note: We set the control input on "eden_end" and "old_eden_top" when using
0N/A // a TLAB to work around a bug where these values were being moved across
0N/A // a safepoint. These are not oops, so they cannot be include in the oop
0N/A // map, but the can be changed by a GC. The proper way to fix this would
0N/A // be to set the raw memory state when generating a SafepointNode. However
0N/A // this will require extensive changes to the loop optimization in order to
0N/A // prevent a degradation of the optimization.
0N/A // See comment in memnode.hpp, around line 227 in class LoadPNode.
0N/A Node* eden_end = make_load(ctrl, mem, eden_end_adr, 0, TypeRawPtr::BOTTOM, T_ADDRESS);
0N/A
0N/A // We need a Region and corresponding Phi's to merge the slow-path and fast-path results.
0N/A // they will not be used if "always_slow" is set
0N/A enum { slow_result_path = 1, fast_result_path = 2 };
0N/A Node *result_region;
0N/A Node *result_phi_rawmem;
0N/A Node *result_phi_rawoop;
0N/A Node *result_phi_i_o;
0N/A
0N/A // The initial slow comparison is a size check, the comparison
0N/A // we want to do is a BoolTest::gt
0N/A bool always_slow = false;
0N/A int tv = _igvn.find_int_con(initial_slow_test, -1);
0N/A if (tv >= 0) {
0N/A always_slow = (tv == 1);
0N/A initial_slow_test = NULL;
0N/A } else {
0N/A initial_slow_test = BoolNode::make_predicate(initial_slow_test, &_igvn);
0N/A }
0N/A
0N/A if (DTraceAllocProbes) {
0N/A // Force slow-path allocation
0N/A always_slow = true;
0N/A initial_slow_test = NULL;
0N/A }
0N/A
0N/A enum { too_big_or_final_path = 1, need_gc_path = 2 };
0N/A Node *slow_region = NULL;
0N/A Node *toobig_false = ctrl;
0N/A
0N/A assert (initial_slow_test == NULL || !always_slow, "arguments must be consistent");
0N/A // generate the initial test if necessary
0N/A if (initial_slow_test != NULL ) {
0N/A slow_region = new (C, 3) RegionNode(3);
0N/A
0N/A // Now make the initial failure test. Usually a too-big test but
0N/A // might be a TRUE for finalizers or a fancy class check for
0N/A // newInstance0.
0N/A IfNode *toobig_iff = new (C, 2) IfNode(ctrl, initial_slow_test, PROB_MIN, COUNT_UNKNOWN);
0N/A transform_later(toobig_iff);
0N/A // Plug the failing-too-big test into the slow-path region
0N/A Node *toobig_true = new (C, 1) IfTrueNode( toobig_iff );
0N/A transform_later(toobig_true);
0N/A slow_region ->init_req( too_big_or_final_path, toobig_true );
0N/A toobig_false = new (C, 1) IfFalseNode( toobig_iff );
0N/A transform_later(toobig_false);
0N/A } else { // No initial test, just fall into next case
0N/A toobig_false = ctrl;
0N/A debug_only(slow_region = NodeSentinel);
0N/A }
0N/A
0N/A Node *slow_mem = mem; // save the current memory state for slow path
0N/A // generate the fast allocation code unless we know that the initial test will always go slow
0N/A if (!always_slow) {
0N/A // allocate the Region and Phi nodes for the result
0N/A result_region = new (C, 3) RegionNode(3);
0N/A result_phi_rawmem = new (C, 3) PhiNode( result_region, Type::MEMORY, TypeRawPtr::BOTTOM );
0N/A result_phi_rawoop = new (C, 3) PhiNode( result_region, TypeRawPtr::BOTTOM );
0N/A result_phi_i_o = new (C, 3) PhiNode( result_region, Type::ABIO ); // I/O is used for Prefetch
0N/A
0N/A // We need a Region for the loop-back contended case.
0N/A enum { fall_in_path = 1, contended_loopback_path = 2 };
0N/A Node *contended_region;
0N/A Node *contended_phi_rawmem;
0N/A if( UseTLAB ) {
0N/A contended_region = toobig_false;
0N/A contended_phi_rawmem = mem;
0N/A } else {
0N/A contended_region = new (C, 3) RegionNode(3);
0N/A contended_phi_rawmem = new (C, 3) PhiNode( contended_region, Type::MEMORY, TypeRawPtr::BOTTOM);
0N/A // Now handle the passing-too-big test. We fall into the contended
0N/A // loop-back merge point.
0N/A contended_region ->init_req( fall_in_path, toobig_false );
0N/A contended_phi_rawmem->init_req( fall_in_path, mem );
0N/A transform_later(contended_region);
0N/A transform_later(contended_phi_rawmem);
0N/A }
0N/A
0N/A // Load(-locked) the heap top.
0N/A // See note above concerning the control input when using a TLAB
0N/A Node *old_eden_top = UseTLAB
0N/A ? new (C, 3) LoadPNode ( ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM )
0N/A : new (C, 3) LoadPLockedNode( contended_region, contended_phi_rawmem, eden_top_adr );
0N/A
0N/A transform_later(old_eden_top);
0N/A // Add to heap top to get a new heap top
0N/A Node *new_eden_top = new (C, 4) AddPNode( top(), old_eden_top, size_in_bytes );
0N/A transform_later(new_eden_top);
0N/A // Check for needing a GC; compare against heap end
0N/A Node *needgc_cmp = new (C, 3) CmpPNode( new_eden_top, eden_end );
0N/A transform_later(needgc_cmp);
0N/A Node *needgc_bol = new (C, 2) BoolNode( needgc_cmp, BoolTest::ge );
0N/A transform_later(needgc_bol);
0N/A IfNode *needgc_iff = new (C, 2) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN );
0N/A transform_later(needgc_iff);
0N/A
0N/A // Plug the failing-heap-space-need-gc test into the slow-path region
0N/A Node *needgc_true = new (C, 1) IfTrueNode( needgc_iff );
0N/A transform_later(needgc_true);
0N/A if( initial_slow_test ) {
0N/A slow_region ->init_req( need_gc_path, needgc_true );
0N/A // This completes all paths into the slow merge point
0N/A transform_later(slow_region);
0N/A } else { // No initial slow path needed!
0N/A // Just fall from the need-GC path straight into the VM call.
0N/A slow_region = needgc_true;
0N/A }
0N/A // No need for a GC. Setup for the Store-Conditional
0N/A Node *needgc_false = new (C, 1) IfFalseNode( needgc_iff );
0N/A transform_later(needgc_false);
0N/A
0N/A // Grab regular I/O before optional prefetch may change it.
0N/A // Slow-path does no I/O so just set it to the original I/O.
0N/A result_phi_i_o->init_req( slow_result_path, i_o );
0N/A
0N/A i_o = prefetch_allocation(i_o, needgc_false, contended_phi_rawmem,
0N/A old_eden_top, new_eden_top, length);
0N/A
0N/A // Store (-conditional) the modified eden top back down.
0N/A // StorePConditional produces flags for a test PLUS a modified raw
0N/A // memory state.
0N/A Node *store_eden_top;
0N/A Node *fast_oop_ctrl;
0N/A if( UseTLAB ) {
0N/A store_eden_top = new (C, 4) StorePNode( needgc_false, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, new_eden_top );
0N/A transform_later(store_eden_top);
0N/A fast_oop_ctrl = needgc_false; // No contention, so this is the fast path
0N/A } else {
0N/A store_eden_top = new (C, 5) StorePConditionalNode( needgc_false, contended_phi_rawmem, eden_top_adr, new_eden_top, old_eden_top );
0N/A transform_later(store_eden_top);
0N/A Node *contention_check = new (C, 2) BoolNode( store_eden_top, BoolTest::ne );
0N/A transform_later(contention_check);
0N/A store_eden_top = new (C, 1) SCMemProjNode(store_eden_top);
0N/A transform_later(store_eden_top);
0N/A
0N/A // If not using TLABs, check to see if there was contention.
0N/A IfNode *contention_iff = new (C, 2) IfNode ( needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN );
0N/A transform_later(contention_iff);
0N/A Node *contention_true = new (C, 1) IfTrueNode( contention_iff );
0N/A transform_later(contention_true);
0N/A // If contention, loopback and try again.
0N/A contended_region->init_req( contended_loopback_path, contention_true );
0N/A contended_phi_rawmem->init_req( contended_loopback_path, store_eden_top );
0N/A
0N/A // Fast-path succeeded with no contention!
0N/A Node *contention_false = new (C, 1) IfFalseNode( contention_iff );
0N/A transform_later(contention_false);
0N/A fast_oop_ctrl = contention_false;
0N/A }
0N/A
0N/A // Rename successful fast-path variables to make meaning more obvious
0N/A Node* fast_oop = old_eden_top;
0N/A Node* fast_oop_rawmem = store_eden_top;
0N/A fast_oop_rawmem = initialize_object(alloc,
0N/A fast_oop_ctrl, fast_oop_rawmem, fast_oop,
0N/A klass_node, length, size_in_bytes);
0N/A
0N/A if (ExtendedDTraceProbes) {
0N/A // Slow-path call
0N/A int size = TypeFunc::Parms + 2;
0N/A CallLeafNode *call = new (C, size) CallLeafNode(OptoRuntime::dtrace_object_alloc_Type(),
0N/A CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc_base),
0N/A "dtrace_object_alloc",
0N/A TypeRawPtr::BOTTOM);
0N/A
0N/A // Get base of thread-local storage area
0N/A Node* thread = new (C, 1) ThreadLocalNode();
0N/A transform_later(thread);
0N/A
0N/A call->init_req(TypeFunc::Parms+0, thread);
0N/A call->init_req(TypeFunc::Parms+1, fast_oop);
0N/A call->init_req( TypeFunc::Control, fast_oop_ctrl );
0N/A call->init_req( TypeFunc::I_O , top() ) ; // does no i/o
0N/A call->init_req( TypeFunc::Memory , fast_oop_rawmem );
0N/A call->init_req( TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr) );
0N/A call->init_req( TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr) );
0N/A transform_later(call);
0N/A fast_oop_ctrl = new (C, 1) ProjNode(call,TypeFunc::Control);
0N/A transform_later(fast_oop_ctrl);
0N/A fast_oop_rawmem = new (C, 1) ProjNode(call,TypeFunc::Memory);
0N/A transform_later(fast_oop_rawmem);
0N/A }
0N/A
0N/A // Plug in the successful fast-path into the result merge point
0N/A result_region ->init_req( fast_result_path, fast_oop_ctrl );
0N/A result_phi_rawoop->init_req( fast_result_path, fast_oop );
0N/A result_phi_i_o ->init_req( fast_result_path, i_o );
0N/A result_phi_rawmem->init_req( fast_result_path, fast_oop_rawmem );
0N/A } else {
0N/A slow_region = ctrl;
0N/A }
0N/A
0N/A // Generate slow-path call
0N/A CallNode *call = new (C, slow_call_type->domain()->cnt())
0N/A CallStaticJavaNode(slow_call_type, slow_call_address,
0N/A OptoRuntime::stub_name(slow_call_address),
0N/A alloc->jvms()->bci(),
0N/A TypePtr::BOTTOM);
0N/A call->init_req( TypeFunc::Control, slow_region );
0N/A call->init_req( TypeFunc::I_O , top() ) ; // does no i/o
0N/A call->init_req( TypeFunc::Memory , slow_mem ); // may gc ptrs
0N/A call->init_req( TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr) );
0N/A call->init_req( TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr) );
0N/A
0N/A call->init_req(TypeFunc::Parms+0, klass_node);
0N/A if (length != NULL) {
0N/A call->init_req(TypeFunc::Parms+1, length);
0N/A }
0N/A
0N/A // Copy debug information and adjust JVMState information, then replace
0N/A // allocate node with the call
0N/A copy_call_debug_info((CallNode *) alloc, call);
0N/A if (!always_slow) {
0N/A call->set_cnt(PROB_UNLIKELY_MAG(4)); // Same effect as RC_UNCOMMON.
0N/A }
0N/A _igvn.hash_delete(alloc);
0N/A _igvn.subsume_node(alloc, call);
0N/A transform_later(call);
0N/A
0N/A // Identify the output projections from the allocate node and
0N/A // adjust any references to them.
0N/A // The control and io projections look like:
0N/A //
0N/A // v---Proj(ctrl) <-----+ v---CatchProj(ctrl)
0N/A // Allocate Catch
0N/A // ^---Proj(io) <-------+ ^---CatchProj(io)
0N/A //
0N/A // We are interested in the CatchProj nodes.
0N/A //
0N/A extract_call_projections(call);
0N/A
0N/A // An allocate node has separate memory projections for the uses on the control and i_o paths
0N/A // Replace uses of the control memory projection with result_phi_rawmem (unless we are only generating a slow call)
0N/A if (!always_slow && _memproj_fallthrough != NULL) {
0N/A for (DUIterator_Fast imax, i = _memproj_fallthrough->fast_outs(imax); i < imax; i++) {
0N/A Node *use = _memproj_fallthrough->fast_out(i);
0N/A _igvn.hash_delete(use);
0N/A imax -= replace_input(use, _memproj_fallthrough, result_phi_rawmem);
0N/A _igvn._worklist.push(use);
0N/A // back up iterator
0N/A --i;
0N/A }
0N/A }
0N/A // Now change uses of _memproj_catchall to use _memproj_fallthrough and delete _memproj_catchall so
0N/A // we end up with a call that has only 1 memory projection
0N/A if (_memproj_catchall != NULL ) {
0N/A if (_memproj_fallthrough == NULL) {
0N/A _memproj_fallthrough = new (C, 1) ProjNode(call, TypeFunc::Memory);
0N/A transform_later(_memproj_fallthrough);
0N/A }
0N/A for (DUIterator_Fast imax, i = _memproj_catchall->fast_outs(imax); i < imax; i++) {
0N/A Node *use = _memproj_catchall->fast_out(i);
0N/A _igvn.hash_delete(use);
0N/A imax -= replace_input(use, _memproj_catchall, _memproj_fallthrough);
0N/A _igvn._worklist.push(use);
0N/A // back up iterator
0N/A --i;
0N/A }
0N/A }
0N/A
0N/A mem = result_phi_rawmem;
0N/A
0N/A // An allocate node has separate i_o projections for the uses on the control and i_o paths
0N/A // Replace uses of the control i_o projection with result_phi_i_o (unless we are only generating a slow call)
0N/A if (_ioproj_fallthrough == NULL) {
0N/A _ioproj_fallthrough = new (C, 1) ProjNode(call, TypeFunc::I_O);
0N/A transform_later(_ioproj_fallthrough);
0N/A } else if (!always_slow) {
0N/A for (DUIterator_Fast imax, i = _ioproj_fallthrough->fast_outs(imax); i < imax; i++) {
0N/A Node *use = _ioproj_fallthrough->fast_out(i);
0N/A
0N/A _igvn.hash_delete(use);
0N/A imax -= replace_input(use, _ioproj_fallthrough, result_phi_i_o);
0N/A _igvn._worklist.push(use);
0N/A // back up iterator
0N/A --i;
0N/A }
0N/A }
0N/A // Now change uses of _ioproj_catchall to use _ioproj_fallthrough and delete _ioproj_catchall so
0N/A // we end up with a call that has only 1 control projection
0N/A if (_ioproj_catchall != NULL ) {
0N/A for (DUIterator_Fast imax, i = _ioproj_catchall->fast_outs(imax); i < imax; i++) {
0N/A Node *use = _ioproj_catchall->fast_out(i);
0N/A _igvn.hash_delete(use);
0N/A imax -= replace_input(use, _ioproj_catchall, _ioproj_fallthrough);
0N/A _igvn._worklist.push(use);
0N/A // back up iterator
0N/A --i;
0N/A }
0N/A }
0N/A
0N/A // if we generated only a slow call, we are done
0N/A if (always_slow)
0N/A return;
0N/A
0N/A
0N/A if (_fallthroughcatchproj != NULL) {
0N/A ctrl = _fallthroughcatchproj->clone();
0N/A transform_later(ctrl);
0N/A _igvn.hash_delete(_fallthroughcatchproj);
0N/A _igvn.subsume_node(_fallthroughcatchproj, result_region);
0N/A } else {
0N/A ctrl = top();
0N/A }
0N/A Node *slow_result;
0N/A if (_resproj == NULL) {
0N/A // no uses of the allocation result
0N/A slow_result = top();
0N/A } else {
0N/A slow_result = _resproj->clone();
0N/A transform_later(slow_result);
0N/A _igvn.hash_delete(_resproj);
0N/A _igvn.subsume_node(_resproj, result_phi_rawoop);
0N/A }
0N/A
0N/A // Plug slow-path into result merge point
0N/A result_region ->init_req( slow_result_path, ctrl );
0N/A result_phi_rawoop->init_req( slow_result_path, slow_result);
0N/A result_phi_rawmem->init_req( slow_result_path, _memproj_fallthrough );
0N/A transform_later(result_region);
0N/A transform_later(result_phi_rawoop);
0N/A transform_later(result_phi_rawmem);
0N/A transform_later(result_phi_i_o);
0N/A // This completes all paths into the result merge point
0N/A}
0N/A
0N/A
0N/A// Helper for PhaseMacroExpand::expand_allocate_common.
0N/A// Initializes the newly-allocated storage.
0N/ANode*
0N/APhaseMacroExpand::initialize_object(AllocateNode* alloc,
0N/A Node* control, Node* rawmem, Node* object,
0N/A Node* klass_node, Node* length,
0N/A Node* size_in_bytes) {
0N/A InitializeNode* init = alloc->initialization();
0N/A // Store the klass & mark bits
0N/A Node* mark_node = NULL;
0N/A // For now only enable fast locking for non-array types
0N/A if (UseBiasedLocking && (length == NULL)) {
0N/A mark_node = make_load(NULL, rawmem, klass_node, Klass::prototype_header_offset_in_bytes() + sizeof(oopDesc), TypeRawPtr::BOTTOM, T_ADDRESS);
0N/A } else {
0N/A mark_node = makecon(TypeRawPtr::make((address)markOopDesc::prototype()));
0N/A }
0N/A rawmem = make_store(control, rawmem, object, oopDesc::mark_offset_in_bytes(), mark_node, T_ADDRESS);
0N/A rawmem = make_store(control, rawmem, object, oopDesc::klass_offset_in_bytes(), klass_node, T_OBJECT);
0N/A int header_size = alloc->minimum_header_size(); // conservatively small
0N/A
0N/A // Array length
0N/A if (length != NULL) { // Arrays need length field
0N/A rawmem = make_store(control, rawmem, object, arrayOopDesc::length_offset_in_bytes(), length, T_INT);
0N/A // conservatively small header size:
0N/A header_size = sizeof(arrayOopDesc);
0N/A ciKlass* k = _igvn.type(klass_node)->is_klassptr()->klass();
0N/A if (k->is_array_klass()) // we know the exact header size in most cases:
0N/A header_size = Klass::layout_helper_header_size(k->layout_helper());
0N/A }
0N/A
0N/A // Clear the object body, if necessary.
0N/A if (init == NULL) {
0N/A // The init has somehow disappeared; be cautious and clear everything.
0N/A //
0N/A // This can happen if a node is allocated but an uncommon trap occurs
0N/A // immediately. In this case, the Initialize gets associated with the
0N/A // trap, and may be placed in a different (outer) loop, if the Allocate
0N/A // is in a loop. If (this is rare) the inner loop gets unrolled, then
0N/A // there can be two Allocates to one Initialize. The answer in all these
0N/A // edge cases is safety first. It is always safe to clear immediately
0N/A // within an Allocate, and then (maybe or maybe not) clear some more later.
0N/A if (!ZeroTLAB)
0N/A rawmem = ClearArrayNode::clear_memory(control, rawmem, object,
0N/A header_size, size_in_bytes,
0N/A &_igvn);
0N/A } else {
0N/A if (!init->is_complete()) {
0N/A // Try to win by zeroing only what the init does not store.
0N/A // We can also try to do some peephole optimizations,
0N/A // such as combining some adjacent subword stores.
0N/A rawmem = init->complete_stores(control, rawmem, object,
0N/A header_size, size_in_bytes, &_igvn);
0N/A }
0N/A
0N/A // We have no more use for this link, since the AllocateNode goes away:
0N/A init->set_req(InitializeNode::RawAddress, top());
0N/A // (If we keep the link, it just confuses the register allocator,
0N/A // who thinks he sees a real use of the address by the membar.)
0N/A }
0N/A
0N/A return rawmem;
0N/A}
0N/A
0N/A// Generate prefetch instructions for next allocations.
0N/ANode* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false,
0N/A Node*& contended_phi_rawmem,
0N/A Node* old_eden_top, Node* new_eden_top,
0N/A Node* length) {
0N/A if( UseTLAB && AllocatePrefetchStyle == 2 ) {
0N/A // Generate prefetch allocation with watermark check.
0N/A // As an allocation hits the watermark, we will prefetch starting
0N/A // at a "distance" away from watermark.
0N/A enum { fall_in_path = 1, pf_path = 2 };
0N/A
0N/A Node *pf_region = new (C, 3) RegionNode(3);
0N/A Node *pf_phi_rawmem = new (C, 3) PhiNode( pf_region, Type::MEMORY,
0N/A TypeRawPtr::BOTTOM );
0N/A // I/O is used for Prefetch
0N/A Node *pf_phi_abio = new (C, 3) PhiNode( pf_region, Type::ABIO );
0N/A
0N/A Node *thread = new (C, 1) ThreadLocalNode();
0N/A transform_later(thread);
0N/A
0N/A Node *eden_pf_adr = new (C, 4) AddPNode( top()/*not oop*/, thread,
0N/A _igvn.MakeConX(in_bytes(JavaThread::tlab_pf_top_offset())) );
0N/A transform_later(eden_pf_adr);
0N/A
0N/A Node *old_pf_wm = new (C, 3) LoadPNode( needgc_false,
0N/A contended_phi_rawmem, eden_pf_adr,
0N/A TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM );
0N/A transform_later(old_pf_wm);
0N/A
0N/A // check against new_eden_top
0N/A Node *need_pf_cmp = new (C, 3) CmpPNode( new_eden_top, old_pf_wm );
0N/A transform_later(need_pf_cmp);
0N/A Node *need_pf_bol = new (C, 2) BoolNode( need_pf_cmp, BoolTest::ge );
0N/A transform_later(need_pf_bol);
0N/A IfNode *need_pf_iff = new (C, 2) IfNode( needgc_false, need_pf_bol,
0N/A PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN );
0N/A transform_later(need_pf_iff);
0N/A
0N/A // true node, add prefetchdistance
0N/A Node *need_pf_true = new (C, 1) IfTrueNode( need_pf_iff );
0N/A transform_later(need_pf_true);
0N/A
0N/A Node *need_pf_false = new (C, 1) IfFalseNode( need_pf_iff );
0N/A transform_later(need_pf_false);
0N/A
0N/A Node *new_pf_wmt = new (C, 4) AddPNode( top(), old_pf_wm,
0N/A _igvn.MakeConX(AllocatePrefetchDistance) );
0N/A transform_later(new_pf_wmt );
0N/A new_pf_wmt->set_req(0, need_pf_true);
0N/A
0N/A Node *store_new_wmt = new (C, 4) StorePNode( need_pf_true,
0N/A contended_phi_rawmem, eden_pf_adr,
0N/A TypeRawPtr::BOTTOM, new_pf_wmt );
0N/A transform_later(store_new_wmt);
0N/A
0N/A // adding prefetches
0N/A pf_phi_abio->init_req( fall_in_path, i_o );
0N/A
0N/A Node *prefetch_adr;
0N/A Node *prefetch;
0N/A uint lines = AllocatePrefetchDistance / AllocatePrefetchStepSize;
0N/A uint step_size = AllocatePrefetchStepSize;
0N/A uint distance = 0;
0N/A
0N/A for ( uint i = 0; i < lines; i++ ) {
0N/A prefetch_adr = new (C, 4) AddPNode( old_pf_wm, new_pf_wmt,
0N/A _igvn.MakeConX(distance) );
0N/A transform_later(prefetch_adr);
0N/A prefetch = new (C, 3) PrefetchWriteNode( i_o, prefetch_adr );
0N/A transform_later(prefetch);
0N/A distance += step_size;
0N/A i_o = prefetch;
0N/A }
0N/A pf_phi_abio->set_req( pf_path, i_o );
0N/A
0N/A pf_region->init_req( fall_in_path, need_pf_false );
0N/A pf_region->init_req( pf_path, need_pf_true );
0N/A
0N/A pf_phi_rawmem->init_req( fall_in_path, contended_phi_rawmem );
0N/A pf_phi_rawmem->init_req( pf_path, store_new_wmt );
0N/A
0N/A transform_later(pf_region);
0N/A transform_later(pf_phi_rawmem);
0N/A transform_later(pf_phi_abio);
0N/A
0N/A needgc_false = pf_region;
0N/A contended_phi_rawmem = pf_phi_rawmem;
0N/A i_o = pf_phi_abio;
0N/A } else if( AllocatePrefetchStyle > 0 ) {
0N/A // Insert a prefetch for each allocation only on the fast-path
0N/A Node *prefetch_adr;
0N/A Node *prefetch;
0N/A // Generate several prefetch instructions only for arrays.
0N/A uint lines = (length != NULL) ? AllocatePrefetchLines : 1;
0N/A uint step_size = AllocatePrefetchStepSize;
0N/A uint distance = AllocatePrefetchDistance;
0N/A for ( uint i = 0; i < lines; i++ ) {
0N/A prefetch_adr = new (C, 4) AddPNode( old_eden_top, new_eden_top,
0N/A _igvn.MakeConX(distance) );
0N/A transform_later(prefetch_adr);
0N/A prefetch = new (C, 3) PrefetchWriteNode( i_o, prefetch_adr );
0N/A // Do not let it float too high, since if eden_top == eden_end,
0N/A // both might be null.
0N/A if( i == 0 ) { // Set control for first prefetch, next follows it
0N/A prefetch->init_req(0, needgc_false);
0N/A }
0N/A transform_later(prefetch);
0N/A distance += step_size;
0N/A i_o = prefetch;
0N/A }
0N/A }
0N/A return i_o;
0N/A}
0N/A
0N/A
0N/Avoid PhaseMacroExpand::expand_allocate(AllocateNode *alloc) {
0N/A expand_allocate_common(alloc, NULL,
0N/A OptoRuntime::new_instance_Type(),
0N/A OptoRuntime::new_instance_Java());
0N/A}
0N/A
0N/Avoid PhaseMacroExpand::expand_allocate_array(AllocateArrayNode *alloc) {
0N/A Node* length = alloc->in(AllocateNode::ALength);
0N/A expand_allocate_common(alloc, length,
0N/A OptoRuntime::new_array_Type(),
0N/A OptoRuntime::new_array_Java());
0N/A}
0N/A
0N/A
0N/A// we have determined that this lock/unlock can be eliminated, we simply
0N/A// eliminate the node without expanding it.
0N/A//
0N/A// Note: The membar's associated with the lock/unlock are currently not
0N/A// eliminated. This should be investigated as a future enhancement.
0N/A//
0N/Avoid PhaseMacroExpand::eliminate_locking_node(AbstractLockNode *alock) {
0N/A Node* mem = alock->in(TypeFunc::Memory);
0N/A
0N/A // The memory projection from a lock/unlock is RawMem
0N/A // The input to a Lock is merged memory, so extract its RawMem input
0N/A // (unless the MergeMem has been optimized away.)
0N/A if (alock->is_Lock()) {
0N/A if (mem->is_MergeMem())
0N/A mem = mem->as_MergeMem()->in(Compile::AliasIdxRaw);
0N/A }
0N/A
0N/A extract_call_projections(alock);
0N/A // There are 2 projections from the lock. The lock node will
0N/A // be deleted when its last use is subsumed below.
0N/A assert(alock->outcnt() == 2 && _fallthroughproj != NULL &&
0N/A _memproj_fallthrough != NULL, "Unexpected projections from Lock/Unlock");
0N/A _igvn.hash_delete(_fallthroughproj);
0N/A _igvn.subsume_node(_fallthroughproj, alock->in(TypeFunc::Control));
0N/A _igvn.hash_delete(_memproj_fallthrough);
0N/A _igvn.subsume_node(_memproj_fallthrough, mem);
0N/A return;
0N/A}
0N/A
0N/A
0N/A//------------------------------expand_lock_node----------------------
0N/Avoid PhaseMacroExpand::expand_lock_node(LockNode *lock) {
0N/A
0N/A Node* ctrl = lock->in(TypeFunc::Control);
0N/A Node* mem = lock->in(TypeFunc::Memory);
0N/A Node* obj = lock->obj_node();
0N/A Node* box = lock->box_node();
0N/A Node *flock = lock->fastlock_node();
0N/A
0N/A if (lock->is_eliminated()) {
0N/A eliminate_locking_node(lock);
0N/A return;
0N/A }
0N/A
0N/A // Make the merge point
0N/A Node *region = new (C, 3) RegionNode(3);
0N/A
0N/A Node *bol = transform_later(new (C, 2) BoolNode(flock,BoolTest::ne));
0N/A Node *iff = new (C, 2) IfNode( ctrl, bol, PROB_MIN, COUNT_UNKNOWN );
0N/A // Optimize test; set region slot 2
0N/A Node *slow_path = opt_iff(region,iff);
0N/A
0N/A // Make slow path call
0N/A CallNode *call = make_slow_call( (CallNode *) lock, OptoRuntime::complete_monitor_enter_Type(), OptoRuntime::complete_monitor_locking_Java(), NULL, slow_path, obj, box );
0N/A
0N/A extract_call_projections(call);
0N/A
0N/A // Slow path can only throw asynchronous exceptions, which are always
0N/A // de-opted. So the compiler thinks the slow-call can never throw an
0N/A // exception. If it DOES throw an exception we would need the debug
0N/A // info removed first (since if it throws there is no monitor).
0N/A assert ( _ioproj_fallthrough == NULL && _ioproj_catchall == NULL &&
0N/A _memproj_catchall == NULL && _catchallcatchproj == NULL, "Unexpected projection from Lock");
0N/A
0N/A // Capture slow path
0N/A // disconnect fall-through projection from call and create a new one
0N/A // hook up users of fall-through projection to region
0N/A Node *slow_ctrl = _fallthroughproj->clone();
0N/A transform_later(slow_ctrl);
0N/A _igvn.hash_delete(_fallthroughproj);
0N/A _fallthroughproj->disconnect_inputs(NULL);
0N/A region->init_req(1, slow_ctrl);
0N/A // region inputs are now complete
0N/A transform_later(region);
0N/A _igvn.subsume_node(_fallthroughproj, region);
0N/A
0N/A // create a Phi for the memory state
0N/A Node *mem_phi = new (C, 3) PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM);
0N/A Node *memproj = transform_later( new (C, 1) ProjNode(call, TypeFunc::Memory) );
0N/A mem_phi->init_req(1, memproj );
0N/A mem_phi->init_req(2, mem);
0N/A transform_later(mem_phi);
0N/A _igvn.hash_delete(_memproj_fallthrough);
0N/A _igvn.subsume_node(_memproj_fallthrough, mem_phi);
0N/A
0N/A
0N/A}
0N/A
0N/A//------------------------------expand_unlock_node----------------------
0N/Avoid PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) {
0N/A
0N/A Node *ctrl = unlock->in(TypeFunc::Control);
0N/A Node* mem = unlock->in(TypeFunc::Memory);
0N/A Node* obj = unlock->obj_node();
0N/A Node* box = unlock->box_node();
0N/A
0N/A
0N/A if (unlock->is_eliminated()) {
0N/A eliminate_locking_node(unlock);
0N/A return;
0N/A }
0N/A
0N/A // No need for a null check on unlock
0N/A
0N/A // Make the merge point
0N/A RegionNode *region = new (C, 3) RegionNode(3);
0N/A
0N/A FastUnlockNode *funlock = new (C, 3) FastUnlockNode( ctrl, obj, box );
0N/A funlock = transform_later( funlock )->as_FastUnlock();
0N/A Node *bol = transform_later(new (C, 2) BoolNode(funlock,BoolTest::ne));
0N/A Node *iff = new (C, 2) IfNode( ctrl, bol, PROB_MIN, COUNT_UNKNOWN );
0N/A // Optimize test; set region slot 2
0N/A Node *slow_path = opt_iff(region,iff);
0N/A
0N/A CallNode *call = make_slow_call( (CallNode *) unlock, OptoRuntime::complete_monitor_exit_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_unlocking_C), "complete_monitor_unlocking_C", slow_path, obj, box );
0N/A
0N/A extract_call_projections(call);
0N/A
0N/A assert ( _ioproj_fallthrough == NULL && _ioproj_catchall == NULL &&
0N/A _memproj_catchall == NULL && _catchallcatchproj == NULL, "Unexpected projection from Lock");
0N/A
0N/A // No exceptions for unlocking
0N/A // Capture slow path
0N/A // disconnect fall-through projection from call and create a new one
0N/A // hook up users of fall-through projection to region
0N/A Node *slow_ctrl = _fallthroughproj->clone();
0N/A transform_later(slow_ctrl);
0N/A _igvn.hash_delete(_fallthroughproj);
0N/A _fallthroughproj->disconnect_inputs(NULL);
0N/A region->init_req(1, slow_ctrl);
0N/A // region inputs are now complete
0N/A transform_later(region);
0N/A _igvn.subsume_node(_fallthroughproj, region);
0N/A
0N/A // create a Phi for the memory state
0N/A Node *mem_phi = new (C, 3) PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM);
0N/A Node *memproj = transform_later( new(C, 1) ProjNode(call, TypeFunc::Memory) );
0N/A mem_phi->init_req(1, memproj );
0N/A mem_phi->init_req(2, mem);
0N/A transform_later(mem_phi);
0N/A _igvn.hash_delete(_memproj_fallthrough);
0N/A _igvn.subsume_node(_memproj_fallthrough, mem_phi);
0N/A
0N/A
0N/A}
0N/A
0N/A//------------------------------expand_macro_nodes----------------------
0N/A// Returns true if a failure occurred.
0N/Abool PhaseMacroExpand::expand_macro_nodes() {
0N/A if (C->macro_count() == 0)
0N/A return false;
0N/A // Make sure expansion will not cause node limit to be exceeded. Worst case is a
0N/A // macro node gets expanded into about 50 nodes. Allow 50% more for optimization
0N/A if (C->check_node_count(C->macro_count() * 75, "out of nodes before macro expansion" ) )
0N/A return true;
0N/A // expand "macro" nodes
0N/A // nodes are removed from the macro list as they are processed
0N/A while (C->macro_count() > 0) {
0N/A Node * n = C->macro_node(0);
0N/A assert(n->is_macro(), "only macro nodes expected here");
0N/A if (_igvn.type(n) == Type::TOP || n->in(0)->is_top() ) {
0N/A // node is unreachable, so don't try to expand it
0N/A C->remove_macro_node(n);
0N/A continue;
0N/A }
0N/A switch (n->class_id()) {
0N/A case Node::Class_Allocate:
0N/A expand_allocate(n->as_Allocate());
0N/A break;
0N/A case Node::Class_AllocateArray:
0N/A expand_allocate_array(n->as_AllocateArray());
0N/A break;
0N/A case Node::Class_Lock:
0N/A expand_lock_node(n->as_Lock());
0N/A break;
0N/A case Node::Class_Unlock:
0N/A expand_unlock_node(n->as_Unlock());
0N/A break;
0N/A default:
0N/A assert(false, "unknown node type in macro list");
0N/A }
0N/A if (C->failing()) return true;
0N/A }
0N/A _igvn.optimize();
0N/A return false;
0N/A}