8279619: [JVMCI] improve EncodedSpeculationReason
Reviewed-by: never
This commit is contained in:
parent
7449e1c661
commit
80739e11b5
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta
test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test
3
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/EncodedSpeculationReason.java
3
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/EncodedSpeculationReason.java
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 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
|
||||
@ -61,6 +61,7 @@ public class EncodedSpeculationReason implements SpeculationReason {
|
||||
if (encoding == null) {
|
||||
encoding = encodingSupplier.get();
|
||||
encoding.addInt(groupId);
|
||||
encoding.addInt(groupName.hashCode());
|
||||
for (Object o : context) {
|
||||
if (o == null) {
|
||||
encoding.addInt(0);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 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
|
||||
@ -20,6 +20,19 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @requires vm.jvmci
|
||||
* @library ../../../../../
|
||||
* @modules java.base/jdk.internal.reflect
|
||||
* jdk.internal.vm.ci/jdk.vm.ci.meta
|
||||
* jdk.internal.vm.ci/jdk.vm.ci.code
|
||||
* jdk.internal.vm.ci/jdk.vm.ci.runtime
|
||||
* jdk.internal.vm.ci/jdk.vm.ci.common
|
||||
* java.base/jdk.internal.misc
|
||||
* @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestSpeculationLog
|
||||
*/
|
||||
package jdk.vm.ci.runtime.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -31,7 +44,9 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.code.CodeCacheProvider;
|
||||
import jdk.vm.ci.meta.EncodedSpeculationReason;
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
import jdk.vm.ci.meta.MetaAccessProvider;
|
||||
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
import jdk.vm.ci.meta.ResolvedJavaType;
|
||||
import jdk.vm.ci.meta.SpeculationLog;
|
||||
@ -128,4 +143,28 @@ public class TestSpeculationLog extends MethodUniverse {
|
||||
JavaConstant e2 = metaAccess.encodeSpeculation(s2);
|
||||
Assert.assertTrue("speculation encoding should maintain identity", e1.equals(e2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodedSpeculationReasonIncludesGroupName() {
|
||||
MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
|
||||
CodeCacheProvider codeCache = JVMCI.getRuntime().getHostJVMCIBackend().getCodeCache();
|
||||
SpeculationLog log = codeCache.createSpeculationLog();
|
||||
Object[] context = {"context"};
|
||||
SpeculationLog.SpeculationReason sr1 = new EncodedSpeculationReason(0, "group0", context);
|
||||
SpeculationLog.SpeculationReason sr2 = new EncodedSpeculationReason(0, "group1", context);
|
||||
SpeculationLog.Speculation s1 = log.speculate(sr1);
|
||||
SpeculationLog.Speculation s2 = log.speculate(sr2);
|
||||
JavaConstant es1 = metaAccess.encodeSpeculation(s1);
|
||||
JavaConstant es2 = metaAccess.encodeSpeculation(s2);
|
||||
if (es1.equals(es2)) {
|
||||
Assert.fail(
|
||||
String.format("EncodedSpeculationReasons with different groupName should produce unique encoded speculations:%n" +
|
||||
" Reason 1: %s%n" +
|
||||
" Reason 2: %s%n" +
|
||||
" Speculation 1: %s%n" +
|
||||
" Speculation 2: %s%n" +
|
||||
" Encoded speculation 1: %s%n" +
|
||||
" Encoded speculation 2: %s%n", sr1, sr2, s1, s2, es1, es2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user