| 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   DCHECK_EQ(1, args.length()); | 267   DCHECK_EQ(1, args.length()); | 
| 268   CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 268   CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 
| 269   Handle<String> type = Object::TypeOf(isolate, object); | 269   Handle<String> type = Object::TypeOf(isolate, object); | 
| 270   THROW_NEW_ERROR_RETURN_FAILURE( | 270   THROW_NEW_ERROR_RETURN_FAILURE( | 
| 271       isolate, NewTypeError(MessageTemplate::kApplyNonFunction, object, type)); | 271       isolate, NewTypeError(MessageTemplate::kApplyNonFunction, object, type)); | 
| 272 } | 272 } | 
| 273 | 273 | 
| 274 namespace { | 274 namespace { | 
| 275 | 275 | 
| 276 void PromiseRejectEvent(Isolate* isolate, Handle<JSObject> promise, | 276 void PromiseRejectEvent(Isolate* isolate, Handle<JSObject> promise, | 
| 277                         Handle<JSObject> rejected_promise, Handle<Object> value, | 277                         Handle<Object> rejected_promise, Handle<Object> value, | 
| 278                         bool debug_event) { | 278                         bool debug_event) { | 
| 279   if (isolate->debug()->is_active() && debug_event) { | 279   if (isolate->debug()->is_active() && debug_event) { | 
| 280     isolate->debug()->OnPromiseReject(rejected_promise, value); | 280     isolate->debug()->OnPromiseReject(rejected_promise, value); | 
| 281   } | 281   } | 
| 282   Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 282   Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 
| 283   // Do not report if we actually have a handler. | 283   // Do not report if we actually have a handler. | 
| 284   if (JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)) { | 284   if (JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)) { | 
| 285     isolate->ReportPromiseReject(promise, value, | 285     isolate->ReportPromiseReject(promise, value, | 
| 286                                  v8::kPromiseRejectWithNoHandler); | 286                                  v8::kPromiseRejectWithNoHandler); | 
| 287   } | 287   } | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 299   PromiseRejectEvent(isolate, promise, promise, value, debug_event); | 299   PromiseRejectEvent(isolate, promise, promise, value, debug_event); | 
| 300   return isolate->heap()->undefined_value(); | 300   return isolate->heap()->undefined_value(); | 
| 301 } | 301 } | 
| 302 | 302 | 
| 303 RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) { | 303 RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) { | 
| 304   DCHECK(args.length() == 2); | 304   DCHECK(args.length() == 2); | 
| 305   HandleScope scope(isolate); | 305   HandleScope scope(isolate); | 
| 306   CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 306   CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 
| 307   CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 307   CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 
| 308 | 308 | 
| 309   Handle<JSObject> rejected_promise = promise; | 309   Handle<Object> rejected_promise = promise; | 
| 310   if (isolate->debug()->is_active()) { | 310   if (isolate->debug()->is_active()) { | 
| 311     Handle<Object> promise_on_stack = isolate->GetPromiseOnStackOnThrow(); | 311     // If the Promise.reject call is caught, then this will return | 
| 312     if (promise_on_stack->IsJSObject()) { | 312     // undefined, which will be interpreted by PromiseRejectEvent | 
| 313       rejected_promise = Handle<JSObject>::cast(promise_on_stack); | 313     // as being a caught exception event. | 
| 314     } | 314     rejected_promise = isolate->GetPromiseOnStackOnThrow(); | 
| 315   } | 315   } | 
| 316   PromiseRejectEvent(isolate, promise, rejected_promise, value, true); | 316   PromiseRejectEvent(isolate, promise, rejected_promise, value, true); | 
| 317   return isolate->heap()->undefined_value(); | 317   return isolate->heap()->undefined_value(); | 
| 318 } | 318 } | 
| 319 | 319 | 
| 320 RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) { | 320 RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) { | 
| 321   DCHECK(args.length() == 1); | 321   DCHECK(args.length() == 1); | 
| 322   HandleScope scope(isolate); | 322   HandleScope scope(isolate); | 
| 323   CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 323   CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 
| 324   Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 324   Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 590 | 590 | 
| 591 RUNTIME_FUNCTION(Runtime_Typeof) { | 591 RUNTIME_FUNCTION(Runtime_Typeof) { | 
| 592   HandleScope scope(isolate); | 592   HandleScope scope(isolate); | 
| 593   DCHECK_EQ(1, args.length()); | 593   DCHECK_EQ(1, args.length()); | 
| 594   CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 594   CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 
| 595   return *Object::TypeOf(isolate, object); | 595   return *Object::TypeOf(isolate, object); | 
| 596 } | 596 } | 
| 597 | 597 | 
| 598 }  // namespace internal | 598 }  // namespace internal | 
| 599 }  // namespace v8 | 599 }  // namespace v8 | 
| OLD | NEW | 
|---|