diff options
author | Gilles Duboscq <gdub@openjdk.org> | 2024-03-03 11:05:33 +0000 |
---|---|---|
committer | Gilles Duboscq <gdub@openjdk.org> | 2024-03-03 11:05:33 +0000 |
commit | 31ac8714e0593f2feaa8e9ebaf32bab904ba6d11 (patch) | |
tree | cf81df47ea73cf95bd8985c93ee51c40a49fa56f | |
parent | 37e01efb7831e29068f834fe0629595cb721b90d (diff) |
Reviewed-by: dnsimon, never, gli
3 files changed, 32 insertions, 4 deletions
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java index 6b9381df1ec..4c9dc509ce1 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -632,7 +632,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp for (int i = 0; i < localVariableTableLength; i++) { final int startBci = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementStartBciOffset); - final int endBci = startBci + UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementLengthOffset); + final int endBci = startBci + UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementLengthOffset) - 1; final int nameCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementNameCpIndexOffset); final int typeCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementDescriptorCpIndexOffset); final int slot = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementSlotOffset); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java index ff444ffe094..c68ce13d811 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -41,10 +41,19 @@ public class Local { this.type = type; } + /** + * Returns the first BCI at which this local has a value (inclusive). + */ public int getStartBCI() { return startBci; } + + /** + * Returns the last BCI at which this local has a value (inclusive). + * If the value returned is less than {@link #getStartBCI}, this object denotes a local + * variable that is never live. + */ public int getEndBCI() { return endBci; } diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java index d12148b1983..ae077b3b3f4 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java @@ -95,6 +95,8 @@ import java.lang.classfile.attribute.CodeAttribute; import jdk.vm.ci.meta.ConstantPool; import jdk.vm.ci.meta.ExceptionHandler; +import jdk.vm.ci.meta.Local; +import jdk.vm.ci.meta.LocalVariableTable; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaMethod.Parameter; import jdk.vm.ci.meta.ResolvedJavaType; @@ -734,6 +736,24 @@ public class TestResolvedJavaMethod extends MethodUniverse { Assert.assertTrue(processedMethodWithManyArgs[0]); } + @Test + public void getLocalVariableTableTest() { + for (ResolvedJavaMethod m : methods.values()) { + LocalVariableTable table = m.getLocalVariableTable(); + if (table == null) { + continue; + } + for (Local l : table.getLocals()) { + if (l.getStartBCI() < 0) { + throw new AssertionError(m.format("%H.%n(%p)") + " local " + l.getName() + " starts at " + l.getStartBCI()); + } + if (l.getEndBCI() >= m.getCodeSize()) { + throw new AssertionError(m.format("%H.%n(%p)") + " (" + m.getCodeSize() + "bytes) local " + l.getName() + " ends at " + l.getEndBCI()); + } + } + } + } + private Method findTestMethod(Method apiMethod) { String testName = apiMethod.getName() + "Test"; for (Method m : getClass().getDeclaredMethods()) { @@ -756,7 +776,6 @@ public class TestResolvedJavaMethod extends MethodUniverse { "canBeInlined", "shouldBeInlined", "getLineNumberTable", - "getLocalVariableTable", "isInVirtualMethodTable", "toParameterTypes", "getParameterAnnotation", |