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

Unified Diff: src/wasm/wasm-js.cc

Issue 2264913002: [wasm] asm.js - Remove Wasm.instantiateModuleFromAsm, use asm.js directly. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 4 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 | « src/runtime/runtime-test.cc ('k') | test/mjsunit/asm/asm-validation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index b23b125bfc676ed05e7d47039508ab2f10a4f8e3..10ae43c78b31a33bd5421412f041f04d1b3ab037 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -126,33 +126,6 @@ void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (result.val) delete result.val;
}
-i::MaybeHandle<i::FixedArray> TranslateAsmModule(i::ParseInfo* info,
- ErrorThrower* thrower) {
- info->set_global();
- info->set_lazy(false);
- info->set_allow_lazy_parsing(false);
- info->set_toplevel(true);
-
- if (!i::Compiler::ParseAndAnalyze(info)) {
- return i::MaybeHandle<i::FixedArray>();
- }
-
- if (info->scope()->declarations()->length() == 0) {
- thrower->Error("Asm.js validation failed: no declarations in scope");
- return i::MaybeHandle<i::FixedArray>();
- }
-
- if (!info->scope()->declarations()->at(0)->IsFunctionDeclaration()) {
- thrower->Error("Asm.js validation failed: non-function declaration");
- return i::MaybeHandle<i::FixedArray>();
- }
-
- info->set_literal(
- info->scope()->declarations()->at(0)->AsFunctionDeclaration()->fun());
-
- return i::AsmJs::ConvertAsmToWasm(info);
-}
-
i::MaybeHandle<i::JSObject> InstantiateModule(
const v8::FunctionCallbackInfo<v8::Value>& args, const byte* start,
const byte* end, ErrorThrower* thrower,
@@ -199,70 +172,6 @@ i::MaybeHandle<i::JSObject> InstantiateModule(
return object;
}
-void InstantiateModuleFromAsm(const v8::FunctionCallbackInfo<v8::Value>& args) {
- HandleScope scope(args.GetIsolate());
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
- ErrorThrower thrower(isolate, "Wasm.instantiateModuleFromAsm()");
-
- if (!args[0]->IsString()) {
- thrower.Error("Asm module text should be a string");
- return;
- }
-
- i::Factory* factory = isolate->factory();
- i::Zone zone(isolate->allocator());
- Local<String> source = Local<String>::Cast(args[0]);
- i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source));
- i::ParseInfo info(&zone, script);
-
- auto wasm_data = TranslateAsmModule(&info, &thrower);
- if (wasm_data.is_null()) {
- thrower.Error("asm.js failed to validate");
- return;
- }
-
- i::Handle<i::JSReceiver> stdlib;
- if (args.Length() > 1 && args[1]->IsObject()) {
- Local<Object> obj = Local<Object>::Cast(args[1]);
- i::Handle<i::Object> hobj =
- i::Handle<i::Object>::cast(v8::Utils::OpenHandle(*obj));
- if (hobj->IsJSReceiver()) {
- stdlib = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj));
- }
- }
-
- i::Handle<i::JSReceiver> foreign;
- if (args.Length() > 2 && args[2]->IsObject()) {
- Local<Object> obj = Local<Object>::Cast(args[2]);
- i::Handle<i::Object> hobj =
- i::Handle<i::Object>::cast(v8::Utils::OpenHandle(*obj));
- if (hobj->IsJSReceiver()) {
- foreign = i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj));
- }
- }
-
- i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null();
- if (args.Length() > 3 && args[3]->IsArrayBuffer()) {
- Local<Object> obj = Local<Object>::Cast(args[3]);
- i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj);
- memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj));
- }
-
- if (!i::AsmJs::IsStdlibValid(isolate, wasm_data.ToHandleChecked(), stdlib)) {
- thrower.Error("Asm module uses missing stdlib function");
- return;
- }
-
- i::MaybeHandle<i::Object> maybe_module_object = i::AsmJs::InstantiateAsmWasm(
- isolate, wasm_data.ToHandleChecked(), memory, foreign);
- if (maybe_module_object.is_null()) {
- return;
- }
-
- args.GetReturnValue().Set(
- v8::Utils::ToLocal(maybe_module_object.ToHandleChecked()));
-}
-
void InstantiateModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
HandleScope scope(args.GetIsolate());
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
@@ -463,8 +372,6 @@ void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule);
InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction);
InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule);
- InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm",
- InstantiateModuleFromAsm);
{
// Add the Wasm.experimentalVersion property.
« no previous file with comments | « src/runtime/runtime-test.cc ('k') | test/mjsunit/asm/asm-validation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698