OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/type-feedback-vector.h" | 5 #include "src/type-feedback-vector.h" |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
9 #include "src/ic/ic-state.h" | 9 #include "src/ic/ic-state.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 LoadICNexus nexus(this, slot); | 226 LoadICNexus nexus(this, slot); |
227 nexus.Clear(shared->code()); | 227 nexus.Clear(shared->code()); |
228 break; | 228 break; |
229 } | 229 } |
230 case FeedbackVectorSlotKind::KEYED_LOAD_IC: { | 230 case FeedbackVectorSlotKind::KEYED_LOAD_IC: { |
231 KeyedLoadICNexus nexus(this, slot); | 231 KeyedLoadICNexus nexus(this, slot); |
232 nexus.Clear(shared->code()); | 232 nexus.Clear(shared->code()); |
233 break; | 233 break; |
234 } | 234 } |
235 case FeedbackVectorSlotKind::STORE_IC: { | 235 case FeedbackVectorSlotKind::STORE_IC: { |
236 DCHECK(FLAG_vector_stores); | |
237 StoreICNexus nexus(this, slot); | 236 StoreICNexus nexus(this, slot); |
238 nexus.Clear(shared->code()); | 237 nexus.Clear(shared->code()); |
239 break; | 238 break; |
240 } | 239 } |
241 case FeedbackVectorSlotKind::KEYED_STORE_IC: { | 240 case FeedbackVectorSlotKind::KEYED_STORE_IC: { |
242 DCHECK(FLAG_vector_stores); | |
243 KeyedStoreICNexus nexus(this, slot); | 241 KeyedStoreICNexus nexus(this, slot); |
244 nexus.Clear(shared->code()); | 242 nexus.Clear(shared->code()); |
245 break; | 243 break; |
246 } | 244 } |
247 case FeedbackVectorSlotKind::GENERAL: { | 245 case FeedbackVectorSlotKind::GENERAL: { |
248 if (obj->IsHeapObject()) { | 246 if (obj->IsHeapObject()) { |
249 InstanceType instance_type = | 247 InstanceType instance_type = |
250 HeapObject::cast(obj)->map()->instance_type(); | 248 HeapObject::cast(obj)->map()->instance_type(); |
251 // AllocationSites are exempt from clearing. They don't store Maps | 249 // AllocationSites are exempt from clearing. They don't store Maps |
252 // or Code pointers which can cause memory leaks if not cleared | 250 // or Code pointers which can cause memory leaks if not cleared |
253 // regularly. | 251 // regularly. |
254 if (instance_type != ALLOCATION_SITE_TYPE) { | 252 if (instance_type != ALLOCATION_SITE_TYPE) { |
255 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER); | 253 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER); |
256 } | 254 } |
257 } | 255 } |
258 break; | 256 break; |
259 } | 257 } |
260 case FeedbackVectorSlotKind::INVALID: | 258 case FeedbackVectorSlotKind::INVALID: |
261 case FeedbackVectorSlotKind::KINDS_NUMBER: | 259 case FeedbackVectorSlotKind::KINDS_NUMBER: |
262 UNREACHABLE(); | 260 UNREACHABLE(); |
263 break; | 261 break; |
264 } | 262 } |
265 } | 263 } |
266 } | 264 } |
267 } | 265 } |
268 | 266 |
269 | 267 |
270 // static | 268 // static |
271 void TypeFeedbackVector::ClearAllKeyedStoreICs(Isolate* isolate) { | 269 void TypeFeedbackVector::ClearAllKeyedStoreICs(Isolate* isolate) { |
272 DCHECK(FLAG_vector_stores); | |
273 SharedFunctionInfo::Iterator iterator(isolate); | 270 SharedFunctionInfo::Iterator iterator(isolate); |
274 SharedFunctionInfo* shared; | 271 SharedFunctionInfo* shared; |
275 while ((shared = iterator.Next())) { | 272 while ((shared = iterator.Next())) { |
276 TypeFeedbackVector* vector = shared->feedback_vector(); | 273 TypeFeedbackVector* vector = shared->feedback_vector(); |
277 vector->ClearKeyedStoreICs(shared); | 274 vector->ClearKeyedStoreICs(shared); |
278 } | 275 } |
279 } | 276 } |
280 | 277 |
281 | 278 |
282 void TypeFeedbackVector::ClearKeyedStoreICs(SharedFunctionInfo* shared) { | 279 void TypeFeedbackVector::ClearKeyedStoreICs(SharedFunctionInfo* shared) { |
283 Isolate* isolate = GetIsolate(); | 280 Isolate* isolate = GetIsolate(); |
284 | 281 |
285 Code* host = shared->code(); | 282 Code* host = shared->code(); |
286 Object* uninitialized_sentinel = | 283 Object* uninitialized_sentinel = |
287 TypeFeedbackVector::RawUninitializedSentinel(isolate); | 284 TypeFeedbackVector::RawUninitializedSentinel(isolate); |
288 | 285 |
289 TypeFeedbackMetadataIterator iter(metadata()); | 286 TypeFeedbackMetadataIterator iter(metadata()); |
290 while (iter.HasNext()) { | 287 while (iter.HasNext()) { |
291 FeedbackVectorSlot slot = iter.Next(); | 288 FeedbackVectorSlot slot = iter.Next(); |
292 FeedbackVectorSlotKind kind = iter.kind(); | 289 FeedbackVectorSlotKind kind = iter.kind(); |
293 if (kind != FeedbackVectorSlotKind::KEYED_STORE_IC) continue; | 290 if (kind != FeedbackVectorSlotKind::KEYED_STORE_IC) continue; |
294 Object* obj = Get(slot); | 291 Object* obj = Get(slot); |
295 if (obj != uninitialized_sentinel) { | 292 if (obj != uninitialized_sentinel) { |
296 DCHECK(FLAG_vector_stores); | |
297 KeyedStoreICNexus nexus(this, slot); | 293 KeyedStoreICNexus nexus(this, slot); |
298 nexus.Clear(host); | 294 nexus.Clear(host); |
299 } | 295 } |
300 } | 296 } |
301 } | 297 } |
302 | 298 |
303 | 299 |
304 // static | 300 // static |
305 Handle<TypeFeedbackVector> TypeFeedbackVector::DummyVector(Isolate* isolate) { | 301 Handle<TypeFeedbackVector> TypeFeedbackVector::DummyVector(Isolate* isolate) { |
306 return isolate->factory()->dummy_vector(); | 302 return isolate->factory()->dummy_vector(); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 return mode; | 843 return mode; |
848 } | 844 } |
849 | 845 |
850 | 846 |
851 IcCheckType KeyedStoreICNexus::GetKeyType() const { | 847 IcCheckType KeyedStoreICNexus::GetKeyType() const { |
852 // The structure of the vector slots tells us the type. | 848 // The structure of the vector slots tells us the type. |
853 return GetFeedback()->IsName() ? PROPERTY : ELEMENT; | 849 return GetFeedback()->IsName() ? PROPERTY : ELEMENT; |
854 } | 850 } |
855 } // namespace internal | 851 } // namespace internal |
856 } // namespace v8 | 852 } // namespace v8 |
OLD | NEW |