2 * Copyright (C) 2008, 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.
26 #ifndef StructureStubInfo_h
27 #define StructureStubInfo_h
29 #include <wtf/Platform.h>
33 #include "CodeOrigin.h"
34 #include "DFGRegisterSet.h"
35 #include "Instruction.h"
36 #include "JITStubRoutine.h"
37 #include "MacroAssembler.h"
39 #include "PolymorphicAccessStructureList.h"
40 #include "Structure.h"
41 #include "StructureStubClearingWatchpoint.h"
42 #include <wtf/OwnPtr.h>
46 class PolymorphicPutByIdList
;
49 access_get_by_id_self
,
50 access_get_by_id_proto
,
51 access_get_by_id_chain
,
52 access_get_by_id_self_list
,
53 access_get_by_id_proto_list
,
54 access_put_by_id_transition_normal
,
55 access_put_by_id_transition_direct
,
56 access_put_by_id_replace
,
57 access_put_by_id_list
,
59 access_get_by_id_generic
,
60 access_put_by_id_generic
,
61 access_get_array_length
,
62 access_get_string_length
,
65 inline bool isGetByIdAccess(AccessType accessType
)
68 case access_get_by_id_self
:
69 case access_get_by_id_proto
:
70 case access_get_by_id_chain
:
71 case access_get_by_id_self_list
:
72 case access_get_by_id_proto_list
:
73 case access_get_by_id_generic
:
74 case access_get_array_length
:
75 case access_get_string_length
:
82 inline bool isPutByIdAccess(AccessType accessType
)
85 case access_put_by_id_transition_normal
:
86 case access_put_by_id_transition_direct
:
87 case access_put_by_id_replace
:
88 case access_put_by_id_list
:
89 case access_put_by_id_generic
:
96 struct StructureStubInfo
{
98 : accessType(access_unset
)
104 void initGetByIdSelf(VM
& vm
, JSCell
* owner
, Structure
* baseObjectStructure
)
106 accessType
= access_get_by_id_self
;
108 u
.getByIdSelf
.baseObjectStructure
.set(vm
, owner
, baseObjectStructure
);
111 void initGetByIdProto(VM
& vm
, JSCell
* owner
, Structure
* baseObjectStructure
, Structure
* prototypeStructure
, bool isDirect
)
113 accessType
= access_get_by_id_proto
;
115 u
.getByIdProto
.baseObjectStructure
.set(vm
, owner
, baseObjectStructure
);
116 u
.getByIdProto
.prototypeStructure
.set(vm
, owner
, prototypeStructure
);
117 u
.getByIdProto
.isDirect
= isDirect
;
120 void initGetByIdChain(VM
& vm
, JSCell
* owner
, Structure
* baseObjectStructure
, StructureChain
* chain
, unsigned count
, bool isDirect
)
122 accessType
= access_get_by_id_chain
;
124 u
.getByIdChain
.baseObjectStructure
.set(vm
, owner
, baseObjectStructure
);
125 u
.getByIdChain
.chain
.set(vm
, owner
, chain
);
126 u
.getByIdChain
.count
= count
;
127 u
.getByIdChain
.isDirect
= isDirect
;
130 void initGetByIdSelfList(PolymorphicAccessStructureList
* structureList
, int listSize
)
132 accessType
= access_get_by_id_self_list
;
134 u
.getByIdSelfList
.structureList
= structureList
;
135 u
.getByIdSelfList
.listSize
= listSize
;
138 void initGetByIdProtoList(PolymorphicAccessStructureList
* structureList
, int listSize
)
140 accessType
= access_get_by_id_proto_list
;
142 u
.getByIdProtoList
.structureList
= structureList
;
143 u
.getByIdProtoList
.listSize
= listSize
;
148 void initPutByIdTransition(VM
& vm
, JSCell
* owner
, Structure
* previousStructure
, Structure
* structure
, StructureChain
* chain
, bool isDirect
)
151 accessType
= access_put_by_id_transition_direct
;
153 accessType
= access_put_by_id_transition_normal
;
155 u
.putByIdTransition
.previousStructure
.set(vm
, owner
, previousStructure
);
156 u
.putByIdTransition
.structure
.set(vm
, owner
, structure
);
157 u
.putByIdTransition
.chain
.set(vm
, owner
, chain
);
160 void initPutByIdReplace(VM
& vm
, JSCell
* owner
, Structure
* baseObjectStructure
)
162 accessType
= access_put_by_id_replace
;
164 u
.putByIdReplace
.baseObjectStructure
.set(vm
, owner
, baseObjectStructure
);
167 void initPutByIdList(PolymorphicPutByIdList
* list
)
169 accessType
= access_put_by_id_list
;
170 u
.putByIdList
.list
= list
;
176 accessType
= access_unset
;
183 bool visitWeakReferences();
195 StructureStubClearingWatchpoint
* addWatchpoint(CodeBlock
* codeBlock
)
197 return WatchpointsOnStructureStubInfo::ensureReferenceAndAddWatchpoint(
198 watchpoints
, codeBlock
, this);
201 unsigned bytecodeIndex
;
208 CodeOrigin codeOrigin
;
209 #endif // ENABLE(DFG_JIT)
213 int8_t registersFlushed
;
215 #if USE(JSVALUE32_64)
219 DFG::RegisterSetPOD usedRegisters
;
220 int32_t deltaCallToDone
;
221 int32_t deltaCallToStorageLoad
;
222 int32_t deltaCallToStructCheck
;
223 int32_t deltaCallToSlowCase
;
224 int32_t deltaCheckImmToCall
;
226 int32_t deltaCallToLoadOrStore
;
228 int32_t deltaCallToTagLoadOrStore
;
229 int32_t deltaCallToPayloadLoadOrStore
;
235 int16_t structureToCompare
;
236 int16_t structureCheck
;
237 int16_t propertyStorageLoad
;
239 int16_t displacementLabel
;
241 int16_t displacementLabel1
;
242 int16_t displacementLabel2
;
245 int16_t coldPathBegin
;
248 int16_t structureToCompare
;
249 int16_t propertyStorageLoad
;
251 int16_t displacementLabel
;
253 int16_t displacementLabel1
;
254 int16_t displacementLabel2
;
258 int16_t methodCheckProtoObj
;
259 int16_t methodCheckProtoStructureToCompare
;
260 int16_t methodCheckPutFunction
;
266 // It would be unwise to put anything here, as it will surely be overwritten.
269 WriteBarrierBase
<Structure
> baseObjectStructure
;
272 WriteBarrierBase
<Structure
> baseObjectStructure
;
273 WriteBarrierBase
<Structure
> prototypeStructure
;
277 WriteBarrierBase
<Structure
> baseObjectStructure
;
278 WriteBarrierBase
<StructureChain
> chain
;
283 PolymorphicAccessStructureList
* structureList
;
287 PolymorphicAccessStructureList
* structureList
;
291 WriteBarrierBase
<Structure
> previousStructure
;
292 WriteBarrierBase
<Structure
> structure
;
293 WriteBarrierBase
<StructureChain
> chain
;
296 WriteBarrierBase
<Structure
> baseObjectStructure
;
299 PolymorphicPutByIdList
* list
;
303 RefPtr
<JITStubRoutine
> stubRoutine
;
304 CodeLocationCall callReturnLocation
;
305 CodeLocationLabel hotPathBegin
;
306 RefPtr
<WatchpointsOnStructureStubInfo
> watchpoints
;
309 inline void* getStructureStubInfoReturnLocation(StructureStubInfo
* structureStubInfo
)
311 return structureStubInfo
->callReturnLocation
.executableAddress();
314 inline unsigned getStructureStubInfoBytecodeIndex(StructureStubInfo
* structureStubInfo
)
316 return structureStubInfo
->bytecodeIndex
;
321 #endif // ENABLE(JIT)
323 #endif // StructureStubInfo_h