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

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

Issue 2540133002: [wasm] Remove raw byte pointers from WasmModule (Closed)
Patch Set: Created 4 years 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
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 f47edb104936cb6e822c3a450535439272cca064..915ea3e36c931bc1fe4ca1c42daeb4ca0d34a6db 100644
--- a/test/common/wasm/wasm-module-runner.cc
+++ b/test/common/wasm/wasm-module-runner.cc
@@ -46,9 +46,9 @@ const WasmModule* DecodeWasmModuleForTesting(
}
const Handle<WasmInstanceObject> InstantiateModuleForTesting(
- Isolate* isolate, ErrorThrower* thrower, const WasmModule* module) {
- CHECK(module != nullptr);
-
+ Isolate* isolate, ErrorThrower* thrower, const WasmModule* module,
+ const ModuleStorage& storage) {
+ DCHECK_NOT_NULL(module);
if (module->import_table.size() > 0) {
thrower->CompileError("Not supported: module has imports.");
}
@@ -59,8 +59,9 @@ const Handle<WasmInstanceObject> InstantiateModuleForTesting(
// again through the normal pipeline.
// TODO(wasm): Use {module} instead of decoding the module bytes again.
MaybeHandle<WasmModuleObject> module_object = CreateModuleObjectFromBytes(
- isolate, module->module_start, module->module_end, thrower,
- ModuleOrigin::kWasmOrigin, Handle<Script>::null(), nullptr, nullptr);
+ isolate, storage.module_bytes.start(), storage.module_bytes.end(),
+ thrower, ModuleOrigin::kWasmOrigin, Handle<Script>::null(), nullptr,
+ nullptr);
if (module_object.is_null()) {
thrower->CompileError("Module pre-validation failed.");
return Handle<WasmInstanceObject>::null();
@@ -85,7 +86,8 @@ const Handle<WasmInstanceObject> CompileInstantiateWasmModuleForTesting(
thrower->CompileError("Wasm module decoding failed");
return Handle<WasmInstanceObject>::null();
}
- return InstantiateModuleForTesting(isolate, thrower, module.get());
+ return InstantiateModuleForTesting(isolate, thrower, module.get(),
+ ModuleStorage(module_start, module_end));
}
int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance,
@@ -110,10 +112,10 @@ int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
}
int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower,
- const WasmModule* module, int function_index,
+ const WasmModule* module,
+ const ModuleStorage& storage, int function_index,
WasmVal* args, bool* possible_nondeterminism) {
- CHECK(module != nullptr);
-
+ DCHECK_NOT_NULL(module);
Zone zone(isolate->allocator(), ZONE_NAME);
v8::internal::HandleScope scope(isolate);
@@ -136,7 +138,8 @@ int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower,
static_cast<byte*>(calloc(GetMinModuleMemSize(module), 1));
instance.globals_start = nullptr;
- WasmInterpreter interpreter(&instance, isolate->allocator());
+ ModuleStorageEnv env(module, &instance, storage);
+ WasmInterpreter interpreter(env, isolate->allocator());
WasmInterpreter::Thread* thread = interpreter.GetThread(0);
thread->Reset();

Powered by Google App Engine
This is Rietveld 408576698