Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,25 +318,13 @@ public List<Class<? extends Feature>> getRequiredFeatures() {

@Override
public void duringSetup(DuringSetupAccess c) {
DuringSetupAccessImpl config = (DuringSetupAccessImpl) c;
AnalysisMetaAccess aMetaAccess = config.getMetaAccess();

try {
/*
* Check early that the classpath is set up correctly. The base class of SubstrateType
* is the NodeClass from Truffle. So we require Truffle on the class path for any images
* and tests that use Graal at run time.
*/
aMetaAccess.lookupJavaType(SubstrateType.class);
} catch (NoClassDefFoundError ex) {
throw VMError.shouldNotReachHere("Building a native image with Graal support requires Truffle on the class path. For unit tests run with 'svmtest', add the option '--truffle'.");
}

ImageSingletons.add(GraalSupport.class, new GraalSupport());

if (!ImageSingletons.contains(RuntimeGraalSetup.class)) {
ImageSingletons.add(RuntimeGraalSetup.class, new SubstrateRuntimeGraalSetup());
}

DuringSetupAccessImpl config = (DuringSetupAccessImpl) c;
AnalysisMetaAccess aMetaAccess = config.getMetaAccess();
GraalProviderObjectReplacements providerReplacements = ImageSingletons.lookup(RuntimeGraalSetup.class).getProviderObjectReplacements(aMetaAccess);
objectReplacer = new GraalObjectReplacer(config.getUniverse(), aMetaAccess, providerReplacements);
config.registerObjectReplacer(objectReplacer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public synchronized SubstrateField createField(ResolvedJavaField original) {
if (ReadableJavaField.injectFinalForRuntimeCompilation(aField.wrapped)) {
modifiers = modifiers | Modifier.FINAL;
}
sField = new SubstrateField(aMetaAccess, aField, modifiers, stringTable);
sField = new SubstrateField(aField, modifiers, stringTable);
fields.put(aField, sField);

sField.setLinks(createType(aField.getType()), createType(aField.getDeclaringClass()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,11 @@
import com.oracle.svm.core.meta.SharedField;
import com.oracle.svm.core.util.HostedStringDeduplication;
import com.oracle.svm.core.util.VMError;
import com.oracle.truffle.api.nodes.Node.Child;
import com.oracle.truffle.api.nodes.Node.Children;
import com.oracle.truffle.api.nodes.NodeCloneable;

import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.PrimitiveConstant;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaType;

public class SubstrateField implements SharedField {

Expand All @@ -66,21 +61,12 @@ public class SubstrateField implements SharedField {
@UnknownObjectField(types = {DirectSubstrateObjectConstant.class, PrimitiveConstant.class}, fullyQualifiedTypes = "jdk.vm.ci.meta.NullConstant")//
JavaConstant constantValue;

/* Truffle access this information frequently, so it is worth caching it in a field. */
final boolean truffleChildField;
final boolean truffleChildrenField;
final boolean truffleCloneableField;

public SubstrateField(MetaAccessProvider originalMetaAccess, ResolvedJavaField original, int modifiers, HostedStringDeduplication stringTable) {
public SubstrateField(ResolvedJavaField original, int modifiers, HostedStringDeduplication stringTable) {
VMError.guarantee(!original.isInternal(), "Internal fields are not supported for JIT compilation");

this.modifiers = modifiers;
this.name = stringTable.deduplicate(original.getName(), true);
this.hashCode = original.hashCode();

truffleChildField = original.getAnnotation(Child.class) != null;
truffleChildrenField = original.getAnnotation(Children.class) != null;
truffleCloneableField = originalMetaAccess.lookupJavaType(NodeCloneable.class).isAssignableFrom((ResolvedJavaType) original.getType());
}

@Platforms(Platform.HOSTED_ONLY.class)
Expand Down
Loading