8379180: C2: assert((ptr->bottom_type() == Type::TOP) || ((base == Compile::current()->top()) == (ptr->bottom_type()->make_ptr()->isa_oopptr() == nullptr))) failed: base input only needed for heap addresses

Reviewed-by: qamai, chagedorn
This commit is contained in:
Roland Westrelin 2026-03-10 09:35:35 +00:00
parent 9a26b4af34
commit 61a9c71983
2 changed files with 91 additions and 47 deletions

View File

@ -1818,81 +1818,81 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false,
Node* old_eden_top, Node* new_eden_top,
intx lines) {
enum { fall_in_path = 1, pf_path = 2 };
if( UseTLAB && AllocatePrefetchStyle == 2 ) {
if (UseTLAB && AllocatePrefetchStyle == 2) {
// Generate prefetch allocation with watermark check.
// As an allocation hits the watermark, we will prefetch starting
// at a "distance" away from watermark.
Node *pf_region = new RegionNode(3);
Node *pf_phi_rawmem = new PhiNode( pf_region, Type::MEMORY,
TypeRawPtr::BOTTOM );
Node* pf_region = new RegionNode(3);
Node* pf_phi_rawmem = new PhiNode(pf_region, Type::MEMORY,
TypeRawPtr::BOTTOM);
// I/O is used for Prefetch
Node *pf_phi_abio = new PhiNode( pf_region, Type::ABIO );
Node* pf_phi_abio = new PhiNode(pf_region, Type::ABIO);
Node *thread = new ThreadLocalNode();
Node* thread = new ThreadLocalNode();
transform_later(thread);
Node *eden_pf_adr = new AddPNode( top()/*not oop*/, thread,
_igvn.MakeConX(in_bytes(JavaThread::tlab_pf_top_offset())) );
Node* eden_pf_adr = new AddPNode(top()/*not oop*/, thread,
_igvn.MakeConX(in_bytes(JavaThread::tlab_pf_top_offset())));
transform_later(eden_pf_adr);
Node *old_pf_wm = new LoadPNode(needgc_false,
Node* old_pf_wm = new LoadPNode(needgc_false,
contended_phi_rawmem, eden_pf_adr,
TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM,
MemNode::unordered);
transform_later(old_pf_wm);
// check against new_eden_top
Node *need_pf_cmp = new CmpPNode( new_eden_top, old_pf_wm );
Node* need_pf_cmp = new CmpPNode(new_eden_top, old_pf_wm);
transform_later(need_pf_cmp);
Node *need_pf_bol = new BoolNode( need_pf_cmp, BoolTest::ge );
Node* need_pf_bol = new BoolNode(need_pf_cmp, BoolTest::ge);
transform_later(need_pf_bol);
IfNode *need_pf_iff = new IfNode( needgc_false, need_pf_bol,
PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN );
IfNode* need_pf_iff = new IfNode(needgc_false, need_pf_bol,
PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN);
transform_later(need_pf_iff);
// true node, add prefetchdistance
Node *need_pf_true = new IfTrueNode( need_pf_iff );
Node* need_pf_true = new IfTrueNode(need_pf_iff);
transform_later(need_pf_true);
Node *need_pf_false = new IfFalseNode( need_pf_iff );
Node* need_pf_false = new IfFalseNode(need_pf_iff);
transform_later(need_pf_false);
Node *new_pf_wmt = new AddPNode( top(), old_pf_wm,
_igvn.MakeConX(AllocatePrefetchDistance) );
transform_later(new_pf_wmt );
Node* new_pf_wmt = new AddPNode(top(), old_pf_wm,
_igvn.MakeConX(AllocatePrefetchDistance));
transform_later(new_pf_wmt);
new_pf_wmt->set_req(0, need_pf_true);
Node *store_new_wmt = new StorePNode(need_pf_true,
Node* store_new_wmt = new StorePNode(need_pf_true,
contended_phi_rawmem, eden_pf_adr,
TypeRawPtr::BOTTOM, new_pf_wmt,
MemNode::unordered);
transform_later(store_new_wmt);
// adding prefetches
pf_phi_abio->init_req( fall_in_path, i_o );
pf_phi_abio->init_req(fall_in_path, i_o);
Node *prefetch_adr;
Node *prefetch;
Node* prefetch_adr;
Node* prefetch;
uint step_size = AllocatePrefetchStepSize;
uint distance = 0;
for ( intx i = 0; i < lines; i++ ) {
prefetch_adr = new AddPNode( old_pf_wm, new_pf_wmt,
_igvn.MakeConX(distance) );
for (intx i = 0; i < lines; i++) {
prefetch_adr = new AddPNode(top(), new_pf_wmt,
_igvn.MakeConX(distance));
transform_later(prefetch_adr);
prefetch = new PrefetchAllocationNode( i_o, prefetch_adr );
prefetch = new PrefetchAllocationNode(i_o, prefetch_adr);
transform_later(prefetch);
distance += step_size;
i_o = prefetch;
}
pf_phi_abio->set_req( pf_path, i_o );
pf_phi_abio->set_req(pf_path, i_o);
pf_region->init_req( fall_in_path, need_pf_false );
pf_region->init_req( pf_path, need_pf_true );
pf_region->init_req(fall_in_path, need_pf_false);
pf_region->init_req(pf_path, need_pf_true);
pf_phi_rawmem->init_req( fall_in_path, contended_phi_rawmem );
pf_phi_rawmem->init_req( pf_path, store_new_wmt );
pf_phi_rawmem->init_req(fall_in_path, contended_phi_rawmem);
pf_phi_rawmem->init_req(pf_path, store_new_wmt);
transform_later(pf_region);
transform_later(pf_phi_rawmem);
@ -1901,7 +1901,7 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false,
needgc_false = pf_region;
contended_phi_rawmem = pf_phi_rawmem;
i_o = pf_phi_abio;
} else if( UseTLAB && AllocatePrefetchStyle == 3 ) {
} else if (UseTLAB && AllocatePrefetchStyle == 3) {
// Insert a prefetch instruction for each allocation.
// This code is used to generate 1 prefetch instruction per cache line.
@ -1910,7 +1910,7 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false,
uint distance = AllocatePrefetchDistance;
// Next cache address.
Node *cache_adr = new AddPNode(old_eden_top, old_eden_top,
Node* cache_adr = new AddPNode(top(), old_eden_top,
_igvn.MakeConX(step_size + distance));
transform_later(cache_adr);
cache_adr = new CastP2XNode(needgc_false, cache_adr);
@ -1924,36 +1924,36 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false,
transform_later(cache_adr);
// Prefetch
Node *prefetch = new PrefetchAllocationNode( contended_phi_rawmem, cache_adr );
Node* prefetch = new PrefetchAllocationNode(contended_phi_rawmem, cache_adr);
prefetch->set_req(0, needgc_false);
transform_later(prefetch);
contended_phi_rawmem = prefetch;
Node *prefetch_adr;
Node* prefetch_adr;
distance = step_size;
for ( intx i = 1; i < lines; i++ ) {
prefetch_adr = new AddPNode( cache_adr, cache_adr,
_igvn.MakeConX(distance) );
for (intx i = 1; i < lines; i++) {
prefetch_adr = new AddPNode(top(), cache_adr,
_igvn.MakeConX(distance));
transform_later(prefetch_adr);
prefetch = new PrefetchAllocationNode( contended_phi_rawmem, prefetch_adr );
prefetch = new PrefetchAllocationNode(contended_phi_rawmem, prefetch_adr);
transform_later(prefetch);
distance += step_size;
contended_phi_rawmem = prefetch;
}
} else if( AllocatePrefetchStyle > 0 ) {
} else if (AllocatePrefetchStyle > 0) {
// Insert a prefetch for each allocation only on the fast-path
Node *prefetch_adr;
Node *prefetch;
Node* prefetch_adr;
Node* prefetch;
// Generate several prefetch instructions.
uint step_size = AllocatePrefetchStepSize;
uint distance = AllocatePrefetchDistance;
for ( intx i = 0; i < lines; i++ ) {
prefetch_adr = new AddPNode( top(), new_eden_top,
_igvn.MakeConX(distance) );
for (intx i = 0; i < lines; i++) {
prefetch_adr = new AddPNode(top(), new_eden_top,
_igvn.MakeConX(distance));
transform_later(prefetch_adr);
prefetch = new PrefetchAllocationNode( i_o, prefetch_adr );
prefetch = new PrefetchAllocationNode(i_o, prefetch_adr);
// Do not let it float too high, since if eden_top == eden_end,
// both might be null.
if( i == 0 ) { // Set control for first prefetch, next follows it
if (i == 0) { // Set control for first prefetch, next follows it
prefetch->init_req(0, needgc_false);
}
transform_later(prefetch);

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2026 IBM Corporation. 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.
*/
/*
* @test
* @bug 8379180
* @summary test AllocatePrefetchStyle
*
* @run main/othervm -Xbatch -XX:AllocatePrefetchStyle=2 compiler.c2.TestAllocatePrefetchStyle
* @run main/othervm -Xbatch -XX:AllocatePrefetchStyle=3 compiler.c2.TestAllocatePrefetchStyle
*/
package compiler.c2;
public class TestAllocatePrefetchStyle {
public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
test();
}
}
private static int[] test() {
return new int[10];
}
}