• 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
5extern class PromiseCapability extends Struct {
6  promise: JSReceiver|Undefined;
7  // TODO(joshualitt): Can these be typed more specifically.
8  resolve: Object;
9  reject: Object;
10}
11
12// PromiseReaction constants
13type PromiseReactionType extends int31 constexpr 'PromiseReaction::Type';
14const kPromiseReactionFulfill: constexpr PromiseReactionType
15    generates 'PromiseReaction::kFulfill';
16const kPromiseReactionReject: constexpr PromiseReactionType
17    generates 'PromiseReaction::kReject';
18const kPromiseReactionSize:
19    constexpr int31 generates 'PromiseReaction::kSize';
20const kPromiseReactionFulfillHandlerOffset: constexpr int31
21    generates 'PromiseReaction::kFulfillHandlerOffset';
22const kPromiseReactionPromiseOrCapabilityOffset: constexpr int31
23    generates 'PromiseReaction::kPromiseOrCapabilityOffset';
24const kPromiseReactionContinuationPreservedEmbedderDataOffset: constexpr int31
25    generates 'PromiseReaction::kContinuationPreservedEmbedderDataOffset';
26
27extern class PromiseReaction extends Struct {
28  next: PromiseReaction|Zero;
29  reject_handler: Callable|Undefined;
30  fulfill_handler: Callable|Undefined;
31  // Either a JSPromise (in case of native promises), a PromiseCapability
32  // (general case), or undefined (in case of await).
33  promise_or_capability: JSPromise|PromiseCapability|Undefined;
34  continuation_preserved_embedder_data: Object|Undefined;
35}
36
37// PromiseReactionJobTask constants
38const kPromiseReactionJobTaskSizeOfAllPromiseReactionJobTasks: constexpr int31
39    generates 'PromiseReactionJobTask::kSizeOfAllPromiseReactionJobTasks';
40const kPromiseReactionJobTaskHandlerOffset: constexpr int31
41    generates 'PromiseReactionJobTask::kHandlerOffset';
42const kPromiseReactionJobTaskPromiseOrCapabilityOffset: constexpr int31
43    generates 'PromiseReactionJobTask::kPromiseOrCapabilityOffset';
44const kPromiseReactionJobTaskContinuationPreservedEmbedderDataOffset:
45    constexpr int31
46    generates 'PromiseReactionJobTask::kContinuationPreservedEmbedderDataOffset'
47    ;
48
49@abstract
50extern class PromiseReactionJobTask extends Microtask {
51  argument: Object;
52  context: Context;
53  handler: Callable|Undefined;
54  // Either a JSPromise (in case of native promises), a PromiseCapability
55  // (general case), or undefined (in case of await).
56  promise_or_capability: JSPromise|PromiseCapability|Undefined;
57  continuation_preserved_embedder_data: Object|Undefined;
58}
59
60extern class PromiseFulfillReactionJobTask extends PromiseReactionJobTask {}
61
62extern class PromiseRejectReactionJobTask extends PromiseReactionJobTask {}
63
64extern class PromiseResolveThenableJobTask extends Microtask {
65  context: Context;
66  promise_to_resolve: JSPromise;
67  thenable: JSReceiver;
68  then: JSReceiver;
69}
70