OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins-promise.h" | 5 #include "src/builtins/builtins-promise.h" |
6 #include "src/builtins/builtins-constructor.h" | 6 #include "src/builtins/builtins-constructor.h" |
7 #include "src/builtins/builtins-utils.h" | 7 #include "src/builtins/builtins-utils.h" |
8 #include "src/builtins/builtins.h" | 8 #include "src/builtins/builtins.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stub-assembler.h" | 10 #include "src/code-stub-assembler.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 Label do_enqueue(this), fulfill(this), if_cycle(this, Label::kDeferred), | 674 Label do_enqueue(this), fulfill(this), if_cycle(this, Label::kDeferred), |
675 if_rejectpromise(this, Label::kDeferred), out(this); | 675 if_rejectpromise(this, Label::kDeferred), out(this); |
676 | 676 |
677 Label cycle_check(this); | 677 Label cycle_check(this); |
678 GotoIfNot(IsPromiseHookEnabledOrDebugIsActive(), &cycle_check); | 678 GotoIfNot(IsPromiseHookEnabledOrDebugIsActive(), &cycle_check); |
679 CallRuntime(Runtime::kPromiseHookResolve, context, promise); | 679 CallRuntime(Runtime::kPromiseHookResolve, context, promise); |
680 Goto(&cycle_check); | 680 Goto(&cycle_check); |
681 | 681 |
682 Bind(&cycle_check); | 682 Bind(&cycle_check); |
683 // 6. If SameValue(resolution, promise) is true, then | 683 // 6. If SameValue(resolution, promise) is true, then |
684 GotoIf(SameValue(promise, result, context), &if_cycle); | 684 GotoIf(SameValue(promise, result), &if_cycle); |
685 | 685 |
686 // 7. If Type(resolution) is not Object, then | 686 // 7. If Type(resolution) is not Object, then |
687 GotoIf(TaggedIsSmi(result), &fulfill); | 687 GotoIf(TaggedIsSmi(result), &fulfill); |
688 GotoIfNot(IsJSReceiver(result), &fulfill); | 688 GotoIfNot(IsJSReceiver(result), &fulfill); |
689 | 689 |
690 Label if_nativepromise(this), if_notnativepromise(this, Label::kDeferred); | 690 Label if_nativepromise(this), if_notnativepromise(this, Label::kDeferred); |
691 Node* const native_context = LoadNativeContext(context); | 691 Node* const native_context = LoadNativeContext(context); |
692 Node* const promise_fun = | 692 Node* const promise_fun = |
693 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); | 693 LoadContextElement(native_context, Context::PROMISE_FUNCTION_INDEX); |
694 BranchIfFastPath(native_context, promise_fun, result, &if_nativepromise, | 694 BranchIfFastPath(native_context, promise_fun, result, &if_nativepromise, |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 { | 1420 { |
1421 // 3.a Let xConstructor be ? Get(x, "constructor"). | 1421 // 3.a Let xConstructor be ? Get(x, "constructor"). |
1422 // The constructor lookup is observable. | 1422 // The constructor lookup is observable. |
1423 Node* const constructor_str = | 1423 Node* const constructor_str = |
1424 HeapConstant(isolate->factory()->constructor_string()); | 1424 HeapConstant(isolate->factory()->constructor_string()); |
1425 Callable getproperty_callable = CodeFactory::GetProperty(isolate); | 1425 Callable getproperty_callable = CodeFactory::GetProperty(isolate); |
1426 Node* const constructor = | 1426 Node* const constructor = |
1427 CallStub(getproperty_callable, context, value, constructor_str); | 1427 CallStub(getproperty_callable, context, value, constructor_str); |
1428 | 1428 |
1429 // 3.b If SameValue(xConstructor, C) is true, return x. | 1429 // 3.b If SameValue(xConstructor, C) is true, return x. |
1430 GotoIfNot(SameValue(constructor, receiver, context), &if_valueisnotpromise); | 1430 GotoIfNot(SameValue(constructor, receiver), &if_valueisnotpromise); |
1431 | 1431 |
1432 Return(value); | 1432 Return(value); |
1433 } | 1433 } |
1434 | 1434 |
1435 Bind(&if_valueisnotpromise); | 1435 Bind(&if_valueisnotpromise); |
1436 { | 1436 { |
1437 Label if_nativepromise(this), if_notnativepromise(this); | 1437 Label if_nativepromise(this), if_notnativepromise(this); |
1438 Branch(WordEqual(promise_fun, receiver), &if_nativepromise, | 1438 Branch(WordEqual(promise_fun, receiver), &if_nativepromise, |
1439 &if_notnativepromise); | 1439 &if_notnativepromise); |
1440 | 1440 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1769 // 5. Return ? Invoke(promise, "then", « thenFinally, catchFinally »). | 1769 // 5. Return ? Invoke(promise, "then", « thenFinally, catchFinally »). |
1770 Node* const result = | 1770 Node* const result = |
1771 CallJS(call_callable, context, then, promise, var_then_finally.value(), | 1771 CallJS(call_callable, context, then, promise, var_then_finally.value(), |
1772 var_catch_finally.value()); | 1772 var_catch_finally.value()); |
1773 Return(result); | 1773 Return(result); |
1774 } | 1774 } |
1775 } | 1775 } |
1776 | 1776 |
1777 } // namespace internal | 1777 } // namespace internal |
1778 } // namespace v8 | 1778 } // namespace v8 |
OLD | NEW |