Skip to content

Commit

Permalink
Replace AnalysisField[] in SubstrateKnownTruffleTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
gergo- committed Oct 13, 2022
1 parent 5520574 commit 3d9720f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ protected ResolvedJavaField findField(ResolvedJavaType declaringClass, String na
}
throw new GraalError("Could not find required field %s.%s", declaringClass.getName(), name);
}

protected ResolvedJavaField[] getInstanceFields(ResolvedJavaType type, boolean includeSuperclasses) {
return type.getInstanceFields(includeSuperclasses);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, 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
Expand Down Expand Up @@ -57,7 +57,7 @@ public class KnownTruffleTypes extends AbstractKnownTruffleTypes {
public final ResolvedJavaField fieldEmptyLongArray = findField(classFrameClass, "EMPTY_LONG_ARRAY");
public final ResolvedJavaField fieldEmptyByteArray = findField(classFrameClass, "EMPTY_BYTE_ARRAY");

public final ResolvedJavaField[] frameFields = classFrameClass.getInstanceFields(true);
public final ResolvedJavaField[] frameFields = getInstanceFields(classFrameClass, true);

public final ResolvedJavaField fieldFrameDescriptorDefaultValue = findField(classFrameDescriptor, "defaultValue");
public final ResolvedJavaField fieldFrameDescriptorMaterializeCalled = findField(classFrameDescriptor, "materializeCalled");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, 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
Expand All @@ -24,8 +24,11 @@
*/
package com.oracle.svm.truffle.api;

import java.util.Arrays;

import org.graalvm.compiler.truffle.compiler.substitutions.KnownTruffleTypes;

import com.oracle.graal.pointsto.meta.AnalysisField;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.svm.core.heap.ReferenceInternals;
import com.oracle.svm.core.heap.Target_java_lang_ref_Reference;
Expand Down Expand Up @@ -55,4 +58,15 @@ protected ResolvedJavaType lookupType(Class<?> c) {
type.registerAsReachable();
return type;
}

@Override
protected ResolvedJavaField[] getInstanceFields(ResolvedJavaType type, boolean includeSuperclasses) {
AnalysisField[] fields = ((AnalysisType) type).getInstanceFields(includeSuperclasses);
/*
* We must not embed an object of dynamic type AnalysisField[] in the image heap. Object
* replacement does not replace arrays, only their elements. Therefore we replace the array
* manually by one with a dynamic type allowed in the image heap.
*/
return Arrays.copyOf(fields, fields.length, ResolvedJavaField[].class);
}
}

0 comments on commit 3d9720f

Please sign in to comment.