js-promise.tq 1.11 KB
Newer Older
Tobias Tebbi's avatar
Tobias Tebbi committed
1 2 3 4
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8
bitfield struct JSPromiseFlags extends uint31 {
  status: PromiseState: 2 bit;
  has_handler: bool: 1 bit;
  handled_hint: bool: 1 bit;
9
  is_silent: bool: 1 bit;
10 11
  async_task_id: int32: 22 bit;
}
Tobias Tebbi's avatar
Tobias Tebbi committed
12 13

extern class JSPromise extends JSObject {
14
  macro Status(): PromiseState {
15
    return this.flags.status;
Tobias Tebbi's avatar
Tobias Tebbi committed
16 17
  }

18
  macro SetStatus(status: constexpr PromiseState): void {
19 20
    assert(this.Status() == PromiseState::kPending);
    assert(status != PromiseState::kPending);
Tobias Tebbi's avatar
Tobias Tebbi committed
21

22
    this.flags.status = status;
Tobias Tebbi's avatar
Tobias Tebbi committed
23 24
  }

25
  macro HasHandler(): bool {
26
    return this.flags.has_handler;
Tobias Tebbi's avatar
Tobias Tebbi committed
27 28
  }

29
  macro SetHasHandler(): void {
30
    this.flags.has_handler = true;
31 32
  }

Tobias Tebbi's avatar
Tobias Tebbi committed
33 34 35
  // Smi 0 terminated list of PromiseReaction objects in case the JSPromise was
  // not settled yet, otherwise the result.
  reactions_or_result: Zero|PromiseReaction|JSAny;
36
  flags: SmiTagged<JSPromiseFlags>;
Tobias Tebbi's avatar
Tobias Tebbi committed
37
}
38 39 40 41

@doNotGenerateCast
extern class JSPromiseConstructor extends JSFunction
    generates 'TNode<JSFunction>';