Commit 255f4507 authored by bradnelson's avatar bradnelson Committed by Commit bot

Drop the compileRun + asmCompileRun methods from wasm.

Now that we have full fledged module instantiation,
keeping alive a second interface seems clunky.

Droping it and switching the tests.

BUG= https://code.google.com/p/v8/issues/detail?id=4203
TEST=test-asm-validator,asm-wasm,other wasm
R=titzer@chromium.org,aseemgarg@chromium.org
LOG=N

Review URL: https://codereview.chromium.org/1660083002

Cr-Commit-Position: refs/heads/master@{#33700}
parent a75b2c8f
...@@ -100,31 +100,6 @@ void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -100,31 +100,6 @@ void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) {
} }
void CompileRun(const v8::FunctionCallbackInfo<v8::Value>& args) {
HandleScope scope(args.GetIsolate());
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
ErrorThrower thrower(isolate, "WASM.compileRun()");
RawBuffer buffer = GetRawBufferArgument(thrower, args);
if (thrower.error()) return;
// Decode and pre-verify the functions before compiling and running.
i::Zone zone;
internal::wasm::ModuleResult result = internal::wasm::DecodeWasmModule(
isolate, &zone, buffer.start, buffer.end, true, false);
if (result.failed()) {
thrower.Failed("", result);
} else {
// Success. Compile and run!
int32_t retval = i::wasm::CompileAndRunWasmModule(isolate, result.val);
args.GetReturnValue().Set(retval);
}
if (result.val) delete result.val;
}
v8::internal::wasm::WasmModuleIndex* TranslateAsmModule(i::ParseInfo* info, v8::internal::wasm::WasmModuleIndex* TranslateAsmModule(i::ParseInfo* info,
ErrorThrower* thrower) { ErrorThrower* thrower) {
info->set_global(); info->set_global();
...@@ -156,37 +131,6 @@ v8::internal::wasm::WasmModuleIndex* TranslateAsmModule(i::ParseInfo* info, ...@@ -156,37 +131,6 @@ v8::internal::wasm::WasmModuleIndex* TranslateAsmModule(i::ParseInfo* info,
} }
void AsmCompileRun(const v8::FunctionCallbackInfo<v8::Value>& args) {
HandleScope scope(args.GetIsolate());
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
ErrorThrower thrower(isolate, "WASM.asmCompileRun()");
if (args.Length() != 1) {
thrower.Error("Invalid argument count");
return;
}
if (!args[0]->IsString()) {
thrower.Error("Asm module text should be a string");
return;
}
i::Factory* factory = isolate->factory();
i::Zone zone;
Local<String> source = Local<String>::Cast(args[0]);
i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source));
i::ParseInfo info(&zone, script);
auto module = TranslateAsmModule(&info, &thrower);
if (module == nullptr) {
return;
}
int32_t result = v8::internal::wasm::CompileAndRunWasmModule(
isolate, module->Begin(), module->End(), true);
args.GetReturnValue().Set(result);
}
void InstantiateModuleCommon(const v8::FunctionCallbackInfo<v8::Value>& args, void InstantiateModuleCommon(const v8::FunctionCallbackInfo<v8::Value>& args,
const byte* start, const byte* end, const byte* start, const byte* end,
ErrorThrower* thrower, bool must_decode) { ErrorThrower* thrower, bool must_decode) {
...@@ -312,11 +256,9 @@ void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) { ...@@ -312,11 +256,9 @@ void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
JSObject::AddProperty(global, name, wasm_object, attributes); JSObject::AddProperty(global, name, wasm_object, attributes);
// Install functions on the WASM object. // Install functions on the WASM object.
InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule);
InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule); InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule);
InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction); InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction);
InstallFunc(isolate, wasm_object, "compileRun", CompileRun); InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule);
InstallFunc(isolate, wasm_object, "asmCompileRun", AsmCompileRun);
InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm", InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm",
InstantiateModuleFromAsm); InstantiateModuleFromAsm);
} }
......
...@@ -9,4 +9,4 @@ function f() { ...@@ -9,4 +9,4 @@ function f() {
} }
assertFalse(_WASMEXP_ == undefined); assertFalse(_WASMEXP_ == undefined);
assertThrows(function() { _WASMEXP_.asmCompileRun(f.toString()); }); assertThrows(function() { _WASMEXP_.instantiateModuleFromAsm(f.toString()); });
This diff is collapsed.
...@@ -28,4 +28,4 @@ var data = bytes( ...@@ -28,4 +28,4 @@ var data = bytes(
'm', 'a', 'i', 'n', 0 // name 'm', 'a', 'i', 'n', 0 // name
); );
assertEquals(kReturnValue, _WASMEXP_.compileRun(data)); assertEquals(kReturnValue, _WASMEXP_.instantiateModule(data).main());
...@@ -8,4 +8,5 @@ assertFalse(undefined === _WASMEXP_); ...@@ -8,4 +8,5 @@ assertFalse(undefined === _WASMEXP_);
assertFalse(undefined == _WASMEXP_); assertFalse(undefined == _WASMEXP_);
assertEquals("function", typeof _WASMEXP_.verifyModule); assertEquals("function", typeof _WASMEXP_.verifyModule);
assertEquals("function", typeof _WASMEXP_.verifyFunction); assertEquals("function", typeof _WASMEXP_.verifyFunction);
assertEquals("function", typeof _WASMEXP_.compileRun); assertEquals("function", typeof _WASMEXP_.instantiateModule);
assertEquals("function", typeof _WASMEXP_.instantiateModuleFromAsm);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment