Chromium Code Reviews| Index: src/wasm/wasm-js.cc |
| diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc |
| index 9494d4c0df72771481cfbaac12e5b170ca3b1ff1..3ee1787cd34ee0c94226eac8b6f2cebdaff3d971 100644 |
| --- a/src/wasm/wasm-js.cc |
| +++ b/src/wasm/wasm-js.cc |
| @@ -160,7 +160,7 @@ i::MaybeHandle<i::JSObject> InstantiateModule( |
| } |
| object = i::wasm::WasmModule::Instantiate( |
| - isolate, module_object.ToHandleChecked(), ffi, memory); |
| + isolate, thrower, module_object.ToHandleChecked(), ffi, memory); |
| if (!object.is_null()) { |
| args.GetReturnValue().Set(v8::Utils::ToLocal(object.ToHandleChecked())); |
| } |
| @@ -296,10 +296,10 @@ void WebAssemblyInstance(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj); |
| memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj)); |
| } |
| - i::MaybeHandle<i::JSObject> instance = |
| - i::wasm::WasmModule::Instantiate(i_isolate, module_obj, ffi, memory); |
| + i::MaybeHandle<i::JSObject> instance = i::wasm::WasmModule::Instantiate( |
| + i_isolate, &thrower, module_obj, ffi, memory); |
| if (instance.is_null()) { |
| - thrower.Error("Could not instantiate module"); |
| + if (!thrower.error()) thrower.Error("Could not instantiate module"); |
| return; |
| } |
| v8::ReturnValue<v8::Value> return_value = args.GetReturnValue(); |
| @@ -406,6 +406,7 @@ void WebAssemblyTable(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| v8::ReturnValue<v8::Value> return_value = args.GetReturnValue(); |
| return_value.Set(Utils::ToLocal(table_obj)); |
| } |
| + |
| void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| v8::Isolate* isolate = args.GetIsolate(); |
| HandleScope scope(isolate); |
| @@ -436,23 +437,14 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| } |
| } |
| i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| - i::Handle<i::JSFunction> memory_cons( |
| - i_isolate->native_context()->wasm_memory_constructor()); |
| - i::Handle<i::JSObject> memory_obj = |
| - i_isolate->factory()->NewJSObject(memory_cons); |
| i::Handle<i::JSArrayBuffer> buffer = |
| i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
| size_t size = static_cast<size_t>(i::wasm::WasmModule::kPageSize) * |
| static_cast<size_t>(initial); |
| i::JSArrayBuffer::SetupAllocatingData(buffer, i_isolate, size); |
| - memory_obj->SetInternalField(0, *buffer); |
| - memory_obj->SetInternalField( |
| - 1, has_maximum |
| - ? static_cast<i::Object*>(i::Smi::FromInt(maximum)) |
| - : static_cast<i::Object*>(i_isolate->heap()->undefined_value())); |
| - i::Handle<i::Symbol> memory_sym( |
| - i_isolate->native_context()->wasm_memory_sym()); |
| - i::Object::SetProperty(memory_obj, memory_sym, memory_obj, i::STRICT).Check(); |
| + |
| + i::Handle<i::JSObject> memory_obj = i::WasmJs::CreateWasmMemoryObject( |
| + i_isolate, buffer, has_maximum, maximum); |
| v8::ReturnValue<v8::Value> return_value = args.GetReturnValue(); |
| return_value.Set(Utils::ToLocal(memory_obj)); |
| } |
| @@ -492,6 +484,24 @@ void WebAssemblyMemoryGetBuffer( |
| } |
| } // namespace |
| +i::Handle<i::JSObject> i::WasmJs::CreateWasmMemoryObject( |
| + i::Isolate* i_isolate, i::Handle<i::JSArrayBuffer> buffer, bool has_maximum, |
| + int maximum) { |
| + i::Handle<i::JSFunction> memory_cons( |
|
bradnelson
2016/09/23 11:36:01
Unfortunate abreviation in a context with s-exprs
titzer
2016/09/23 12:07:30
Changed to _ctor.
|
| + i_isolate->native_context()->wasm_memory_constructor()); |
| + i::Handle<i::JSObject> memory_obj = |
| + i_isolate->factory()->NewJSObject(memory_cons); |
| + memory_obj->SetInternalField(0, *buffer); |
| + memory_obj->SetInternalField( |
| + 1, has_maximum |
| + ? static_cast<i::Object*>(i::Smi::FromInt(maximum)) |
| + : static_cast<i::Object*>(i_isolate->heap()->undefined_value())); |
| + i::Handle<i::Symbol> memory_sym( |
| + i_isolate->native_context()->wasm_memory_sym()); |
| + i::Object::SetProperty(memory_obj, memory_sym, memory_obj, i::STRICT).Check(); |
| + return memory_obj; |
| +} |
| + |
| // TODO(titzer): we use the API to create the function template because the |
| // internal guts are too ugly to replicate here. |
| static i::Handle<i::FunctionTemplateInfo> NewTemplate(i::Isolate* i_isolate, |