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

Side by Side Diff: src/wasm/wasm-js.cc

Issue 2825073002: [wasm] Fix DCHECK handiling pending exceptions. (Closed)
Patch Set: formatting Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regress-712569.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api-natives.h" 5 #include "src/api-natives.h"
6 #include "src/api.h" 6 #include "src/api.h"
7 #include "src/asmjs/asm-js.h" 7 #include "src/asmjs/asm-js.h"
8 #include "src/asmjs/asm-typer.h" 8 #include "src/asmjs/asm-typer.h"
9 #include "src/asmjs/asm-wasm-builder.h" 9 #include "src/asmjs/asm-wasm-builder.h"
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 14 matching lines...) Expand all
25 #include "src/wasm/wasm-result.h" 25 #include "src/wasm/wasm-result.h"
26 26
27 typedef uint8_t byte; 27 typedef uint8_t byte;
28 28
29 using v8::internal::wasm::ErrorThrower; 29 using v8::internal::wasm::ErrorThrower;
30 30
31 namespace v8 { 31 namespace v8 {
32 32
33 namespace { 33 namespace {
34 34
35 #define ASSIGN(type, var, expr) \ 35 #define ASSIGN(type, var, expr) \
36 Local<type> var; \ 36 Local<type> var; \
37 do { \ 37 do { \
38 if (!expr.ToLocal(&var)) { \ 38 if (!expr.ToLocal(&var)) { \
39 DCHECK(i_isolate->has_pending_exception()); \ 39 DCHECK(i_isolate->has_scheduled_exception()); \
40 } \ 40 return; \
41 } else { \
42 DCHECK(!i_isolate->has_scheduled_exception()); \
43 } \
41 } while (false) 44 } while (false)
42 45
43 // TODO(wasm): move brand check to the respective types, and don't throw 46 // TODO(wasm): move brand check to the respective types, and don't throw
44 // in it, rather, use a provided ErrorThrower, or let caller handle it. 47 // in it, rather, use a provided ErrorThrower, or let caller handle it.
45 static bool HasBrand(i::Handle<i::Object> value, i::Handle<i::Symbol> sym) { 48 static bool HasBrand(i::Handle<i::Object> value, i::Handle<i::Symbol> sym) {
46 if (!value->IsJSObject()) return false; 49 if (!value->IsJSObject()) return false;
47 i::Handle<i::JSObject> object = i::Handle<i::JSObject>::cast(value); 50 i::Handle<i::JSObject> object = i::Handle<i::JSObject>::cast(value);
48 Maybe<bool> has_brand = i::JSObject::HasOwnProperty(object, sym); 51 Maybe<bool> has_brand = i::JSObject::HasOwnProperty(object, sym);
49 return has_brand.FromMaybe(false); 52 return has_brand.FromMaybe(false);
50 } 53 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 121 }
119 if (length > i::wasm::kV8MaxWasmModuleSize) { 122 if (length > i::wasm::kV8MaxWasmModuleSize) {
120 thrower->RangeError("buffer source exceeds maximum size of %zu (is %zu)", 123 thrower->RangeError("buffer source exceeds maximum size of %zu (is %zu)",
121 i::wasm::kV8MaxWasmModuleSize, length); 124 i::wasm::kV8MaxWasmModuleSize, length);
122 } 125 }
123 if (thrower->error()) return i::wasm::ModuleWireBytes(nullptr, nullptr); 126 if (thrower->error()) return i::wasm::ModuleWireBytes(nullptr, nullptr);
124 // TODO(titzer): use the handle as well? 127 // TODO(titzer): use the handle as well?
125 return i::wasm::ModuleWireBytes(start, start + length); 128 return i::wasm::ModuleWireBytes(start, start + length);
126 } 129 }
127 130
128 i::MaybeHandle<i::JSReceiver> GetValueAsImports(const Local<Value>& arg, 131 i::MaybeHandle<i::JSReceiver> GetValueAsImports(Local<Value> arg,
129 ErrorThrower* thrower) { 132 ErrorThrower* thrower) {
130 if (arg->IsUndefined()) return {}; 133 if (arg->IsUndefined()) return {};
131 134
132 if (!arg->IsObject()) { 135 if (!arg->IsObject()) {
133 thrower->TypeError("Argument 1 must be an object"); 136 thrower->TypeError("Argument 1 must be an object");
134 return {}; 137 return {};
135 } 138 }
136 Local<Object> obj = Local<Object>::Cast(arg); 139 Local<Object> obj = Local<Object>::Cast(arg);
137 return i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj)); 140 return i::Handle<i::JSReceiver>::cast(v8::Utils::OpenHandle(*obj));
138 } 141 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 316
314 HandleScope scope(args.GetIsolate()); 317 HandleScope scope(args.GetIsolate());
315 318
316 Local<Context> context = isolate->GetCurrentContext(); 319 Local<Context> context = isolate->GetCurrentContext();
317 Local<Value> module = args[0]; 320 Local<Value> module = args[0];
318 321
319 const uint8_t* instance_str = reinterpret_cast<const uint8_t*>("instance"); 322 const uint8_t* instance_str = reinterpret_cast<const uint8_t*>("instance");
320 const uint8_t* module_str = reinterpret_cast<const uint8_t*>("module"); 323 const uint8_t* module_str = reinterpret_cast<const uint8_t*>("module");
321 Local<Value> instance; 324 Local<Value> instance;
322 if (!WebAssemblyInstantiateImpl(isolate, module, args.Data()) 325 if (!WebAssemblyInstantiateImpl(isolate, module, args.Data())
323 .ToLocal(&instance)) 326 .ToLocal(&instance)) {
324 return; 327 return;
328 }
325 329
326 Local<Object> ret = Object::New(isolate); 330 Local<Object> ret = Object::New(isolate);
327 Local<String> instance_name = 331 Local<String> instance_name =
328 String::NewFromOneByte(isolate, instance_str, 332 String::NewFromOneByte(isolate, instance_str,
329 NewStringType::kInternalized) 333 NewStringType::kInternalized)
330 .ToLocalChecked(); 334 .ToLocalChecked();
331 Local<String> module_name = 335 Local<String> module_name =
332 String::NewFromOneByte(isolate, module_str, NewStringType::kInternalized) 336 String::NewFromOneByte(isolate, module_str, NewStringType::kInternalized)
333 .ToLocalChecked(); 337 .ToLocalChecked();
334 338
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate); 972 i::Handle<i::Symbol> symbol(isolate->context()->wasm_memory_sym(), isolate);
969 return HasBrand(value, symbol); 973 return HasBrand(value, symbol);
970 } 974 }
971 975
972 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) { 976 bool WasmJs::IsWasmTableObject(Isolate* isolate, Handle<Object> value) {
973 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate); 977 i::Handle<i::Symbol> symbol(isolate->context()->wasm_table_sym(), isolate);
974 return HasBrand(value, symbol); 978 return HasBrand(value, symbol);
975 } 979 }
976 } // namespace internal 980 } // namespace internal
977 } // namespace v8 981 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regress-712569.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698