Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: test/common/wasm/wasm-module-runner.cc

Issue 2424623002: [wasm] Use a Managed<WasmModule> to hold metadata about modules. (Closed)
Patch Set: [wasm] Use a Managed<WasmModule> to hold metadata about modules. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/common/wasm/wasm-module-runner.h ('k') | test/fuzzer/wasm-code.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/common/wasm/wasm-module-runner.cc
diff --git a/test/common/wasm/wasm-module-runner.cc b/test/common/wasm/wasm-module-runner.cc
index 2eece57184a2db530314eeab35481c233a900ea1..01c4b624b09a08e542acbcf46db826b17e56e8f1 100644
--- a/test/common/wasm/wasm-module-runner.cc
+++ b/test/common/wasm/wasm-module-runner.cc
@@ -23,7 +23,7 @@ uint32_t GetMinModuleMemSize(const WasmModule* module) {
return WasmModule::kPageSize * module->min_mem_pages;
}
-const WasmModule* DecodeWasmModuleForTesting(Isolate* isolate, Zone* zone,
+const WasmModule* DecodeWasmModuleForTesting(Isolate* isolate,
ErrorThrower* thrower,
const byte* module_start,
const byte* module_end,
@@ -31,18 +31,19 @@ const WasmModule* DecodeWasmModuleForTesting(Isolate* isolate, Zone* zone,
// Decode the module, but don't verify function bodies, since we'll
// be compiling them anyway.
ModuleResult decoding_result =
- DecodeWasmModule(isolate, zone, module_start, module_end, false, origin);
+ DecodeWasmModule(isolate, module_start, module_end, false, origin);
- std::unique_ptr<const WasmModule> module(decoding_result.val);
if (decoding_result.failed()) {
// Module verification failed. throw.
thrower->CompileError("WASM.compileRun() failed: %s",
decoding_result.error_msg.get());
- return nullptr;
}
- if (thrower->error()) return nullptr;
- return module.release();
+ if (thrower->error()) {
+ if (decoding_result.val) delete decoding_result.val;
+ return nullptr;
+ }
+ return decoding_result.val;
}
const Handle<JSObject> InstantiateModuleForTesting(Isolate* isolate,
@@ -78,16 +79,16 @@ const Handle<JSObject> InstantiateModuleForTesting(Isolate* isolate,
}
const Handle<JSObject> CompileInstantiateWasmModuleForTesting(
- Isolate* isolate, ErrorThrower* thrower, Zone* zone,
- const byte* module_start, const byte* module_end, ModuleOrigin origin) {
- std::unique_ptr<const WasmModule> module(DecodeWasmModuleForTesting(
- isolate, zone, thrower, module_start, module_end, origin));
+ Isolate* isolate, ErrorThrower* thrower, const byte* module_start,
+ const byte* module_end, ModuleOrigin origin) {
+ const WasmModule* module = DecodeWasmModuleForTesting(
+ isolate, thrower, module_start, module_end, origin);
if (module == nullptr) {
thrower->CompileError("Wasm module decoding failed");
return Handle<JSObject>::null();
}
- return InstantiateModuleForTesting(isolate, thrower, module.get());
+ return InstantiateModuleForTesting(isolate, thrower, module);
}
int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance,
@@ -102,10 +103,9 @@ int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance,
int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
const byte* module_end, ModuleOrigin origin) {
HandleScope scope(isolate);
- Zone zone(isolate->allocator(), ZONE_NAME);
ErrorThrower thrower(isolate, "CompileAndRunWasmModule");
Handle<JSObject> instance = CompileInstantiateWasmModuleForTesting(
- isolate, &thrower, &zone, module_start, module_end, origin);
+ isolate, &thrower, module_start, module_end, origin);
if (instance.is_null()) {
return -1;
}
« no previous file with comments | « test/common/wasm/wasm-module-runner.h ('k') | test/fuzzer/wasm-code.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698