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

Side by Side Diff: src/objects.cc

Issue 942833002: Only normalize prototypes in OptimizeAsPrototype if it would benefit. (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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 10050 matching lines...) Expand 10 before | Expand all | Expand 10 after
10061 10061
10062 int slack = map->unused_property_fields(); 10062 int slack = map->unused_property_fields();
10063 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); 10063 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack);
10064 if (slack != 0) { 10064 if (slack != 0) {
10065 // Resize the initial map and all maps in its transition tree. 10065 // Resize the initial map and all maps in its transition tree.
10066 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); 10066 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack);
10067 } 10067 }
10068 } 10068 }
10069 10069
10070 10070
10071 static bool PrototypeBenefitsFromNormalization(Handle<JSObject> object) {
10072 DisallowHeapAllocation no_gc;
10073 if (!object->HasFastProperties()) return false;
10074 Map* map = object->map();
10075 if (map->is_prototype_map()) return false;
10076 DescriptorArray* descriptors = map->instance_descriptors();
10077 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
10078 PropertyDetails details = descriptors->GetDetails(i);
10079 if (details.location() == kDescriptor) continue;
10080 if (details.representation().IsHeapObject() ||
10081 details.representation().IsTagged()) {
10082 FieldIndex index = FieldIndex::ForDescriptor(map, i);
10083 if (object->RawFastPropertyAt(index)->IsJSFunction()) return true;
10084 }
10085 }
10086 return false;
10087 }
10088
10089
10071 void JSObject::OptimizeAsPrototype(Handle<JSObject> object, 10090 void JSObject::OptimizeAsPrototype(Handle<JSObject> object,
10072 PrototypeOptimizationMode mode) { 10091 PrototypeOptimizationMode mode) {
10073 if (object->IsGlobalObject()) return; 10092 if (object->IsGlobalObject()) return;
10074 if (object->IsJSGlobalProxy()) return; 10093 if (object->IsJSGlobalProxy()) return;
10075 if (mode == FAST_PROTOTYPE && !object->map()->is_prototype_map()) { 10094 if (mode == FAST_PROTOTYPE && PrototypeBenefitsFromNormalization(object)) {
10076 // First normalize to ensure all JSFunctions are DATA_CONSTANT. 10095 // First normalize to ensure all JSFunctions are DATA_CONSTANT.
10077 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0, 10096 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0,
10078 "NormalizeAsPrototype"); 10097 "NormalizeAsPrototype");
10079 } 10098 }
10080 bool has_just_copied_map = false; 10099 bool has_just_copied_map = false;
10081 if (!object->HasFastProperties()) { 10100 if (!object->HasFastProperties()) {
10082 JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype"); 10101 JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype");
10083 has_just_copied_map = true; 10102 has_just_copied_map = true;
10084 } 10103 }
10085 if (mode == FAST_PROTOTYPE && object->HasFastProperties() && 10104 if (mode == FAST_PROTOTYPE && object->HasFastProperties() &&
(...skipping 7220 matching lines...) Expand 10 before | Expand all | Expand 10 after
17306 CompilationInfo* info) { 17325 CompilationInfo* info) {
17307 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17326 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17308 handle(cell->dependent_code(), info->isolate()), 17327 handle(cell->dependent_code(), info->isolate()),
17309 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17328 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17310 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17329 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17311 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17330 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17312 cell, info->zone()); 17331 cell, info->zone());
17313 } 17332 }
17314 17333
17315 } } // namespace v8::internal 17334 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698