Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
* vim: set ts=8 sts=2 et sw=2 tw=80:
3
* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
// Specialized .h file to be used by both JS and C++ code.
8
9
#ifndef builtin_SelfHostingDefines_h
10
#define builtin_SelfHostingDefines_h
11
12
// Utility macros.
13
#define TO_INT32(x) ((x) | 0)
14
#define TO_UINT32(x) ((x) >>> 0)
15
#define IS_UINT32(x) ((x) >>> 0 == = (x))
16
#define MAX_UINT32 0xffffffff
17
#define MAX_NUMERIC_INDEX 0x1fffffffffffff // == Math.pow(2, 53) - 1
18
19
// Unforgeable version of Function.prototype.apply.
20
#define FUN_APPLY(FUN, RECEIVER, ARGS) \
21
callFunction(std_Function_apply, FUN, RECEIVER, ARGS)
22
23
// NB: keep this in sync with the copy in vm/ArgumentsObject.h.
24
#define MAX_ARGS_LENGTH (500 * 1000)
25
26
// NB: keep this in sync with js::MaxStringLength in jsfriendapi.h.
27
#define MAX_STRING_LENGTH ((1 << 30) - 2)
28
29
// Spread non-empty argument list of up to 15 elements.
30
#define SPREAD(v, n) SPREAD_##n(v)
31
#define SPREAD_1(v) v[0]
32
#define SPREAD_2(v) SPREAD_1(v), v[1]
33
#define SPREAD_3(v) SPREAD_2(v), v[2]
34
#define SPREAD_4(v) SPREAD_3(v), v[3]
35
#define SPREAD_5(v) SPREAD_4(v), v[4]
36
#define SPREAD_6(v) SPREAD_5(v), v[5]
37
#define SPREAD_7(v) SPREAD_6(v), v[6]
38
#define SPREAD_8(v) SPREAD_7(v), v[7]
39
#define SPREAD_9(v) SPREAD_8(v), v[8]
40
#define SPREAD_10(v) SPREAD_9(v), v[9]
41
#define SPREAD_11(v) SPREAD_10(v), v[10]
42
#define SPREAD_12(v) SPREAD_11(v), v[11]
43
#define SPREAD_13(v) SPREAD_12(v), v[12]
44
#define SPREAD_14(v) SPREAD_13(v), v[13]
45
#define SPREAD_15(v) SPREAD_14(v), v[14]
46
47
// Property descriptor attributes.
48
#define ATTR_ENUMERABLE 0x01
49
#define ATTR_CONFIGURABLE 0x02
50
#define ATTR_WRITABLE 0x04
51
52
#define ATTR_NONENUMERABLE 0x08
53
#define ATTR_NONCONFIGURABLE 0x10
54
#define ATTR_NONWRITABLE 0x20
55
56
// Property descriptor kind, must be different from the descriptor attributes.
57
#define DATA_DESCRIPTOR_KIND 0x100
58
#define ACCESSOR_DESCRIPTOR_KIND 0x200
59
60
// Property descriptor array indices.
61
#define PROP_DESC_ATTRS_AND_KIND_INDEX 0
62
#define PROP_DESC_VALUE_INDEX 1
63
#define PROP_DESC_GETTER_INDEX 1
64
#define PROP_DESC_SETTER_INDEX 2
65
66
// The extended slot of uncloned self-hosted function, in which the original
67
// name for self-hosted builtins is stored by `_SetCanonicalName`.
68
#define ORIGINAL_FUNCTION_NAME_SLOT 0
69
70
// The extended slot of cloned self-hosted function, in which the self-hosted
71
// name for self-hosted builtins is stored.
72
#define LAZY_FUNCTION_NAME_SLOT 0
73
74
// Stores the length for bound functions, so the .length property doesn't need
75
// to be resolved eagerly.
76
#define BOUND_FUN_LENGTH_SLOT 1
77
78
#define ITERATOR_SLOT_TARGET 0
79
// Used for collection iterators.
80
#define ITERATOR_SLOT_RANGE 1
81
// Used for list, i.e. Array and String, iterators.
82
#define ITERATOR_SLOT_NEXT_INDEX 1
83
#define ITERATOR_SLOT_ITEM_KIND 2
84
85
#define ITEM_KIND_KEY 0
86
#define ITEM_KIND_VALUE 1
87
#define ITEM_KIND_KEY_AND_VALUE 2
88
89
#define REGEXP_SOURCE_SLOT 1
90
#define REGEXP_FLAGS_SLOT 2
91
92
#define REGEXP_IGNORECASE_FLAG 0x01
93
#define REGEXP_GLOBAL_FLAG 0x02
94
#define REGEXP_MULTILINE_FLAG 0x04
95
#define REGEXP_STICKY_FLAG 0x08
96
#define REGEXP_UNICODE_FLAG 0x10
97
98
#define REGEXP_STRING_ITERATOR_REGEXP_SLOT 0
99
#define REGEXP_STRING_ITERATOR_STRING_SLOT 1
100
#define REGEXP_STRING_ITERATOR_SOURCE_SLOT 2
101
#define REGEXP_STRING_ITERATOR_FLAGS_SLOT 3
102
#define REGEXP_STRING_ITERATOR_LASTINDEX_SLOT 4
103
104
#define REGEXP_STRING_ITERATOR_LASTINDEX_DONE -1
105
#define REGEXP_STRING_ITERATOR_LASTINDEX_SLOW -2
106
107
#define MODULE_OBJECT_ENVIRONMENT_SLOT 1
108
#define MODULE_OBJECT_STATUS_SLOT 3
109
#define MODULE_OBJECT_EVALUATION_ERROR_SLOT 4
110
#define MODULE_OBJECT_DFS_INDEX_SLOT 14
111
#define MODULE_OBJECT_DFS_ANCESTOR_INDEX_SLOT 15
112
113
#define MODULE_STATUS_UNINSTANTIATED 0
114
#define MODULE_STATUS_INSTANTIATING 1
115
#define MODULE_STATUS_INSTANTIATED 2
116
#define MODULE_STATUS_EVALUATING 3
117
#define MODULE_STATUS_EVALUATED 4
118
#define MODULE_STATUS_EVALUATED_ERROR 5
119
120
#define INTL_INTERNALS_OBJECT_SLOT 0
121
122
#define NOT_OBJECT_KIND_DESCRIPTOR 0
123
124
#define TYPEDARRAY_KIND_INT8 0
125
#define TYPEDARRAY_KIND_UINT8 1
126
#define TYPEDARRAY_KIND_INT16 2
127
#define TYPEDARRAY_KIND_UINT16 3
128
#define TYPEDARRAY_KIND_INT32 4
129
#define TYPEDARRAY_KIND_UINT32 5
130
#define TYPEDARRAY_KIND_FLOAT32 6
131
#define TYPEDARRAY_KIND_FLOAT64 7
132
#define TYPEDARRAY_KIND_UINT8CLAMPED 8
133
#define TYPEDARRAY_KIND_BIGINT64 9
134
#define TYPEDARRAY_KIND_BIGUINT64 10
135
136
#endif