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 "Structure.h"
40 #include "StructureStubClearingWatchpoint.h"
41 #include <wtf/OwnPtr.h>
45 class PolymorphicPutByIdList;
48 access_get_by_id_self,
49 access_get_by_id_proto,
50 access_get_by_id_chain,
51 access_get_by_id_self_list,
52 access_get_by_id_proto_list,
53 access_put_by_id_transition_normal,
54 access_put_by_id_transition_direct,
55 access_put_by_id_replace,
56 access_put_by_id_list,
58 access_get_by_id_generic,
59 access_put_by_id_generic,
60 access_get_array_length,
61 access_get_string_length,
64 inline bool isGetByIdAccess(AccessType accessType)
67 case access_get_by_id_self:
68 case access_get_by_id_proto:
69 case access_get_by_id_chain:
70 case access_get_by_id_self_list:
71 case access_get_by_id_proto_list:
72 case access_get_by_id_generic:
73 case access_get_array_length:
74 case access_get_string_length:
81 inline bool isPutByIdAccess(AccessType accessType)
84 case access_put_by_id_transition_normal:
85 case access_put_by_id_transition_direct:
86 case access_put_by_id_replace:
87 case access_put_by_id_list:
88 case access_put_by_id_generic:
95 struct StructureStubInfo {
97 : accessType(access_unset)
102 void initGetByIdSelf(JSGlobalData& globalData, JSCell* owner, Structure* baseObjectStructure)
104 accessType = access_get_by_id_self;
106 u.getByIdSelf.baseObjectStructure.set(globalData, owner, baseObjectStructure);
109 void initGetByIdProto(JSGlobalData& globalData, JSCell* owner, Structure* baseObjectStructure, Structure* prototypeStructure, bool isDirect)
111 accessType = access_get_by_id_proto;
113 u.getByIdProto.baseObjectStructure.set(globalData, owner, baseObjectStructure);
114 u.getByIdProto.prototypeStructure.set(globalData, owner, prototypeStructure);
115 u.getByIdProto.isDirect = isDirect;
118 void initGetByIdChain(JSGlobalData& globalData, JSCell* owner, Structure* baseObjectStructure, StructureChain* chain, unsigned count, bool isDirect)
120 accessType = access_get_by_id_chain;
122 u.getByIdChain.baseObjectStructure.set(globalData, owner, baseObjectStructure);
123 u.getByIdChain.chain.set(globalData, owner, chain);
124 u.getByIdChain.count = count;
125 u.getByIdChain.isDirect = isDirect;
128 void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize)
130 accessType = access_get_by_id_self_list;
132 u.getByIdSelfList.structureList = structureList;
133 u.getByIdSelfList.listSize = listSize;
136 void initGetByIdProtoList(PolymorphicAccessStructureList* structureList, int listSize)
138 accessType = access_get_by_id_proto_list;
140 u.getByIdProtoList.structureList = structureList;
141 u.getByIdProtoList.listSize = listSize;
146 void initPutByIdTransition(JSGlobalData& globalData, JSCell* owner, Structure* previousStructure, Structure* structure, StructureChain* chain, bool isDirect)
149 accessType = access_put_by_id_transition_direct;
151 accessType = access_put_by_id_transition_normal;
153 u.putByIdTransition.previousStructure.set(globalData, owner, previousStructure);
154 u.putByIdTransition.structure.set(globalData, owner, structure);
155 u.putByIdTransition.chain.set(globalData, owner, chain);
158 void initPutByIdReplace(JSGlobalData& globalData, JSCell* owner, Structure* baseObjectStructure)
160 accessType = access_put_by_id_replace;
162 u.putByIdReplace.baseObjectStructure.set(globalData, owner, baseObjectStructure);
165 void initPutByIdList(PolymorphicPutByIdList* list)
167 accessType = access_put_by_id_list;
168 u.putByIdList.list = list;
174 accessType = access_unset;
181 bool visitWeakReferences();
193 StructureStubClearingWatchpoint* addWatchpoint(CodeBlock* codeBlock)
195 return WatchpointsOnStructureStubInfo::ensureReferenceAndAddWatchpoint(
196 watchpoints, codeBlock, this);
199 unsigned bytecodeIndex;
205 CodeOrigin codeOrigin;
206 #endif // ENABLE(DFG_JIT)
210 int8_t registersFlushed;
212 #if USE(JSVALUE32_64)
216 DFG::RegisterSetPOD usedRegisters;
217 int32_t deltaCallToDone;
218 int32_t deltaCallToStorageLoad;
219 int32_t deltaCallToStructCheck;
220 int32_t deltaCallToSlowCase;
221 int32_t deltaCheckImmToCall;
223 int32_t deltaCallToLoadOrStore;
225 int32_t deltaCallToTagLoadOrStore;
226 int32_t deltaCallToPayloadLoadOrStore;
232 int16_t structureToCompare;
233 int16_t structureCheck;
234 int16_t propertyStorageLoad;
236 int16_t displacementLabel;
238 int16_t displacementLabel1;
239 int16_t displacementLabel2;
242 int16_t coldPathBegin;
245 int16_t structureToCompare;
246 int16_t propertyStorageLoad;
248 int16_t displacementLabel;
250 int16_t displacementLabel1;
251 int16_t displacementLabel2;
255 int16_t methodCheckProtoObj;
256 int16_t methodCheckProtoStructureToCompare;
257 int16_t methodCheckPutFunction;
263 // It would be unwise to put anything here, as it will surely be overwritten.
266 WriteBarrierBase<Structure> baseObjectStructure;
269 WriteBarrierBase<Structure> baseObjectStructure;
270 WriteBarrierBase<Structure> prototypeStructure;
274 WriteBarrierBase<Structure> baseObjectStructure;
275 WriteBarrierBase<StructureChain> chain;
280 PolymorphicAccessStructureList* structureList;
284 PolymorphicAccessStructureList* structureList;
288 WriteBarrierBase<Structure> previousStructure;
289 WriteBarrierBase<Structure> structure;
290 WriteBarrierBase<StructureChain> chain;
293 WriteBarrierBase<Structure> baseObjectStructure;
296 PolymorphicPutByIdList* list;
300 RefPtr<JITStubRoutine> stubRoutine;
301 CodeLocationCall callReturnLocation;
302 CodeLocationLabel hotPathBegin;
303 RefPtr<WatchpointsOnStructureStubInfo> watchpoints;
306 inline void* getStructureStubInfoReturnLocation(StructureStubInfo* structureStubInfo)
308 return structureStubInfo->callReturnLocation.executableAddress();
311 inline unsigned getStructureStubInfoBytecodeIndex(StructureStubInfo* structureStubInfo)
313 return structureStubInfo->bytecodeIndex;
318 #endif // ENABLE(JIT)
320 #endif // StructureStubInfo_h