Skip to content

Commit 14b87a0

Browse files
committed
webimage: adopt VMError substitutions
1 parent a6b7594 commit 14b87a0

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasm/substitute/VMErrorSubstitutions.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131

3232
import com.oracle.svm.core.NeverInline;
3333
import com.oracle.svm.core.SubstrateUtil;
34+
import com.oracle.svm.core.annotate.AnnotateOriginal;
3435
import com.oracle.svm.core.annotate.Substitute;
3536
import com.oracle.svm.core.annotate.TargetClass;
3637
import com.oracle.svm.core.heap.RestrictHeapAccess;
3738
import com.oracle.svm.core.log.Log;
3839
import com.oracle.svm.guest.staging.Uninterruptible;
39-
import com.oracle.svm.shared.util.VMError;
4040
import com.oracle.svm.hosted.webimage.wasm.nodes.WasmTrapNode;
41+
import com.oracle.svm.shared.util.VMError;
4142
import com.oracle.svm.webimage.platform.WebImageWasmLMPlatform;
4243
import com.oracle.svm.webimage.substitute.system.Target_java_lang_Throwable_Web;
4344

@@ -83,7 +84,7 @@ static void shutdown(String msg, Throwable ex) {
8384
@TargetClass(VMError.class)
8485
@Platforms(WebImageWasmLMPlatform.class)
8586
@SuppressWarnings("unused")
86-
final class Target_com_oracle_svm_core_util_VMError_Web {
87+
final class Target_com_oracle_svm_core_shared_VMError_Web {
8788

8889
/*
8990
* These substitutions let the svm print the real message. The original VMError methods throw a
@@ -149,4 +150,12 @@ private static RuntimeException intentionallyUnimplemented() {
149150
private static RuntimeException unsupportedFeature(String msg) {
150151
throw new Error("UNSUPPORTED FEATURE: " + msg);
151152
}
153+
154+
@AnnotateOriginal
155+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
156+
public static native void guarantee(boolean condition);
157+
158+
@AnnotateOriginal
159+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
160+
public static native void guarantee(boolean condition, String msg);
152161
}

web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/wasmgc/substitute/WasmGCVMErrorSubstitutions.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
import org.graalvm.nativeimage.Platforms;
2929

3030
import com.oracle.svm.core.SubstrateUtil;
31+
import com.oracle.svm.core.annotate.AnnotateOriginal;
3132
import com.oracle.svm.core.annotate.Substitute;
3233
import com.oracle.svm.core.annotate.TargetClass;
3334
import com.oracle.svm.core.jdk.UnsupportedFeatureError;
34-
import com.oracle.svm.shared.util.VMError;
35+
import com.oracle.svm.guest.staging.Uninterruptible;
3536
import com.oracle.svm.hosted.webimage.wasm.debug.WasmDebug;
3637
import com.oracle.svm.hosted.webimage.wasm.nodes.WasmTrapNode;
38+
import com.oracle.svm.shared.util.VMError;
3739
import com.oracle.svm.webimage.platform.WebImageWasmGCPlatform;
3840
import com.oracle.svm.webimage.substitute.system.Target_java_lang_Throwable_Web;
3941

@@ -58,7 +60,7 @@ static RuntimeException shouldNotReachHere(String msg, Throwable ex) {
5860
@TargetClass(VMError.class)
5961
@Platforms(WebImageWasmGCPlatform.class)
6062
@SuppressWarnings("unused")
61-
final class Target_com_oracle_svm_core_util_VMError_Web {
63+
final class Target_com_oracle_svm_shared_util_VMError_Web {
6264

6365
@Substitute
6466
private static RuntimeException shouldNotReachHere(String msg) {
@@ -109,4 +111,12 @@ private static RuntimeException intentionallyUnimplemented() {
109111
private static RuntimeException unsupportedFeature(String msg) {
110112
throw new UnsupportedFeatureError(msg);
111113
}
114+
115+
@AnnotateOriginal
116+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
117+
public static native void guarantee(boolean condition);
118+
119+
@AnnotateOriginal
120+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
121+
public static native void guarantee(boolean condition, String msg);
112122
}

web-image/src/com.oracle.svm.webimage/src/com/oracle/svm/webimage/substitute/system/WebImageJavaLangSubstitutions.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@
4848
import com.oracle.svm.core.NeverInline;
4949
import com.oracle.svm.core.OS;
5050
import com.oracle.svm.core.SubstrateUtil;
51-
import com.oracle.svm.guest.staging.Uninterruptible;
51+
import com.oracle.svm.core.annotate.AnnotateOriginal;
5252
import com.oracle.svm.core.annotate.Delete;
5353
import com.oracle.svm.core.annotate.Substitute;
5454
import com.oracle.svm.core.annotate.TargetClass;
5555
import com.oracle.svm.core.jdk.Resources;
5656
import com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystem;
5757
import com.oracle.svm.core.jdk.resources.ResourceStorageEntryBase;
58+
import com.oracle.svm.guest.staging.Uninterruptible;
5859
import com.oracle.svm.shared.util.VMError;
5960
import com.oracle.svm.webimage.functionintrinsics.JSFunctionIntrinsics;
6061
import com.oracle.svm.webimage.functionintrinsics.JSInternalErrors;
@@ -105,7 +106,7 @@ private static String getSystemGMTOffsetID() {
105106
@TargetClass(com.oracle.svm.shared.util.VMError.class)
106107
@Platforms(WebImageJSPlatform.class)
107108
@SuppressWarnings("unused")
108-
final class Target_com_oracle_svm_core_util_VMError_Web {
109+
final class Target_com_oracle_svm_core_shared_VMError_Web {
109110

110111
/*
111112
* m These substitutions let the svm print the real message. The original VMError methods throw
@@ -160,6 +161,14 @@ private static RuntimeException intentionallyUnimplemented() {
160161
private static RuntimeException unsupportedFeature(String msg) {
161162
throw new Error("UNSUPPORTED FEATURE: " + msg);
162163
}
164+
165+
@AnnotateOriginal
166+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
167+
public static native void guarantee(boolean condition);
168+
169+
@AnnotateOriginal
170+
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
171+
public static native void guarantee(boolean condition, String msg);
163172
}
164173

165174
@TargetClass(className = "jdk.internal.misc.Unsafe")

0 commit comments

Comments
 (0)