Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: src/objects.h

Issue 2590563003: [promises] Remove deferred object (Closed)
Patch Set: add comments Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 6573 matching lines...) Expand 10 before | Expand all | Expand 10 after
6584 }; 6584 };
6585 6585
6586 class JSPromise; 6586 class JSPromise;
6587 6587
6588 // Struct to hold state required for PromiseReactionJob. 6588 // Struct to hold state required for PromiseReactionJob.
6589 class PromiseReactionJobInfo : public Struct { 6589 class PromiseReactionJobInfo : public Struct {
6590 public: 6590 public:
6591 DECL_ACCESSORS(promise, JSPromise) 6591 DECL_ACCESSORS(promise, JSPromise)
6592 DECL_ACCESSORS(value, Object) 6592 DECL_ACCESSORS(value, Object)
6593 DECL_ACCESSORS(tasks, Object) 6593 DECL_ACCESSORS(tasks, Object)
6594 DECL_ACCESSORS(deferred, Object) 6594
6595 // Check comment in JSPromise for information on what state these
6596 // deferred fields could be in.
6597 DECL_ACCESSORS(deferred_promise, Object)
6598 DECL_ACCESSORS(deferred_on_resolve, Object)
6599 DECL_ACCESSORS(deferred_on_reject, Object)
6595 DECL_ACCESSORS(debug_id, Object) 6600 DECL_ACCESSORS(debug_id, Object)
6596 DECL_ACCESSORS(debug_name, Object) 6601 DECL_ACCESSORS(debug_name, Object)
6597 DECL_ACCESSORS(context, Context) 6602 DECL_ACCESSORS(context, Context)
6598 6603
6599 static const int kPromiseOffset = Struct::kHeaderSize; 6604 static const int kPromiseOffset = Struct::kHeaderSize;
6600 static const int kValueOffset = kPromiseOffset + kPointerSize; 6605 static const int kValueOffset = kPromiseOffset + kPointerSize;
6601 static const int kTasksOffset = kValueOffset + kPointerSize; 6606 static const int kTasksOffset = kValueOffset + kPointerSize;
6602 static const int kDeferredOffset = kTasksOffset + kPointerSize; 6607 static const int kDeferredPromiseOffset = kTasksOffset + kPointerSize;
6603 static const int kDebugIdOffset = kDeferredOffset + kPointerSize; 6608 static const int kDeferredOnResolveOffset =
6609 kDeferredPromiseOffset + kPointerSize;
6610 static const int kDeferredOnRejectOffset =
6611 kDeferredOnResolveOffset + kPointerSize;
6612 static const int kDebugIdOffset = kDeferredOnRejectOffset + kPointerSize;
6604 static const int kDebugNameOffset = kDebugIdOffset + kPointerSize; 6613 static const int kDebugNameOffset = kDebugIdOffset + kPointerSize;
6605 static const int kContextOffset = kDebugNameOffset + kPointerSize; 6614 static const int kContextOffset = kDebugNameOffset + kPointerSize;
6606 static const int kSize = kContextOffset + kPointerSize; 6615 static const int kSize = kContextOffset + kPointerSize;
6607 6616
6608 DECLARE_CAST(PromiseReactionJobInfo) 6617 DECLARE_CAST(PromiseReactionJobInfo)
6609 DECLARE_PRINTER(PromiseReactionJobInfo) 6618 DECLARE_PRINTER(PromiseReactionJobInfo)
6610 DECLARE_VERIFIER(PromiseReactionJobInfo) 6619 DECLARE_VERIFIER(PromiseReactionJobInfo)
6611 6620
6612 private: 6621 private:
6613 DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseReactionJobInfo); 6622 DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseReactionJobInfo);
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
8620 kSize> BodyDescriptor; 8629 kSize> BodyDescriptor;
8621 }; 8630 };
8622 8631
8623 class JSPromise : public JSObject { 8632 class JSPromise : public JSObject {
8624 public: 8633 public:
8625 DECL_INT_ACCESSORS(status) 8634 DECL_INT_ACCESSORS(status)
8626 DECL_ACCESSORS(result, Object) 8635 DECL_ACCESSORS(result, Object)
8627 8636
8628 // There are 3 possible states for these fields -- 8637 // There are 3 possible states for these fields --
8629 // 1) Undefined -- This is the zero state when there is no callback 8638 // 1) Undefined -- This is the zero state when there is no callback
8630 // or deferred registered. 8639 // or deferred fields registered.
8640 //
8631 // 2) Object -- There is a single Callable directly attached to the 8641 // 2) Object -- There is a single Callable directly attached to the
8632 // fulfill_reactions, reject_reactions and the deferred JSObject is 8642 // fulfill_reactions, reject_reactions and the deferred fields are
8633 // directly attached to the deferred field. 8643 // directly attached to the slots. In this state, deferred_promise
8644 // is a JSReceiver and deferred_on_{resolve, reject} are Callables.
8645 //
8634 // 3) FixedArray -- There is more than one callback and deferred 8646 // 3) FixedArray -- There is more than one callback and deferred
8635 // attached to a FixedArray. 8647 // fields attached to a FixedArray.
8636 DECL_ACCESSORS(deferred, Object) 8648 DECL_ACCESSORS(deferred_promise, Object)
8649 DECL_ACCESSORS(deferred_on_resolve, Object)
8650 DECL_ACCESSORS(deferred_on_reject, Object)
8637 DECL_ACCESSORS(fulfill_reactions, Object) 8651 DECL_ACCESSORS(fulfill_reactions, Object)
8638 DECL_ACCESSORS(reject_reactions, Object) 8652 DECL_ACCESSORS(reject_reactions, Object)
8639 8653
8640 DECL_INT_ACCESSORS(flags) 8654 DECL_INT_ACCESSORS(flags)
8641 8655
8642 // [has_handler]: Whether this promise has a reject handler or not. 8656 // [has_handler]: Whether this promise has a reject handler or not.
8643 DECL_BOOLEAN_ACCESSORS(has_handler) 8657 DECL_BOOLEAN_ACCESSORS(has_handler)
8644 8658
8645 static const char* Status(int status); 8659 static const char* Status(int status);
8646 8660
8647 DECLARE_CAST(JSPromise) 8661 DECLARE_CAST(JSPromise)
8648 8662
8649 // Dispatched behavior. 8663 // Dispatched behavior.
8650 DECLARE_PRINTER(JSPromise) 8664 DECLARE_PRINTER(JSPromise)
8651 DECLARE_VERIFIER(JSPromise) 8665 DECLARE_VERIFIER(JSPromise)
8652 8666
8653 // Layout description. 8667 // Layout description.
8654 static const int kStatusOffset = JSObject::kHeaderSize; 8668 static const int kStatusOffset = JSObject::kHeaderSize;
8655 static const int kResultOffset = kStatusOffset + kPointerSize; 8669 static const int kResultOffset = kStatusOffset + kPointerSize;
8656 static const int kDeferredOffset = kResultOffset + kPointerSize; 8670 static const int kDeferredPromiseOffset = kResultOffset + kPointerSize;
8657 static const int kFulfillReactionsOffset = kDeferredOffset + kPointerSize; 8671 static const int kDeferredOnResolveOffset =
8672 kDeferredPromiseOffset + kPointerSize;
8673 static const int kDeferredOnRejectOffset =
8674 kDeferredOnResolveOffset + kPointerSize;
8675 static const int kFulfillReactionsOffset =
8676 kDeferredOnRejectOffset + kPointerSize;
8658 static const int kRejectReactionsOffset = 8677 static const int kRejectReactionsOffset =
8659 kFulfillReactionsOffset + kPointerSize; 8678 kFulfillReactionsOffset + kPointerSize;
8660 static const int kFlagsOffset = kRejectReactionsOffset + kPointerSize; 8679 static const int kFlagsOffset = kRejectReactionsOffset + kPointerSize;
8661 static const int kSize = kFlagsOffset + kPointerSize; 8680 static const int kSize = kFlagsOffset + kPointerSize;
8662 8681
8663 // Flags layout. 8682 // Flags layout.
8664 static const int kHasHandlerBit = 0; 8683 static const int kHasHandlerBit = 0;
8665 }; 8684 };
8666 8685
8667 // Regular expressions 8686 // Regular expressions
(...skipping 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after
11695 } 11714 }
11696 }; 11715 };
11697 11716
11698 11717
11699 } // NOLINT, false-positive due to second-order macros. 11718 } // NOLINT, false-positive due to second-order macros.
11700 } // NOLINT, false-positive due to second-order macros. 11719 } // NOLINT, false-positive due to second-order macros.
11701 11720
11702 #include "src/objects/object-macros-undef.h" 11721 #include "src/objects/object-macros-undef.h"
11703 11722
11704 #endif // V8_OBJECTS_H_ 11723 #endif // V8_OBJECTS_H_
OLDNEW
« src/builtins/builtins-promise.cc ('K') | « src/js/promise.js ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698