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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 debug_id = accessor->Get(array, 0); | 594 debug_id = accessor->Get(array, 0); |
595 debug_name = accessor->Get(array, 1); | 595 debug_name = accessor->Get(array, 1); |
596 } | 596 } |
597 } | 597 } |
598 Handle<PromiseReactionJobInfo> info = | 598 Handle<PromiseReactionJobInfo> info = |
599 isolate->factory()->NewPromiseReactionJobInfo(value, tasks, deferred, | 599 isolate->factory()->NewPromiseReactionJobInfo(value, tasks, deferred, |
600 debug_id, debug_name, | 600 debug_id, debug_name, |
601 isolate->native_context()); | 601 isolate->native_context()); |
602 isolate->EnqueueMicrotask(info); | 602 isolate->EnqueueMicrotask(info); |
603 } | 603 } |
604 | |
605 void PromiseFulfill(Isolate* isolate, Handle<JSReceiver> promise, | |
606 Handle<Smi> status, Handle<Object> value, | |
607 Handle<Symbol> reaction) { | |
608 Handle<Object> tasks = JSReceiver::GetDataProperty(promise, reaction); | |
609 if (!tasks->IsUndefined(isolate)) { | |
610 Handle<Object> deferred = JSReceiver::GetDataProperty( | |
611 promise, isolate->factory()->promise_deferred_reaction_symbol()); | |
612 EnqueuePromiseReactionJob(isolate, value, tasks, deferred, status); | |
613 } | |
614 } | |
615 } // namespace | 604 } // namespace |
616 | 605 |
617 RUNTIME_FUNCTION(Runtime_PromiseReject) { | |
618 DCHECK(args.length() == 3); | |
619 HandleScope scope(isolate); | |
620 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | |
621 CONVERT_ARG_HANDLE_CHECKED(Object, reason, 1); | |
622 CONVERT_BOOLEAN_ARG_CHECKED(debug_event, 2); | |
623 | |
624 PromiseRejectEvent(isolate, promise, promise, reason, debug_event); | |
625 | |
626 Handle<Smi> status = handle(Smi::FromInt(kPromiseRejected), isolate); | |
627 Handle<Symbol> reaction = | |
628 isolate->factory()->promise_reject_reactions_symbol(); | |
629 PromiseFulfill(isolate, promise, status, reason, reaction); | |
630 return isolate->heap()->undefined_value(); | |
631 } | |
632 | |
633 RUNTIME_FUNCTION(Runtime_PromiseFulfill) { | 606 RUNTIME_FUNCTION(Runtime_PromiseFulfill) { |
634 DCHECK(args.length() == 4); | 607 DCHECK(args.length() == 4); |
635 HandleScope scope(isolate); | 608 HandleScope scope(isolate); |
636 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, promise, 0); | 609 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, promise, 0); |
637 CONVERT_ARG_HANDLE_CHECKED(Smi, status, 1); | 610 CONVERT_ARG_HANDLE_CHECKED(Smi, status, 1); |
638 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 611 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
639 CONVERT_ARG_HANDLE_CHECKED(Symbol, reaction, 3); | 612 CONVERT_ARG_HANDLE_CHECKED(Symbol, reaction, 3); |
640 PromiseFulfill(isolate, promise, status, value, reaction); | 613 Handle<Object> tasks = JSReceiver::GetDataProperty(promise, reaction); |
| 614 if (!tasks->IsUndefined(isolate)) { |
| 615 Handle<Object> deferred = JSReceiver::GetDataProperty( |
| 616 promise, isolate->factory()->promise_deferred_reaction_symbol()); |
| 617 EnqueuePromiseReactionJob(isolate, value, tasks, deferred, status); |
| 618 } |
641 return isolate->heap()->undefined_value(); | 619 return isolate->heap()->undefined_value(); |
642 } | 620 } |
643 | 621 |
644 RUNTIME_FUNCTION(Runtime_EnqueuePromiseReactionJob) { | 622 RUNTIME_FUNCTION(Runtime_EnqueuePromiseReactionJob) { |
645 HandleScope scope(isolate); | 623 HandleScope scope(isolate); |
646 DCHECK(args.length() == 4); | 624 DCHECK(args.length() == 4); |
647 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 625 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
648 CONVERT_ARG_HANDLE_CHECKED(Object, tasks, 1); | 626 CONVERT_ARG_HANDLE_CHECKED(Object, tasks, 1); |
649 CONVERT_ARG_HANDLE_CHECKED(Object, deferred, 2); | 627 CONVERT_ARG_HANDLE_CHECKED(Object, deferred, 2); |
650 CONVERT_ARG_HANDLE_CHECKED(Object, status, 3); | 628 CONVERT_ARG_HANDLE_CHECKED(Object, status, 3); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 | 692 |
715 RUNTIME_FUNCTION(Runtime_Typeof) { | 693 RUNTIME_FUNCTION(Runtime_Typeof) { |
716 HandleScope scope(isolate); | 694 HandleScope scope(isolate); |
717 DCHECK_EQ(1, args.length()); | 695 DCHECK_EQ(1, args.length()); |
718 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 696 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
719 return *Object::TypeOf(isolate, object); | 697 return *Object::TypeOf(isolate, object); |
720 } | 698 } |
721 | 699 |
722 } // namespace internal | 700 } // namespace internal |
723 } // namespace v8 | 701 } // namespace v8 |
OLD | NEW |