Revision: 14728
Author:   [email protected]
Date:     Tue May 21 04:20:24 2013
Log:      Don't create new maps in CurrentMapForDeprecated.

[email protected]

Review URL: https://chromiumcodereview.appspot.com/15358005
http://code.google.com/p/v8/source/detail?r=14728

Modified:
 /branches/bleeding_edge/src/ast.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/type-info.cc

=======================================
--- /branches/bleeding_edge/src/ast.h   Wed May 15 02:04:10 2013
+++ /branches/bleeding_edge/src/ast.h   Tue May 21 04:20:24 2013
@@ -278,7 +278,9 @@
   int length() const { return list_.length(); }

   void AddMapIfMissing(Handle<Map> map, Zone* zone) {
-    map = Map::CurrentMapForDeprecated(map);
+    Map* updated = map->CurrentMapForDeprecated();
+    if (updated == NULL) return;
+    map = Handle<Map>(updated);
     for (int i = 0; i < length(); ++i) {
       if (at(i).is_identical_to(map)) return;
     }
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Thu May 16 23:58:06 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Tue May 21 04:20:24 2013
@@ -1832,7 +1832,7 @@
   } else {
     if_nil.Then();
     if_nil.Else();
-    if (types.Contains(CompareNilICStub::MONOMORPHIC_MAP)) {
+ if (!map.is_null() && types.Contains(CompareNilICStub::MONOMORPHIC_MAP)) {
       BuildCheckNonSmi(value);
// For ICs, the map checked below is a sentinel map that gets replaced by // the monomorphic map when the code is used as a template to generate a
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Wed May 15 08:23:53 2013
+++ /branches/bleeding_edge/src/objects-inl.h   Tue May 21 04:20:24 2013
@@ -3622,12 +3622,6 @@
   }
   return false;
 }
-
-
-Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
-  if (!map->is_deprecated()) return map;
-  return GeneralizeRepresentation(map, 0, Representation::Smi());
-}


 void Map::NotifyLeafMapLayoutChange() {
=======================================
--- /branches/bleeding_edge/src/objects.cc      Mon May 20 23:36:24 2013
+++ /branches/bleeding_edge/src/objects.cc      Tue May 21 04:20:24 2013
@@ -2537,6 +2537,7 @@
   int descriptors = old_map->NumberOfOwnDescriptors();
   Map* root_map = old_map->FindRootMap();

+  // Check the state of the root map.
   if (!old_map->EquivalentToForTransition(root_map)) {
     return CopyGeneralizeAllRepresentations();
   }
@@ -2547,7 +2548,6 @@
       verbatim, descriptors, old_descriptors);
   if (updated == NULL) return CopyGeneralizeAllRepresentations();

-  // Check the state of the root map.
   DescriptorArray* updated_descriptors = updated->instance_descriptors();

   int valid = updated->NumberOfOwnDescriptors();
@@ -2622,6 +2622,34 @@
   new_map->set_owns_descriptors(true);
   return new_map;
 }
+
+
+Map* Map::CurrentMapForDeprecated() {
+  AssertNoAllocation no_allocation;
+  if (!is_deprecated()) return this;
+
+  DescriptorArray* old_descriptors = instance_descriptors();
+
+  int descriptors = NumberOfOwnDescriptors();
+  Map* root_map = FindRootMap();
+
+  // Check the state of the root map.
+  if (!EquivalentToForTransition(root_map)) return NULL;
+  int verbatim = root_map->NumberOfOwnDescriptors();
+
+  Map* updated = root_map->FindUpdatedMap(
+      verbatim, descriptors, old_descriptors);
+  if (updated == NULL) return NULL;
+
+  DescriptorArray* updated_descriptors = updated->instance_descriptors();
+  int valid = updated->NumberOfOwnDescriptors();
+  if (!updated_descriptors->IsMoreGeneralThan(
+          verbatim, valid, descriptors, old_descriptors)) {
+    return NULL;
+  }
+
+  return updated;
+}


 MaybeObject* JSObject::SetPropertyWithInterceptor(
=======================================
--- /branches/bleeding_edge/src/objects.h       Thu May 16 03:59:17 2013
+++ /branches/bleeding_edge/src/objects.h       Tue May 21 04:20:24 2013
@@ -5377,9 +5377,8 @@
   // Returns a non-deprecated version of the input. If the input was not
// deprecated, it is directly returned. Otherwise, the non-deprecated version // is found by re-transitioning from the root of the transition tree using the - // descriptor array of the map. New maps (and transitions) may be created if
-  // no new (more general) version exists.
-  static inline Handle<Map> CurrentMapForDeprecated(Handle<Map> map);
+  // descriptor array of the map. Returns NULL if no updated map is found.
+  Map* CurrentMapForDeprecated();

   MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
   MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
=======================================
--- /branches/bleeding_edge/src/type-info.cc    Thu May 16 03:59:17 2013
+++ /branches/bleeding_edge/src/type-info.cc    Tue May 21 04:20:24 2013
@@ -105,6 +105,8 @@
         Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL;
     if (!preliminary_checks) return false;
     Map* map = code->FindFirstMap();
+    if (map == NULL) return false;
+    map = map->CurrentMapForDeprecated();
     return map != NULL && !CanRetainOtherContext(map, *native_context_);
   }
   return false;
@@ -136,6 +138,8 @@
         Code::ExtractTypeFromFlags(code->flags()) == Code::NORMAL;
     if (!preliminary_checks) return false;
     Map* map = code->FindFirstMap();
+    if (map == NULL) return false;
+    map = map->CurrentMapForDeprecated();
     return map != NULL && !CanRetainOtherContext(map, *native_context_);
   }
   return false;
@@ -192,14 +196,12 @@
   Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId());
   if (map_or_code->IsCode()) {
     Handle<Code> code = Handle<Code>::cast(map_or_code);
-    Handle<Map> first_map(code->FindFirstMap());
-    ASSERT(!first_map.is_null());
-    first_map = Map::CurrentMapForDeprecated(first_map);
-    return CanRetainOtherContext(*first_map, *native_context_)
+    Map* map = code->FindFirstMap()->CurrentMapForDeprecated();
+    return map == NULL || CanRetainOtherContext(map, *native_context_)
         ? Handle<Map>::null()
-        : first_map;
+        : Handle<Map>(map);
   }
-  return Map::CurrentMapForDeprecated(Handle<Map>::cast(map_or_code));
+  return Handle<Map>::cast(map_or_code);
 }


@@ -209,14 +211,12 @@
   Handle<Object> map_or_code = GetInfo(ast_id);
   if (map_or_code->IsCode()) {
     Handle<Code> code = Handle<Code>::cast(map_or_code);
-    Handle<Map> first_map(code->FindFirstMap());
-    ASSERT(!first_map.is_null());
-    first_map = Map::CurrentMapForDeprecated(first_map);
-    return CanRetainOtherContext(*first_map, *native_context_)
+    Map* map = code->FindFirstMap()->CurrentMapForDeprecated();
+    return map == NULL || CanRetainOtherContext(map, *native_context_)
         ? Handle<Map>::null()
-        : first_map;
+        : Handle<Map>(map);
   }
-  return Map::CurrentMapForDeprecated(Handle<Map>::cast(map_or_code));
+  return Handle<Map>::cast(map_or_code);
 }


@@ -224,10 +224,15 @@
     TypeFeedbackId id) {
   Handle<Object> maybe_code = GetInfo(id);
   if (maybe_code->IsCode()) {
-    Map* first_map = Handle<Code>::cast(maybe_code)->FindFirstMap();
-    if (first_map != NULL) {
-      return Map::CurrentMapForDeprecated(Handle<Map>(first_map));
-    }
+    Map* map = Handle<Code>::cast(maybe_code)->FindFirstMap();
+    if (map == NULL) return Handle<Map>();
+    map = map->CurrentMapForDeprecated();
+    return map == NULL || CanRetainOtherContext(map, *native_context_)
+           ? Handle<Map>()
+           : Handle<Map>(map);
+  } else if (maybe_code->IsMap()) {
+    ASSERT(!Handle<Map>::cast(maybe_code)->is_deprecated());
+    return Handle<Map>::cast(maybe_code);
   }
   return Handle<Map>();
 }
@@ -351,8 +356,7 @@
 Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap(
     ObjectLiteral::Property* prop) {
   ASSERT(ObjectLiteralStoreIsMonomorphic(prop));
-  return Map::CurrentMapForDeprecated(
-      Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId())));
+  return Handle<Map>::cast(GetInfo(prop->key()->LiteralFeedbackId()));
 }


@@ -431,12 +435,10 @@
   if (state != CompareIC::KNOWN_OBJECT) {
     return Handle<Map>::null();
   }
-  Handle<Map> first_map(code->FindFirstMap());
-  ASSERT(!first_map.is_null());
-  first_map = Map::CurrentMapForDeprecated(first_map);
-  return CanRetainOtherContext(*first_map, *native_context_)
+  Map* map = code->FindFirstMap()->CurrentMapForDeprecated();
+  return map == NULL || CanRetainOtherContext(map, *native_context_)
       ? Handle<Map>::null()
-      : first_map;
+      : Handle<Map>(map);
 }


@@ -723,7 +725,8 @@
               SetInfo(ast_id, static_cast<Object*>(target));
             } else if (!CanRetainOtherContext(Map::cast(map),
                                               *native_context_)) {
-              SetInfo(ast_id, map);
+              Map* feedback = Map::cast(map)->CurrentMapForDeprecated();
+              if (feedback != NULL) SetInfo(ast_id, feedback);
             }
           }
         } else {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to