2 * Copyright (C) 2008, 2012-2015 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 "CodeOrigin.h"
30 #include "Instruction.h"
31 #include "JITStubRoutine.h"
32 #include "MacroAssembler.h"
34 #include "PolymorphicAccessStructureList.h"
35 #include "RegisterSet.h"
36 #include "SpillRegistersMode.h"
37 #include "Structure.h"
38 #include "StructureStubClearingWatchpoint.h"
44 class PolymorphicGetByIdList
;
45 class PolymorphicPutByIdList
;
48 access_get_by_id_self
,
49 access_get_by_id_list
,
50 access_put_by_id_transition_normal
,
51 access_put_by_id_transition_direct
,
52 access_put_by_id_replace
,
53 access_put_by_id_list
,
58 inline bool isGetByIdAccess(AccessType accessType
)
61 case access_get_by_id_self
:
62 case access_get_by_id_list
:
69 inline bool isPutByIdAccess(AccessType accessType
)
72 case access_put_by_id_transition_normal
:
73 case access_put_by_id_transition_direct
:
74 case access_put_by_id_replace
:
75 case access_put_by_id_list
:
82 inline bool isInAccess(AccessType accessType
)
92 struct StructureStubInfo
{
94 : accessType(access_unset
)
101 void initGetByIdSelf(VM
& vm
, JSCell
* owner
, Structure
* baseObjectStructure
)
103 accessType
= access_get_by_id_self
;
105 u
.getByIdSelf
.baseObjectStructure
.set(vm
, owner
, baseObjectStructure
);
108 void initGetByIdList(PolymorphicGetByIdList
* list
)
110 accessType
= access_get_by_id_list
;
111 u
.getByIdList
.list
= list
;
116 void initPutByIdTransition(VM
& vm
, JSCell
* owner
, Structure
* previousStructure
, Structure
* structure
, StructureChain
* chain
, bool isDirect
)
119 accessType
= access_put_by_id_transition_direct
;
121 accessType
= access_put_by_id_transition_normal
;
123 u
.putByIdTransition
.previousStructure
.set(vm
, owner
, previousStructure
);
124 u
.putByIdTransition
.structure
.set(vm
, owner
, structure
);
125 u
.putByIdTransition
.chain
.set(vm
, owner
, chain
);
128 void initPutByIdReplace(VM
& vm
, JSCell
* owner
, Structure
* baseObjectStructure
)
130 accessType
= access_put_by_id_replace
;
132 u
.putByIdReplace
.baseObjectStructure
.set(vm
, owner
, baseObjectStructure
);
135 void initPutByIdList(PolymorphicPutByIdList
* list
)
137 accessType
= access_put_by_id_list
;
138 u
.putByIdList
.list
= list
;
141 void initInList(PolymorphicAccessStructureList
* list
, int listSize
)
143 accessType
= access_in_list
;
144 u
.inList
.structureList
= list
;
145 u
.inList
.listSize
= listSize
;
151 accessType
= access_unset
;
152 stubRoutine
= nullptr;
153 watchpoints
= nullptr;
158 // Check if the stub has weak references that are dead. If there are dead ones that imply
159 // that the stub should be entirely reset, this should return false. If there are dead ones
160 // that can be handled internally by the stub and don't require a full reset, then this
161 // should reset them and return true. If there are no dead weak references, return true.
162 // If this method returns true it means that it has left the stub in a state where all
163 // outgoing GC pointers are known to point to currently marked objects; this method is
164 // allowed to accomplish this by either clearing those pointers somehow or by proving that
165 // they have already been marked. It is not allowed to mark new objects.
166 bool visitWeakReferences(RepatchBuffer
&);
178 StructureStubClearingWatchpoint
* addWatchpoint(CodeBlock
* codeBlock
)
180 return WatchpointsOnStructureStubInfo::ensureReferenceAndAddWatchpoint(
181 watchpoints
, codeBlock
, this);
187 bool tookSlowPath
: 1;
189 CodeOrigin codeOrigin
;
192 unsigned spillMode
: 8;
194 #if USE(JSVALUE32_64)
198 RegisterSet usedRegisters
;
199 int32_t deltaCallToDone
;
200 int32_t deltaCallToStorageLoad
;
201 int32_t deltaCallToJump
;
202 int32_t deltaCallToSlowCase
;
203 int32_t deltaCheckImmToCall
;
205 int32_t deltaCallToLoadOrStore
;
207 int32_t deltaCallToTagLoadOrStore
;
208 int32_t deltaCallToPayloadLoadOrStore
;
214 // It would be unwise to put anything here, as it will surely be overwritten.
217 WriteBarrierBase
<Structure
> baseObjectStructure
;
220 WriteBarrierBase
<Structure
> baseObjectStructure
;
221 WriteBarrierBase
<Structure
> prototypeStructure
;
225 WriteBarrierBase
<Structure
> baseObjectStructure
;
226 WriteBarrierBase
<StructureChain
> chain
;
231 PolymorphicGetByIdList
* list
;
234 WriteBarrierBase
<Structure
> previousStructure
;
235 WriteBarrierBase
<Structure
> structure
;
236 WriteBarrierBase
<StructureChain
> chain
;
239 WriteBarrierBase
<Structure
> baseObjectStructure
;
242 PolymorphicPutByIdList
* list
;
245 PolymorphicAccessStructureList
* structureList
;
250 RefPtr
<JITStubRoutine
> stubRoutine
;
251 CodeLocationCall callReturnLocation
;
252 RefPtr
<WatchpointsOnStructureStubInfo
> watchpoints
;
255 inline CodeOrigin
getStructureStubInfoCodeOrigin(StructureStubInfo
& structureStubInfo
)
257 return structureStubInfo
.codeOrigin
;
260 typedef HashMap
<CodeOrigin
, StructureStubInfo
*, CodeOriginApproximateHash
> StubInfoMap
;
264 typedef HashMap
<int, void*> StubInfoMap
;
266 #endif // ENABLE(JIT)
270 #endif // StructureStubInfo_h