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
2 changes: 1 addition & 1 deletion substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@ def capnp_compile(args):
if capnpcjava_home is None or not exists(capnpcjava_home + '/capnpc-java'):
mx.abort('Clone and build capnproto/capnproto-java from GitHub and point CAPNPROTOJAVA_HOME to its path.')
srcdir = 'src/com.oracle.svm.hosted/resources/'
outdir = 'src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/'
outdir = 'src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/imagelayer/'
command = ['capnp', 'compile',
'--import-path=' + capnpcjava_home + '/compiler/src/main/schema/',
'--output=' + capnpcjava_home + '/capnpc-java:' + outdir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
import com.oracle.graal.pointsto.heap.HeapSnapshotVerifier;
import com.oracle.graal.pointsto.heap.HostedValuesProvider;
import com.oracle.graal.pointsto.heap.ImageHeap;
import com.oracle.graal.pointsto.heap.ImageLayerLoader;
import com.oracle.graal.pointsto.heap.ImageLayerSnapshotUtil;
import com.oracle.graal.pointsto.heap.ImageLayerWriter;
import com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor;
import com.oracle.graal.pointsto.meta.AnalysisMetaAccess;
import com.oracle.graal.pointsto.meta.AnalysisMetaAccessExtensionProvider;
Expand Down Expand Up @@ -163,18 +160,9 @@ private PointsToAnalyzer(String mainEntryClass, OptionValues options) {
aUniverse.setBigBang(bigbang);
ImageHeap heap = new ImageHeap();
HostedValuesProvider hostedValuesProvider = new HostedValuesProvider(aMetaAccess, aUniverse);
ImageLayerSnapshotUtil imageLayerSnapshotUtil = new ImageLayerSnapshotUtil(false);
ImageLayerLoader imageLayerLoader = new ImageLayerLoader();
imageLayerLoader.setImageLayerSnapshotUtil(imageLayerSnapshotUtil);
imageLayerLoader.setUniverse(aUniverse);
aUniverse.setImageLayerLoader(imageLayerLoader);
StandaloneImageHeapScanner heapScanner = new StandaloneImageHeapScanner(bigbang, heap, aMetaAccess,
snippetReflection, aConstantReflection, new AnalysisObjectScanningObserver(bigbang), analysisClassLoader, hostedValuesProvider);
aUniverse.setHeapScanner(heapScanner);
imageLayerLoader.executeHeapScannerTasks();
ImageLayerWriter imageLayerWriter = new ImageLayerWriter(true, true);
imageLayerWriter.setImageLayerSnapshotUtil(imageLayerSnapshotUtil);
imageLayerWriter.setImageHeap(heap);
HeapSnapshotVerifier heapVerifier = new StandaloneHeapSnapshotVerifier(bigbang, heap, heapScanner);
aUniverse.setHeapVerifier(heapVerifier);
/* Register already created types as assignable. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected Class<?> getClass(String className) {
}

@Override
protected ValueSupplier<JavaConstant> readHostedFieldValue(AnalysisField field, JavaConstant receiver) {
public ValueSupplier<JavaConstant> readHostedFieldValue(AnalysisField field, JavaConstant receiver) {
ValueSupplier<JavaConstant> ret = super.readHostedFieldValue(field, receiver);
if (ret.get() == null && field.isStatic()) {
ResolvedJavaField wrappedField = field.getWrapped();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (c) 2024, 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.graal.pointsto.api;

import java.util.Set;

import com.oracle.graal.pointsto.flow.AnalysisParsedGraph;
import com.oracle.graal.pointsto.heap.ImageHeapConstant;
import com.oracle.graal.pointsto.meta.AnalysisField;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.util.AnalysisError;

import jdk.vm.ci.meta.JavaConstant;

public class ImageLayerLoader {
/**
* Returns the type id of the given type in the base layer if it exists. This makes the link
* between the base layer and the extension layer as the id is used to determine which constant
* should be linked to this type.
*/
@SuppressWarnings("unused")
public int lookupHostedTypeInBaseLayer(AnalysisType type) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public void initializeBaseLayerType(AnalysisType type) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

/**
* Returns the method id of the given method in the base layer if it exists. This makes the link
* between the base layer and the extension layer as the id is used to determine the method used
* in RelocatableConstants.
*/
@SuppressWarnings("unused")
public int lookupHostedMethodInBaseLayer(AnalysisMethod analysisMethod) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public void addBaseLayerMethod(AnalysisMethod analysisMethod) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

/**
* We save analysis parsed graphs for methods considered
* {@link AnalysisMethod#isTrackedAcrossLayers()}.
*/
@SuppressWarnings("unused")
public boolean hasAnalysisParsedGraph(AnalysisMethod analysisMethod) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public AnalysisParsedGraph getAnalysisParsedGraph(AnalysisMethod analysisMethod) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public void loadPriorStrengthenedGraphAnalysisElements(AnalysisMethod analysisMethod) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

/**
* Returns the field id of the given field in the base layer if it exists. This makes the link
* between the base layer and the extension image as the id allows to set the flags of the
* fields in the extension image.
*/
@SuppressWarnings("unused")
public int lookupHostedFieldInBaseLayer(AnalysisField analysisField) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public void addBaseLayerField(AnalysisField analysisField) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public void initializeBaseLayerField(AnalysisField analysisField) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public boolean hasValueForConstant(JavaConstant javaConstant) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public ImageHeapConstant getValueForConstant(JavaConstant javaConstant) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public Set<Integer> getRelinkedFields(AnalysisType type) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public boolean hasDynamicHubIdentityHashCode(int tid) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}

@SuppressWarnings("unused")
public int getDynamicHubIdentityHashCode(int tid) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.graal.pointsto.heap;
package com.oracle.graal.pointsto.api;

import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedAnalysisMethod;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedAnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.util.AnalysisError;

public class ImageLayerLoaderHelper {
protected ImageLayerLoader imageLayerLoader;

public ImageLayerLoaderHelper(ImageLayerLoader imageLayerLoader) {
this.imageLayerLoader = imageLayerLoader;
}

@SuppressWarnings("unused")
protected boolean loadType(PersistedAnalysisType.Reader typeData, int tid) {
return false;
}
public class ImageLayerWriter {

@SuppressWarnings("unused")
protected boolean loadMethod(PersistedAnalysisMethod.Reader methodData, int mid) {
return false;
public void onTrackedAcrossLayer(AnalysisMethod method, Object reason) {
throw AnalysisError.shouldNotReachHere("This method should not be called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private InstanceData(AnalysisType type, JavaConstant hostedObject, Object[] fiel
this(type, hostedObject, -1, -1);
}

ImageHeapInstance(AnalysisType type, JavaConstant hostedObject, int identityHashCode, int id) {
public ImageHeapInstance(AnalysisType type, JavaConstant hostedObject, int identityHashCode, int id) {
super(new InstanceData(type, hostedObject, null, identityHashCode, id), false);
}

Expand All @@ -98,7 +98,7 @@ public InstanceData getConstantData() {
return (InstanceData) super.getConstantData();
}

void setFieldValues(Object[] fieldValues) {
public void setFieldValues(Object[] fieldValues) {
boolean success = valuesHandle.compareAndSet(constantData, null, fieldValues);
AnalysisError.guarantee(success, "Unexpected field values reference for constant %s", this);
}
Expand Down Expand Up @@ -149,7 +149,18 @@ public Object getFieldValue(AnalysisField field) {
/* Base layer constants that are not relinked might not have field positions computed */
field.getType().getInstanceFields(true);
}
return arrayHandle.getVolatile(getFieldValues(), field.getPosition());
return getFieldValue(field.getPosition());
}

public Object getFieldValue(int fieldPosition) {
return arrayHandle.getVolatile(getFieldValues(), fieldPosition);
}

public int getFieldValuesSize() {
if (isReaderInstalled()) {
return getConstantData().fieldValues.length;
}
return 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private ObjectArrayData(AnalysisType type, JavaConstant hostedObject, Object[] a
this(type, hostedObject, length, -1, -1);
}

ImageHeapObjectArray(AnalysisType type, JavaConstant hostedObject, int length, int identityHashCode, int id) {
public ImageHeapObjectArray(AnalysisType type, JavaConstant hostedObject, int length, int identityHashCode, int id) {
super(new ObjectArrayData(type, hostedObject, null, length, identityHashCode, id), false);
}

Expand All @@ -92,7 +92,7 @@ public ObjectArrayData getConstantData() {
return (ObjectArrayData) super.getConstantData();
}

void setElementValues(Object[] elementValues) {
public void setElementValues(Object[] elementValues) {
boolean success = elementsHandle.compareAndSet(constantData, null, elementValues);
AnalysisError.guarantee(success, "Unexpected field values reference for constant %s", this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private PrimitiveArrayData(AnalysisType type, JavaConstant hostedObject, Object
this(type, hostedObject, array, length, -1, -1);
}

ImageHeapPrimitiveArray(AnalysisType type, JavaConstant hostedObject, Object array, int length, int identityHashCode, int id) {
public ImageHeapPrimitiveArray(AnalysisType type, JavaConstant hostedObject, Object array, int length, int identityHashCode, int id) {
super(new PrimitiveArrayData(type, hostedObject,
/* We need a clone of the hosted array so that we have a stable snapshot. */
getClone(type.getComponentType().getJavaKind(), array),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.oracle.graal.pointsto.ObjectScanner.ScanReason;
import com.oracle.graal.pointsto.ObjectScanningObserver;
import com.oracle.graal.pointsto.api.HostVM;
import com.oracle.graal.pointsto.api.ImageLayerLoader;
import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException;
import com.oracle.graal.pointsto.heap.HeapSnapshotVerifier.ScanningObserver;
import com.oracle.graal.pointsto.heap.value.ValueSupplier;
Expand Down Expand Up @@ -830,7 +831,7 @@ protected void rescanEconomicMap(EconomicMap<?, ?> object) {
}
}

void doScan(JavaConstant constant) {
public void doScan(JavaConstant constant) {
doScan(constant, OtherReason.RESCAN);
}

Expand Down
Loading