Skip to content

Commit

Permalink
[GR-2654] Adapt to jvmci-0.24 changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
vjovanov committed Feb 10, 2017
2 parents e1a8546 + 958d3ce commit 5b8cebe
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dist: trusty

env:
global:
- JVMCI_VERSION="jvmci-0.23"
- JVMCI_BASE_JDK8="jdk1.8.0_111"
- JVMCI_VERSION="jvmci-0.24"
- JVMCI_BASE_JDK8="jdk1.8.0_121"
- JDK9_EA_BUILD="152"
matrix:
- JDK="jdk8" GATE="style,fullbuild"
Expand Down
6 changes: 3 additions & 3 deletions ci_common/common.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
overlay = 2547479e992d700df5c4d5207a8dfe9c00a89747

java7 : {name : oraclejdk, version : "7", platformspecific: true}
java8 : {name : labsjdk, version : "8u111-jvmci-0.23", platformspecific: true}
java8 : {name : labsjdk, version : "8u121-jvmci-0.24", platformspecific: true}
java9 : {name : labsjdk, version : "9-SNAPSHOT", platformspecific: true}
java9EA : {name : labsjdk, version : "9-ea+152", platformspecific: true}
java8Debug : {name : labsjdk, version : "8u111-jvmci-0.23-fastdebug", platformspecific: true}
java9EA : {name : labsjdk, version : "9-ea+156", platformspecific: true}
java8Debug : {name : labsjdk, version : "8u121-jvmci-0.24-fastdebug", platformspecific: true}

mx : {
packages : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,24 @@ public class HotSpotResolvedJavaFieldTest extends HotSpotGraalCompilerTest {
private static final Class<?>[] classesWithInternalFields = {Class.class, ClassLoader.class};

private static final Method createFieldMethod;
private static final Field indexField;

static {
Method ret = null;
Method m = null;
Field f = null;
try {
Class<?> typeImpl = Class.forName("jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl");
ret = typeImpl.getDeclaredMethod("createField", String.class, JavaType.class, long.class, int.class);
Util.setAccessible(ret, true);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
e.printStackTrace();
m = typeImpl.getDeclaredMethod("createField", JavaType.class, long.class, int.class, int.class);
Util.setAccessible(m, true);
Class<?> fieldImpl = Class.forName("jdk.vm.ci.hotspot.HotSpotResolvedJavaFieldImpl");
f = fieldImpl.getDeclaredField("index");
Util.setAccessible(f, true);
} catch (Exception e) {
throw new AssertionError(e);
}

createFieldMethod = ret;
createFieldMethod = m;
indexField = f;
}

/**
Expand Down Expand Up @@ -96,21 +102,22 @@ public void testModifiersForInternal() {

/**
* Tests that {@code HotSpotResolvedObjectType#createField(String, JavaType, long, int)} always
* returns the same object for an internal field.
* returns an {@linkplain ResolvedJavaField#equals(Object) equivalent} object for an internal
* field.
*
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
@Test
public void testCachingForInternalFields() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Assert.assertTrue("HotSpotResolvedObjectTypeImpl.createField method not found", createFieldMethod != null);
public void testEquivalenceForInternalFields() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
for (Class<?> c : classesWithInternalFields) {
HotSpotResolvedObjectType type = HotSpotResolvedObjectType.fromObjectClass(c);
for (ResolvedJavaField field : type.getInstanceFields(false)) {
if (field.isInternal()) {
HotSpotResolvedJavaField expected = (HotSpotResolvedJavaField) field;
ResolvedJavaField actual = (ResolvedJavaField) createFieldMethod.invoke(type, expected.getName(), expected.getType(), expected.offset(), expected.getModifiers());
int index = indexField.getInt(expected);
ResolvedJavaField actual = (ResolvedJavaField) createFieldMethod.invoke(type, expected.getType(), expected.offset(), expected.getModifiers(), index);
Assert.assertEquals(expected, actual);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public final int logMinObjAlignment() {
return (int) (Math.log(objectAlignment) / Math.log(2));
}

public final int narrowKlassSize = getTypeSize("narrowKlass");
public final int narrowKlassSize = getFieldValue("CompilerToVM::Data::sizeof_narrowKlass", Integer.class, "int");
public final long narrowKlassBase = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_base", Long.class, "address");
public final int narrowKlassShift = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_shift", Integer.class, "int");
public final int logKlassAlignment = getConstant("LogKlassAlignmentInBytes", Integer.class);
Expand Down Expand Up @@ -288,7 +288,7 @@ public int layoutHelperElementTypePrimitiveInPlace() {
return (layoutHelperArrayTagTypeValue & ~layoutHelperArrayTagObjectValue) << layoutHelperArrayTagShift;
}

public final int vtableEntrySize = getTypeSize("vtableEntry");
public final int vtableEntrySize = getFieldValue("CompilerToVM::Data::sizeof_vtableEntry", Integer.class, "int");
public final int vtableEntryMethodOffset = getFieldOffset("vtableEntry::_method", Integer.class, "Method*");

public final int instanceKlassInitStateOffset = getFieldOffset("InstanceKlass::_init_state", Integer.class, "u1");
Expand All @@ -300,7 +300,7 @@ public int layoutHelperElementTypePrimitiveInPlace() {
public final int instanceKlassStateLinked = getConstant("InstanceKlass::linked", Integer.class);
public final int instanceKlassStateFullyInitialized = getConstant("InstanceKlass::fully_initialized", Integer.class);

public final int arrayOopDescSize = getTypeSize("arrayOopDesc");
public final int arrayOopDescSize = getFieldValue("CompilerToVM::Data::sizeof_arrayOopDesc", Integer.class, "int");

/**
* The offset of the array length word in an array object's header.
Expand Down Expand Up @@ -501,7 +501,7 @@ public long tlabIntArrayMarkWord() {
public final int compilationLevelFullOptimization = getConstant("CompLevel_full_optimization",
Integer.class);

public final int constantPoolSize = getTypeSize("ConstantPool");
public final int constantPoolSize = getFieldValue("CompilerToVM::Data::sizeof_ConstantPool", Integer.class, "int");
public final int constantPoolLengthOffset = getFieldOffset("ConstantPool::_length",
Integer.class, "int");

Expand Down Expand Up @@ -558,7 +558,7 @@ public int g1SATBQueueBufferOffset() {
public final int klassOffset = getFieldValue("java_lang_Class::_klass_offset", Integer.class, "int");
public final int arrayKlassOffset = getFieldValue("java_lang_Class::_array_klass_offset", Integer.class, "int");

public final int basicLockSize = getTypeSize("BasicLock");
public final int basicLockSize = getFieldValue("CompilerToVM::Data::sizeof_BasicLock", Integer.class, "int");
public final int basicLockDisplacedHeaderOffset = getFieldOffset("BasicLock::_displaced_header", Integer.class, "markOop");

public final int threadAllocatedBytesOffset = getFieldOffset("Thread::_allocated_bytes", Integer.class, "jlong");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
class JVMCIVersionCheck {

private static final int JVMCI8_MIN_MAJOR_VERSION = 0;
private static final int JVMCI8_MIN_MINOR_VERSION = 23;
private static final int JVMCI8_MIN_MINOR_VERSION = 24;

private static final int JVMCI9_MIN_EA_BUILD = 152;
private static final int JVMCI9_MIN_EA_BUILD = 156;

private static void failVersionCheck(boolean exit, String reason, Object... args) {
Formatter errorMessage = new Formatter().format(reason, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.replacements.ReplacementsImpl;
import org.graalvm.compiler.replacements.Snippets;
import org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider;
import org.graalvm.compiler.word.ObjectAccess;
import org.graalvm.compiler.word.Pointer;
import org.graalvm.compiler.word.Word;
Expand All @@ -45,6 +46,7 @@

import jdk.vm.ci.code.BytecodeFrame;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaMethod;

/**
Expand All @@ -57,7 +59,11 @@ public class ObjectAccessTest extends GraalCompilerTest implements Snippets {
private final ReplacementsImpl installer;

public ObjectAccessTest() {
installer = (ReplacementsImpl) getReplacements();
ReplacementsImpl d = (ReplacementsImpl) getReplacements();
MetaAccessProvider metaAccess = d.providers.getMetaAccess();
ClassfileBytecodeProvider bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, d.snippetReflection, ClassLoader.getSystemClassLoader());
installer = new ReplacementsImpl(d.providers, d.snippetReflection, bytecodeProvider, d.target);
installer.setGraphBuilderPlugins(d.getGraphBuilderPlugins());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public ClassfileBytecodeProvider(MetaAccessProvider metaAccess, SnippetReflectio
this.loader = cl == null ? ClassLoader.getSystemClassLoader() : cl;
}

public ClassfileBytecodeProvider(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, ClassLoader loader) {
this.metaAccess = metaAccess;
this.snippetReflection = snippetReflection;
this.loader = loader;
}

@Override
public Bytecode getBytecode(ResolvedJavaMethod method) {
Classfile classfile = getClassfile(resolveToClass(method.getDeclaringClass().getName()));
Expand Down

0 comments on commit 5b8cebe

Please sign in to comment.