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

Unified Diff: src/objects.cc

Issue 932583002: Remove prototype key from the prototype transitions since its also embedded in the target map. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f21a001dcae4152f9e328385ac13de7828bc347b..425d7703752554a1dd6a264ba1733402d1df7d59 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -7490,13 +7490,8 @@ class IntrusivePrototypeTransitionIterator {
Map* GetTransition(int transitionNumber) {
FixedArray* proto_trans = reinterpret_cast<FixedArray*>(proto_trans_);
- return Map::cast(proto_trans->get(IndexFor(transitionNumber)));
- }
-
- int IndexFor(int transitionNumber) {
- return Map::kProtoTransitionHeaderSize +
- Map::kProtoTransitionMapOffset +
- transitionNumber * Map::kProtoTransitionElementsPerEntry;
+ int index = Map::kProtoTransitionHeaderSize + transitionNumber;
+ return Map::cast(proto_trans->get(index));
}
Map* map_;
@@ -11810,17 +11805,12 @@ MaybeHandle<Object> JSArray::SetElementsLength(
Handle<Map> Map::GetPrototypeTransition(Handle<Map> map,
Handle<Object> prototype) {
+ DisallowHeapAllocation no_gc;
FixedArray* cache = map->GetPrototypeTransitions();
int number_of_transitions = map->NumberOfProtoTransitions();
- const int proto_offset =
- kProtoTransitionHeaderSize + kProtoTransitionPrototypeOffset;
- const int map_offset = kProtoTransitionHeaderSize + kProtoTransitionMapOffset;
- const int step = kProtoTransitionElementsPerEntry;
for (int i = 0; i < number_of_transitions; i++) {
- if (cache->get(proto_offset + i * step) == *prototype) {
- Object* result = cache->get(map_offset + i * step);
- return Handle<Map>(Map::cast(result));
- }
+ Map* map = Map::cast(cache->get(kProtoTransitionHeaderSize + i));
+ if (map->prototype() == *prototype) return handle(map);
}
return Handle<Map>();
}
@@ -11836,28 +11826,27 @@ Handle<Map> Map::PutPrototypeTransition(Handle<Map> map,
if (map->is_prototype_map()) return map;
if (map->is_dictionary_map() || !FLAG_cache_prototype_transitions) return map;
- const int step = kProtoTransitionElementsPerEntry;
const int header = kProtoTransitionHeaderSize;
Handle<FixedArray> cache(map->GetPrototypeTransitions());
- int capacity = (cache->length() - header) / step;
+ int capacity = cache->length() - header;
int transitions = map->NumberOfProtoTransitions() + 1;
if (transitions > capacity) {
- if (capacity > kMaxCachedPrototypeTransitions) return map;
+ // Grow array by factor 2 up to MaxCachedPrototypeTransitions.
+ int new_capacity = Min(kMaxCachedPrototypeTransitions, transitions * 2);
Hannes Payer (out of office) 2015/02/16 13:37:20 We could have used a constant there for the growin
+ if (new_capacity == capacity) return map;
- // Grow array by factor 2 over and above what we need.
- cache = FixedArray::CopySize(cache, transitions * 2 * step + header);
+ cache = FixedArray::CopySize(cache, header + new_capacity);
SetPrototypeTransitions(map, cache);
}
// Reload number of transitions as GC might shrink them.
int last = map->NumberOfProtoTransitions();
- int entry = header + last * step;
+ int entry = header + last;
- cache->set(entry + kProtoTransitionPrototypeOffset, *prototype);
- cache->set(entry + kProtoTransitionMapOffset, *target_map);
+ cache->set(entry, *target_map);
map->SetNumberOfProtoTransitions(last + 1);
return map;
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698