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

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

Issue 2534613002: [ic] Use validity cells to protect keyed element stores against object's prototype chain modificati… (Closed)
Patch Set: The fix Created 4 years 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
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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 case FeedbackVectorSlotKind::KINDS_NUMBER: 320 case FeedbackVectorSlotKind::KINDS_NUMBER:
321 UNREACHABLE(); 321 UNREACHABLE();
322 break; 322 break;
323 } 323 }
324 } 324 }
325 } 325 }
326 } 326 }
327 327
328 328
329 // static 329 // static
330 void TypeFeedbackVector::ClearAllKeyedStoreICs(Isolate* isolate) {
331 SharedFunctionInfo::Iterator iterator(isolate);
332 SharedFunctionInfo* shared;
333 while ((shared = iterator.Next())) {
334 if (!shared->OptimizedCodeMapIsCleared()) {
335 FixedArray* optimized_code_map = shared->optimized_code_map();
336 int length = optimized_code_map->length();
337 for (int i = SharedFunctionInfo::kEntriesStart; i < length;
338 i += SharedFunctionInfo::kEntryLength) {
339 WeakCell* cell = WeakCell::cast(
340 optimized_code_map->get(i + SharedFunctionInfo::kLiteralsOffset));
341 if (cell->value()->IsLiteralsArray()) {
342 TypeFeedbackVector* vector =
343 LiteralsArray::cast(cell->value())->feedback_vector();
344 vector->ClearKeyedStoreICs(shared);
345 }
346 }
347 }
348 }
349 }
350
351
352 void TypeFeedbackVector::ClearKeyedStoreICs(SharedFunctionInfo* shared) {
353 Isolate* isolate = GetIsolate();
354
355 Code* host = shared->code();
356 Object* uninitialized_sentinel =
357 TypeFeedbackVector::RawUninitializedSentinel(isolate);
358
359 TypeFeedbackMetadataIterator iter(metadata());
360 while (iter.HasNext()) {
361 FeedbackVectorSlot slot = iter.Next();
362 FeedbackVectorSlotKind kind = iter.kind();
363 if (kind != FeedbackVectorSlotKind::KEYED_STORE_IC) continue;
364 Object* obj = Get(slot);
365 if (obj != uninitialized_sentinel) {
366 KeyedStoreICNexus nexus(this, slot);
367 nexus.Clear(host);
368 }
369 }
370 }
371
372
373 // static
374 Handle<TypeFeedbackVector> TypeFeedbackVector::DummyVector(Isolate* isolate) { 330 Handle<TypeFeedbackVector> TypeFeedbackVector::DummyVector(Isolate* isolate) {
375 return isolate->factory()->dummy_vector(); 331 return isolate->factory()->dummy_vector();
376 } 332 }
377 333
378 334
379 Handle<FixedArray> FeedbackNexus::EnsureArrayOfSize(int length) { 335 Handle<FixedArray> FeedbackNexus::EnsureArrayOfSize(int length) {
380 Isolate* isolate = GetIsolate(); 336 Isolate* isolate = GetIsolate();
381 Handle<Object> feedback = handle(GetFeedback(), isolate); 337 Handle<Object> feedback = handle(GetFeedback(), isolate);
382 if (!feedback->IsFixedArray() || 338 if (!feedback->IsFixedArray() ||
383 FixedArray::cast(*feedback)->length() != length) { 339 FixedArray::cast(*feedback)->length() != length) {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(GetIsolate()), 709 SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(GetIsolate()),
754 SKIP_WRITE_BARRIER); 710 SKIP_WRITE_BARRIER);
755 } else { 711 } else {
756 array = EnsureExtraArrayOfSize(receiver_count * 2); 712 array = EnsureExtraArrayOfSize(receiver_count * 2);
757 SetFeedback(*name); 713 SetFeedback(*name);
758 } 714 }
759 715
760 InstallHandlers(array, maps, handlers); 716 InstallHandlers(array, maps, handlers);
761 } 717 }
762 718
763
764 void KeyedStoreICNexus::ConfigurePolymorphic(MapHandleList* maps, 719 void KeyedStoreICNexus::ConfigurePolymorphic(MapHandleList* maps,
765 MapHandleList* transitioned_maps, 720 MapHandleList* transitioned_maps,
766 CodeHandleList* handlers) { 721 List<Handle<Object>>* handlers) {
767 int receiver_count = maps->length(); 722 int receiver_count = maps->length();
768 DCHECK(receiver_count > 1); 723 DCHECK(receiver_count > 1);
769 Handle<FixedArray> array = EnsureArrayOfSize(receiver_count * 3); 724 Handle<FixedArray> array = EnsureArrayOfSize(receiver_count * 3);
770 SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(GetIsolate()), 725 SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(GetIsolate()),
771 SKIP_WRITE_BARRIER); 726 SKIP_WRITE_BARRIER);
772 727
773 Handle<Oddball> undefined_value = GetIsolate()->factory()->undefined_value(); 728 Handle<Oddball> undefined_value = GetIsolate()->factory()->undefined_value();
774 for (int i = 0; i < receiver_count; ++i) { 729 for (int i = 0; i < receiver_count; ++i) {
775 Handle<Map> map = maps->at(i); 730 Handle<Map> map = maps->at(i);
776 Handle<WeakCell> cell = Map::WeakCellForMap(map); 731 Handle<WeakCell> cell = Map::WeakCellForMap(map);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 KeyedAccessStoreMode mode = STANDARD_STORE; 908 KeyedAccessStoreMode mode = STANDARD_STORE;
954 MapHandleList maps; 909 MapHandleList maps;
955 List<Handle<Object>> handlers; 910 List<Handle<Object>> handlers;
956 911
957 if (GetKeyType() == PROPERTY) return mode; 912 if (GetKeyType() == PROPERTY) return mode;
958 913
959 ExtractMaps(&maps); 914 ExtractMaps(&maps);
960 FindHandlers(&handlers, maps.length()); 915 FindHandlers(&handlers, maps.length());
961 for (int i = 0; i < handlers.length(); i++) { 916 for (int i = 0; i < handlers.length(); i++) {
962 // The first handler that isn't the slow handler will have the bits we need. 917 // The first handler that isn't the slow handler will have the bits we need.
963 Handle<Code> handler = Handle<Code>::cast(handlers.at(i)); 918 Handle<Object> maybe_code_handler = handlers.at(i);
919 Handle<Code> handler;
920 if (maybe_code_handler->IsTuple2()) {
921 Handle<Tuple2> data_handler = Handle<Tuple2>::cast(maybe_code_handler);
922 handler = handle(Code::cast(data_handler->value2()));
923 } else {
924 handler = Handle<Code>::cast(maybe_code_handler);
925 }
964 CodeStub::Major major_key = CodeStub::MajorKeyFromKey(handler->stub_key()); 926 CodeStub::Major major_key = CodeStub::MajorKeyFromKey(handler->stub_key());
965 uint32_t minor_key = CodeStub::MinorKeyFromKey(handler->stub_key()); 927 uint32_t minor_key = CodeStub::MinorKeyFromKey(handler->stub_key());
966 CHECK(major_key == CodeStub::KeyedStoreSloppyArguments || 928 CHECK(major_key == CodeStub::KeyedStoreSloppyArguments ||
967 major_key == CodeStub::StoreFastElement || 929 major_key == CodeStub::StoreFastElement ||
968 major_key == CodeStub::StoreElement || 930 major_key == CodeStub::StoreElement ||
969 major_key == CodeStub::ElementsTransitionAndStore || 931 major_key == CodeStub::ElementsTransitionAndStore ||
970 major_key == CodeStub::NoCache); 932 major_key == CodeStub::NoCache);
971 if (major_key != CodeStub::NoCache) { 933 if (major_key != CodeStub::NoCache) {
972 mode = CommonStoreModeBits::decode(minor_key); 934 mode = CommonStoreModeBits::decode(minor_key);
973 break; 935 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 return BinaryOperationHintFromFeedback(feedback); 982 return BinaryOperationHintFromFeedback(feedback);
1021 } 983 }
1022 984
1023 CompareOperationHint CompareICNexus::GetCompareOperationFeedback() const { 985 CompareOperationHint CompareICNexus::GetCompareOperationFeedback() const {
1024 int feedback = Smi::cast(GetFeedback())->value(); 986 int feedback = Smi::cast(GetFeedback())->value();
1025 return CompareOperationHintFromFeedback(feedback); 987 return CompareOperationHintFromFeedback(feedback);
1026 } 988 }
1027 989
1028 } // namespace internal 990 } // namespace internal
1029 } // namespace v8 991 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698