Revision: 15843
Author:   [email protected]
Date:     Wed Jul 24 01:05:49 2013
Log:      Avoid adding HWrapReceiver during graph building.

This adds an early check to the graph builder which prevents adding an
HWrapReceiver instruction if the receiver type is already known at graph
building time. Also HAllocate no longer unnecessarily postpones setting
it's type until type inference but sets it right away. These changes are
in preparation for escape analysis.

[email protected]

Review URL: https://codereview.chromium.org/19493005
http://code.google.com/p/v8/source/detail?r=15843

Modified:
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/hydrogen-instructions.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h

=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Jul 23 12:27:00 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Jul 24 01:05:49 2013
@@ -3242,11 +3242,6 @@
 HType HStringCharFromCode::CalculateInferredType() {
   return HType::String();
 }
-
-
-HType HAllocate::CalculateInferredType() {
-  return type_;
-}


 void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Tue Jul 23 06:35:10 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Wed Jul 24 01:05:49 2013
@@ -4919,10 +4919,10 @@
   };

   HAllocate(HValue* context, HValue* size, HType type, Flags flags)
-      : type_(type),
-        flags_(flags) {
+      : flags_(flags) {
     SetOperandAt(0, context);
     SetOperandAt(1, size);
+    set_type(type);
     set_representation(Representation::Tagged());
     SetFlag(kTrackSideEffectDominators);
     SetGVNFlag(kChangesNewSpacePromotion);
@@ -4947,7 +4947,6 @@

   HValue* context() { return OperandAt(0); }
   HValue* size() { return OperandAt(1); }
-  HType type() { return type_; }

   virtual Representation RequiredInputRepresentation(int index) {
     if (index == 0) {
@@ -4964,8 +4963,6 @@
   void set_known_initial_map(Handle<Map> known_initial_map) {
     known_initial_map_ = known_initial_map;
   }
-
-  virtual HType CalculateInferredType();

   bool CanAllocateInNewSpace() const {
     return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0;
@@ -5012,7 +5009,6 @@
   DECLARE_CONCRETE_INSTRUCTION(Allocate)

  private:
-  HType type_;
   Flags flags_;
   Handle<Map> known_initial_map_;
 };
@@ -5021,10 +5017,10 @@
 class HInnerAllocatedObject: public HTemplateInstruction<1> {
  public:
HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
-      : offset_(offset),
-        type_(type) {
+      : offset_(offset) {
     ASSERT(value->IsAllocate());
     SetOperandAt(0, value);
+    set_type(type);
     set_representation(Representation::Tagged());
   }

@@ -5034,8 +5030,6 @@
   virtual Representation RequiredInputRepresentation(int index) {
     return Representation::Tagged();
   }
-
-  virtual HType CalculateInferredType() { return type_; }

   virtual void PrintDataTo(StringStream* stream);

@@ -5043,7 +5037,6 @@

  private:
   int offset_;
-  HType type_;
 };


=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Wed Jul 24 01:00:52 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Wed Jul 24 01:05:49 2013
@@ -1040,12 +1040,17 @@
 }


-HValue* HGraphBuilder::BuildCheckMap(HValue* obj,
-                                     Handle<Map> map) {
+HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) {
   HCheckMaps* check = HCheckMaps::New(obj, map, zone(), top_info());
   AddInstruction(check);
   return check;
 }
+
+
+HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) {
+  if (object->type().IsJSObject()) return object;
+  return Add<HWrapReceiver>(object, function);
+}


 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
@@ -6886,7 +6891,7 @@
   if (function_state()->outer() == NULL) {
     HInstruction* elements = Add<HArgumentsElements>(false);
     HInstruction* length = Add<HArgumentsLength>(elements);
-    HValue* wrapped_receiver = Add<HWrapReceiver>(receiver, function);
+    HValue* wrapped_receiver = BuildWrapReceiver(receiver, function);
     HInstruction* result =
         new(zone()) HApplyArguments(function,
                                     wrapped_receiver,
@@ -6903,7 +6908,7 @@
     HArgumentsObject* args = function_state()->entry()->arguments_object();
     const ZoneList<HValue*>* arguments_values = args->arguments_values();
     int arguments_count = arguments_values->length();
-    PushAndAdd(new(zone()) HWrapReceiver(receiver, function));
+    Push(BuildWrapReceiver(receiver, function));
     for (int i = 1; i < arguments_count; i++) {
       Push(arguments_values->at(i));
     }
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Tue Jul 23 06:35:10 2013
+++ /branches/bleeding_edge/src/hydrogen.h      Wed Jul 24 01:05:49 2013
@@ -1038,6 +1038,7 @@

   HValue* BuildCheckHeapObject(HValue* object);
   HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
+  HValue* BuildWrapReceiver(HValue* object, HValue* function);

   // Building common constructs
   HValue* BuildCheckForCapacityGrow(HValue* object,

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