Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index ab13412f52989ecc7eb9e6510ab6d46afe0a9e73..cc9482b01fb93f3f2c0531c2cd02473c864d353b 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -9505,13 +9505,17 @@ void JSObject::OptimizeAsPrototype(Handle<JSObject> object, |
JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0, |
"NormalizeAsPrototype"); |
} |
+ bool has_just_copied_map = false; |
if (!object->HasFastProperties()) { |
JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype"); |
+ has_just_copied_map = true; |
} |
if (mode == FAST_PROTOTYPE && object->HasFastProperties() && |
!object->map()->is_prototype_map()) { |
- Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); |
- JSObject::MigrateToMap(object, new_map); |
+ if (!has_just_copied_map) { |
+ Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); |
+ JSObject::MigrateToMap(object, new_map); |
+ } |
object->map()->set_is_prototype_map(true); |
} |
} |