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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | 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 b3ac81a8aa9cc97ea280ab7fa78705d1c1adc251..100cbf90b3493860d8bd0c5c5b4246d8f57e495d 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -10068,11 +10068,30 @@ void JSFunction::CompleteInobjectSlackTracking() {
}
+static bool PrototypeBenefitsFromNormalization(Handle<JSObject> object) {
+ DisallowHeapAllocation no_gc;
+ if (!object->HasFastProperties()) return false;
+ Map* map = object->map();
+ if (map->is_prototype_map()) return false;
+ DescriptorArray* descriptors = map->instance_descriptors();
+ for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
+ PropertyDetails details = descriptors->GetDetails(i);
+ if (details.location() == kDescriptor) continue;
+ if (details.representation().IsHeapObject() ||
+ details.representation().IsTagged()) {
+ FieldIndex index = FieldIndex::ForDescriptor(map, i);
+ if (object->RawFastPropertyAt(index)->IsJSFunction()) return true;
+ }
+ }
+ return false;
+}
+
+
void JSObject::OptimizeAsPrototype(Handle<JSObject> object,
PrototypeOptimizationMode mode) {
if (object->IsGlobalObject()) return;
if (object->IsJSGlobalProxy()) return;
- if (mode == FAST_PROTOTYPE && !object->map()->is_prototype_map()) {
+ if (mode == FAST_PROTOTYPE && PrototypeBenefitsFromNormalization(object)) {
// First normalize to ensure all JSFunctions are DATA_CONSTANT.
JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0,
"NormalizeAsPrototype");
« 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