Skip to content

Commit

Permalink
fix bug of download binary when instrumentation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
doehyunbaek committed Feb 16, 2024
1 parent 10ba666 commit 9462fbd
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ function setup() {
// const p_instrumenting = performanceEvent(`instrumentation of wasm binary ${this_i}`)
try {
const { instrumented, js } = instrument_wasm(new Uint8Array(buffer));
// self.performanceList.push(p_instrumenting.stop())
wasabis.push(eval(js + '\nWasabi'))
buffer = new Uint8Array(instrumented)
importObject = importObjectWithHooks(importObject, this_i)
self.analysis.push(setupAnalysis(wasabis[this_i]))
let result
result = original_instantiate(buffer, importObject)
result.then(({ module, instance }) => {
wireInstanceExports(instance, this_i)
self.analysis[this_i].init()

})
// self.performanceList.push(p_instantiationTime.stop())
return result
} catch (e) {
console.error('Instrumentation failed. Downloading the original data')
let blob = new Blob([buffer.bytes]);
Expand All @@ -78,20 +92,6 @@ function setup() {
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
}
// self.performanceList.push(p_instrumenting.stop())
wasabis.push(eval(js + '\nWasabi'))
buffer = new Uint8Array(instrumented)
importObject = importObjectWithHooks(importObject, this_i)
self.analysis.push(setupAnalysis(wasabis[this_i]))
let result
result = original_instantiate(buffer, importObject)
result.then(({ module, instance }) => {
wireInstanceExports(instance, this_i)
self.analysis[this_i].init()

})
// self.performanceList.push(p_instantiationTime.stop())
return result
};
// replace instantiateStreaming
WebAssembly.instantiateStreaming = async function (source, obj) {
Expand Down

0 comments on commit 9462fbd

Please sign in to comment.