mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
8307588: [JVMCI] HotSpotConstantPool#lookupBootstrapMethodInvocation broken by JDK-8301995
Reviewed-by: dnsimon, never, kvn
(cherry picked from commit 040cb7b5a9)
This commit is contained in:
committed by
Vitaly Provodin
parent
5141c38d45
commit
2b8b6f87ba
@@ -284,16 +284,6 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
return index < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@code ConstantPool::decode_invokedynamic_index}.
|
||||
*/
|
||||
private static int decodeInvokedynamicIndex(int i) {
|
||||
if (!isInvokedynamicIndex(i)) {
|
||||
throw new IllegalArgumentException("not an invokedynamic index: " + i);
|
||||
}
|
||||
return ~i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the raw {@code ConstantPool*} value for the this constant pool.
|
||||
*/
|
||||
@@ -824,18 +814,16 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleO
|
||||
* @return constant pool index
|
||||
*/
|
||||
public int rawIndexToConstantPoolIndex(int rawIndex, int opcode) {
|
||||
int index;
|
||||
if (isInvokedynamicIndex(rawIndex)) {
|
||||
if (opcode != Bytecodes.INVOKEDYNAMIC) {
|
||||
throw new IllegalArgumentException("expected INVOKEDYNAMIC at " + rawIndex + ", got " + opcode);
|
||||
}
|
||||
return index = decodeInvokedynamicIndex(rawIndex);
|
||||
} else {
|
||||
if (opcode == Bytecodes.INVOKEDYNAMIC) {
|
||||
throw new IllegalArgumentException("unexpected INVOKEDYNAMIC at " + rawIndex);
|
||||
}
|
||||
index = rawIndexToConstantPoolCacheIndex(rawIndex, opcode);
|
||||
return compilerToVM().resolveInvokeDynamicInPool(this, rawIndex);
|
||||
}
|
||||
if (opcode == Bytecodes.INVOKEDYNAMIC) {
|
||||
throw new IllegalArgumentException("unexpected INVOKEDYNAMIC at " + rawIndex);
|
||||
}
|
||||
int index = rawIndexToConstantPoolCacheIndex(rawIndex, opcode);
|
||||
return compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2023, 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
|
||||
@@ -333,6 +333,8 @@ public class TestDynamicConstant implements Opcodes {
|
||||
Assert.assertTrue((code[bci] & 0xff) == INVOKEDYNAMIC, "unexpected bytecode");
|
||||
int cpi = beS4(code, bci + 1);
|
||||
method.getConstantPool().loadReferencedType(cpi, INVOKEDYNAMIC, false);
|
||||
BootstrapMethodInvocation bmi = method.getConstantPool().lookupBootstrapMethodInvocation(cpi, INVOKEDYNAMIC);
|
||||
Assert.assertEquals(bmi.getName(), "do_concat");
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
|
||||
Reference in New Issue
Block a user