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 @@ -228,22 +228,28 @@ private static void specifyAlignment(MEM_EXTENDED_PARAMETER extendedParameter, M
* the memory layout that the native code expects, it is sufficient to ensure the correct
* order of the fields, which is easily done by prefixing the field names.
*/
extendedParameter.f1Type(MemExtendedParameterAddressRequirements);
extendedParameter.f2Pointer(addressRequirements.rawValue());
addressRequirements.f1LowestStartingAddress(WordFactory.nullPointer());
addressRequirements.f2HighestEndingAddress(WordFactory.nullPointer());
addressRequirements.f3Alignment(alignment);
extendedParameter.setF1Type(MemExtendedParameterAddressRequirements);
extendedParameter.setF2Pointer(addressRequirements.rawValue());
addressRequirements.setF1LowestStartingAddress(WordFactory.nullPointer());
addressRequirements.setF2HighestEndingAddress(WordFactory.nullPointer());
addressRequirements.setF3Alignment(alignment);
}

/** Represents an extended parameter for a function that manages virtual memory. */
@RawStructure
private interface MEM_EXTENDED_PARAMETER extends PointerBase {
/* This structure must exactly match the memory layout expected by the native code. */
@RawField
void f1Type(long value);
void setF1Type(long value);

@RawField
void f2Pointer(long value);
long getF1Type();

@RawField
void setF2Pointer(long value);

@RawField
long getF2Pointer();
}

/** MEM_EXTENDED_PARAMETER_TYPE enumeration Constants. */
Expand All @@ -257,13 +263,22 @@ private interface MEM_EXTENDED_PARAMETER extends PointerBase {
private interface MEM_ADDRESS_REQUIREMENTS extends PointerBase {
/* This structure must exactly match the memory layout expected by the native code. */
@RawField
void f1LowestStartingAddress(PointerBase value);
void setF1LowestStartingAddress(PointerBase value);

@RawField
PointerBase getF1LowestStartingAddress();

@RawField
void setF2HighestEndingAddress(PointerBase value);

@RawField
PointerBase getF2HighestEndingAddress();

@RawField
void f2HighestEndingAddress(PointerBase value);
void setF3Alignment(UnsignedWord value);

@RawField
void f3Alignment(UnsignedWord value);
UnsignedWord getF3Alignment();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLev
log.string("General purpose register values:").indent(true);
RegisterDumper.singleton().dumpRegisters(log, context.getRegisterContext(), printLocationInfo, allowJavaHeapAccess, allowUnsafeOperations);
log.indent(false);
} else if (CalleeSavedRegisters.supportedByPlatform() && context.frameHasCalleeSavedRegisters()) {
} else if (CalleeSavedRegisters.supportedByPlatform() && context.getFrameHasCalleeSavedRegisters()) {
CalleeSavedRegisters.singleton().dumpRegisters(log, context.getStackPointer(), printLocationInfo, allowJavaHeapAccess, allowUnsafeOperations);
}
}
Expand Down Expand Up @@ -1037,7 +1037,7 @@ public interface ErrorContext extends PointerBase {
void setRegisterContext(RegisterDumper.Context value);

@RawField
boolean frameHasCalleeSavedRegisters();
boolean getFrameHasCalleeSavedRegisters();

@RawField
void setFrameHasCalleeSavedRegisters(boolean value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.graalvm.compiler.word.Word;
import org.graalvm.nativeimage.c.function.CodePointer;
import org.graalvm.nativeimage.c.struct.RawField;
import org.graalvm.nativeimage.c.struct.RawFieldOffset;
import org.graalvm.nativeimage.c.struct.RawStructure;
import org.graalvm.word.UnsignedWord;

Expand All @@ -36,6 +37,7 @@
import com.oracle.svm.core.deopt.SubstrateInstalledCode;
import com.oracle.svm.core.heap.RuntimeCodeInfoGCSupport;
import com.oracle.svm.core.util.DuplicatedInNativeCode;
import com.oracle.svm.core.util.VMError;

import jdk.vm.ci.code.InstalledCode;

Expand Down Expand Up @@ -246,6 +248,11 @@ interface CodeInfoImpl extends CodeInfo {
@RawField
Word getGCData();

@RawFieldOffset
static int offsetOfGCData() {
throw VMError.unimplemented(); // replaced
}

@RawField
void setAllObjectsAreInImageHeap(boolean value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.util.GraalAccess;
import com.oracle.svm.core.c.struct.PinnedObjectField;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.c.BuiltinDirectives;
import com.oracle.svm.hosted.c.NativeCodeContext;
import com.oracle.svm.hosted.c.NativeLibraries;
Expand Down Expand Up @@ -345,12 +346,40 @@ private void createRawStructInfo(ResolvedJavaType type) {
StructFieldInfo fieldInfo = new StructFieldInfo(entry.getKey(), elementKind(entry.getValue()));
fieldInfo.adoptChildren(entry.getValue());
structInfo.adoptChild(fieldInfo);
verifyRawStructFieldAccessors(fieldInfo);
}

nativeCodeInfo.adoptChild(structInfo);
nativeLibs.registerElementInfo(type, structInfo);
}

private void verifyRawStructFieldAccessors(StructFieldInfo fieldInfo) {
boolean hasGetter = false;
boolean hasSetter = false;
for (ElementInfo child : fieldInfo.getChildren()) {
if (child instanceof AccessorInfo) {
AccessorKind kind = ((AccessorInfo) child).getAccessorKind();
if (kind == AccessorKind.GETTER) {
hasGetter = true;
} else if (kind == AccessorKind.SETTER) {
hasSetter = true;
} else if (kind == AccessorKind.ADDRESS || kind == AccessorKind.OFFSET) {
hasGetter = true;
hasSetter = true;
} else {
throw VMError.shouldNotReachHere("Unexpected accessor kind: " + kind);
}
}
}

if (!hasSetter) {
nativeLibs.addError(String.format("%s.%s does not have a setter. @RawStructure fields need both a getter and a setter.", fieldInfo.getParent().getName(), fieldInfo.getName()));
}
if (!hasGetter) {
nativeLibs.addError(String.format("%s.%s does not have a getter. @RawStructure fields need both a getter and a setter.", fieldInfo.getParent().getName(), fieldInfo.getName()));
}
}

private boolean hasLocationIdentityParameter(ResolvedJavaMethod method) {
int parameterCount = getParameterCount(method);
if (parameterCount == 0) {
Expand Down