forked from darionco/JavaScriptCore-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexingType.h
More file actions
executable file
·159 lines (127 loc) · 6.29 KB
/
IndexingType.h
File metadata and controls
executable file
·159 lines (127 loc) · 6.29 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef IndexingType_h
#define IndexingType_h
#include "SpeculatedType.h"
#include <wtf/StdLibExtras.h>
namespace JSC {
typedef uint8_t IndexingType;
// Flags for testing the presence of capabilities.
static const IndexingType IsArray = 0x01;
// The shape of the indexed property storage.
static const IndexingType IndexingShapeMask = 0x1E;
static const IndexingType NoIndexingShape = 0x00;
static const IndexingType UndecidedShape = 0x02; // Only useful for arrays.
static const IndexingType Int32Shape = 0x14;
static const IndexingType DoubleShape = 0x16;
static const IndexingType ContiguousShape = 0x1A;
static const IndexingType ArrayStorageShape = 0x1C;
static const IndexingType SlowPutArrayStorageShape = 0x1E;
static const IndexingType IndexingShapeShift = 1;
static const IndexingType NumberOfIndexingShapes = 16;
// Additional flags for tracking the history of the type. These are usually
// masked off unless you ask for them directly.
static const IndexingType MayHaveIndexedAccessors = 0x20;
// List of acceptable array types.
static const IndexingType NonArray = 0x0;
static const IndexingType NonArrayWithInt32 = Int32Shape;
static const IndexingType NonArrayWithDouble = DoubleShape;
static const IndexingType NonArrayWithContiguous = ContiguousShape;
static const IndexingType NonArrayWithArrayStorage = ArrayStorageShape;
static const IndexingType NonArrayWithSlowPutArrayStorage = SlowPutArrayStorageShape;
static const IndexingType ArrayClass = IsArray; // I'd want to call this "Array" but this would lead to disastrous namespace pollution.
static const IndexingType ArrayWithUndecided = IsArray | UndecidedShape;
static const IndexingType ArrayWithInt32 = IsArray | Int32Shape;
static const IndexingType ArrayWithDouble = IsArray | DoubleShape;
static const IndexingType ArrayWithContiguous = IsArray | ContiguousShape;
static const IndexingType ArrayWithArrayStorage = IsArray | ArrayStorageShape;
static const IndexingType ArrayWithSlowPutArrayStorage = IsArray | SlowPutArrayStorageShape;
#define ALL_BLANK_INDEXING_TYPES \
NonArray: \
case ArrayClass
#define ALL_UNDECIDED_INDEXING_TYPES \
ArrayWithUndecided
#define ALL_INT32_INDEXING_TYPES \
NonArrayWithInt32: \
case ArrayWithInt32
#define ALL_DOUBLE_INDEXING_TYPES \
NonArrayWithDouble: \
case ArrayWithDouble
#define ALL_CONTIGUOUS_INDEXING_TYPES \
NonArrayWithContiguous: \
case ArrayWithContiguous
#define ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES \
ArrayWithArrayStorage: \
case ArrayWithSlowPutArrayStorage
#define ALL_ARRAY_STORAGE_INDEXING_TYPES \
NonArrayWithArrayStorage: \
case NonArrayWithSlowPutArrayStorage: \
case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES
static inline bool hasIndexedProperties(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) != NoIndexingShape;
}
static inline bool hasUndecided(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == UndecidedShape;
}
static inline bool hasInt32(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == Int32Shape;
}
static inline bool hasDouble(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == DoubleShape;
}
static inline bool hasContiguous(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == ContiguousShape;
}
// FIXME: This is an awkward name. This should really be called hasArrayStorage()
// and then next method down should be called hasAnyArrayStorage().
static inline bool hasFastArrayStorage(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == ArrayStorageShape;
}
static inline bool hasArrayStorage(IndexingType indexingType)
{
return static_cast<uint8_t>((indexingType & IndexingShapeMask) - ArrayStorageShape) <= static_cast<uint8_t>(SlowPutArrayStorageShape - ArrayStorageShape);
}
static inline bool shouldUseSlowPut(IndexingType indexingType)
{
return (indexingType & IndexingShapeMask) == SlowPutArrayStorageShape;
}
// Return an indexing type that can handle all of the elements of both indexing types.
IndexingType leastUpperBoundOfIndexingTypes(IndexingType, IndexingType);
IndexingType leastUpperBoundOfIndexingTypeAndType(IndexingType, SpeculatedType);
IndexingType leastUpperBoundOfIndexingTypeAndValue(IndexingType, JSValue);
void dumpIndexingType(PrintStream&, IndexingType);
MAKE_PRINT_ADAPTOR(IndexingTypeDump, IndexingType, dumpIndexingType);
// Mask of all possible types.
static const IndexingType AllArrayTypes = 31;
// Mask of all possible types including the history.
static const IndexingType AllArrayTypesAndHistory = 127;
} // namespace JSC
#endif // IndexingType_h