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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// Copyright 2018 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.
#ifndef V8_BUILTINS_BUILTINS_PROMISE_H_
#define V8_BUILTINS_BUILTINS_PROMISE_H_
#include "src/objects/contexts.h"
namespace v8 {
namespace internal {
class PromiseBuiltins {
public:
enum PromiseResolvingFunctionContextSlot {
// The promise which resolve/reject callbacks fulfill.
kPromiseSlot = Context::MIN_CONTEXT_SLOTS,
// Whether the callback was already invoked.
kAlreadyResolvedSlot,
// Whether to trigger a debug event or not. Used in catch
// prediction.
kDebugEventSlot,
kPromiseContextLength,
};
// TODO(bmeurer): Move this to a proper context map in contexts.h?
// Similar to the AwaitContext that we introduced for await closures.
enum PromiseAllResolveElementContextSlots {
// Remaining elements count
kPromiseAllResolveElementRemainingSlot = Context::MIN_CONTEXT_SLOTS,
// Promise capability from Promise.all
kPromiseAllResolveElementCapabilitySlot,
// Values array from Promise.all
kPromiseAllResolveElementValuesArraySlot,
kPromiseAllResolveElementLength
};
enum PromiseAnyRejectElementContextSlots {
// Remaining elements count
kPromiseAnyRejectElementRemainingSlot = Context::MIN_CONTEXT_SLOTS,
// Promise capability from Promise.any
kPromiseAnyRejectElementCapabilitySlot,
// errors array from Promise.any
kPromiseAnyRejectElementErrorsArraySlot,
kPromiseAnyRejectElementLength
};
enum FunctionContextSlot {
kCapabilitySlot = Context::MIN_CONTEXT_SLOTS,
kCapabilitiesContextLength,
};
// This is used by the Promise.prototype.finally builtin to store
// onFinally callback and the Promise constructor.
// TODO(gsathya): For native promises we can create a variant of
// this without extra space for the constructor to save memory.
enum PromiseFinallyContextSlot {
kOnFinallySlot = Context::MIN_CONTEXT_SLOTS,
kConstructorSlot,
kPromiseFinallyContextLength,
};
// This is used by the ThenFinally and CatchFinally builtins to
// store the value to return or reason to throw.
enum PromiseValueThunkOrReasonContextSlot {
kValueSlot = Context::MIN_CONTEXT_SLOTS,
kPromiseValueThunkOrReasonContextLength,
};
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseBuiltins);
};
} // namespace internal
} // namespace v8
#endif // V8_BUILTINS_BUILTINS_PROMISE_H_
|