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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ic/ic.h" | 7 #include "src/ic/ic.h" |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/objects.h" | 9 #include "src/objects.h" |
10 #include "src/type-feedback-vector-inl.h" | 10 #include "src/type-feedback-vector-inl.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Isolate* isolate, Handle<TypeFeedbackVector> vector) { | 132 Isolate* isolate, Handle<TypeFeedbackVector> vector) { |
133 Handle<TypeFeedbackVector> result; | 133 Handle<TypeFeedbackVector> result; |
134 result = Handle<TypeFeedbackVector>::cast( | 134 result = Handle<TypeFeedbackVector>::cast( |
135 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector))); | 135 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector))); |
136 return result; | 136 return result; |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 // This logic is copied from | 140 // This logic is copied from |
141 // StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget. | 141 // StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget. |
142 static bool ClearLogic(Heap* heap, int ic_age) { | 142 static bool ClearLogic(Heap* heap) { |
143 return FLAG_cleanup_code_caches_at_gc && | 143 return FLAG_cleanup_code_caches_at_gc && |
144 heap->isolate()->serializer_enabled(); | 144 heap->isolate()->serializer_enabled(); |
145 } | 145 } |
146 | 146 |
147 | 147 |
148 void TypeFeedbackVector::ClearSlots(SharedFunctionInfo* shared) { | 148 void TypeFeedbackVector::ClearSlotsImpl(SharedFunctionInfo* shared, |
| 149 bool force_clear) { |
149 int slots = Slots(); | 150 int slots = Slots(); |
150 Isolate* isolate = GetIsolate(); | 151 Heap* heap = GetIsolate()->heap(); |
| 152 |
| 153 if (!force_clear && !ClearLogic(heap)) return; |
| 154 |
151 Object* uninitialized_sentinel = | 155 Object* uninitialized_sentinel = |
152 TypeFeedbackVector::RawUninitializedSentinel(isolate->heap()); | 156 TypeFeedbackVector::RawUninitializedSentinel(heap); |
153 | |
154 for (int i = 0; i < slots; i++) { | 157 for (int i = 0; i < slots; i++) { |
155 FeedbackVectorSlot slot(i); | 158 FeedbackVectorSlot slot(i); |
156 Object* obj = Get(slot); | 159 Object* obj = Get(slot); |
157 if (obj->IsHeapObject()) { | 160 if (obj->IsHeapObject()) { |
158 InstanceType instance_type = | 161 InstanceType instance_type = |
159 HeapObject::cast(obj)->map()->instance_type(); | 162 HeapObject::cast(obj)->map()->instance_type(); |
160 // AllocationSites are exempt from clearing. They don't store Maps | 163 // AllocationSites are exempt from clearing. They don't store Maps |
161 // or Code pointers which can cause memory leaks if not cleared | 164 // or Code pointers which can cause memory leaks if not cleared |
162 // regularly. | 165 // regularly. |
163 if (instance_type != ALLOCATION_SITE_TYPE) { | 166 if (instance_type != ALLOCATION_SITE_TYPE) { |
164 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER); | 167 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER); |
165 } | 168 } |
166 } | 169 } |
167 } | 170 } |
168 } | 171 } |
169 | 172 |
170 | 173 |
171 void TypeFeedbackVector::ClearICSlotsImpl(SharedFunctionInfo* shared, | 174 void TypeFeedbackVector::ClearICSlotsImpl(SharedFunctionInfo* shared, |
172 bool force_clear) { | 175 bool force_clear) { |
173 Heap* heap = GetIsolate()->heap(); | 176 Heap* heap = GetIsolate()->heap(); |
174 | 177 |
175 // I'm not sure yet if this ic age is the correct one. | 178 if (!force_clear && !ClearLogic(heap)) return; |
176 int ic_age = shared->ic_age(); | |
177 | |
178 if (!force_clear && !ClearLogic(heap, ic_age)) return; | |
179 | 179 |
180 int slots = ICSlots(); | 180 int slots = ICSlots(); |
181 Code* host = shared->code(); | 181 Code* host = shared->code(); |
182 Object* uninitialized_sentinel = | 182 Object* uninitialized_sentinel = |
183 TypeFeedbackVector::RawUninitializedSentinel(heap); | 183 TypeFeedbackVector::RawUninitializedSentinel(heap); |
184 for (int i = 0; i < slots; i++) { | 184 for (int i = 0; i < slots; i++) { |
185 FeedbackVectorICSlot slot(i); | 185 FeedbackVectorICSlot slot(i); |
186 Object* obj = Get(slot); | 186 Object* obj = Get(slot); |
187 if (obj != uninitialized_sentinel) { | 187 if (obj != uninitialized_sentinel) { |
188 Code::Kind kind = GetKind(slot); | 188 Code::Kind kind = GetKind(slot); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 536 |
537 Name* KeyedLoadICNexus::FindFirstName() const { | 537 Name* KeyedLoadICNexus::FindFirstName() const { |
538 Object* feedback = GetFeedback(); | 538 Object* feedback = GetFeedback(); |
539 if (feedback->IsString()) { | 539 if (feedback->IsString()) { |
540 return Name::cast(feedback); | 540 return Name::cast(feedback); |
541 } | 541 } |
542 return NULL; | 542 return NULL; |
543 } | 543 } |
544 } | 544 } |
545 } // namespace v8::internal | 545 } // namespace v8::internal |
OLD | NEW |