2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "ClassInfo.h"
32 #include "CodeLocation.h"
33 #include "IndexingType.h"
34 #include "JITStubRoutine.h"
35 #include "Structure.h"
57 inline bool isOptimizableIndexingType(IndexingType indexingType
)
59 switch (indexingType
) {
60 case ALL_INT32_INDEXING_TYPES
:
61 case ALL_DOUBLE_INDEXING_TYPES
:
62 case ALL_CONTIGUOUS_INDEXING_TYPES
:
63 case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES
:
70 inline bool hasOptimizableIndexingForJSType(JSType type
)
73 case DirectArgumentsType
:
74 case ScopedArgumentsType
:
81 inline bool hasOptimizableIndexingForClassInfo(const ClassInfo
* classInfo
)
83 return isTypedView(classInfo
->typedArrayStorageType
);
86 inline bool hasOptimizableIndexing(Structure
* structure
)
88 return isOptimizableIndexingType(structure
->indexingType())
89 || hasOptimizableIndexingForJSType(structure
->typeInfo().type())
90 || hasOptimizableIndexingForClassInfo(structure
->classInfo());
93 inline JITArrayMode
jitArrayModeForIndexingType(IndexingType indexingType
)
95 switch (indexingType
) {
96 case ALL_INT32_INDEXING_TYPES
:
98 case ALL_DOUBLE_INDEXING_TYPES
:
100 case ALL_CONTIGUOUS_INDEXING_TYPES
:
101 return JITContiguous
;
102 case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES
:
103 return JITArrayStorage
;
106 return JITContiguous
;
110 inline JITArrayMode
jitArrayModeForJSType(JSType type
)
113 case DirectArgumentsType
:
114 return JITDirectArguments
;
115 case ScopedArgumentsType
:
116 return JITScopedArguments
;
118 RELEASE_ASSERT_NOT_REACHED();
119 return JITContiguous
;
123 inline JITArrayMode
jitArrayModeForClassInfo(const ClassInfo
* classInfo
)
125 switch (classInfo
->typedArrayStorageType
) {
129 return JITInt16Array
;
131 return JITInt32Array
;
133 return JITUint8Array
;
134 case TypeUint8Clamped
:
135 return JITUint8ClampedArray
;
137 return JITUint16Array
;
139 return JITUint32Array
;
141 return JITFloat32Array
;
143 return JITFloat64Array
;
146 return JITContiguous
;
150 inline bool jitArrayModePermitsPut(JITArrayMode mode
)
153 case JITDirectArguments
:
154 case JITScopedArguments
:
155 // We could support put_by_val on these at some point, but it's just not that profitable
163 inline TypedArrayType
typedArrayTypeForJITArrayMode(JITArrayMode mode
)
174 case JITUint8ClampedArray
:
175 return TypeUint8Clamped
;
180 case JITFloat32Array
:
182 case JITFloat64Array
:
186 return NotTypedArray
;
190 inline JITArrayMode
jitArrayModeForStructure(Structure
* structure
)
192 if (isOptimizableIndexingType(structure
->indexingType()))
193 return jitArrayModeForIndexingType(structure
->indexingType());
195 if (hasOptimizableIndexingForJSType(structure
->typeInfo().type()))
196 return jitArrayModeForJSType(structure
->typeInfo().type());
198 ASSERT(hasOptimizableIndexingForClassInfo(structure
->classInfo()));
199 return jitArrayModeForClassInfo(structure
->classInfo());
205 ByValInfo(unsigned bytecodeIndex
, CodeLocationJump badTypeJump
, JITArrayMode arrayMode
, int16_t badTypeJumpToDone
, int16_t returnAddressToSlowPath
)
206 : bytecodeIndex(bytecodeIndex
)
207 , badTypeJump(badTypeJump
)
208 , arrayMode(arrayMode
)
209 , badTypeJumpToDone(badTypeJumpToDone
)
210 , returnAddressToSlowPath(returnAddressToSlowPath
)
215 unsigned bytecodeIndex
;
216 CodeLocationJump badTypeJump
;
217 JITArrayMode arrayMode
; // The array mode that was baked into the inline JIT code.
218 int16_t badTypeJumpToDone
;
219 int16_t returnAddressToSlowPath
;
220 unsigned slowPathCount
;
221 RefPtr
<JITStubRoutine
> stubRoutine
;
224 inline unsigned getByValInfoBytecodeIndex(ByValInfo
* info
)
226 return info
->bytecodeIndex
;
231 #endif // ENABLE(JIT)
233 #endif // ByValInfo_h