8359235: C1 compilation fails with "assert(is_single_stack() && !is_virtual()) failed: type check"

Reviewed-by: thartmann, dlong
This commit is contained in:
Guanqiang Han 2025-08-13 10:52:54 +00:00 committed by Tobias Hartmann
parent e77cdd93ea
commit f3b34d32d6
6 changed files with 84 additions and 8 deletions

View file

@ -2813,7 +2813,7 @@ void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest, LIR_PatchCode patch_code, C
return;
}
__ lea(dest->as_register_lo(), as_Address(addr->as_address_ptr()));
__ lea(dest->as_pointer_register(), as_Address(addr->as_address_ptr()));
}

View file

@ -981,7 +981,7 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) {
CallingConvention* cc = frame_map()->c_calling_convention(&signature);
const LIR_Opr result_reg = result_register_for(x->type());
LIR_Opr addr = new_pointer_register();
LIR_Opr addr = new_register(T_ADDRESS);
__ leal(LIR_OprFact::address(a), addr);
crc.load_item_force(cc->at(0));
@ -1058,7 +1058,7 @@ void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
CallingConvention* cc = frame_map()->c_calling_convention(&signature);
const LIR_Opr result_reg = result_register_for(x->type());
LIR_Opr addr = new_pointer_register();
LIR_Opr addr = new_register(T_ADDRESS);
__ leal(LIR_OprFact::address(a), addr);
crc.load_item_force(cc->at(0));

View file

@ -1821,7 +1821,7 @@ void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest, LIR_PatchCode patch_code, C
}
LIR_Address* adr = addr->as_address_ptr();
Register dst = dest->as_register_lo();
Register dst = dest->as_pointer_register();
assert_different_registers(dst, t0);
if (adr->base()->is_valid() && dst == adr->base()->as_pointer_register() && (!adr->index()->is_cpu_register())) {

View file

@ -837,7 +837,7 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) {
CallingConvention* cc = frame_map()->c_calling_convention(&signature);
const LIR_Opr result_reg = result_register_for(x->type());
LIR_Opr addr = new_pointer_register();
LIR_Opr addr = new_register(T_ADDRESS);
__ leal(LIR_OprFact::address(a), addr);
crc.load_item_force(cc->at(0));

View file

@ -961,7 +961,7 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) {
CallingConvention* cc = frame_map()->c_calling_convention(&signature);
const LIR_Opr result_reg = result_register_for(x->type());
LIR_Opr addr = new_pointer_register();
LIR_Opr addr = new_register(T_ADDRESS);
__ leal(LIR_OprFact::address(a), addr);
crc.load_item_force(cc->at(0));
@ -1100,10 +1100,10 @@ void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
CallingConvention* cc = frame_map()->c_calling_convention(&signature);
const LIR_Opr result_reg = result_register_for(x->type());
LIR_Opr ptr_addr_a = new_pointer_register();
LIR_Opr ptr_addr_a = new_register(T_ADDRESS);
__ leal(LIR_OprFact::address(addr_a), ptr_addr_a);
LIR_Opr ptr_addr_b = new_pointer_register();
LIR_Opr ptr_addr_b = new_register(T_ADDRESS);
__ leal(LIR_OprFact::address(addr_b), ptr_addr_b);
__ move(ptr_addr_a, cc->at(0));

View file

@ -0,0 +1,76 @@
/*
* Copyright (c) 2025, 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.
*/
/**
* @test
* @bug 8359235
* @summary Test C1 stack2reg after fixing incorrect use of T_LONG in intrinsic
* @requires vm.debug == true & vm.compiler1.enabled
* @run main/othervm -XX:TieredStopAtLevel=1
* -XX:C1MaxInlineSize=200
* -XX:CompileThreshold=10
* -XX:CompileCommand=compileonly,java.lang.invoke.LambdaFormEditor::putInCache
* compiler.intrinsics.TestStack2RegSlotMismatch
*/
package compiler.intrinsics;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
public class TestStack2RegSlotMismatch {
public static int target(int x, int y) {
return x + y;
}
public static void main(String[] args) throws Throwable {
MethodHandle mh = MethodHandles.lookup().findStatic(
TestStack2RegSlotMismatch.class,
"target",
MethodType.methodType(int.class, int.class, int.class)
);
List<Object> argsList = new ArrayList<>();
int j = 0;
for (int i = 0; i < 50; i++) {
mh = MethodHandles.dropArguments(mh, 0, int.class);
argsList.add(0);
argsList.add(1);
argsList.add(2);
Object result = mh.invokeWithArguments(argsList);
j += (int) result;
argsList.remove(argsList.size() - 1);
argsList.remove(argsList.size() - 1);
if (i % 5 == 0) {
Thread.sleep(1000);
}
}
if (j == 150) {
System.out.println("passed");
} else {
throw new Exception("TestStack2RegSlotMismatch Error");
}
}
}