2 * Copyright (C) 2012 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"
55 inline bool isOptimizableIndexingType(IndexingType indexingType
)
57 switch (indexingType
) {
58 case ALL_INT32_INDEXING_TYPES
:
59 case ALL_DOUBLE_INDEXING_TYPES
:
60 case ALL_CONTIGUOUS_INDEXING_TYPES
:
61 case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES
:
68 inline bool hasOptimizableIndexingForClassInfo(const ClassInfo
* classInfo
)
70 return isTypedView(classInfo
->typedArrayStorageType
);
73 inline bool hasOptimizableIndexing(Structure
* structure
)
75 return isOptimizableIndexingType(structure
->indexingType())
76 || hasOptimizableIndexingForClassInfo(structure
->classInfo());
79 inline JITArrayMode
jitArrayModeForIndexingType(IndexingType indexingType
)
81 switch (indexingType
) {
82 case ALL_INT32_INDEXING_TYPES
:
84 case ALL_DOUBLE_INDEXING_TYPES
:
86 case ALL_CONTIGUOUS_INDEXING_TYPES
:
88 case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES
:
89 return JITArrayStorage
;
96 inline JITArrayMode
jitArrayModeForClassInfo(const ClassInfo
* classInfo
)
98 switch (classInfo
->typedArrayStorageType
) {
102 return JITInt16Array
;
104 return JITInt32Array
;
106 return JITUint8Array
;
107 case TypeUint8Clamped
:
108 return JITUint8ClampedArray
;
110 return JITUint16Array
;
112 return JITUint32Array
;
114 return JITFloat32Array
;
116 return JITFloat64Array
;
119 return JITContiguous
;
123 inline TypedArrayType
typedArrayTypeForJITArrayMode(JITArrayMode mode
)
134 case JITUint8ClampedArray
:
135 return TypeUint8Clamped
;
140 case JITFloat32Array
:
142 case JITFloat64Array
:
146 return NotTypedArray
;
150 inline JITArrayMode
jitArrayModeForStructure(Structure
* structure
)
152 if (isOptimizableIndexingType(structure
->indexingType()))
153 return jitArrayModeForIndexingType(structure
->indexingType());
155 ASSERT(hasOptimizableIndexingForClassInfo(structure
->classInfo()));
156 return jitArrayModeForClassInfo(structure
->classInfo());
162 ByValInfo(unsigned bytecodeIndex
, CodeLocationJump badTypeJump
, JITArrayMode arrayMode
, int16_t badTypeJumpToDone
, int16_t returnAddressToSlowPath
)
163 : bytecodeIndex(bytecodeIndex
)
164 , badTypeJump(badTypeJump
)
165 , arrayMode(arrayMode
)
166 , badTypeJumpToDone(badTypeJumpToDone
)
167 , returnAddressToSlowPath(returnAddressToSlowPath
)
172 unsigned bytecodeIndex
;
173 CodeLocationJump badTypeJump
;
174 JITArrayMode arrayMode
; // The array mode that was baked into the inline JIT code.
175 int16_t badTypeJumpToDone
;
176 int16_t returnAddressToSlowPath
;
177 unsigned slowPathCount
;
178 RefPtr
<JITStubRoutine
> stubRoutine
;
181 inline unsigned getByValInfoBytecodeIndex(ByValInfo
* info
)
183 return info
->bytecodeIndex
;
188 #endif // ENABLE(JIT)
190 #endif // ByValInfo_h