|
Lines 25-32
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec1
|
| 25 |
*/ |
25 |
*/ |
| 26 |
|
26 |
|
| 27 |
#include "config.h" |
27 |
#include "config.h" |
| 28 |
#include "InByIdStatus.h" |
28 |
#include "InByStatus.h" |
| 29 |
|
29 |
|
|
|
30 |
#include "CacheableIdentifierInlines.h" |
| 30 |
#include "CodeBlock.h" |
31 |
#include "CodeBlock.h" |
| 31 |
#include "ComplexGetStatus.h" |
32 |
#include "ComplexGetStatus.h" |
| 32 |
#include "ICStatusUtils.h" |
33 |
#include "ICStatusUtils.h" |
|
Lines 36-81
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec2
|
| 36 |
|
37 |
|
| 37 |
namespace JSC { |
38 |
namespace JSC { |
| 38 |
|
39 |
|
| 39 |
bool InByIdStatus::appendVariant(const InByIdVariant& variant) |
40 |
bool InByStatus::appendVariant(const InByIdVariant& variant) |
| 40 |
{ |
41 |
{ |
| 41 |
return appendICStatusVariant(m_variants, variant); |
42 |
return appendICStatusVariant(m_variants, variant); |
| 42 |
} |
43 |
} |
| 43 |
|
44 |
|
| 44 |
void InByIdStatus::shrinkToFit() |
45 |
void InByStatus::shrinkToFit() |
| 45 |
{ |
46 |
{ |
| 46 |
m_variants.shrinkToFit(); |
47 |
m_variants.shrinkToFit(); |
| 47 |
} |
48 |
} |
| 48 |
|
49 |
|
| 49 |
#if ENABLE(JIT) |
50 |
#if ENABLE(JIT) |
| 50 |
InByIdStatus InByIdStatus::computeFor(CodeBlock* profiledBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, UniquedStringImpl* uid, ExitFlag didExit) |
51 |
InByStatus InByStatus::computeFor(CodeBlock* profiledBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, ExitFlag didExit) |
| 51 |
{ |
52 |
{ |
| 52 |
ConcurrentJSLocker locker(profiledBlock->m_lock); |
53 |
ConcurrentJSLocker locker(profiledBlock->m_lock); |
| 53 |
|
54 |
|
| 54 |
InByIdStatus result; |
55 |
InByStatus result; |
| 55 |
|
56 |
|
| 56 |
#if ENABLE(DFG_JIT) |
57 |
#if ENABLE(DFG_JIT) |
| 57 |
result = computeForStubInfoWithoutExitSiteFeedback(locker, profiledBlock->vm(), map.get(CodeOrigin(bytecodeIndex)).stubInfo, uid); |
58 |
result = computeForStubInfoWithoutExitSiteFeedback(locker, profiledBlock->vm(), map.get(CodeOrigin(bytecodeIndex)).stubInfo); |
| 58 |
|
59 |
|
| 59 |
if (!result.takesSlowPath() && didExit) |
60 |
if (!result.takesSlowPath() && didExit) |
| 60 |
return InByIdStatus(TakesSlowPath); |
61 |
return InByStatus(TakesSlowPath); |
| 61 |
#else |
62 |
#else |
| 62 |
UNUSED_PARAM(map); |
63 |
UNUSED_PARAM(map); |
| 63 |
UNUSED_PARAM(bytecodeIndex); |
64 |
UNUSED_PARAM(bytecodeIndex); |
| 64 |
UNUSED_PARAM(uid); |
|
|
| 65 |
UNUSED_PARAM(didExit); |
65 |
UNUSED_PARAM(didExit); |
| 66 |
#endif |
66 |
#endif |
| 67 |
|
67 |
|
| 68 |
return result; |
68 |
return result; |
| 69 |
} |
69 |
} |
| 70 |
|
70 |
|
| 71 |
InByIdStatus InByIdStatus::computeFor(CodeBlock* profiledBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, UniquedStringImpl* uid) |
71 |
InByStatus InByStatus::computeFor(CodeBlock* profiledBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex) |
| 72 |
{ |
72 |
{ |
| 73 |
return computeFor(profiledBlock, map, bytecodeIndex, uid, hasBadCacheExitSite(profiledBlock, bytecodeIndex)); |
73 |
return computeFor(profiledBlock, map, bytecodeIndex, hasBadCacheExitSite(profiledBlock, bytecodeIndex)); |
| 74 |
} |
74 |
} |
| 75 |
|
75 |
|
| 76 |
InByIdStatus InByIdStatus::computeFor( |
76 |
InByStatus InByStatus::computeFor( |
| 77 |
CodeBlock* profiledBlock, ICStatusMap& baselineMap, |
77 |
CodeBlock* profiledBlock, ICStatusMap& baselineMap, |
| 78 |
ICStatusContextStack& contextStack, CodeOrigin codeOrigin, UniquedStringImpl* uid) |
78 |
ICStatusContextStack& contextStack, CodeOrigin codeOrigin) |
| 79 |
{ |
79 |
{ |
| 80 |
BytecodeIndex bytecodeIndex = codeOrigin.bytecodeIndex(); |
80 |
BytecodeIndex bytecodeIndex = codeOrigin.bytecodeIndex(); |
| 81 |
ExitFlag didExit = hasBadCacheExitSite(profiledBlock, bytecodeIndex); |
81 |
ExitFlag didExit = hasBadCacheExitSite(profiledBlock, bytecodeIndex); |
|
Lines 83-106
InByIdStatus InByIdStatus::computeFor(
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec3
|
| 83 |
for (ICStatusContext* context : contextStack) { |
83 |
for (ICStatusContext* context : contextStack) { |
| 84 |
ICStatus status = context->get(codeOrigin); |
84 |
ICStatus status = context->get(codeOrigin); |
| 85 |
|
85 |
|
| 86 |
auto bless = [&] (const InByIdStatus& result) -> InByIdStatus { |
86 |
auto bless = [&] (const InByStatus& result) -> InByStatus { |
| 87 |
if (!context->isInlined(codeOrigin)) { |
87 |
if (!context->isInlined(codeOrigin)) { |
| 88 |
InByIdStatus baselineResult = computeFor( |
88 |
InByStatus baselineResult = computeFor( |
| 89 |
profiledBlock, baselineMap, bytecodeIndex, uid, didExit); |
89 |
profiledBlock, baselineMap, bytecodeIndex, didExit); |
| 90 |
baselineResult.merge(result); |
90 |
baselineResult.merge(result); |
| 91 |
return baselineResult; |
91 |
return baselineResult; |
| 92 |
} |
92 |
} |
| 93 |
if (didExit.isSet(ExitFromInlined)) |
93 |
if (didExit.isSet(ExitFromInlined)) |
| 94 |
return InByIdStatus(TakesSlowPath); |
94 |
return InByStatus(TakesSlowPath); |
| 95 |
return result; |
95 |
return result; |
| 96 |
}; |
96 |
}; |
| 97 |
|
97 |
|
| 98 |
#if ENABLE(DFG_JIT) |
98 |
#if ENABLE(DFG_JIT) |
| 99 |
if (status.stubInfo) { |
99 |
if (status.stubInfo) { |
| 100 |
InByIdStatus result; |
100 |
InByStatus result; |
| 101 |
{ |
101 |
{ |
| 102 |
ConcurrentJSLocker locker(context->optimizedCodeBlock->m_lock); |
102 |
ConcurrentJSLocker locker(context->optimizedCodeBlock->m_lock); |
| 103 |
result = computeForStubInfoWithoutExitSiteFeedback(locker, profiledBlock->vm(), status.stubInfo, uid); |
103 |
result = computeForStubInfoWithoutExitSiteFeedback(locker, profiledBlock->vm(), status.stubInfo); |
| 104 |
} |
104 |
} |
| 105 |
if (result.isSet()) |
105 |
if (result.isSet()) |
| 106 |
return bless(result); |
106 |
return bless(result); |
|
Lines 111-154
InByIdStatus InByIdStatus::computeFor(
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec4
|
| 111 |
return bless(*status.inStatus); |
111 |
return bless(*status.inStatus); |
| 112 |
} |
112 |
} |
| 113 |
|
113 |
|
| 114 |
return computeFor(profiledBlock, baselineMap, bytecodeIndex, uid, didExit); |
114 |
return computeFor(profiledBlock, baselineMap, bytecodeIndex, didExit); |
| 115 |
} |
115 |
} |
| 116 |
#endif // ENABLE(JIT) |
116 |
#endif // ENABLE(JIT) |
| 117 |
|
117 |
|
| 118 |
#if ENABLE(DFG_JIT) |
118 |
#if ENABLE(DFG_JIT) |
| 119 |
InByIdStatus InByIdStatus::computeForStubInfo(const ConcurrentJSLocker& locker, CodeBlock* profiledBlock, StructureStubInfo* stubInfo, CodeOrigin codeOrigin, UniquedStringImpl* uid) |
119 |
InByStatus InByStatus::computeForStubInfo(const ConcurrentJSLocker& locker, CodeBlock* profiledBlock, StructureStubInfo* stubInfo, CodeOrigin codeOrigin) |
| 120 |
{ |
120 |
{ |
| 121 |
InByIdStatus result = InByIdStatus::computeForStubInfoWithoutExitSiteFeedback(locker, profiledBlock->vm(), stubInfo, uid); |
121 |
InByStatus result = InByStatus::computeForStubInfoWithoutExitSiteFeedback(locker, profiledBlock->vm(), stubInfo); |
| 122 |
|
122 |
|
| 123 |
if (!result.takesSlowPath() && hasBadCacheExitSite(profiledBlock, codeOrigin.bytecodeIndex())) |
123 |
if (!result.takesSlowPath() && hasBadCacheExitSite(profiledBlock, codeOrigin.bytecodeIndex())) |
| 124 |
return InByIdStatus(TakesSlowPath); |
124 |
return InByStatus(TakesSlowPath); |
| 125 |
return result; |
125 |
return result; |
| 126 |
} |
126 |
} |
| 127 |
|
127 |
|
| 128 |
InByIdStatus InByIdStatus::computeForStubInfoWithoutExitSiteFeedback(const ConcurrentJSLocker&, VM& vm, StructureStubInfo* stubInfo, UniquedStringImpl* uid) |
128 |
InByStatus InByStatus::computeForStubInfoWithoutExitSiteFeedback(const ConcurrentJSLocker&, VM& vm, StructureStubInfo* stubInfo) |
| 129 |
{ |
129 |
{ |
| 130 |
StubInfoSummary summary = StructureStubInfo::summary(vm, stubInfo); |
130 |
StubInfoSummary summary = StructureStubInfo::summary(vm, stubInfo); |
| 131 |
if (!isInlineable(summary)) |
131 |
if (!isInlineable(summary)) |
| 132 |
return InByIdStatus(summary); |
132 |
return InByStatus(summary); |
| 133 |
|
133 |
|
| 134 |
// Finally figure out if we can derive an access strategy. |
134 |
// Finally figure out if we can derive an access strategy. |
| 135 |
InByIdStatus result; |
135 |
InByStatus result; |
| 136 |
result.m_state = Simple; |
136 |
result.m_state = Simple; |
| 137 |
switch (stubInfo->cacheType()) { |
137 |
switch (stubInfo->cacheType()) { |
| 138 |
case CacheType::Unset: |
138 |
case CacheType::Unset: |
| 139 |
return InByIdStatus(NoInformation); |
139 |
return InByStatus(NoInformation); |
| 140 |
|
140 |
|
| 141 |
case CacheType::InByIdSelf: { |
141 |
case CacheType::InByIdSelf: { |
| 142 |
Structure* structure = stubInfo->u.byIdSelf.baseObjectStructure.get(); |
142 |
Structure* structure = stubInfo->u.byIdSelf.baseObjectStructure.get(); |
| 143 |
if (structure->takesSlowPathInDFGForImpureProperty()) |
143 |
if (structure->takesSlowPathInDFGForImpureProperty()) |
| 144 |
return InByIdStatus(TakesSlowPath); |
144 |
return InByStatus(TakesSlowPath); |
|
|
145 |
CacheableIdentifier identifier = stubInfo->identifier(); |
| 146 |
UniquedStringImpl* uid = identifier.uid(); |
| 147 |
RELEASE_ASSERT(uid); |
| 148 |
InByIdVariant variant(WTFMove(identifier)); |
| 145 |
unsigned attributes; |
149 |
unsigned attributes; |
| 146 |
InByIdVariant variant; |
|
|
| 147 |
variant.m_offset = structure->getConcurrently(uid, attributes); |
150 |
variant.m_offset = structure->getConcurrently(uid, attributes); |
| 148 |
if (!isValidOffset(variant.m_offset)) |
151 |
if (!isValidOffset(variant.m_offset)) |
| 149 |
return InByIdStatus(TakesSlowPath); |
152 |
return InByStatus(TakesSlowPath); |
| 150 |
if (attributes & PropertyAttribute::CustomAccessorOrValue) |
153 |
if (attributes & PropertyAttribute::CustomAccessorOrValue) |
| 151 |
return InByIdStatus(TakesSlowPath); |
154 |
return InByStatus(TakesSlowPath); |
| 152 |
|
155 |
|
| 153 |
variant.m_structureSet.add(structure); |
156 |
variant.m_structureSet.add(structure); |
| 154 |
bool didAppend = result.appendVariant(variant); |
157 |
bool didAppend = result.appendVariant(variant); |
|
Lines 161-170
InByIdStatus InByIdStatus::computeForStubInfoWithoutExitSiteFeedback(const Concu
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec5
|
| 161 |
for (unsigned listIndex = 0; listIndex < list->size(); ++listIndex) { |
164 |
for (unsigned listIndex = 0; listIndex < list->size(); ++listIndex) { |
| 162 |
const AccessCase& access = list->at(listIndex); |
165 |
const AccessCase& access = list->at(listIndex); |
| 163 |
if (access.viaProxy()) |
166 |
if (access.viaProxy()) |
| 164 |
return InByIdStatus(TakesSlowPath); |
167 |
return InByStatus(TakesSlowPath); |
| 165 |
|
168 |
|
| 166 |
if (access.usesPolyProto()) |
169 |
if (access.usesPolyProto()) |
| 167 |
return InByIdStatus(TakesSlowPath); |
170 |
return InByStatus(TakesSlowPath); |
| 168 |
|
171 |
|
| 169 |
Structure* structure = access.structure(); |
172 |
Structure* structure = access.structure(); |
| 170 |
if (!structure) { |
173 |
if (!structure) { |
|
Lines 174-189
InByIdStatus InByIdStatus::computeForStubInfoWithoutExitSiteFeedback(const Concu
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec6
|
| 174 |
// have to use value profiling to discover something that the AccessCase could have |
177 |
// have to use value profiling to discover something that the AccessCase could have |
| 175 |
// told us. But, it works well enough. So, our only concern here is to not |
178 |
// told us. But, it works well enough. So, our only concern here is to not |
| 176 |
// crash on null structure. |
179 |
// crash on null structure. |
| 177 |
return InByIdStatus(TakesSlowPath); |
180 |
return InByStatus(TakesSlowPath); |
| 178 |
} |
181 |
} |
| 179 |
|
182 |
|
| 180 |
ComplexGetStatus complexGetStatus = ComplexGetStatus::computeFor(structure, access.conditionSet(), uid); |
183 |
ComplexGetStatus complexGetStatus = ComplexGetStatus::computeFor(structure, access.conditionSet(), access.uid()); |
| 181 |
switch (complexGetStatus.kind()) { |
184 |
switch (complexGetStatus.kind()) { |
| 182 |
case ComplexGetStatus::ShouldSkip: |
185 |
case ComplexGetStatus::ShouldSkip: |
| 183 |
continue; |
186 |
continue; |
| 184 |
|
187 |
|
| 185 |
case ComplexGetStatus::TakesSlowPath: |
188 |
case ComplexGetStatus::TakesSlowPath: |
| 186 |
return InByIdStatus(TakesSlowPath); |
189 |
return InByStatus(TakesSlowPath); |
| 187 |
|
190 |
|
| 188 |
case ComplexGetStatus::Inlineable: { |
191 |
case ComplexGetStatus::Inlineable: { |
| 189 |
switch (access.type()) { |
192 |
switch (access.type()) { |
|
Lines 191-205
InByIdStatus InByIdStatus::computeForStubInfoWithoutExitSiteFeedback(const Concu
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec7
|
| 191 |
case AccessCase::InMiss: |
194 |
case AccessCase::InMiss: |
| 192 |
break; |
195 |
break; |
| 193 |
default: |
196 |
default: |
| 194 |
return InByIdStatus(TakesSlowPath); |
197 |
return InByStatus(TakesSlowPath); |
| 195 |
} |
198 |
} |
| 196 |
|
199 |
|
| 197 |
InByIdVariant variant( |
200 |
InByIdVariant variant( |
| 198 |
StructureSet(structure), complexGetStatus.offset(), |
201 |
access.identifier(), StructureSet(structure), complexGetStatus.offset(), |
| 199 |
complexGetStatus.conditionSet()); |
202 |
complexGetStatus.conditionSet()); |
| 200 |
|
203 |
|
| 201 |
if (!result.appendVariant(variant)) |
204 |
if (!result.appendVariant(variant)) |
| 202 |
return InByIdStatus(TakesSlowPath); |
205 |
return InByStatus(TakesSlowPath); |
| 203 |
break; |
206 |
break; |
| 204 |
} |
207 |
} |
| 205 |
} |
208 |
} |
|
Lines 210-224
InByIdStatus InByIdStatus::computeForStubInfoWithoutExitSiteFeedback(const Concu
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec8
|
| 210 |
} |
213 |
} |
| 211 |
|
214 |
|
| 212 |
default: |
215 |
default: |
| 213 |
return InByIdStatus(TakesSlowPath); |
216 |
return InByStatus(TakesSlowPath); |
| 214 |
} |
217 |
} |
| 215 |
|
218 |
|
| 216 |
RELEASE_ASSERT_NOT_REACHED(); |
219 |
RELEASE_ASSERT_NOT_REACHED(); |
| 217 |
return InByIdStatus(); |
220 |
return InByStatus(); |
| 218 |
} |
221 |
} |
| 219 |
#endif |
222 |
#endif |
| 220 |
|
223 |
|
| 221 |
void InByIdStatus::merge(const InByIdStatus& other) |
224 |
void InByStatus::merge(const InByStatus& other) |
| 222 |
{ |
225 |
{ |
| 223 |
if (other.m_state == NoInformation) |
226 |
if (other.m_state == NoInformation) |
| 224 |
return; |
227 |
return; |
|
Lines 230-241
void InByIdStatus::merge(const InByIdStatus& other)
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec9
|
| 230 |
|
233 |
|
| 231 |
case Simple: |
234 |
case Simple: |
| 232 |
if (other.m_state != Simple) { |
235 |
if (other.m_state != Simple) { |
| 233 |
*this = InByIdStatus(TakesSlowPath); |
236 |
*this = InByStatus(TakesSlowPath); |
| 234 |
return; |
237 |
return; |
| 235 |
} |
238 |
} |
| 236 |
for (const InByIdVariant& otherVariant : other.m_variants) { |
239 |
for (const InByIdVariant& otherVariant : other.m_variants) { |
| 237 |
if (!appendVariant(otherVariant)) { |
240 |
if (!appendVariant(otherVariant)) { |
| 238 |
*this = InByIdStatus(TakesSlowPath); |
241 |
*this = InByStatus(TakesSlowPath); |
| 239 |
return; |
242 |
return; |
| 240 |
} |
243 |
} |
| 241 |
} |
244 |
} |
|
Lines 249-255
void InByIdStatus::merge(const InByIdStatus& other)
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec10
|
| 249 |
RELEASE_ASSERT_NOT_REACHED(); |
252 |
RELEASE_ASSERT_NOT_REACHED(); |
| 250 |
} |
253 |
} |
| 251 |
|
254 |
|
| 252 |
void InByIdStatus::filter(const StructureSet& structureSet) |
255 |
void InByStatus::filter(const StructureSet& structureSet) |
| 253 |
{ |
256 |
{ |
| 254 |
if (m_state != Simple) |
257 |
if (m_state != Simple) |
| 255 |
return; |
258 |
return; |
|
Lines 259-274
void InByIdStatus::filter(const StructureSet& structureSet)
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec11
|
| 259 |
} |
262 |
} |
| 260 |
|
263 |
|
| 261 |
template<typename Visitor> |
264 |
template<typename Visitor> |
| 262 |
void InByIdStatus::markIfCheap(Visitor& visitor) |
265 |
void InByStatus::markIfCheap(Visitor& visitor) |
| 263 |
{ |
266 |
{ |
| 264 |
for (InByIdVariant& variant : m_variants) |
267 |
for (InByIdVariant& variant : m_variants) |
| 265 |
variant.markIfCheap(visitor); |
268 |
variant.markIfCheap(visitor); |
| 266 |
} |
269 |
} |
| 267 |
|
270 |
|
| 268 |
template void InByIdStatus::markIfCheap(AbstractSlotVisitor&); |
271 |
template void InByStatus::markIfCheap(AbstractSlotVisitor&); |
| 269 |
template void InByIdStatus::markIfCheap(SlotVisitor&); |
272 |
template void InByStatus::markIfCheap(SlotVisitor&); |
| 270 |
|
273 |
|
| 271 |
bool InByIdStatus::finalize(VM& vm) |
274 |
bool InByStatus::finalize(VM& vm) |
| 272 |
{ |
275 |
{ |
| 273 |
for (InByIdVariant& variant : m_variants) { |
276 |
for (InByIdVariant& variant : m_variants) { |
| 274 |
if (!variant.finalize(vm)) |
277 |
if (!variant.finalize(vm)) |
|
Lines 277-283
bool InByIdStatus::finalize(VM& vm)
a/Source/JavaScriptCore/bytecode/InByIdStatus.cpp_sec12
|
| 277 |
return true; |
280 |
return true; |
| 278 |
} |
281 |
} |
| 279 |
|
282 |
|
| 280 |
void InByIdStatus::dump(PrintStream& out) const |
283 |
CacheableIdentifier InByStatus::singleIdentifier() const |
|
|
284 |
{ |
| 285 |
if (m_variants.isEmpty()) |
| 286 |
return nullptr; |
| 287 |
|
| 288 |
CacheableIdentifier result = m_variants.first().identifier(); |
| 289 |
if (!result) |
| 290 |
return nullptr; |
| 291 |
for (size_t i = 1; i < m_variants.size(); ++i) { |
| 292 |
CacheableIdentifier identifier = m_variants[i].identifier(); |
| 293 |
if (!identifier) |
| 294 |
return nullptr; |
| 295 |
if (identifier != result) |
| 296 |
return nullptr; |
| 297 |
} |
| 298 |
return result; |
| 299 |
} |
| 300 |
|
| 301 |
void InByStatus::dump(PrintStream& out) const |
| 281 |
{ |
302 |
{ |
| 282 |
out.print("("); |
303 |
out.print("("); |
| 283 |
switch (m_state) { |
304 |
switch (m_state) { |