Reviewers: Sven Panne,

Message:
PTAL

Description:
Don't create new maps in CurrentMapForDeprecated.

Please review this at https://chromiumcodereview.appspot.com/15358005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/ast.h
  M src/objects-inl.h
  M src/objects.h
  M src/objects.cc
  M src/type-info.cc


Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index d697da7bda41a7cda38a6f510044edbd4eddc8ec..236173b17ac6767cd54aa9ce93e72d0969f72857 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -279,6 +279,7 @@ class SmallMapList {

   void AddMapIfMissing(Handle<Map> map, Zone* zone) {
     map = Map::CurrentMapForDeprecated(map);
+    if (map.is_null()) return;
     for (int i = 0; i < length(); ++i) {
       if (at(i).is_identical_to(map)) return;
     }
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 8c6e9253e11a12c21c86487fce8496e42239dc19..c48876bfb0e0f1e226a03f0c6965a00c72e8c552 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -3624,12 +3624,6 @@ bool Map::CanBeDeprecated() {
 }


-Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
-  if (!map->is_deprecated()) return map;
-  return GeneralizeRepresentation(map, 0, Representation::Smi());
-}
-
-
 void Map::NotifyLeafMapLayoutChange() {
   dependent_code()->DeoptimizeDependentCodeGroup(
       GetIsolate(),
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 16d38a6c9a142471f81968bb55c9fc90b4c05ddf..074114ecdf8151838845b9b28206b4d680feec43 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2537,6 +2537,7 @@ MaybeObject* Map::GeneralizeRepresentation(int modify_index,
   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 @@ MaybeObject* Map::GeneralizeRepresentation(int modify_index,
       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();
@@ -2624,6 +2624,34 @@ MaybeObject* Map::GeneralizeRepresentation(int modify_index,
 }


+Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> old_map) {
+  AssertNoAllocation no_allocation;
+  if (!old_map->is_deprecated()) return old_map;
+
+  DescriptorArray* old_descriptors = old_map->instance_descriptors();
+
+  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 Handle<Map>::null();
+  int verbatim = root_map->NumberOfOwnDescriptors();
+
+  Map* updated = root_map->FindUpdatedMap(
+      verbatim, descriptors, old_descriptors);
+  if (updated == NULL) return Handle<Map>::null();
+
+  DescriptorArray* updated_descriptors = updated->instance_descriptors();
+  int valid = updated->NumberOfOwnDescriptors();
+  if (!updated_descriptors->IsMoreGeneralThan(
+          verbatim, valid, descriptors, old_descriptors)) {
+    return Handle<Map>::null();
+  }
+
+  return Handle<Map>(updated);
+}
+
+
 MaybeObject* JSObject::SetPropertyWithInterceptor(
     Name* name,
     Object* value,
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index d466f6571515d3eeb8aaf5b082f7591c36cfd89c..d18b36d8f9d18f45c0b5536e11132c900a9147b1 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -5377,9 +5377,9 @@ class Map: public HeapObject {
   // 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 Handle<Map>::null() if no updated map
+  // is found.
+  static Handle<Map> CurrentMapForDeprecated(Handle<Map> map);

   MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
   MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
Index: src/type-info.cc
diff --git a/src/type-info.cc b/src/type-info.cc
index 21dcf74cabd944c1082b3c3c291c10b638ae3201..4e6b05e7095695dd4490e3c5d9692bfbc5b07320 100644
--- a/src/type-info.cc
+++ b/src/type-info.cc
@@ -195,6 +195,7 @@ Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) {
     Handle<Map> first_map(code->FindFirstMap());
     ASSERT(!first_map.is_null());
     first_map = Map::CurrentMapForDeprecated(first_map);
+    if (first_map.is_null()) return first_map;
     return CanRetainOtherContext(*first_map, *native_context_)
         ? Handle<Map>::null()
         : first_map;
@@ -212,6 +213,7 @@ Handle<Map> TypeFeedbackOracle::StoreMonomorphicReceiverType(
     Handle<Map> first_map(code->FindFirstMap());
     ASSERT(!first_map.is_null());
     first_map = Map::CurrentMapForDeprecated(first_map);
+    if (first_map.is_null()) return first_map;
     return CanRetainOtherContext(*first_map, *native_context_)
         ? Handle<Map>::null()
         : first_map;
@@ -434,6 +436,7 @@ Handle<Map> TypeFeedbackOracle::GetCompareMap(CompareOperation* expr) {
   Handle<Map> first_map(code->FindFirstMap());
   ASSERT(!first_map.is_null());
   first_map = Map::CurrentMapForDeprecated(first_map);
+  if (first_map.is_null()) return first_map;
   return CanRetainOtherContext(*first_map, *native_context_)
       ? Handle<Map>::null()
       : first_map;


--
--
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