Skip to content

Commit c43db7c

Browse files
committed
[GR-33010] Updated WASM API to use instance_export method.
PullRequest: js/2098
2 parents 173443d + 429556c commit c43db7c

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

graal-js/mx.graal-js/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
"name" : "regex",
2626
"subdir" : True,
27-
"version" : "3ecf62bb01af00121fad8f9b7b13ef5740e0695e",
27+
"version" : "5aa724e48260c9e03e579f940d300fc76f509b68",
2828
"urls" : [
2929
{"url" : "https://github.com/oracle/graal.git", "kind" : "git"},
3030
{"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/JSRealm.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ public class JSRealm {
385385
private final Object wasmModuleExports;
386386
private final Object wasmModuleImports;
387387
private final Object wasmCustomSections;
388+
private final Object wasmInstanceExport;
388389

389390
private final DynamicObject webAssemblyObject;
390391
private final DynamicObject webAssemblyGlobalConstructor;
@@ -752,6 +753,7 @@ public JSRealm(JSContext context, TruffleLanguage.Env env) {
752753
wasmModuleExports = wasmInterop.readMember(wasmObject, "module_exports");
753754
wasmModuleImports = wasmInterop.readMember(wasmObject, "module_imports");
754755
wasmCustomSections = wasmInterop.readMember(wasmObject, "custom_sections");
756+
wasmInstanceExport = wasmInterop.readMember(wasmObject, "instance_export");
755757
} catch (InteropException ex) {
756758
throw Errors.shouldNotReachHere(ex);
757759
}
@@ -790,6 +792,7 @@ public JSRealm(JSContext context, TruffleLanguage.Env env) {
790792
this.wasmModuleExports = null;
791793
this.wasmModuleImports = null;
792794
this.wasmCustomSections = null;
795+
this.wasmInstanceExport = null;
793796

794797
this.webAssemblyObject = null;
795798
this.webAssemblyGlobalConstructor = null;
@@ -2527,6 +2530,10 @@ public Object getWASMGlobalWrite() {
25272530
return wasmGlobalWrite;
25282531
}
25292532

2533+
public Object getWASMInstanceExport() {
2534+
return wasmInstanceExport;
2535+
}
2536+
25302537
public DynamicObject getWebAssemblyModulePrototype() {
25312538
return webAssemblyModulePrototype;
25322539
}

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/builtins/wasm/JSWebAssemblyInstance.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ private static Object createExportsObject(JSContext context, JSRealm realm, Obje
160160
try {
161161
Object exportsFunction = realm.getWASMModuleExports();
162162
Object exportsInfo = InteropLibrary.getUncached(exportsFunction).execute(exportsFunction, wasmModule);
163-
Object wasmExports = InteropLibrary.getUncached(wasmInstance).readMember(wasmInstance, "exports");
164-
InteropLibrary wasmExportsInterop = InteropLibrary.getUncached(wasmExports);
163+
Object instanceExport = realm.getWASMInstanceExport();
165164
InteropLibrary exportsInterop = InteropLibrary.getUncached(exportsInfo);
166165
long size = exportsInterop.getArraySize(exportsInfo);
167166

@@ -170,7 +169,7 @@ private static Object createExportsObject(JSContext context, JSRealm realm, Obje
170169
InteropLibrary exportInterop = InteropLibrary.getUncached(exportInfo);
171170
String name = asString(exportInterop.readMember(exportInfo, "name"));
172171
String externtype = asString(exportInterop.readMember(exportInfo, "kind"));
173-
Object externval = wasmExportsInterop.readMember(wasmExports, name);
172+
Object externval = InteropLibrary.getUncached().execute(instanceExport, wasmInstance, name);
174173
Object value;
175174

176175
if ("function".equals(externtype)) {

0 commit comments

Comments
 (0)