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.
29 #include <wtf/Platform.h>
33 #include "ClassInfo.h"
34 #include "CodeLocation.h"
35 #include "IndexingType.h"
36 #include "JITStubRoutine.h"
37 #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 hasOptimizableIndexingForClassInfo(const ClassInfo
* classInfo
)
72 return classInfo
->typedArrayStorageType
!= TypedArrayNone
;
75 inline bool hasOptimizableIndexing(Structure
* structure
)
77 return isOptimizableIndexingType(structure
->indexingType())
78 || hasOptimizableIndexingForClassInfo(structure
->classInfo());
81 inline JITArrayMode
jitArrayModeForIndexingType(IndexingType indexingType
)
83 switch (indexingType
) {
84 case ALL_INT32_INDEXING_TYPES
:
86 case ALL_DOUBLE_INDEXING_TYPES
:
88 case ALL_CONTIGUOUS_INDEXING_TYPES
:
90 case ARRAY_WITH_ARRAY_STORAGE_INDEXING_TYPES
:
91 return JITArrayStorage
;
98 inline JITArrayMode
jitArrayModeForClassInfo(const ClassInfo
* classInfo
)
100 switch (classInfo
->typedArrayStorageType
) {
103 case TypedArrayInt16
:
104 return JITInt16Array
;
105 case TypedArrayInt32
:
106 return JITInt32Array
;
107 case TypedArrayUint8
:
108 return JITUint8Array
;
109 case TypedArrayUint8Clamped
:
110 return JITUint8ClampedArray
;
111 case TypedArrayUint16
:
112 return JITUint16Array
;
113 case TypedArrayUint32
:
114 return JITUint32Array
;
115 case TypedArrayFloat32
:
116 return JITFloat32Array
;
117 case TypedArrayFloat64
:
118 return JITFloat64Array
;
121 return JITContiguous
;
125 inline JITArrayMode
jitArrayModeForStructure(Structure
* structure
)
127 if (isOptimizableIndexingType(structure
->indexingType()))
128 return jitArrayModeForIndexingType(structure
->indexingType());
130 ASSERT(hasOptimizableIndexingForClassInfo(structure
->classInfo()));
131 return jitArrayModeForClassInfo(structure
->classInfo());
137 ByValInfo(unsigned bytecodeIndex
, CodeLocationJump badTypeJump
, JITArrayMode arrayMode
, int16_t badTypeJumpToDone
, int16_t returnAddressToSlowPath
)
138 : bytecodeIndex(bytecodeIndex
)
139 , badTypeJump(badTypeJump
)
140 , arrayMode(arrayMode
)
141 , badTypeJumpToDone(badTypeJumpToDone
)
142 , returnAddressToSlowPath(returnAddressToSlowPath
)
147 unsigned bytecodeIndex
;
148 CodeLocationJump badTypeJump
;
149 JITArrayMode arrayMode
; // The array mode that was baked into the inline JIT code.
150 int16_t badTypeJumpToDone
;
151 int16_t returnAddressToSlowPath
;
152 unsigned slowPathCount
;
153 RefPtr
<JITStubRoutine
> stubRoutine
;
156 inline unsigned getByValInfoBytecodeIndex(ByValInfo
* info
)
158 return info
->bytecodeIndex
;
163 #endif // ENABLE(JIT)
165 #endif // ByValInfo_h