Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: src/type-feedback-vector.cc

Issue 2674593003: [TypeFeedbackVector] Root feedback vectors at function literal site. (Closed)
Patch Set: REBASE+liveedit fix. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/s390/macro-assembler-s390.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-inl.h" 8 #include "src/ic/ic-inl.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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (length == kReservedIndexCount) { 196 if (length == kReservedIndexCount) {
197 return Handle<TypeFeedbackVector>::cast( 197 return Handle<TypeFeedbackVector>::cast(
198 factory->empty_type_feedback_vector()); 198 factory->empty_type_feedback_vector());
199 } 199 }
200 200
201 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED); 201 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED);
202 array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map()); 202 array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map());
203 array->set(kMetadataIndex, *metadata); 203 array->set(kMetadataIndex, *metadata);
204 array->set(kInvocationCountIndex, Smi::kZero); 204 array->set(kInvocationCountIndex, Smi::kZero);
205 205
206 DisallowHeapAllocation no_gc;
207
208 // Ensure we can skip the write barrier 206 // Ensure we can skip the write barrier
209 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); 207 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
208 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel);
210 Handle<Oddball> undefined_value = factory->undefined_value(); 209 Handle<Oddball> undefined_value = factory->undefined_value();
211 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel);
212 for (int i = 0; i < slot_count;) { 210 for (int i = 0; i < slot_count;) {
213 FeedbackVectorSlot slot(i); 211 FeedbackVectorSlot slot(i);
214 FeedbackVectorSlotKind kind = metadata->GetKind(slot); 212 FeedbackVectorSlotKind kind = metadata->GetKind(slot);
215 int index = TypeFeedbackVector::GetIndex(slot); 213 int index = TypeFeedbackVector::GetIndex(slot);
216 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); 214 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
217 215
218 Object* value;
219 Object* extra_value = *uninitialized_sentinel; 216 Object* extra_value = *uninitialized_sentinel;
220 switch (kind) { 217 switch (kind) {
221 case FeedbackVectorSlotKind::LOAD_GLOBAL_IC: 218 case FeedbackVectorSlotKind::LOAD_GLOBAL_IC:
222 value = isolate->heap()->empty_weak_cell(); 219 array->set(index, isolate->heap()->empty_weak_cell(),
220 SKIP_WRITE_BARRIER);
223 break; 221 break;
224 case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC: 222 case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC:
225 case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC: 223 case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC:
226 value = Smi::kZero; 224 array->set(index, Smi::kZero, SKIP_WRITE_BARRIER);
227 break; 225 break;
228 case FeedbackVectorSlotKind::CREATE_CLOSURE: 226 case FeedbackVectorSlotKind::CREATE_CLOSURE: {
229 // TODO(mvstanton): Root feedback vectors in this location. 227 Handle<Cell> cell = factory->NewCell(undefined_value);
230 value = isolate->heap()->empty_type_feedback_vector(); 228 array->set(index, *cell);
231 break; 229 break;
230 }
232 case FeedbackVectorSlotKind::LITERAL: 231 case FeedbackVectorSlotKind::LITERAL:
233 value = *undefined_value; 232 array->set(index, *undefined_value, SKIP_WRITE_BARRIER);
234 break; 233 break;
235 case FeedbackVectorSlotKind::CALL_IC: 234 case FeedbackVectorSlotKind::CALL_IC:
236 value = *uninitialized_sentinel; 235 array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
237 extra_value = Smi::kZero; 236 extra_value = Smi::kZero;
238 break; 237 break;
239 case FeedbackVectorSlotKind::LOAD_IC: 238 case FeedbackVectorSlotKind::LOAD_IC:
240 case FeedbackVectorSlotKind::KEYED_LOAD_IC: 239 case FeedbackVectorSlotKind::KEYED_LOAD_IC:
241 case FeedbackVectorSlotKind::STORE_SLOPPY_IC: 240 case FeedbackVectorSlotKind::STORE_SLOPPY_IC:
242 case FeedbackVectorSlotKind::STORE_STRICT_IC: 241 case FeedbackVectorSlotKind::STORE_STRICT_IC:
243 case FeedbackVectorSlotKind::KEYED_STORE_SLOPPY_IC: 242 case FeedbackVectorSlotKind::KEYED_STORE_SLOPPY_IC:
244 case FeedbackVectorSlotKind::KEYED_STORE_STRICT_IC: 243 case FeedbackVectorSlotKind::KEYED_STORE_STRICT_IC:
245 case FeedbackVectorSlotKind::STORE_DATA_PROPERTY_IN_LITERAL_IC: 244 case FeedbackVectorSlotKind::STORE_DATA_PROPERTY_IN_LITERAL_IC:
246 case FeedbackVectorSlotKind::GENERAL: 245 case FeedbackVectorSlotKind::GENERAL:
247 value = *uninitialized_sentinel; 246 array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
248 break; 247 break;
249 248
250 case FeedbackVectorSlotKind::INVALID: 249 case FeedbackVectorSlotKind::INVALID:
251 case FeedbackVectorSlotKind::KINDS_NUMBER: 250 case FeedbackVectorSlotKind::KINDS_NUMBER:
252 UNREACHABLE(); 251 UNREACHABLE();
253 value = Smi::kZero; 252 array->set(index, Smi::kZero, SKIP_WRITE_BARRIER);
254 break; 253 break;
255 } 254 }
256 array->set(index, value, SKIP_WRITE_BARRIER);
257 for (int j = 1; j < entry_size; j++) { 255 for (int j = 1; j < entry_size; j++) {
258 array->set(index + j, extra_value, SKIP_WRITE_BARRIER); 256 array->set(index + j, extra_value, SKIP_WRITE_BARRIER);
259 } 257 }
260 i += entry_size; 258 i += entry_size;
261 } 259 }
262 return Handle<TypeFeedbackVector>::cast(array); 260 return Handle<TypeFeedbackVector>::cast(array);
263 } 261 }
264 262
265 // static 263 // static
266 Handle<TypeFeedbackVector> TypeFeedbackVector::Copy( 264 Handle<TypeFeedbackVector> TypeFeedbackVector::Copy(
267 Isolate* isolate, Handle<TypeFeedbackVector> vector) { 265 Isolate* isolate, Handle<TypeFeedbackVector> vector) {
268 Handle<TypeFeedbackVector> result; 266 Handle<TypeFeedbackVector> result;
269 result = Handle<TypeFeedbackVector>::cast( 267 result = Handle<TypeFeedbackVector>::cast(
270 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector))); 268 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector)));
271 return result; 269 return result;
272 } 270 }
273 271
274
275 // This logic is copied from 272 // This logic is copied from
276 // StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget. 273 // StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget.
277 static bool ClearLogic(Isolate* isolate) { 274 static bool ClearLogic(Isolate* isolate) {
278 return FLAG_cleanup_code_caches_at_gc && isolate->serializer_enabled(); 275 return FLAG_cleanup_code_caches_at_gc && isolate->serializer_enabled();
279 } 276 }
280 277
281
282 void TypeFeedbackVector::ClearSlotsImpl(SharedFunctionInfo* shared, 278 void TypeFeedbackVector::ClearSlotsImpl(SharedFunctionInfo* shared,
283 bool force_clear) { 279 bool force_clear) {
284 Isolate* isolate = GetIsolate(); 280 Isolate* isolate = GetIsolate();
285 if (!force_clear && !ClearLogic(isolate)) return; 281 if (!force_clear && !ClearLogic(isolate)) return;
286 282
287 if (this == isolate->heap()->empty_type_feedback_vector()) return; 283 if (this == isolate->heap()->empty_type_feedback_vector()) return;
288 284
289 Object* uninitialized_sentinel = 285 Object* uninitialized_sentinel =
290 TypeFeedbackVector::RawUninitializedSentinel(isolate); 286 TypeFeedbackVector::RawUninitializedSentinel(isolate);
291 Oddball* undefined_value = isolate->heap()->undefined_value(); 287 Oddball* undefined_value = isolate->heap()->undefined_value();
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( 1046 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic(
1051 Handle<Name> name, Handle<Map> receiver_map) { 1047 Handle<Name> name, Handle<Map> receiver_map) {
1052 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 1048 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
1053 1049
1054 SetFeedback(*cell); 1050 SetFeedback(*cell);
1055 SetFeedbackExtra(*name); 1051 SetFeedbackExtra(*name);
1056 } 1052 }
1057 1053
1058 } // namespace internal 1054 } // namespace internal
1059 } // namespace v8 1055 } // namespace v8
OLDNEW
« no previous file with comments | « src/s390/macro-assembler-s390.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698