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

Unified Diff: src/compiler/js-native-context-specialization.cc

Issue 2231683002: [turbofan] Properly guard keyed stores wrt. setters in the prototype chain. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2232483002
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-5275-1.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-native-context-specialization.cc
diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc
index 26793cc85185ea395bf134c0a6395df17f475b7e..eb71da5e0b46f52fb767413f0241fa8f9972f068 100644
--- a/src/compiler/js-native-context-specialization.cc
+++ b/src/compiler/js-native-context-specialization.cc
@@ -472,6 +472,41 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess(
DeoptimizeReason::kInsufficientTypeFeedbackForGenericKeyedAccess);
}
+ // For holey stores or growing stores, we need to check that the prototype
+ // chain contains no setters for elements, and we need to guard those checks
+ // via code dependencies on the relevant prototype maps.
+ if (access_mode == AccessMode::kStore) {
+ ZoneVector<Handle<Map>> prototype_maps(zone());
+ for (ElementAccessInfo const& access_info : access_infos) {
+ for (Handle<Map> receiver_map : access_info.receiver_maps()) {
+ // If the {receiver_map} has a prototype and it's elements backing
+ // store is either holey, or we have a potentially growing store,
+ // then we need to check that all prototypes have stable maps with
+ // fast elements (and we need to guard against changes to that below).
+ if (!receiver_map->prototype()->IsNull(isolate()) &&
Toon Verwaest 2016/08/10 05:38:36 drop this null check, already covered in the loop
Benedikt Meurer 2016/08/10 05:41:46 Done.
+ (IsHoleyElementsKind(receiver_map->elements_kind()) ||
+ IsGrowStoreMode(store_mode))) {
+ // Make sure all prototypes are stable and have fast elements.
+ for (Handle<Map> map = receiver_map;;) {
+ Handle<Object> map_prototype(map->prototype(), isolate());
+ if (map_prototype->IsNull(isolate())) break;
+ if (!map_prototype->IsJSObject()) return NoChange();
+ map = handle(Handle<JSObject>::cast(map_prototype)->map(),
Toon Verwaest 2016/08/10 05:38:36 JSObject::cast(*map_prototype)->map() is shorter :
Benedikt Meurer 2016/08/10 05:41:46 Acknowledged.
+ isolate());
+ if (!map->is_stable()) return NoChange();
+ if (!IsFastElementsKind(map->elements_kind())) return NoChange();
+ prototype_maps.push_back(map);
Toon Verwaest 2016/08/10 05:38:36 Most of the time this will only cover array_protot
Benedikt Meurer 2016/08/10 05:41:46 Added a TODO.
+ }
+ }
+ }
+ }
+
+ // Install dependencies on the relevant prototype maps.
+ for (Handle<Map> prototype_map : prototype_maps) {
+ dependencies()->AssumeMapStable(prototype_map);
+ }
+ }
+
// Ensure that {receiver} is a heap object.
effect = BuildCheckTaggedPointer(receiver, effect, control);
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-5275-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698