8136931: more fine-grained condition checking for BMH species creation

Reviewed-by: psandoz, sundar
This commit is contained in:
Michael Haupt 2015-09-23 08:43:51 +02:00
parent 79396c340c
commit f1f609ddaa
3 changed files with 30 additions and 3 deletions

View File

@ -404,6 +404,14 @@ import jdk.internal.org.objectweb.asm.Type;
d = lookupCache(types);
// Class loading must have upgraded the cache.
assert(d != null && !d.isPlaceholder());
if (OBSERVE_BMH_SPECIES_CREATION) {
if (d == null) {
throw new IllegalStateException("d == null");
}
if (d.isPlaceholder()) {
throw new IllegalStateException("d is place holder");
}
}
return d;
}
static SpeciesData getForClass(String types, Class<? extends BoundMethodHandle> clazz) {
@ -415,6 +423,9 @@ import jdk.internal.org.objectweb.asm.Type;
if (d != null) return d;
d = new SpeciesData(types);
assert(d.isPlaceholder());
if (OBSERVE_BMH_SPECIES_CREATION && !d.isPlaceholder()) {
throw new IllegalStateException("d is not place holder");
}
CACHE.put(types, d);
return d;
}
@ -422,6 +433,15 @@ import jdk.internal.org.objectweb.asm.Type;
SpeciesData d2;
assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder());
assert(!d.isPlaceholder());
if (OBSERVE_BMH_SPECIES_CREATION) {
d2 = CACHE.get(types);
if (d2 != null && !d2.isPlaceholder()) {
throw new IllegalStateException("non-null d2 is not place holder");
}
if (d.isPlaceholder()) {
throw new IllegalStateException("d is place holder");
}
}
CACHE.put(types, d);
return d;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015, 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
@ -51,8 +51,12 @@ import sun.misc.Unsafe;
static final boolean PROFILE_GWT;
static final int CUSTOMIZE_THRESHOLD;
// This is a temporary property added for improved error reporting; it will
// be removed once it has served its purpose.
static final boolean OBSERVE_BMH_SPECIES_CREATION;
static {
final Object[] values = new Object[9];
final Object[] values = new Object[10];
AccessController.doPrivileged(new PrivilegedAction<>() {
public Void run() {
values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
@ -64,6 +68,7 @@ import sun.misc.Unsafe;
values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0);
values[7] = Boolean.parseBoolean(System.getProperty("java.lang.invoke.MethodHandle.PROFILE_GWT", "true"));
values[8] = Integer.getInteger("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", 127);
values[9] = Boolean.getBoolean("java.lang.invoke.MethodHandle.OBSERVE_BMH_SPECIES_CREATION");
return null;
}
});
@ -77,6 +82,8 @@ import sun.misc.Unsafe;
PROFILE_GWT = (Boolean) values[7];
CUSTOMIZE_THRESHOLD = (Integer) values[8];
OBSERVE_BMH_SPECIES_CREATION = (Boolean) values[9];
if (CUSTOMIZE_THRESHOLD < -1 || CUSTOMIZE_THRESHOLD > 127) {
throw newInternalError("CUSTOMIZE_THRESHOLD should be in [-1...127] range");
}

View File

@ -32,7 +32,7 @@
* @build LambdaFormTestCase
* @build LFCachingTestCase
* @build LFMultiThreadCachingTest
* @run main/othervm LFMultiThreadCachingTest
* @run main/othervm -Djava.lang.invoke.MethodHandle.OBSERVE_BMH_SPECIES_CREATION=true LFMultiThreadCachingTest
*/
import java.lang.invoke.MethodHandle;