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

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

Issue 2447013004: [wasm] Remove the "Wasm" object. (Closed)
Patch Set: fix regression test 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 | « no previous file | test/mjsunit/regress/regress-575364.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 6fde52b90bd67dcd54675268197d1b02bcd28ca2..72482388ed3099febfe994aa1b7a968270c3ab1a 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -92,108 +92,6 @@ RawBuffer GetRawBufferSource(
return {start, end};
}
-void VerifyModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
- HandleScope scope(args.GetIsolate());
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
- ErrorThrower thrower(isolate, "Wasm.verifyModule()");
-
- if (args.Length() < 1) {
- thrower.TypeError("Argument 0 must be a buffer source");
- return;
- }
- RawBuffer buffer = GetRawBufferSource(args[0], &thrower);
- if (thrower.error()) return;
-
- internal::wasm::ModuleResult result = internal::wasm::DecodeWasmModule(
- isolate, buffer.start, buffer.end, true, internal::wasm::kWasmOrigin);
-
- if (result.failed()) {
- thrower.CompileFailed("", result);
- }
-
- if (result.val) delete result.val;
-}
-
-void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) {
- HandleScope scope(args.GetIsolate());
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
- ErrorThrower thrower(isolate, "Wasm.verifyFunction()");
-
- if (args.Length() < 1) {
- thrower.TypeError("Argument 0 must be a buffer source");
- return;
- }
- RawBuffer buffer = GetRawBufferSource(args[0], &thrower);
- if (thrower.error()) return;
-
- internal::wasm::FunctionResult result;
- {
- // Verification of a single function shouldn't allocate.
- i::DisallowHeapAllocation no_allocation;
- i::Zone zone(isolate->allocator(), ZONE_NAME);
- result = internal::wasm::DecodeWasmFunction(isolate, &zone, nullptr,
- buffer.start, buffer.end);
- }
-
- if (result.failed()) {
- thrower.CompileFailed("", result);
- }
-
- if (result.val) delete result.val;
-}
-
-i::MaybeHandle<i::JSObject> InstantiateModule(
- const v8::FunctionCallbackInfo<v8::Value>& args, const byte* start,
- const byte* end, ErrorThrower* thrower) {
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
-
- // Decode but avoid a redundant pass over function bodies for verification.
- // Verification will happen during compilation.
- i::Zone zone(isolate->allocator(), ZONE_NAME);
- i::MaybeHandle<i::JSObject> module_object =
- i::wasm::CreateModuleObjectFromBytes(
- isolate, start, end, thrower, i::wasm::kWasmOrigin,
- i::Handle<i::Script>::null(), nullptr, nullptr);
- i::MaybeHandle<i::JSObject> object;
- if (!module_object.is_null()) {
- // Success. Instantiate the module and return the object.
- i::Handle<i::JSObject> ffi = i::Handle<i::JSObject>::null();
- if (args.Length() > 1 && args[1]->IsObject()) {
- Local<Object> obj = Local<Object>::Cast(args[1]);
- ffi = i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj));
- }
-
- i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null();
- if (args.Length() > 2 && args[2]->IsArrayBuffer()) {
- Local<Object> obj = Local<Object>::Cast(args[2]);
- i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj);
- memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj));
- }
-
- object = i::wasm::WasmModule::Instantiate(
- isolate, thrower, module_object.ToHandleChecked(), ffi, memory);
- if (!object.is_null()) {
- args.GetReturnValue().Set(v8::Utils::ToLocal(object.ToHandleChecked()));
- }
- }
- return object;
-}
-
-void InstantiateModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
- HandleScope scope(args.GetIsolate());
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
- ErrorThrower thrower(isolate, "Wasm.instantiateModule()");
-
- if (args.Length() < 1) {
- thrower.TypeError("Argument 0 must be a buffer source");
- return;
- }
- RawBuffer buffer = GetRawBufferSource(args[0], &thrower);
- if (buffer.start == nullptr) return;
-
- InstantiateModule(args, buffer.start, buffer.end, &thrower);
-}
-
static i::MaybeHandle<i::JSObject> CreateModuleObject(
v8::Isolate* isolate, const v8::Local<v8::Value> source,
ErrorThrower* thrower) {
@@ -877,44 +775,13 @@ void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
return;
}
- Factory* factory = isolate->factory();
-
// Setup wasm function map.
Handle<Context> context(global->native_context(), isolate);
InstallWasmMapsIfNeeded(isolate, context);
- if (!FLAG_expose_wasm) {
- return;
- }
-
- // Bind the experimental "Wasm" object.
- // TODO(rossberg, titzer): remove once it's no longer needed.
- {
- Handle<String> name = v8_str(isolate, "Wasm");
- Handle<JSFunction> cons = factory->NewFunction(name);
- JSFunction::SetInstancePrototype(
- cons, Handle<Object>(context->initial_object_prototype(), isolate));
- cons->shared()->set_instance_class_name(*name);
- Handle<JSObject> wasm_object = factory->NewJSObject(cons, TENURED);
- PropertyAttributes attributes = static_cast<PropertyAttributes>(DONT_ENUM);
- JSObject::AddProperty(global, name, wasm_object, attributes);
-
- // Install functions on the WASM object.
- InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule);
- InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction);
- InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule);
-
- {
- // Add the Wasm.experimentalVersion property.
- Handle<String> name = v8_str(isolate, "experimentalVersion");
- PropertyAttributes attributes =
- static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
- Handle<Smi> value =
- Handle<Smi>(Smi::FromInt(wasm::kWasmVersion), isolate);
- JSObject::AddProperty(wasm_object, name, value, attributes);
- }
+ if (FLAG_expose_wasm) {
+ InstallWasmConstructors(isolate, global, context);
}
- InstallWasmConstructors(isolate, global, context);
}
void WasmJs::InstallWasmMapsIfNeeded(Isolate* isolate,
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-575364.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698