• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5@generateCppClass
6extern class PromiseCapability extends Struct {
7  promise: JSReceiver|Undefined;
8  // TODO(joshualitt): Can these be typed more specifically.
9  resolve: Object;
10  reject: Object;
11}
12
13// PromiseReaction constants
14type PromiseReactionType extends int31 constexpr 'PromiseReaction::Type';
15const kPromiseReactionFulfill: constexpr PromiseReactionType
16    generates 'PromiseReaction::kFulfill';
17const kPromiseReactionReject: constexpr PromiseReactionType
18    generates 'PromiseReaction::kReject';
19const kPromiseReactionSize:
20    constexpr int31 generates 'PromiseReaction::kSize';
21const kPromiseReactionFulfillHandlerOffset: constexpr int31
22    generates 'PromiseReaction::kFulfillHandlerOffset';
23const kPromiseReactionPromiseOrCapabilityOffset: constexpr int31
24    generates 'PromiseReaction::kPromiseOrCapabilityOffset';
25const kPromiseReactionContinuationPreservedEmbedderDataOffset: constexpr int31
26    generates 'PromiseReaction::kContinuationPreservedEmbedderDataOffset';
27
28@generateCppClass
29extern class PromiseReaction extends Struct {
30  next: PromiseReaction|Zero;
31  reject_handler: Callable|Undefined;
32  fulfill_handler: Callable|Undefined;
33  // Either a JSPromise (in case of native promises), a PromiseCapability
34  // (general case), or undefined (in case of await).
35  promise_or_capability: JSPromise|PromiseCapability|Undefined;
36  continuation_preserved_embedder_data: Object|Undefined;
37}
38
39// PromiseReactionJobTask constants
40const kPromiseReactionJobTaskSizeOfAllPromiseReactionJobTasks: constexpr int31
41    generates 'PromiseReactionJobTask::kSizeOfAllPromiseReactionJobTasks';
42const kPromiseReactionJobTaskHandlerOffset: constexpr int31
43    generates 'PromiseReactionJobTask::kHandlerOffset';
44const kPromiseReactionJobTaskPromiseOrCapabilityOffset: constexpr int31
45    generates 'PromiseReactionJobTask::kPromiseOrCapabilityOffset';
46const kPromiseReactionJobTaskContinuationPreservedEmbedderDataOffset:
47    constexpr int31
48    generates 'PromiseReactionJobTask::kContinuationPreservedEmbedderDataOffset'
49    ;
50
51@abstract
52@generateCppClass
53extern class PromiseReactionJobTask extends Microtask {
54  argument: Object;
55  context: Context;
56  handler: Callable|Undefined;
57  // Either a JSPromise (in case of native promises), a PromiseCapability
58  // (general case), or undefined (in case of await).
59  promise_or_capability: JSPromise|PromiseCapability|Undefined;
60  continuation_preserved_embedder_data: Object|Undefined;
61}
62
63@generateCppClass
64extern class PromiseFulfillReactionJobTask extends PromiseReactionJobTask {
65}
66
67@generateCppClass
68extern class PromiseRejectReactionJobTask extends PromiseReactionJobTask {
69}
70
71@generateCppClass
72extern class PromiseResolveThenableJobTask extends Microtask {
73  context: Context;
74  promise_to_resolve: JSPromise;
75  thenable: JSReceiver;
76  then: JSReceiver;
77}
78