| Index: src/wasm/wasm-js.cc
|
| diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
|
| index 36f286f73cffcd58a940d74e7d06442ed8fe1f92..e79a9db20c2bdfb095d2455ae3be05b45f4f5c9d 100644
|
| --- a/src/wasm/wasm-js.cc
|
| +++ b/src/wasm/wasm-js.cc
|
| @@ -57,7 +57,7 @@ RawBuffer GetRawBufferSource(
|
| end = start + contents.ByteLength();
|
|
|
| if (start == nullptr || end == start) {
|
| - thrower->Error("ArrayBuffer argument is empty");
|
| + thrower->CompileError("ArrayBuffer argument is empty");
|
| }
|
| } else if (source->IsTypedArray()) {
|
| // A TypedArray was passed.
|
| @@ -71,10 +71,10 @@ RawBuffer GetRawBufferSource(
|
| end = start + array->ByteLength();
|
|
|
| if (start == nullptr || end == start) {
|
| - thrower->Error("ArrayBuffer argument is empty");
|
| + thrower->TypeError("ArrayBuffer argument is empty");
|
| }
|
| } else {
|
| - thrower->Error("Argument 0 must be an ArrayBuffer or Uint8Array");
|
| + thrower->TypeError("Argument 0 must be an ArrayBuffer or Uint8Array");
|
| }
|
|
|
| return {start, end};
|
| @@ -98,7 +98,7 @@ void VerifyModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| true, internal::wasm::kWasmOrigin);
|
|
|
| if (result.failed()) {
|
| - thrower.Failed("", result);
|
| + thrower.CompileFailed("", result);
|
| }
|
|
|
| if (result.val) delete result.val;
|
| @@ -126,7 +126,7 @@ void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| }
|
|
|
| if (result.failed()) {
|
| - thrower.Failed("", result);
|
| + thrower.CompileFailed("", result);
|
| }
|
|
|
| if (result.val) delete result.val;
|
| @@ -334,9 +334,10 @@ void WebAssemblyInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| i::MaybeHandle<i::JSObject> instance = i::wasm::WasmModule::Instantiate(
|
| i_isolate, &thrower, module_obj, ffi, memory);
|
| if (instance.is_null()) {
|
| - if (!thrower.error()) thrower.Error("Could not instantiate module");
|
| + if (!thrower.error()) thrower.RuntimeError("Could not instantiate module");
|
| return;
|
| }
|
| + DCHECK(!i_isolate->has_pending_exception());
|
| v8::ReturnValue<v8::Value> return_value = args.GetReturnValue();
|
| return_value.Set(Utils::ToLocal(instance.ToHandleChecked()));
|
| }
|
| @@ -444,7 +445,7 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| ErrorThrower thrower(reinterpret_cast<i::Isolate*>(isolate),
|
| "WebAssembly.Module()");
|
| if (args.Length() < 1 || !args[0]->IsObject()) {
|
| - thrower.TypeError("Argument 0 must be a table descriptor");
|
| + thrower.TypeError("Argument 0 must be a memory descriptor");
|
| return;
|
| }
|
| Local<Context> context = isolate->GetCurrentContext();
|
| @@ -664,6 +665,17 @@ void WasmJs::InstallWasmConstructors(Isolate* isolate,
|
| memory_constructor, DONT_ENUM);
|
| InstallFunc(isolate, memory_proto, "grow", WebAssemblyMemoryGrow);
|
| InstallGetter(isolate, memory_proto, "buffer", WebAssemblyMemoryGetBuffer);
|
| +
|
| + // Setup errors
|
| + attributes = static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
|
| + Handle<JSFunction> compile_error(
|
| + isolate->native_context()->wasm_compile_error_function());
|
| + JSObject::AddProperty(wasm_object, isolate->factory()->CompileError_string(),
|
| + compile_error, attributes);
|
| + Handle<JSFunction> runtime_error(
|
| + isolate->native_context()->wasm_runtime_error_function());
|
| + JSObject::AddProperty(wasm_object, isolate->factory()->RuntimeError_string(),
|
| + runtime_error, attributes);
|
| }
|
|
|
| void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
|
|
|