|
31 | 31 | import org.graalvm.nativeimage.Platform;
|
32 | 32 | import org.graalvm.nativeimage.Platforms;
|
33 | 33 | import org.graalvm.nativeimage.c.function.CodePointer;
|
34 |
| -import org.graalvm.nativeimage.c.struct.SizeOf; |
35 | 34 | import org.graalvm.word.ComparableWord;
|
36 | 35 | import org.graalvm.word.UnsignedWord;
|
37 | 36 |
|
38 | 37 | import com.oracle.svm.core.BuildPhaseProvider.AfterCompilation;
|
39 | 38 | import com.oracle.svm.core.MemoryWalker;
|
40 | 39 | import com.oracle.svm.core.Uninterruptible;
|
| 40 | +import com.oracle.svm.core.c.CIsolateData; |
| 41 | +import com.oracle.svm.core.c.CIsolateDataFactory; |
41 | 42 | import com.oracle.svm.core.c.NonmovableArray;
|
42 | 43 | import com.oracle.svm.core.c.NonmovableArrays;
|
43 | 44 | import com.oracle.svm.core.c.NonmovableObjectArray;
|
|
48 | 49 | public class ImageCodeInfo {
|
49 | 50 | public static final String CODE_INFO_NAME = "image code";
|
50 | 51 |
|
51 |
| - /** Memory in the image heap to contain our {@link CodeInfo} structure at runtime. */ |
52 |
| - private final byte[] runtimeCodeInfoData; |
| 52 | + private final CIsolateData<CodeInfoImpl> runtimeCodeInfo = CIsolateDataFactory.createStruct("runtimeCodeInfo", CodeInfoImpl.class); |
53 | 53 |
|
54 | 54 | @Platforms(Platform.HOSTED_ONLY.class) //
|
55 | 55 | private final HostedImageCodeInfo hostedImageCodeInfo = new HostedImageCodeInfo();
|
@@ -78,14 +78,11 @@ public class ImageCodeInfo {
|
78 | 78 | NonmovableArrays.setObject(objfields, CodeInfoImpl.TETHER_OBJFIELD, new CodeInfoTether(true));
|
79 | 79 | // no InstalledCode for image code
|
80 | 80 | objectFields = NonmovableArrays.getHostedArray(objfields);
|
81 |
| - |
82 |
| - int runtimeInfoSize = SizeOf.get(CodeInfoImpl.class); |
83 |
| - runtimeCodeInfoData = new byte[runtimeInfoSize]; |
84 | 81 | }
|
85 | 82 |
|
86 | 83 | @Uninterruptible(reason = "Executes during isolate creation.")
|
87 | 84 | CodeInfo prepareCodeInfo() {
|
88 |
| - CodeInfoImpl info = NonmovableArrays.addressOf(NonmovableArrays.fromImageHeap(runtimeCodeInfoData), 0); |
| 85 | + CodeInfoImpl info = runtimeCodeInfo.get(); |
89 | 86 | assert info.getCodeStart().isNull() : "already initialized";
|
90 | 87 |
|
91 | 88 | info.setObjectFields(NonmovableArrays.fromImageHeap(objectFields));
|
|
0 commit comments