Revision: 15806
Author:   [email protected]
Date:     Mon Jul 22 07:15:58 2013
Log: Avoid repeated rewrites of global store to constant IC due to store of same value.

[email protected]

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

Modified:
 /branches/bleeding_edge/src/code-stubs-hydrogen.cc
 /branches/bleeding_edge/src/stub-cache.cc

=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Fri Jul 19 06:30:49 2013 +++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Mon Jul 22 07:15:58 2013
@@ -850,23 +850,25 @@
   HParameter* receiver = GetParameter(0);
   HParameter* value = GetParameter(2);

+ // Check that the map of the global has not changed: use a placeholder map
+  // that will be replaced later with the global object's map.
+  Handle<Map> placeholder_map = isolate()->factory()->meta_map();
+  AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone()));
+
+ HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged());
+  HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
+  HValue* cell_contents = Add<HLoadNamedField>(cell, access);
+
   if (stub->is_constant()) {
-    // Assume every store to a constant value changes it.
-    current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
-    set_current_block(NULL);
+    IfBuilder builder(this);
+    builder.If<HCompareObjectEqAndBranch>(cell_contents, value);
+    builder.Then();
+    builder.ElseDeopt();
+    builder.End();
   } else {
- HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged());
-
- // Check that the map of the global has not changed: use a placeholder map
-    // that will be replaced later with the global object's map.
-    Handle<Map> placeholder_map = isolate()->factory()->meta_map();
-    AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone()));
-
// Load the payload of the global parameter cell. A hole indicates that the
     // property has been deleted and that the store must be handled by the
     // runtime.
-    HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
-    HValue* cell_contents = Add<HLoadNamedField>(cell, access);
     IfBuilder builder(this);
     HValue* hole_value = Add<HConstant>(hole, Representation::Tagged());
     builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value);
@@ -876,6 +878,7 @@
     Add<HStoreNamedField>(cell, access, value);
     builder.End();
   }
+
   return value;
 }

=======================================
--- /branches/bleeding_edge/src/stub-cache.cc   Wed Jul 17 04:37:20 2013
+++ /branches/bleeding_edge/src/stub-cache.cc   Mon Jul 22 07:15:58 2013
@@ -563,16 +563,15 @@
       Code::STORE_IC, Code::NORMAL, stub.GetExtraICState());
   if (!code.is_null()) return code;

-  if (is_constant) return stub.GetCode(isolate_);
-
// Replace the placeholder cell and global object map with the actual global
   // cell and receiver map.
-  Handle<Map> cell_map(isolate_->heap()->global_property_cell_map());
   Handle<Map> meta_map(isolate_->heap()->meta_map());
   Handle<Object> receiver_map(receiver->map(), isolate_);
   code = stub.GetCodeCopyFromTemplate(isolate_);
   code->ReplaceNthObject(1, *meta_map, *receiver_map);
+  Handle<Map> cell_map(isolate_->heap()->global_property_cell_map());
   code->ReplaceNthObject(1, *cell_map, *cell);
+
   JSObject::UpdateMapCodeCache(receiver, name, code);

   return code;

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