/* * Copyright (c) 2005, 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. *
*/
// Search for a memory operation for the specified memory slice. static Node *scan_mem_chain(Node *mem, int alias_idx, int offset, Node *start_mem, Node *alloc, PhaseGVN *phase) {
Node *orig_mem = mem;
Node *alloc_mem = alloc->in(TypeFunc::Memory); const TypeOopPtr *tinst = phase->C->get_adr_type(alias_idx)->isa_oopptr(); while (true) { if (mem == alloc_mem || mem == start_mem ) { return mem; // hit one of our sentinels
} elseif (mem->is_MergeMem()) {
mem = mem->as_MergeMem()->memory_at(alias_idx);
} elseif (mem->is_Proj() && mem->as_Proj()->_con == TypeFunc::Memory) {
Node *in = mem->in(0); // we can safely skip over safepoints, calls, locks and membars because we // already know that the object is safe to eliminate. if (in->is_Initialize() && in->as_Initialize()->allocation() == alloc) { return in;
} elseif (in->is_Call()) {
CallNode *call = in->as_Call(); if (call->may_modify(tinst, phase)) {
assert(call->is_ArrayCopy(), "ArrayCopy is the only call node that doesn't make allocation escape"); if (call->as_ArrayCopy()->modifies(offset, offset, phase, false)) { return in;
}
}
mem = in->in(TypeFunc::Memory);
} elseif (in->is_MemBar()) {
ArrayCopyNode* ac = NULL; if (ArrayCopyNode::may_modify(tinst, in->as_MemBar(), phase, ac)) { if (ac != NULL) {
assert(ac->is_clonebasic(), "Only basic clone is a non escaping clone"); return ac;
}
}
mem = in->in(TypeFunc::Memory);
} else { #ifdef ASSERT
in->dump();
mem->dump();
assert(false, "unexpected projection"); #endif
}
} elseif (mem->is_Store()) { const TypePtr* atype = mem->as_Store()->adr_type(); int adr_idx = phase->C->get_alias_index(atype); if (adr_idx == alias_idx) {
assert(atype->isa_oopptr(), "address type must be oopptr"); int adr_offset = atype->offset();
uint adr_iid = atype->is_oopptr()->instance_id(); // Array elements references have the same alias_idx // but different offset and different instance_id. if (adr_offset == offset && adr_iid == alloc->_idx) { return mem;
}
} else {
assert(adr_idx == Compile::AliasIdxRaw, "address must match or be raw");
}
mem = mem->in(MemNode::Memory);
} elseif (mem->is_ClearArray()) { if (!ClearArrayNode::step_through(&mem, alloc->_idx, phase)) { // Can not bypass initialization of the instance // we are looking.
debug_only(intptr_t offset;)
assert(alloc == AllocateNode::Ideal_allocation(mem->in(3), phase, offset), "sanity");
InitializeNode* init = alloc->as_Allocate()->initialization(); // We are looking for stored value, return Initialize node // or memory edge from Allocate node. if (init != NULL) { return init;
} else { return alloc->in(TypeFunc::Memory); // It will produce zero value (see callers).
}
} // Otherwise skip it (the call updated 'mem' value).
} elseif (mem->Opcode() == Op_SCMemProj) {
mem = mem->in(0);
Node* adr = NULL; if (mem->is_LoadStore()) {
adr = mem->in(MemNode::Address);
} else {
assert(mem->Opcode() == Op_EncodeISOArray ||
mem->Opcode() == Op_StrCompressedCopy, "sanity");
adr = mem->in(3); // Destination array
} const TypePtr* atype = adr->bottom_type()->is_ptr(); int adr_idx = phase->C->get_alias_index(atype); if (adr_idx == alias_idx) {
DEBUG_ONLY(mem->dump();)
assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field"); return NULL;
}
mem = mem->in(MemNode::Memory);
} elseif (mem->Opcode() == Op_StrInflatedCopy) {
Node* adr = mem->in(3); // Destination array const TypePtr* atype = adr->bottom_type()->is_ptr(); int adr_idx = phase->C->get_alias_index(atype); if (adr_idx == alias_idx) {
DEBUG_ONLY(mem->dump();)
assert(false, "Object is not scalar replaceable if a StrInflatedCopy node accesses its field"); return NULL;
}
mem = mem->in(MemNode::Memory);
} else { return mem;
}
assert(mem != orig_mem, "dead memory loop");
}
}
// Generate loads from source of the arraycopy for fields of // destination needed at a deoptimization point
Node* PhaseMacroExpand::make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset, Node* ctl, Node* mem, BasicType ft, const Type *ftype, AllocateNode *alloc) {
BasicType bt = ft; const Type *type = ftype; if (ft == T_NARROWOOP) {
bt = T_OBJECT;
type = ftype->make_oopptr();
}
Node* res = NULL; if (ac->is_clonebasic()) {
assert(ac->in(ArrayCopyNode::Src) != ac->in(ArrayCopyNode::Dest), "clone source equals destination");
Node* base = ac->in(ArrayCopyNode::Src);
Node* adr = _igvn.transform(new AddPNode(base, base, MakeConX(offset))); const TypePtr* adr_type = _igvn.type(base)->is_ptr()->add_offset(offset);
MergeMemNode* mergemen = _igvn.transform(MergeMemNode::make(mem))->as_MergeMem();
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
res = ArrayCopyNode::load(bs, &_igvn, ctl, mergemen, adr, adr_type, type, bt);
} else { if (ac->modifies(offset, offset, &_igvn, true)) {
assert(ac->in(ArrayCopyNode::Dest) == alloc->result_cast(), "arraycopy destination should be allocation's result");
uint shift = exact_log2(type2aelembytes(bt));
Node* src_pos = ac->in(ArrayCopyNode::SrcPos);
Node* dest_pos = ac->in(ArrayCopyNode::DestPos); const TypeInt* src_pos_t = _igvn.type(src_pos)->is_int(); const TypeInt* dest_pos_t = _igvn.type(dest_pos)->is_int();
Node* adr = NULL; const TypePtr* adr_type = NULL; if (src_pos_t->is_con() && dest_pos_t->is_con()) {
intptr_t off = ((src_pos_t->get_con() - dest_pos_t->get_con()) << shift) + offset;
Node* base = ac->in(ArrayCopyNode::Src);
adr = _igvn.transform(new AddPNode(base, base, MakeConX(off)));
adr_type = _igvn.type(base)->is_ptr()->add_offset(off); if (ac->in(ArrayCopyNode::Src) == ac->in(ArrayCopyNode::Dest)) { // Don't emit a new load from src if src == dst but try to get the value from memory instead return value_from_mem(ac->in(TypeFunc::Memory), ctl, ft, ftype, adr_type->isa_oopptr(), alloc);
}
} else {
Node* diff = _igvn.transform(new SubINode(ac->in(ArrayCopyNode::SrcPos), ac->in(ArrayCopyNode::DestPos))); #ifdef _LP64
diff = _igvn.transform(new ConvI2LNode(diff)); #endif
diff = _igvn.transform(new LShiftXNode(diff, intcon(shift)));
Node* off = _igvn.transform(new AddXNode(MakeConX(offset), diff));
Node* base = ac->in(ArrayCopyNode::Src);
adr = _igvn.transform(new AddPNode(base, base, off));
adr_type = _igvn.type(base)->is_ptr()->add_offset(Type::OffsetBot); if (ac->in(ArrayCopyNode::Src) == ac->in(ArrayCopyNode::Dest)) { // Non constant offset in the array: we can't statically // determine the value return NULL;
}
}
MergeMemNode* mergemen = _igvn.transform(MergeMemNode::make(mem))->as_MergeMem();
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
res = ArrayCopyNode::load(bs, &_igvn, ctl, mergemen, adr, adr_type, type, bt);
}
} if (res != NULL) { if (ftype->isa_narrowoop()) { // PhaseMacroExpand::scalar_replacement adds DecodeN nodes
res = _igvn.transform(new EncodePNode(res, ftype));
} return res;
} return NULL;
}
// // Given a Memory Phi, compute a value Phi containing the values from stores // on the input paths. // Note: this function is recursive, its depth is limited by the "level" argument // Returns the computed Phi, or NULL if it cannot compute it.
Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type *phi_type, const TypeOopPtr *adr_t, AllocateNode *alloc, Node_Stack *value_phis, int level) {
assert(mem->is_Phi(), "sanity"); int alias_idx = C->get_alias_index(adr_t); int offset = adr_t->offset(); int instance_id = adr_t->instance_id();
// Check if an appropriate value phi already exists.
Node* region = mem->in(0); for (DUIterator_Fast kmax, k = region->fast_outs(kmax); k < kmax; k++) {
Node* phi = region->fast_out(k); if (phi->is_Phi() && phi != mem &&
phi->as_Phi()->is_same_inst_field(phi_type, (int)mem->_idx, instance_id, alias_idx, offset)) { return phi;
}
} // Check if an appropriate new value phi already exists.
Node* new_phi = value_phis->find(mem->_idx); if (new_phi != NULL) return new_phi;
if (level <= 0) { return NULL; // Give up: phi tree too deep
}
Node *start_mem = C->start()->proj_out_or_null(TypeFunc::Memory);
Node *alloc_mem = alloc->in(TypeFunc::Memory);
// create a new Phi for the value
PhiNode *phi = new PhiNode(mem->in(0), phi_type, NULL, mem->_idx, instance_id, alias_idx, offset);
transform_later(phi);
value_phis->push(phi, mem->_idx);
for (uint j = 1; j < length; j++) {
Node *in = mem->in(j); if (in == NULL || in->is_top()) {
values.at_put(j, in);
} else {
Node *val = scan_mem_chain(in, alias_idx, offset, start_mem, alloc, &_igvn); if (val == start_mem || val == alloc_mem) { // hit a sentinel, return appropriate 0 value
values.at_put(j, _igvn.zerocon(ft)); continue;
} if (val->is_Initialize()) {
val = val->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn);
} if (val == NULL) { return NULL; // can't find a value on this path
} if (val == mem) {
values.at_put(j, mem);
} elseif (val->is_Store()) {
Node* n = val->in(MemNode::ValueIn);
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
n = bs->step_over_gc_barrier(n); if (is_subword_type(ft)) {
n = Compile::narrow_value(ft, n, phi_type, &_igvn, true);
}
values.at_put(j, n);
} elseif(val->is_Proj() && val->in(0) == alloc) {
values.at_put(j, _igvn.zerocon(ft));
} elseif (val->is_Phi()) {
val = value_from_mem_phi(val, ft, phi_type, adr_t, alloc, value_phis, level-1); if (val == NULL) { return NULL;
}
values.at_put(j, val);
} elseif (val->Opcode() == Op_SCMemProj) {
assert(val->in(0)->is_LoadStore() ||
val->in(0)->Opcode() == Op_EncodeISOArray ||
val->in(0)->Opcode() == Op_StrCompressedCopy, "sanity");
assert(false, "Object is not scalar replaceable if a LoadStore node accesses its field"); return NULL;
} elseif (val->is_ArrayCopy()) {
Node* res = make_arraycopy_load(val->as_ArrayCopy(), offset, val->in(0), val->in(TypeFunc::Memory), ft, phi_type, alloc); if (res == NULL) { return NULL;
}
values.at_put(j, res);
} else {
DEBUG_ONLY( val->dump(); )
assert(false, "unknown node on this path"); return NULL; // unknown node on this path
}
}
} // Set Phi's inputs for (uint j = 1; j < length; j++) { if (values.at(j) == mem) {
phi->init_req(j, phi);
} else {
phi->init_req(j, values.at(j));
}
} return phi;
}
// Search the last value stored into the object's field.
Node *PhaseMacroExpand::value_from_mem(Node *sfpt_mem, Node *sfpt_ctl, BasicType ft, const Type *ftype, const TypeOopPtr *adr_t, AllocateNode *alloc) {
assert(adr_t->is_known_instance_field(), "instance required"); int instance_id = adr_t->instance_id();
assert((uint)instance_id == alloc->_idx, "wrong allocation");
bool done = sfpt_mem == alloc_mem;
Node *mem = sfpt_mem; while (!done) { if (visited.test_set(mem->_idx)) { return NULL; // found a loop, give up
}
mem = scan_mem_chain(mem, alias_idx, offset, start_mem, alloc, &_igvn); if (mem == start_mem || mem == alloc_mem) {
done = true; // hit a sentinel, return appropriate 0 value
} elseif (mem->is_Initialize()) {
mem = mem->as_Initialize()->find_captured_store(offset, type2aelembytes(ft), &_igvn); if (mem == NULL) {
done = true; // Something go wrong.
} elseif (mem->is_Store()) { const TypePtr* atype = mem->as_Store()->adr_type();
assert(C->get_alias_index(atype) == Compile::AliasIdxRaw, "store is correct memory slice");
done = true;
}
} elseif (mem->is_Store()) { const TypeOopPtr* atype = mem->as_Store()->adr_type()->isa_oopptr();
assert(atype != NULL, "address type must be oopptr");
assert(C->get_alias_index(atype) == alias_idx &&
atype->is_known_instance_field() && atype->offset() == offset &&
atype->instance_id() == instance_id, "store is correct memory slice");
done = true;
} elseif (mem->is_Phi()) { // try to find a phi's unique input
Node *unique_input = NULL;
Node *top = C->top(); for (uint i = 1; i < mem->req(); i++) {
Node *n = scan_mem_chain(mem->in(i), alias_idx, offset, start_mem, alloc, &_igvn); if (n == NULL || n == top || n == mem) { continue;
} elseif (unique_input == NULL) {
unique_input = n;
} elseif (unique_input != n) {
unique_input = top; break;
}
} if (unique_input != NULL && unique_input != top) {
mem = unique_input;
} else {
done = true;
}
} elseif (mem->is_ArrayCopy()) {
done = true;
} else {
DEBUG_ONLY( mem->dump(); )
assert(false, "unexpected node");
}
} if (mem != NULL) { if (mem == start_mem || mem == alloc_mem) { // hit a sentinel, return appropriate 0 value return _igvn.zerocon(ft);
} elseif (mem->is_Store()) {
Node* n = mem->in(MemNode::ValueIn);
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
n = bs->step_over_gc_barrier(n); return n;
} elseif (mem->is_Phi()) { // attempt to produce a Phi reflecting the values on the input paths of the Phi
Node_Stack value_phis(8);
Node* phi = value_from_mem_phi(mem, ft, ftype, adr_t, alloc, &value_phis, ValueSearchLimit); if (phi != NULL) { return phi;
} else { // Kill all new Phis while(value_phis.is_nonempty()) {
Node* n = value_phis.node();
_igvn.replace_node(n, C->top());
value_phis.pop();
}
}
} elseif (mem->is_ArrayCopy()) {
Node* ctl = mem->in(0);
Node* m = mem->in(TypeFunc::Memory); if (sfpt_ctl->is_Proj() && sfpt_ctl->as_Proj()->is_uncommon_trap_proj(Deoptimization::Reason_none)) { // pin the loads in the uncommon trap path
ctl = sfpt_ctl;
m = sfpt_mem;
} return make_arraycopy_load(mem->as_ArrayCopy(), offset, ctl, m, ft, ftype, alloc);
}
} // Something go wrong. return NULL;
}
// Check the possibility of scalar replacement. bool PhaseMacroExpand::can_eliminate_allocation(AllocateNode *alloc, GrowableArray <SafePointNode *>& safepoints) { // Scan the uses of the allocation to check for anything that would // prevent us from eliminating it.
NOT_PRODUCT( constchar* fail_eliminate = NULL; )
DEBUG_ONLY( Node* disq_node = NULL; ) bool can_eliminate = true;
Node* res = alloc->result_cast(); const TypeOopPtr* res_type = NULL; if (res == NULL) { // All users were eliminated.
} elseif (!res->is_CheckCastPP()) {
NOT_PRODUCT(fail_eliminate = "Allocation does not have unique CheckCastPP";)
can_eliminate = false;
} else {
res_type = _igvn.type(res)->isa_oopptr(); if (res_type == NULL) {
NOT_PRODUCT(fail_eliminate = "Neither instance or array allocation";)
can_eliminate = false;
} elseif (res_type->isa_aryptr()) { int length = alloc->in(AllocateNode::ALength)->find_int_con(-1); if (length < 0) {
NOT_PRODUCT(fail_eliminate = "Array's size is not constant";)
can_eliminate = false;
}
}
}
if (can_eliminate && res != NULL) {
BarrierSetC2 *bs = BarrierSet::barrier_set()->barrier_set_c2(); for (DUIterator_Fast jmax, j = res->fast_outs(jmax);
j < jmax && can_eliminate; j++) {
Node* use = res->fast_out(j);
if (use->is_AddP()) { const TypePtr* addp_type = _igvn.type(use)->is_ptr(); int offset = addp_type->offset();
if (offset == Type::OffsetTop || offset == Type::OffsetBot) {
NOT_PRODUCT(fail_eliminate = "Undefined field reference";)
can_eliminate = false; break;
} for (DUIterator_Fast kmax, k = use->fast_outs(kmax);
k < kmax && can_eliminate; k++) {
Node* n = use->fast_out(k); if (!n->is_Store() && n->Opcode() != Op_CastP2X && !bs->is_gc_pre_barrier_node(n)) {
DEBUG_ONLY(disq_node = n;) if (n->is_Load() || n->is_LoadStore()) {
NOT_PRODUCT(fail_eliminate = "Field load";)
} else {
NOT_PRODUCT(fail_eliminate = "Not store field reference";)
}
can_eliminate = false;
}
}
} elseif (use->is_ArrayCopy() &&
(use->as_ArrayCopy()->is_clonebasic() ||
use->as_ArrayCopy()->is_arraycopy_validated() ||
use->as_ArrayCopy()->is_copyof_validated() ||
use->as_ArrayCopy()->is_copyofrange_validated()) &&
use->in(ArrayCopyNode::Dest) == res) { // ok to eliminate
} elseif (use->is_SafePoint()) {
SafePointNode* sfpt = use->as_SafePoint(); if (sfpt->is_Call() && sfpt->as_Call()->has_non_debug_use(res)) { // Object is passed as argument.
DEBUG_ONLY(disq_node = use;)
NOT_PRODUCT(fail_eliminate = "Object is passed as argument";)
can_eliminate = false;
}
Node* sfptMem = sfpt->memory(); if (sfptMem == NULL || sfptMem->is_top()) {
DEBUG_ONLY(disq_node = use;)
NOT_PRODUCT(fail_eliminate = "NULL or TOP memory";)
can_eliminate = false;
} else {
safepoints.append_if_missing(sfpt);
}
} elseif (use->Opcode() != Op_CastP2X) { // CastP2X is used by card mark if (use->is_Phi()) { if (use->outcnt() == 1 && use->unique_out()->Opcode() == Op_Return) {
NOT_PRODUCT(fail_eliminate = "Object is return value";)
} else {
NOT_PRODUCT(fail_eliminate = "Object is referenced by Phi";)
}
DEBUG_ONLY(disq_node = use;)
} else { if (use->Opcode() == Op_Return) {
NOT_PRODUCT(fail_eliminate = "Object is return value";)
}else {
NOT_PRODUCT(fail_eliminate = "Object is referenced by node";)
}
DEBUG_ONLY(disq_node = use;)
}
can_eliminate = false;
}
}
}
#ifndef PRODUCT if (PrintEliminateAllocations) { if (can_eliminate) {
tty->print("Scalar "); if (res == NULL)
alloc->dump(); else
res->dump();
} elseif (alloc->_is_scalar_replaceable) {
tty->print("NotScalar (%s)", fail_eliminate); if (res == NULL)
alloc->dump(); else
res->dump(); #ifdef ASSERT if (disq_node != NULL) {
tty->print(" >>>> ");
disq_node->dump();
} #endif/*ASSERT*/
}
} #endif return can_eliminate;
}
ciInstanceKlass* iklass = NULL; int nfields = 0; int array_base = 0; int element_size = 0;
BasicType basic_elem_type = T_ILLEGAL; const Type* field_type = NULL;
Node* res = alloc->result_cast();
assert(res == NULL || res->is_CheckCastPP(), "unexpected AllocateNode result"); const TypeOopPtr* res_type = NULL; if (res != NULL) { // Could be NULL when there are no users
res_type = _igvn.type(res)->isa_oopptr();
}
if (res != NULL) { if (res_type->isa_instptr()) { // find the fields of the class which will be needed for safepoint debug information
iklass = res_type->is_instptr()->instance_klass();
nfields = iklass->nof_nonstatic_fields();
} else { // find the array's elements which will be needed for safepoint debug information
nfields = alloc->in(AllocateNode::ALength)->find_int_con(-1);
assert(nfields >= 0, "must be an array klass.");
basic_elem_type = res_type->is_aryptr()->elem()->array_element_basic_type();
array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
element_size = type2aelembytes(basic_elem_type);
field_type = res_type->is_aryptr()->elem();
}
} // // Process the safepoint uses // while (safepoints.length() > 0) {
SafePointNode* sfpt = safepoints.pop();
Node* mem = sfpt->memory();
Node* ctl = sfpt->control();
assert(sfpt->jvms() != NULL, "missed JVMS"); // Fields of scalar objs are referenced only at the end // of regular debuginfo at the last (youngest) JVMS. // Record relative start index.
uint first_ind = (sfpt->req() - sfpt->jvms()->scloff());
SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, #ifdef ASSERT
alloc, #endif
first_ind, nfields);
sobj->init_req(0, C->root());
transform_later(sobj);
// Scan object's fields adding an input to the safepoint for each field. for (int j = 0; j < nfields; j++) {
intptr_t offset;
ciField* field = NULL; if (iklass != NULL) {
field = iklass->nonstatic_field_at(j);
offset = field->offset();
ciType* elem_type = field->type();
basic_elem_type = field->layout_type();
// The next code is taken from Parse::do_get_xxx(). if (is_reference_type(basic_elem_type)) { if (!elem_type->is_loaded()) {
field_type = TypeInstPtr::BOTTOM;
} elseif (field != NULL && field->is_static_constant()) {
ciObject* con = field->constant_value().as_object(); // Do not "join" in the previous type; it doesn't add value, // and may yield a vacuous result if the field is of interface type.
field_type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
assert(field_type != NULL, "field singleton type must be consistent");
} else {
field_type = TypeOopPtr::make_from_klass(elem_type->as_klass());
} if (UseCompressedOops) {
field_type = field_type->make_narrowoop();
basic_elem_type = T_NARROWOOP;
}
} else {
field_type = Type::get_const_basic_type(basic_elem_type);
}
} else {
offset = array_base + j * (intptr_t)element_size;
}
Node *field_val = value_from_mem(mem, ctl, basic_elem_type, field_type, field_addr_type, alloc); if (field_val == NULL) { // We weren't able to find a value for this field, // give up on eliminating this allocation.
// Remove any extra entries we added to the safepoint.
uint last = sfpt->req() - 1; for (int k = 0; k < j; k++) {
sfpt->del_req(last--);
}
_igvn._worklist.push(sfpt); // rollback processed safepoints while (safepoints_done.length() > 0) {
SafePointNode* sfpt_done = safepoints_done.pop(); // remove any extra entries we added to the safepoint
last = sfpt_done->req() - 1; for (int k = 0; k < nfields; k++) {
sfpt_done->del_req(last--);
}
JVMState *jvms = sfpt_done->jvms();
jvms->set_endoff(sfpt_done->req()); // Now make a pass over the debug information replacing any references // to SafePointScalarObjectNode with the allocated object. int start = jvms->debug_start(); int end = jvms->debug_end(); for (int i = start; i < end; i++) { if (sfpt_done->in(i)->is_SafePointScalarObject()) {
SafePointScalarObjectNode* scobj = sfpt_done->in(i)->as_SafePointScalarObject(); if (scobj->first_index(jvms) == sfpt_done->req() &&
scobj->n_fields() == (uint)nfields) {
assert(scobj->alloc() == alloc, "sanity");
sfpt_done->set_req(i, res);
}
}
}
_igvn._worklist.push(sfpt_done);
} #ifndef PRODUCT if (PrintEliminateAllocations) { if (field != NULL) {
tty->print("=== At SafePoint node %d can't find value of Field: ",
sfpt->_idx);
field->print(); int field_idx = C->get_alias_index(field_addr_type);
tty->print(" (alias_idx=%d)", field_idx);
} else { // Array's element
tty->print("=== At SafePoint node %d can't find value of array element [%d]",
sfpt->_idx, j);
}
tty->print(", which prevents elimination of: "); if (res == NULL)
alloc->dump(); else
res->dump();
} #endif returnfalse;
} if (UseCompressedOops && field_type->isa_narrowoop()) { // Enable "DecodeN(EncodeP(Allocate)) --> Allocate" transformation // to be able scalar replace the allocation. if (field_val->is_EncodeP()) {
field_val = field_val->in(1);
} else {
field_val = transform_later(new DecodeNNode(field_val, field_val->get_ptr_type()));
}
}
sfpt->add_req(field_val);
}
JVMState *jvms = sfpt->jvms();
jvms->set_endoff(sfpt->req()); // Now make a pass over the debug information replacing any references // to the allocated object with "sobj" int start = jvms->debug_start(); int end = jvms->debug_end();
sfpt->replace_edges_in_range(res, sobj, start, end, &_igvn);
_igvn._worklist.push(sfpt);
safepoints_done.append_if_missing(sfpt); // keep it for rollback
} returntrue;
}
// Set control to top. IGVN will remove the remaining projections
ac->set_req(0, top());
ac->replace_edge(res, top(), &_igvn);
// Disconnect src right away: it can help find new // opportunities for allocation elimination
Node* src = ac->in(ArrayCopyNode::Src);
ac->replace_edge(src, top(), &_igvn); // src can be top at this point if src and dest of the // arraycopy were the same if (src->outcnt() == 0 && !src->is_top()) {
_igvn.remove_dead_node(src);
}
}
_igvn._worklist.push(ac);
} else {
eliminate_gc_barrier(use);
}
j -= (oc1 - res->outcnt());
}
assert(res->outcnt() == 0, "all uses of allocated objects must be deleted");
_igvn.remove_dead_node(res);
}
// // Process other users of allocation's projections // if (_callprojs.resproj != NULL && _callprojs.resproj->outcnt() != 0) { // First disconnect stores captured by Initialize node. // If Initialize node is eliminated first in the following code, // it will kill such stores and DUIterator_Last will assert. for (DUIterator_Fast jmax, j = _callprojs.resproj->fast_outs(jmax); j < jmax; j++) {
Node* use = _callprojs.resproj->fast_out(j); if (use->is_AddP()) { // raw memory addresses used only by the initialization
_igvn.replace_node(use, C->top());
--j; --jmax;
}
} for (DUIterator_Last jmin, j = _callprojs.resproj->last_outs(jmin); j >= jmin; ) {
Node* use = _callprojs.resproj->last_out(j);
uint oc1 = _callprojs.resproj->outcnt(); if (use->is_Initialize()) { // Eliminate Initialize node.
InitializeNode *init = use->as_Initialize();
assert(init->outcnt() <= 2, "only a control and memory projection expected");
Node *ctrl_proj = init->proj_out_or_null(TypeFunc::Control); if (ctrl_proj != NULL) {
_igvn.replace_node(ctrl_proj, init->in(TypeFunc::Control)); #ifdef ASSERT // If the InitializeNode has no memory out, it will die, and tmp will become NULL
Node* tmp = init->in(TypeFunc::Control);
assert(tmp == NULL || tmp == _callprojs.fallthrough_catchproj, "allocation control projection"); #endif
}
Node *mem_proj = init->proj_out_or_null(TypeFunc::Memory); if (mem_proj != NULL) {
Node *mem = init->in(TypeFunc::Memory); #ifdef ASSERT if (mem->is_MergeMem()) {
assert(mem->in(TypeFunc::Memory) == _callprojs.fallthrough_memproj, "allocation memory projection");
} else {
assert(mem == _callprojs.fallthrough_memproj, "allocation memory projection");
} #endif
_igvn.replace_node(mem_proj, mem);
}
} else {
assert(false, "only Initialize or AddP expected");
}
j -= (oc1 - _callprojs.resproj->outcnt());
}
} if (_callprojs.fallthrough_catchproj != NULL) {
_igvn.replace_node(_callprojs.fallthrough_catchproj, alloc->in(TypeFunc::Control));
} if (_callprojs.fallthrough_memproj != NULL) {
_igvn.replace_node(_callprojs.fallthrough_memproj, alloc->in(TypeFunc::Memory));
} if (_callprojs.catchall_memproj != NULL) {
_igvn.replace_node(_callprojs.catchall_memproj, C->top());
} if (_callprojs.fallthrough_ioproj != NULL) {
_igvn.replace_node(_callprojs.fallthrough_ioproj, alloc->in(TypeFunc::I_O));
} if (_callprojs.catchall_ioproj != NULL) {
_igvn.replace_node(_callprojs.catchall_ioproj, C->top());
} if (_callprojs.catchall_catchproj != NULL) {
_igvn.replace_node(_callprojs.catchall_catchproj, C->top());
}
}
bool PhaseMacroExpand::eliminate_allocate_node(AllocateNode *alloc) { // If reallocation fails during deoptimization we'll pop all // interpreter frames for this compiled frame and that won't play // nice with JVMTI popframe. // We avoid this issue by eager reallocation when the popframe request // is received. if (!EliminateAllocations || !alloc->_is_non_escaping) { returnfalse;
}
Node* klass = alloc->in(AllocateNode::KlassNode); const TypeKlassPtr* tklass = _igvn.type(klass)->is_klassptr();
Node* res = alloc->result_cast(); // Eliminate boxing allocations which are not used // regardless scalar replaceable status. bool boxing_alloc = C->eliminate_boxing() &&
tklass->isa_instklassptr() &&
tklass->is_instklassptr()->instance_klass()->is_box_klass(); if (!alloc->_is_scalar_replaceable && (!boxing_alloc || (res != NULL))) { returnfalse;
}
GrowableArray <SafePointNode *> safepoints; if (!can_eliminate_allocation(alloc, safepoints)) { returnfalse;
}
if (!alloc->_is_scalar_replaceable) {
assert(res == NULL, "sanity"); // We can only eliminate allocation if all debug info references // are already replaced with SafePointScalarObject because // we can't search for a fields value without instance_id. if (safepoints.length() > 0) { returnfalse;
}
}
if (!scalar_replacement(alloc, safepoints)) { returnfalse;
}
CompileLog* log = C->log(); if (log != NULL) {
log->head("eliminate_allocation type='%d'",
log->identify(tklass->exact_klass()));
JVMState* p = alloc->jvms(); while (p != NULL) {
log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
p = p->caller();
}
log->tail("eliminate_allocation");
}
process_users_of_allocation(alloc);
#ifndef PRODUCT if (PrintEliminateAllocations) { if (alloc->is_AllocateArray())
tty->print_cr("++++ Eliminated: %d AllocateArray", alloc->_idx); else
tty->print_cr("++++ Eliminated: %d Allocate", alloc->_idx);
} #endif
returntrue;
}
bool PhaseMacroExpand::eliminate_boxing_node(CallStaticJavaNode *boxing) { // EA should remove all uses of non-escaping boxing node. if (!C->eliminate_boxing() || boxing->proj_out_or_null(TypeFunc::Parms) != NULL) { returnfalse;
}
//============================================================================= // // A L L O C A T I O N // // Allocation attempts to be fast in the case of frequent small objects. // It breaks down like this: // // 1) Size in doublewords is computed. This is a constant for objects and // variable for most arrays. Doubleword units are used to avoid size // overflow of huge doubleword arrays. We need doublewords in the end for // rounding. // // 2) Size is checked for being 'too large'. Too-large allocations will go // the slow path into the VM. The slow path can throw any required // exceptions, and does all the special checks for very large arrays. The // size test can constant-fold away for objects. For objects with // finalizers it constant-folds the otherway: you always go slow with // finalizers. // // 3) If NOT using TLABs, this is the contended loop-back point. // Load-Locked the heap top. If using TLABs normal-load the heap top. // // 4) Check that heap top + size*8 < max. If we fail go the slow ` route. // NOTE: "top+size*8" cannot wrap the 4Gig line! Here's why: for largish // "size*8" we always enter the VM, where "largish" is a constant picked small // enough that there's always space between the eden max and 4Gig (old space is // there so it's quite large) and large enough that the cost of entering the VM // is dwarfed by the cost to initialize the space. // // 5) If NOT using TLABs, Store-Conditional the adjusted heap top back // down. If contended, repeat at step 3. If using TLABs normal-store // adjusted heap top back down; there is no contention. // // 6) If !ZeroTLAB then Bulk-clear the object/array. Fill in klass & mark // fields. // // 7) Merge with the slow-path; cast the raw memory pointer to the correct // oop flavor. // //============================================================================= // FastAllocateSizeLimit value is in DOUBLEWORDS. // Allocations bigger than this always go the slow route. // This value must be small enough that allocation attempts that need to // trigger exceptions go the slow route. Also, it must be small enough so // that heap_top + size_in_bytes does not wrap around the 4Gig limit. //=============================================================================j// // %%% Here is an old comment from parseHelper.cpp; is it outdated? // The allocator will coalesce int->oop copies away. See comment in // coalesce.cpp about how this works. It depends critically on the exact // code shape produced here, so if you are changing this code shape // make sure the GC info for the heap-top is correct in and around the // slow-path call. //
void PhaseMacroExpand::expand_allocate_common(
AllocateNode* alloc, // allocation node to be expanded
Node* length, // array length for an array allocation const TypeFunc* slow_call_type, // Type of slow call
address slow_call_address, // Address of slow call
Node* valid_length_test // whether length is valid or not
)
{
Node* ctrl = alloc->in(TypeFunc::Control);
Node* mem = alloc->in(TypeFunc::Memory);
Node* i_o = alloc->in(TypeFunc::I_O);
Node* size_in_bytes = alloc->in(AllocateNode::AllocSize);
Node* klass_node = alloc->in(AllocateNode::KlassNode);
Node* initial_slow_test = alloc->in(AllocateNode::InitialTest);
assert(ctrl != NULL, "must have control");
// We need a Region and corresponding Phi's to merge the slow-path and fast-path results. // they will not be used if "always_slow" is set enum { slow_result_path = 1, fast_result_path = 2 };
Node *result_region = NULL;
Node *result_phi_rawmem = NULL;
Node *result_phi_rawoop = NULL;
Node *result_phi_i_o = NULL;
// The initial slow comparison is a size check, the comparison // we want to do is a BoolTest::gt bool expand_fast_path = true; int tv = _igvn.find_int_con(initial_slow_test, -1); if (tv >= 0) { // InitialTest has constant result // 0 - can fit in TLAB // 1 - always too big or negative
assert(tv <= 1, "0 or 1 if a constant");
expand_fast_path = (tv == 0);
initial_slow_test = NULL;
} else {
initial_slow_test = BoolNode::make_predicate(initial_slow_test, &_igvn);
}
if (!UseTLAB) { // Force slow-path allocation
expand_fast_path = false;
initial_slow_test = NULL;
}
bool allocation_has_use = (alloc->result_cast() != NULL); if (!allocation_has_use) {
InitializeNode* init = alloc->initialization(); if (init != NULL) {
init->remove(&_igvn);
} if (expand_fast_path && (initial_slow_test == NULL)) { // Remove allocation node and return. // Size is a non-negative constant -> no initial check needed -> directly to fast path. // Also, no usages -> empty fast path -> no fall out to slow path -> nothing left. #ifndef PRODUCT if (PrintEliminateAllocations) {
tty->print("NotUsed ");
Node* res = alloc->proj_out_or_null(TypeFunc::Parms); if (res != NULL) {
res->dump();
} else {
alloc->dump();
}
} #endif
yank_alloc_node(alloc); return;
}
}
// generate the initial test if necessary if (initial_slow_test != NULL ) {
assert (expand_fast_path, "Only need test if there is a fast path");
slow_region = new RegionNode(3);
// Now make the initial failure test. Usually a too-big test but // might be a TRUE for finalizers or a fancy class check for // newInstance0.
IfNode *toobig_iff = new IfNode(ctrl, initial_slow_test, PROB_MIN, COUNT_UNKNOWN);
transform_later(toobig_iff); // Plug the failing-too-big test into the slow-path region
Node *toobig_true = new IfTrueNode( toobig_iff );
transform_later(toobig_true);
slow_region ->init_req( too_big_or_final_path, toobig_true );
toobig_false = new IfFalseNode( toobig_iff );
transform_later(toobig_false);
} else { // No initial test, just fall into next case
assert(allocation_has_use || !expand_fast_path, "Should already have been handled");
toobig_false = ctrl;
debug_only(slow_region = NodeSentinel);
}
// If we are here there are several possibilities // - expand_fast_path is false - then only a slow path is expanded. That's it. // no_initial_check means a constant allocation. // - If check always evaluates to false -> expand_fast_path is false (see above) // - If check always evaluates to true -> directly into fast path (but may bailout to slowpath) // if !allocation_has_use the fast path is empty // if !allocation_has_use && no_initial_check // - Then there are no fastpath that can fall out to slowpath -> no allocation code at all. // removed by yank_alloc_node above.
Node *slow_mem = mem; // save the current memory state for slow path // generate the fast allocation code unless we know that the initial test will always go slow if (expand_fast_path) { // Fast path modifies only raw memory. if (mem->is_MergeMem()) {
mem = mem->as_MergeMem()->memory_at(Compile::AliasIdxRaw);
}
// allocate the Region and Phi nodes for the result
result_region = new RegionNode(3);
result_phi_rawmem = new PhiNode(result_region, Type::MEMORY, TypeRawPtr::BOTTOM);
result_phi_i_o = new PhiNode(result_region, Type::ABIO); // I/O is used for Prefetch
// Grab regular I/O before optional prefetch may change it. // Slow-path does no I/O so just set it to the original I/O.
result_phi_i_o->init_req(slow_result_path, i_o);
// Name successful fast-path variables
Node* fast_oop_ctrl;
Node* fast_oop_rawmem; if (allocation_has_use) {
Node* needgc_ctrl = NULL;
result_phi_rawoop = new PhiNode(result_region, TypeRawPtr::BOTTOM);
if (initial_slow_test != NULL) { // This completes all paths into the slow merge point
slow_region->init_req(need_gc_path, needgc_ctrl);
transform_later(slow_region);
} else { // No initial slow path needed! // Just fall from the need-GC path straight into the VM call.
slow_region = needgc_ctrl;
}
// Plug in the successful fast-path into the result merge point
result_region ->init_req(fast_result_path, fast_oop_ctrl);
result_phi_i_o ->init_req(fast_result_path, i_o);
result_phi_rawmem->init_req(fast_result_path, fast_oop_rawmem);
} else {
slow_region = ctrl;
result_phi_i_o = i_o; // Rename it to use in the following code.
}
// Generate slow-path call
CallNode *call = new CallStaticJavaNode(slow_call_type, slow_call_address,
OptoRuntime::stub_name(slow_call_address),
TypePtr::BOTTOM);
call->init_req(TypeFunc::Control, slow_region);
call->init_req(TypeFunc::I_O, top()); // does no i/o
call->init_req(TypeFunc::Memory, slow_mem); // may gc ptrs
call->init_req(TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr));
call->init_req(TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr));
call->init_req(TypeFunc::Parms+0, klass_node); if (length != NULL) {
call->init_req(TypeFunc::Parms+1, length);
}
// Copy debug information and adjust JVMState information, then replace // allocate node with the call
call->copy_call_debug_info(&_igvn, alloc); // For array allocations, copy the valid length check to the call node so Compile::final_graph_reshaping() can verify // that the call has the expected number of CatchProj nodes (in case the allocation always fails and the fallthrough // path dies). if (valid_length_test != NULL) {
call->add_req(valid_length_test);
} if (expand_fast_path) {
call->set_cnt(PROB_UNLIKELY_MAG(4)); // Same effect as RC_UNCOMMON.
} else { // Hook i_o projection to avoid its elimination during allocation // replacement (when only a slow call is generated).
call->set_req(TypeFunc::I_O, result_phi_i_o);
}
_igvn.replace_node(alloc, call);
transform_later(call);
// Identify the output projections from the allocate node and // adjust any references to them. // The control and io projections look like: // // v---Proj(ctrl) <-----+ v---CatchProj(ctrl) // Allocate Catch // ^---Proj(io) <-------+ ^---CatchProj(io) // // We are interested in the CatchProj nodes. //
call->extract_projections(&_callprojs, false/*separate_io_proj*/, false /*do_asserts*/);
// An allocate node has separate memory projections for the uses on // the control and i_o paths. Replace the control memory projection with // result_phi_rawmem (unless we are only generating a slow call when // both memory projections are combined) if (expand_fast_path && _callprojs.fallthrough_memproj != NULL) {
migrate_outs(_callprojs.fallthrough_memproj, result_phi_rawmem);
} // Now change uses of catchall_memproj to use fallthrough_memproj and delete // catchall_memproj so we end up with a call that has only 1 memory projection. if (_callprojs.catchall_memproj != NULL ) { if (_callprojs.fallthrough_memproj == NULL) {
_callprojs.fallthrough_memproj = new ProjNode(call, TypeFunc::Memory);
transform_later(_callprojs.fallthrough_memproj);
}
migrate_outs(_callprojs.catchall_memproj, _callprojs.fallthrough_memproj);
_igvn.remove_dead_node(_callprojs.catchall_memproj);
}
// An allocate node has separate i_o projections for the uses on the control // and i_o paths. Always replace the control i_o projection with result i_o // otherwise incoming i_o become dead when only a slow call is generated // (it is different from memory projections where both projections are // combined in such case). if (_callprojs.fallthrough_ioproj != NULL) {
migrate_outs(_callprojs.fallthrough_ioproj, result_phi_i_o);
} // Now change uses of catchall_ioproj to use fallthrough_ioproj and delete // catchall_ioproj so we end up with a call that has only 1 i_o projection. if (_callprojs.catchall_ioproj != NULL ) { if (_callprojs.fallthrough_ioproj == NULL) {
_callprojs.fallthrough_ioproj = new ProjNode(call, TypeFunc::I_O);
transform_later(_callprojs.fallthrough_ioproj);
}
migrate_outs(_callprojs.catchall_ioproj, _callprojs.fallthrough_ioproj);
_igvn.remove_dead_node(_callprojs.catchall_ioproj);
}
// if we generated only a slow call, we are done if (!expand_fast_path) { // Now we can unhook i_o. if (result_phi_i_o->outcnt() > 1) {
call->set_req(TypeFunc::I_O, top());
} else {
assert(result_phi_i_o->unique_ctrl_out() == call, "sanity"); // Case of new array with negative size known during compilation. // AllocateArrayNode::Ideal() optimization disconnect unreachable // following code since call to runtime will throw exception. // As result there will be no users of i_o after the call. // Leave i_o attached to this call to avoid problems in preceding graph.
} return;
}
if (_callprojs.fallthrough_catchproj != NULL) {
ctrl = _callprojs.fallthrough_catchproj->clone();
transform_later(ctrl);
_igvn.replace_node(_callprojs.fallthrough_catchproj, result_region);
} else {
ctrl = top();
}
Node *slow_result; if (_callprojs.resproj == NULL) { // no uses of the allocation result
slow_result = top();
} else {
slow_result = _callprojs.resproj->clone();
transform_later(slow_result);
_igvn.replace_node(_callprojs.resproj, result_phi_rawoop);
}
// Plug slow-path into result merge point
result_region->init_req( slow_result_path, ctrl);
transform_later(result_region); if (allocation_has_use) {
result_phi_rawoop->init_req(slow_result_path, slow_result);
transform_later(result_phi_rawoop);
}
result_phi_rawmem->init_req(slow_result_path, _callprojs.fallthrough_memproj);
transform_later(result_phi_rawmem);
transform_later(result_phi_i_o); // This completes all paths into the result merge point
}
// Remove alloc node that has no uses. void PhaseMacroExpand::yank_alloc_node(AllocateNode* alloc) {
Node* ctrl = alloc->in(TypeFunc::Control);
Node* mem = alloc->in(TypeFunc::Memory);
Node* i_o = alloc->in(TypeFunc::I_O);
alloc->extract_projections(&_callprojs, false/*separate_io_proj*/, false /*do_asserts*/); if (_callprojs.resproj != NULL) { for (DUIterator_Fast imax, i = _callprojs.resproj->fast_outs(imax); i < imax; i++) {
Node* use = _callprojs.resproj->fast_out(i);
use->isa_MemBar()->remove(&_igvn);
--imax;
--i; // back up iterator
}
assert(_callprojs.resproj->outcnt() == 0, "all uses must be deleted");
_igvn.remove_dead_node(_callprojs.resproj);
} if (_callprojs.fallthrough_catchproj != NULL) {
migrate_outs(_callprojs.fallthrough_catchproj, ctrl);
_igvn.remove_dead_node(_callprojs.fallthrough_catchproj);
} if (_callprojs.catchall_catchproj != NULL) {
_igvn.rehash_node_delayed(_callprojs.catchall_catchproj);
_callprojs.catchall_catchproj->set_req(0, top());
} if (_callprojs.fallthrough_proj != NULL) {
Node* catchnode = _callprojs.fallthrough_proj->unique_ctrl_out();
_igvn.remove_dead_node(catchnode);
_igvn.remove_dead_node(_callprojs.fallthrough_proj);
} if (_callprojs.fallthrough_memproj != NULL) {
migrate_outs(_callprojs.fallthrough_memproj, mem);
_igvn.remove_dead_node(_callprojs.fallthrough_memproj);
} if (_callprojs.fallthrough_ioproj != NULL) {
migrate_outs(_callprojs.fallthrough_ioproj, i_o);
_igvn.remove_dead_node(_callprojs.fallthrough_ioproj);
} if (_callprojs.catchall_memproj != NULL) {
_igvn.rehash_node_delayed(_callprojs.catchall_memproj);
_callprojs.catchall_memproj->set_req(0, top());
} if (_callprojs.catchall_ioproj != NULL) {
_igvn.rehash_node_delayed(_callprojs.catchall_ioproj);
_callprojs.catchall_ioproj->set_req(0, top());
} #ifndef PRODUCT if (PrintEliminateAllocations) { if (alloc->is_AllocateArray()) {
tty->print_cr("++++ Eliminated: %d AllocateArray", alloc->_idx);
} else {
tty->print_cr("++++ Eliminated: %d Allocate", alloc->_idx);
}
} #endif
_igvn.remove_dead_node(alloc);
}
void PhaseMacroExpand::expand_initialize_membar(AllocateNode* alloc, InitializeNode* init,
Node*& fast_oop_ctrl, Node*& fast_oop_rawmem) { // If initialization is performed by an array copy, any required // MemBarStoreStore was already added. If the object does not // escape no need for a MemBarStoreStore. If the object does not // escape in its initializer and memory barrier (MemBarStoreStore or // stronger) is already added at exit of initializer, also no need // for a MemBarStoreStore. Otherwise we need a MemBarStoreStore // so that stores that initialize this object can't be reordered // with a subsequent store that makes this object accessible by // other threads. // Other threads include java threads and JVM internal threads // (for example concurrent GC threads). Current concurrent GC // implementation: G1 will not scan newly created object, // so it's safe to skip storestore barrier when allocation does // not escape. if (!alloc->does_not_escape_thread() &&
!alloc->is_allocation_MemBar_redundant() &&
(init == NULL || !init->is_complete_with_arraycopy())) { if (init == NULL || init->req() < InitializeNode::RawStores) { // No InitializeNode or no stores captured by zeroing // elimination. Simply add the MemBarStoreStore after object // initialization.
MemBarNode* mb = MemBarNode::make(C, Op_MemBarStoreStore, Compile::AliasIdxBot);
transform_later(mb);
mb->init_req(TypeFunc::Memory, fast_oop_rawmem);
mb->init_req(TypeFunc::Control, fast_oop_ctrl);
fast_oop_ctrl = new ProjNode(mb, TypeFunc::Control);
transform_later(fast_oop_ctrl);
fast_oop_rawmem = new ProjNode(mb, TypeFunc::Memory);
transform_later(fast_oop_rawmem);
} else { // Add the MemBarStoreStore after the InitializeNode so that // all stores performing the initialization that were moved // before the InitializeNode happen before the storestore // barrier.
Node* ctrl = new ProjNode(init, TypeFunc::Control);
transform_later(ctrl);
Node* mem = new ProjNode(init, TypeFunc::Memory);
transform_later(mem);
// The MemBarStoreStore depends on control and memory coming // from the InitializeNode
mb->init_req(TypeFunc::Memory, mem);
mb->init_req(TypeFunc::Control, ctrl);
ctrl = new ProjNode(mb, TypeFunc::Control);
transform_later(ctrl);
mem = new ProjNode(mb, TypeFunc::Memory);
transform_later(mem);
// All nodes that depended on the InitializeNode for control // and memory must now depend on the MemBarNode that itself // depends on the InitializeNode if (init_ctrl != NULL) {
_igvn.replace_node(init_ctrl, ctrl);
} if (init_mem != NULL) {
_igvn.replace_node(init_mem, mem);
}
}
}
}
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.