summaryrefslogtreecommitdiff
path: root/chromium/v8/src/objects/js-promise.tq
blob: 01426fd6d2e745e51049385e22dafed240828d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 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.

bitfield struct JSPromiseFlags extends uint31 {
  status: PromiseState: 2 bit;
  has_handler: bool: 1 bit;
  handled_hint: bool: 1 bit;
  is_silent: bool: 1 bit;
  async_task_id: int32: 22 bit;
}

extern class JSPromise extends JSObject {
  macro Status(): PromiseState {
    return this.flags.status;
  }

  macro SetStatus(status: constexpr PromiseState): void {
    dcheck(this.Status() == PromiseState::kPending);
    dcheck(status != PromiseState::kPending);

    this.flags.status = status;
  }

  macro HasHandler(): bool {
    return this.flags.has_handler;
  }

  macro SetHasHandler(): void {
    this.flags.has_handler = true;
  }

  // Smi 0 terminated list of PromiseReaction objects in case the JSPromise was
  // not settled yet, otherwise the result.
  reactions_or_result: Zero|PromiseReaction|JSAny;
  flags: SmiTagged<JSPromiseFlags>;
}

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