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-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 #include "src/promise-utils.h" | 9 #include "src/promise-utils.h" |
10 | 10 |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } | 472 } |
473 | 473 |
474 a->Bind(&if_existingcallbacks); | 474 a->Bind(&if_existingcallbacks); |
475 { | 475 { |
476 Label if_singlecallback(a), if_multiplecallbacks(a); | 476 Label if_singlecallback(a), if_multiplecallbacks(a); |
477 a->BranchIfJSObject(existing_deferred, &if_singlecallback, | 477 a->BranchIfJSObject(existing_deferred, &if_singlecallback, |
478 &if_multiplecallbacks); | 478 &if_multiplecallbacks); |
479 | 479 |
480 a->Bind(&if_singlecallback); | 480 a->Bind(&if_singlecallback); |
481 { | 481 { |
482 // Create new FixedArrays to store callbacks. | 482 // Create new FixedArrays to store callbacks, and migrate |
| 483 // existing callbacks. |
483 Node* const deferreds = | 484 Node* const deferreds = |
484 a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2)); | 485 a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2)); |
| 486 a->StoreFixedArrayElement(deferreds, 0, existing_deferred); |
| 487 a->StoreFixedArrayElement(deferreds, 1, deferred); |
| 488 |
485 Node* const fulfill_reactions = | 489 Node* const fulfill_reactions = |
486 a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2)); | 490 a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2)); |
487 Node* const reject_reactions = | |
488 a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2)); | |
489 | |
490 // Store existing callbacks in FixedArrays. | |
491 a->StoreFixedArrayElement(deferreds, 0, existing_deferred); | |
492 a->StoreFixedArrayElement( | 491 a->StoreFixedArrayElement( |
493 fulfill_reactions, 0, | 492 fulfill_reactions, 0, |
494 a->LoadObjectField(promise, JSPromise::kFulfillReactionsOffset)); | 493 a->LoadObjectField(promise, JSPromise::kFulfillReactionsOffset)); |
| 494 a->StoreFixedArrayElement(fulfill_reactions, 1, var_on_resolve.value()); |
| 495 |
| 496 Node* const reject_reactions = |
| 497 a->AllocateFixedArray(FAST_ELEMENTS, a->Int32Constant(2)); |
495 a->StoreFixedArrayElement( | 498 a->StoreFixedArrayElement( |
496 reject_reactions, 0, | 499 reject_reactions, 0, |
497 a->LoadObjectField(promise, JSPromise::kRejectReactionsOffset)); | 500 a->LoadObjectField(promise, JSPromise::kRejectReactionsOffset)); |
498 | |
499 // Store new callbacks in FixedArrays. | |
500 a->StoreFixedArrayElement(deferreds, 1, deferred); | |
501 a->StoreFixedArrayElement(fulfill_reactions, 1, var_on_resolve.value()); | |
502 a->StoreFixedArrayElement(reject_reactions, 1, var_on_reject.value()); | 501 a->StoreFixedArrayElement(reject_reactions, 1, var_on_reject.value()); |
503 | 502 |
504 // Store new FixedArrays in promise. | 503 // Store new FixedArrays in promise. |
505 a->StoreObjectField(promise, JSPromise::kDeferredOffset, deferreds); | 504 a->StoreObjectField(promise, JSPromise::kDeferredOffset, deferreds); |
506 a->StoreObjectField(promise, JSPromise::kFulfillReactionsOffset, | 505 a->StoreObjectField(promise, JSPromise::kFulfillReactionsOffset, |
507 fulfill_reactions); | 506 fulfill_reactions); |
508 a->StoreObjectField(promise, JSPromise::kRejectReactionsOffset, | 507 a->StoreObjectField(promise, JSPromise::kRejectReactionsOffset, |
509 reject_reactions); | 508 reject_reactions); |
510 a->Goto(&out); | 509 a->Goto(&out); |
511 } | 510 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 // 5. Return PerformPromiseThen(promise, onFulfilled, onRejected, | 662 // 5. Return PerformPromiseThen(promise, onFulfilled, onRejected, |
664 // resultCapability). | 663 // resultCapability). |
665 a.Bind(&perform_promise_then); | 664 a.Bind(&perform_promise_then); |
666 Node* const result = InternalPerformPromiseThen( | 665 Node* const result = InternalPerformPromiseThen( |
667 &a, context, promise, on_resolve, on_reject, var_deferred.value()); | 666 &a, context, promise, on_resolve, on_reject, var_deferred.value()); |
668 a.Return(result); | 667 a.Return(result); |
669 } | 668 } |
670 | 669 |
671 } // namespace internal | 670 } // namespace internal |
672 } // namespace v8 | 671 } // namespace v8 |
OLD | NEW |