Skip to content

Commit

Permalink
Fix WebAssembly.instantiate() handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwokka committed Feb 6, 2024
1 parent 7d2a3a0 commit 7f7b851
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions content/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,10 @@ const webAssemblyInstantiateHook = function(inObject, importObject = {}) {
importObject.env = {};
}

importObject.env.readWatchCallback = readWatchCallback;
importObject.env.writeWatchCallback = writeWatchCallback;
const cetusIdentifier = cetusInstances.reserveIdentifier();

importObject.env.readWatchCallback = function() { readWatchCallback(cetusIdentifier) };
importObject.env.writeWatchCallback = function() { writeWatchCallback(cetusIdentifier) };

return new Promise(function(resolve, reject) {
oldWebAssemblyInstantiate(instrumentedObject, importObject).then(function(instanceObject) {
Expand All @@ -1159,8 +1161,6 @@ const webAssemblyInstantiateHook = function(inObject, importObject = {}) {
colorError("WebAssembly.instantiate() failed to retrieve a WebAssembly.Memory object");
}

const cetusIdentifier = cetusInstances.reserveIdentifier();

const watchpointExports = [];

for (let i = 0; i < cetusOptions.wpCount; i++) {
Expand Down Expand Up @@ -1235,12 +1235,12 @@ const webAssemblyInstanceProxy = new Proxy(WebAssembly.Instance, {
importObject.env = {};
}

importObject.env.readWatchCallback = readWatchCallback;
importObject.env.writeWatchCallback = writeWatchCallback;
const cetusIdentifier = cetusInstances.reserveIdentifier();

const result = new target(module, importObject);
importObject.env.readWatchCallback = function() { readWatchCallback(cetusIdentifier) };
importObject.env.writeWatchCallback = function() { writeWatchCallback(cetusIdentifier) };

const cetusIdentifier = cetusInstances.reserveIdentifier();
const result = new target(module, importObject);

const watchpointExports = [];

Expand Down

0 comments on commit 7f7b851

Please sign in to comment.