Revision: 14745
Author:   [email protected]
Date:     Wed May 22 03:46:33 2013
Log:      Keep representations while overwriting transitions.

BUG=chromium:241477
[email protected]

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

Modified:
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/test/mjsunit/track-fields.js

=======================================
--- /branches/bleeding_edge/src/objects.cc      Tue May 21 10:21:27 2013
+++ /branches/bleeding_edge/src/objects.cc      Wed May 22 03:46:33 2013
@@ -2056,8 +2056,8 @@
   Map* old_target = old_map->GetTransition(transition_index);
   Object* result;

-  MaybeObject* maybe_result =
-      ConvertDescriptorToField(name, new_value, attributes);
+  MaybeObject* maybe_result = ConvertDescriptorToField(
+      name, new_value, attributes, OMIT_TRANSITION_KEEP_REPRESENTATIONS);
   if (!maybe_result->To(&result)) return maybe_result;

   if (!HasFastProperties()) return result;
@@ -2098,7 +2098,8 @@

 MaybeObject* JSObject::ConvertDescriptorToField(Name* name,
                                                 Object* new_value,
- PropertyAttributes attributes) { + PropertyAttributes attributes,
+                                                TransitionFlag flag) {
   if (map()->unused_property_fields() == 0 &&
TooManyFastProperties(properties()->length(), MAY_BE_STORE_FROM_KEYED)) {
     Object* obj;
@@ -2114,8 +2115,7 @@

   // Make a new map for the object.
   Map* new_map;
-  MaybeObject* maybe_new_map = map()->CopyInsertDescriptor(&new_field,
- OMIT_TRANSITION); + MaybeObject* maybe_new_map = map()->CopyInsertDescriptor(&new_field, flag);
   if (!maybe_new_map->To(&new_map)) return maybe_new_map;

   // Make new properties array if necessary.
@@ -6389,7 +6389,7 @@

     set_transitions(transitions);
     result->SetBackPointer(this);
-  } else {
+  } else if (flag != OMIT_TRANSITION_KEEP_REPRESENTATIONS) {
     descriptors->InitializeRepresentations(Representation::Tagged());
   }

@@ -6397,6 +6397,8 @@
 }


+// Since this method is used to rewrite an existing transition tree, it can
+// always insert transitions without checking.
 MaybeObject* Map::CopyInstallDescriptors(int new_descriptor,
                                          DescriptorArray* descriptors) {
   ASSERT(descriptors->IsSortedNoDuplicates());
@@ -6419,18 +6421,14 @@
   result->set_unused_property_fields(unused_property_fields);
   result->set_owns_descriptors(false);

-  if (CanHaveMoreTransitions()) {
-    Name* name = descriptors->GetKey(new_descriptor);
-    TransitionArray* transitions;
-    MaybeObject* maybe_transitions =
-        AddTransition(name, result, SIMPLE_TRANSITION);
-    if (!maybe_transitions->To(&transitions)) return maybe_transitions;
+  Name* name = descriptors->GetKey(new_descriptor);
+  TransitionArray* transitions;
+  MaybeObject* maybe_transitions =
+      AddTransition(name, result, SIMPLE_TRANSITION);
+  if (!maybe_transitions->To(&transitions)) return maybe_transitions;

-    set_transitions(transitions);
-    result->SetBackPointer(this);
-  } else {
-    descriptors->InitializeRepresentations(Representation::Tagged());
-  }
+  set_transitions(transitions);
+  result->SetBackPointer(this);

   return result;
 }
=======================================
--- /branches/bleeding_edge/src/objects.h       Tue May 21 04:20:24 2013
+++ /branches/bleeding_edge/src/objects.h       Wed May 22 03:46:33 2013
@@ -254,6 +254,7 @@
 // Indicates whether transitions can be added to a source map or not.
 enum TransitionFlag {
   INSERT_TRANSITION,
+  OMIT_TRANSITION_KEEP_REPRESENTATIONS,
   OMIT_TRANSITION
 };

@@ -2200,7 +2201,8 @@
   MUST_USE_RESULT MaybeObject* ConvertDescriptorToField(
       Name* name,
       Object* new_value,
-      PropertyAttributes attributes);
+      PropertyAttributes attributes,
+      TransitionFlag flag = OMIT_TRANSITION);

   MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map);
   MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation(
=======================================
--- /branches/bleeding_edge/test/mjsunit/track-fields.js Thu May 16 20:16:20 2013 +++ /branches/bleeding_edge/test/mjsunit/track-fields.js Wed May 22 03:46:33 2013
@@ -306,3 +306,22 @@
 test_fic(ftest4);
 assertTrue(%HaveSameMap(ftest1, ftest3));
 assertTrue(%HaveSameMap(ftest3, ftest4));
+
+// Test representations and transition conversions.
+function read_first_double(o) {
+  return o.first_double;
+}
+var df1 = {};
+df1.first_double=1.6;
+read_first_double(df1);
+read_first_double(df1);
+function some_function1() { return 10; }
+var df2 = {};
+df2.first_double = 1.7;
+df2.second_function = some_function1;
+function some_function2() { return 20; }
+var df3 = {};
+df3.first_double = 1.7;
+df3.second_function = some_function2;
+df1.first_double = 10;
+read_first_double(df1);

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