2 * Copyright (C) 2008 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.
26 #ifndef StructureStubInfo_h
27 #define StructureStubInfo_h
29 #include <wtf/Platform.h>
33 #include "CodeOrigin.h"
34 #include "Instruction.h"
35 #include "MacroAssembler.h"
37 #include "Structure.h"
41 class PolymorphicPutByIdList
;
44 access_get_by_id_self
,
45 access_get_by_id_proto
,
46 access_get_by_id_chain
,
47 access_get_by_id_self_list
,
48 access_get_by_id_proto_list
,
49 access_put_by_id_transition_normal
,
50 access_put_by_id_transition_direct
,
51 access_put_by_id_replace
,
52 access_put_by_id_list
,
54 access_get_by_id_generic
,
55 access_put_by_id_generic
,
56 access_get_array_length
,
57 access_get_string_length
,
60 inline bool isGetByIdAccess(AccessType accessType
)
63 case access_get_by_id_self
:
64 case access_get_by_id_proto
:
65 case access_get_by_id_chain
:
66 case access_get_by_id_self_list
:
67 case access_get_by_id_proto_list
:
68 case access_get_by_id_generic
:
69 case access_get_array_length
:
70 case access_get_string_length
:
77 inline bool isPutByIdAccess(AccessType accessType
)
80 case access_put_by_id_transition_normal
:
81 case access_put_by_id_transition_direct
:
82 case access_put_by_id_replace
:
83 case access_put_by_id_list
:
84 case access_put_by_id_generic
:
91 struct StructureStubInfo
{
93 : accessType(access_unset
)
98 void initGetByIdSelf(JSGlobalData
& globalData
, JSCell
* owner
, Structure
* baseObjectStructure
)
100 accessType
= access_get_by_id_self
;
102 u
.getByIdSelf
.baseObjectStructure
.set(globalData
, owner
, baseObjectStructure
);
105 void initGetByIdProto(JSGlobalData
& globalData
, JSCell
* owner
, Structure
* baseObjectStructure
, Structure
* prototypeStructure
)
107 accessType
= access_get_by_id_proto
;
109 u
.getByIdProto
.baseObjectStructure
.set(globalData
, owner
, baseObjectStructure
);
110 u
.getByIdProto
.prototypeStructure
.set(globalData
, owner
, prototypeStructure
);
113 void initGetByIdChain(JSGlobalData
& globalData
, JSCell
* owner
, Structure
* baseObjectStructure
, StructureChain
* chain
)
115 accessType
= access_get_by_id_chain
;
117 u
.getByIdChain
.baseObjectStructure
.set(globalData
, owner
, baseObjectStructure
);
118 u
.getByIdChain
.chain
.set(globalData
, owner
, chain
);
121 void initGetByIdSelfList(PolymorphicAccessStructureList
* structureList
, int listSize
)
123 accessType
= access_get_by_id_self_list
;
125 u
.getByIdSelfList
.structureList
= structureList
;
126 u
.getByIdSelfList
.listSize
= listSize
;
129 void initGetByIdProtoList(PolymorphicAccessStructureList
* structureList
, int listSize
)
131 accessType
= access_get_by_id_proto_list
;
133 u
.getByIdProtoList
.structureList
= structureList
;
134 u
.getByIdProtoList
.listSize
= listSize
;
139 void initPutByIdTransition(JSGlobalData
& globalData
, JSCell
* owner
, Structure
* previousStructure
, Structure
* structure
, StructureChain
* chain
, bool isDirect
)
142 accessType
= access_put_by_id_transition_direct
;
144 accessType
= access_put_by_id_transition_normal
;
146 u
.putByIdTransition
.previousStructure
.set(globalData
, owner
, previousStructure
);
147 u
.putByIdTransition
.structure
.set(globalData
, owner
, structure
);
148 u
.putByIdTransition
.chain
.set(globalData
, owner
, chain
);
151 void initPutByIdReplace(JSGlobalData
& globalData
, JSCell
* owner
, Structure
* baseObjectStructure
)
153 accessType
= access_put_by_id_replace
;
155 u
.putByIdReplace
.baseObjectStructure
.set(globalData
, owner
, baseObjectStructure
);
158 void initPutByIdList(PolymorphicPutByIdList
* list
)
160 accessType
= access_put_by_id_list
;
161 u
.putByIdList
.list
= list
;
167 accessType
= access_unset
;
168 stubRoutine
= MacroAssemblerCodeRef();
173 bool visitWeakReferences();
185 unsigned bytecodeIndex
;
191 CodeOrigin codeOrigin
;
192 #endif // ENABLE(DFG_JIT)
196 int8_t registersFlushed
;
198 #if USE(JSVALUE32_64)
203 int16_t deltaCallToDone
;
204 int16_t deltaCallToStructCheck
;
205 int16_t deltaCallToSlowCase
;
206 int16_t deltaCheckImmToCall
;
208 int16_t deltaCallToLoadOrStore
;
210 int16_t deltaCallToTagLoadOrStore
;
211 int16_t deltaCallToPayloadLoadOrStore
;
217 int16_t structureToCompare
;
218 int16_t structureCheck
;
220 int16_t displacementLabel
;
222 int16_t displacementLabel1
;
223 int16_t displacementLabel2
;
226 int16_t coldPathBegin
;
229 int16_t structureToCompare
;
231 int16_t displacementLabel
;
233 int16_t displacementLabel1
;
234 int16_t displacementLabel2
;
238 int16_t methodCheckProtoObj
;
239 int16_t methodCheckProtoStructureToCompare
;
240 int16_t methodCheckPutFunction
;
246 // It would be unwise to put anything here, as it will surely be overwritten.
249 WriteBarrierBase
<Structure
> baseObjectStructure
;
252 WriteBarrierBase
<Structure
> baseObjectStructure
;
253 WriteBarrierBase
<Structure
> prototypeStructure
;
256 WriteBarrierBase
<Structure
> baseObjectStructure
;
257 WriteBarrierBase
<StructureChain
> chain
;
260 PolymorphicAccessStructureList
* structureList
;
264 PolymorphicAccessStructureList
* structureList
;
268 WriteBarrierBase
<Structure
> previousStructure
;
269 WriteBarrierBase
<Structure
> structure
;
270 WriteBarrierBase
<StructureChain
> chain
;
273 WriteBarrierBase
<Structure
> baseObjectStructure
;
276 PolymorphicPutByIdList
* list
;
280 MacroAssemblerCodeRef stubRoutine
;
281 CodeLocationCall callReturnLocation
;
282 CodeLocationLabel hotPathBegin
;
285 inline void* getStructureStubInfoReturnLocation(StructureStubInfo
* structureStubInfo
)
287 return structureStubInfo
->callReturnLocation
.executableAddress();
290 inline unsigned getStructureStubInfoBytecodeIndex(StructureStubInfo
* structureStubInfo
)
292 return structureStubInfo
->bytecodeIndex
;
297 #endif // ENABLE(JIT)
299 #endif // StructureStubInfo_h