OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 HandleScope scope(isolate); | 267 HandleScope scope(isolate); |
268 DCHECK_EQ(1, args.length()); | 268 DCHECK_EQ(1, args.length()); |
269 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 269 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
270 Handle<String> type = Object::TypeOf(isolate, object); | 270 Handle<String> type = Object::TypeOf(isolate, object); |
271 THROW_NEW_ERROR_RETURN_FAILURE( | 271 THROW_NEW_ERROR_RETURN_FAILURE( |
272 isolate, NewTypeError(MessageTemplate::kApplyNonFunction, object, type)); | 272 isolate, NewTypeError(MessageTemplate::kApplyNonFunction, object, type)); |
273 } | 273 } |
274 | 274 |
275 | 275 |
276 RUNTIME_FUNCTION(Runtime_PromiseRejectEvent) { | 276 RUNTIME_FUNCTION(Runtime_PromiseRejectEvent) { |
277 DCHECK(args.length() == 3); | 277 DCHECK(args.length() == 4); |
278 HandleScope scope(isolate); | 278 HandleScope scope(isolate); |
279 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 279 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); |
280 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 280 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
281 CONVERT_BOOLEAN_ARG_CHECKED(debug_event, 2); | 281 CONVERT_BOOLEAN_ARG_CHECKED(debug_event, 2); |
282 if (debug_event) isolate->debug()->OnPromiseReject(promise, value); | 282 CONVERT_BOOLEAN_ARG_CHECKED(from_promise_reject, 3); |
adamk
2016/08/23 22:29:27
Rather than taking a second bool arg, you could sp
Dan Ehrenberg
2016/08/23 23:28:38
Very good point, done.
| |
283 if (debug_event) { | |
284 Handle<JSObject> rejected_promise = promise; | |
285 if (from_promise_reject) { | |
286 Handle<Object> promise_on_stack = isolate->GetPromiseOnStackOnThrow(); | |
287 if (promise_on_stack->IsJSObject()) | |
288 rejected_promise = Handle<JSObject>::cast(promise_on_stack); | |
289 } | |
290 isolate->debug()->OnPromiseReject(rejected_promise, value); | |
291 } | |
283 Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 292 Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); |
284 // Do not report if we actually have a handler. | 293 // Do not report if we actually have a handler. |
285 if (JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)) { | 294 if (JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)) { |
286 isolate->ReportPromiseReject(promise, value, | 295 isolate->ReportPromiseReject(promise, value, |
287 v8::kPromiseRejectWithNoHandler); | 296 v8::kPromiseRejectWithNoHandler); |
288 } | 297 } |
289 return isolate->heap()->undefined_value(); | 298 return isolate->heap()->undefined_value(); |
290 } | 299 } |
291 | 300 |
292 | 301 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 | 572 |
564 RUNTIME_FUNCTION(Runtime_Typeof) { | 573 RUNTIME_FUNCTION(Runtime_Typeof) { |
565 HandleScope scope(isolate); | 574 HandleScope scope(isolate); |
566 DCHECK_EQ(1, args.length()); | 575 DCHECK_EQ(1, args.length()); |
567 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 576 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
568 return *Object::TypeOf(isolate, object); | 577 return *Object::TypeOf(isolate, object); |
569 } | 578 } |
570 | 579 |
571 } // namespace internal | 580 } // namespace internal |
572 } // namespace v8 | 581 } // namespace v8 |
OLD | NEW |