Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 258390c4d5cb2b62ff079e31d90de3e5595b6fcb..2b17ebb8b12d816c4401ecffdb18f861fc088a15 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -9416,13 +9416,17 @@ void JSObject::OptimizeAsPrototype(Handle<JSObject> object, |
// First normalize to ensure all JSFunctions are CONSTANT. |
JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0); |
} |
+ bool has_just_copied_map = false; |
if (!object->HasFastProperties()) { |
JSObject::MigrateSlowToFast(object, 0); |
+ 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())); |
- JSObject::MigrateToMap(object, new_map); |
+ if (!has_just_copied_map) { |
+ Handle<Map> new_map = Map::Copy(handle(object->map())); |
+ JSObject::MigrateToMap(object, new_map); |
+ } |
object->map()->set_is_prototype_map(true); |
} |
} |