Revision: 15360
Author:   [email protected]
Date:     Thu Jun 27 07:36:14 2013
Log: Add templatized convienience functions for adding hydrogen instructions

[email protected]

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

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

=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Thu Jun 13 10:38:10 2013 +++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Thu Jun 27 07:36:14 2013
@@ -599,7 +599,7 @@
HConstant* initial_capacity_node = new(zone()) HConstant(initial_capacity);
   AddInstruction(initial_capacity_node);

-  HBoundsCheck* checked_arg = AddBoundsCheck(argument, max_alloc_length);
+ HBoundsCheck* checked_arg = Add<HBoundsCheck>(argument, max_alloc_length);
   IfBuilder if_builder(this);
   if_builder.IfCompare(checked_arg, constant_zero, Token::EQ);
   if_builder.Then();
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Thu Jun 27 07:22:07 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Thu Jun 27 07:36:14 2013
@@ -987,13 +987,6 @@
   ASSERT(no_side_effects_scope_count_ == 0);
   current_block()->AddSimulate(id, removable);
 }
-
-
-HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, HValue* length) {
-  HBoundsCheck* result = new(graph()->zone()) HBoundsCheck(index, length);
-  AddInstruction(result);
-  return result;
-}


 HReturn* HGraphBuilder::AddReturn(HValue* value) {
@@ -1175,7 +1168,7 @@

   length_checker.Else();

-  AddBoundsCheck(key, length);
+  Add<HBoundsCheck>(key, length);
   environment()->Push(elements);

   length_checker.End();
@@ -1280,7 +1273,7 @@
       return result;
     } else {
       ASSERT(store_mode == STANDARD_STORE);
-      checked_key = AddBoundsCheck(key, length);
+      checked_key = Add<HBoundsCheck>(key, length);
       HLoadExternalArrayPointer* external_elements =
           new(zone) HLoadExternalArrayPointer(elements);
       AddInstruction(external_elements);
@@ -1308,7 +1301,7 @@
                                          length, key, is_js_array);
     checked_key = key;
   } else {
-    checked_key = AddBoundsCheck(key, length);
+    checked_key = Add<HBoundsCheck>(key, length);

     if (is_store && (fast_elements || fast_smi_only_elements)) {
       if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) {
@@ -7274,7 +7267,7 @@
         && todo_external_array) {
       HInstruction* length =
           AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
-      checked_key = AddBoundsCheck(key, length);
+      checked_key = Add<HBoundsCheck>(key, length);
       external_elements = new(zone()) HLoadExternalArrayPointer(elements);
       AddInstruction(external_elements);
     }
@@ -7317,7 +7310,7 @@
             typecheck, Representation::Smi());
         length->set_type(HType::Smi());

-        checked_key = AddBoundsCheck(key, length);
+        checked_key = Add<HBoundsCheck>(key, length);
         access = AddInstruction(BuildFastElementAccess(
             elements, checked_key, val, elements_kind_branch,
             elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE));
@@ -7335,7 +7328,7 @@

         set_current_block(if_fastobject);
length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
-        checked_key = AddBoundsCheck(key, length);
+        checked_key = Add<HBoundsCheck>(key, length);
         access = AddInstruction(BuildFastElementAccess(
             elements, checked_key, val, elements_kind_branch,
             elements_kind, is_store, NEVER_RETURN_HOLE, STANDARD_STORE));
@@ -7487,7 +7480,7 @@
           new(zone()) HArgumentsElements(false));
       HInstruction* length = AddInstruction(
           new(zone()) HArgumentsLength(elements));
-      HInstruction* checked_key = AddBoundsCheck(key, length);
+      HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length, checked_key);
     } else {
       EnsureArgumentsArePushedForAccess();
@@ -7498,7 +7491,7 @@
           arguments_environment()->parameter_count() - 1;
       HInstruction* length = AddInstruction(new(zone()) HConstant(
           argument_count));
-      HInstruction* checked_key = AddBoundsCheck(key, length);
+      HInstruction* checked_key = Add<HBoundsCheck>(key, length);
result = new(zone()) HAccessArgumentsAt(elements, length, checked_key);
     }
   }
@@ -9323,7 +9316,7 @@
   AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
   HInstruction* length = HStringLength::New(zone(), string);
   AddInstruction(length);
-  HInstruction* checked_index = AddBoundsCheck(index, length);
+  HInstruction* checked_index = Add<HBoundsCheck>(index, length);
   return new(zone()) HStringCharCodeAt(context, string, checked_index);
 }

@@ -10537,7 +10530,7 @@
   HInstruction* elements = AddInstruction(
       new(zone()) HArgumentsElements(false));
HInstruction* length = AddInstruction(new(zone()) HArgumentsLength(elements));
-  HInstruction* checked_index = AddBoundsCheck(index, length);
+  HInstruction* checked_index = Add<HBoundsCheck>(index, length);
   HAccessArgumentsAt* result =
       new(zone()) HAccessArgumentsAt(elements, length, checked_index);
   return ast_context()->ReturnInstruction(result, call->id());
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Thu Jun 27 06:13:18 2013
+++ /branches/bleeding_edge/src/hydrogen.h      Thu Jun 27 07:36:14 2013
@@ -994,9 +994,27 @@

   // Adding instructions.
   HInstruction* AddInstruction(HInstruction* instr);
+
+  template<class I>
+  I* Add() { return static_cast<I*>(AddInstruction(new(zone()) I())); }
+
+  template<class I, class P1>
+  I* Add(P1 p1) {
+    return static_cast<I*>(AddInstruction(new(zone()) I(p1)));
+  }
+
+  template<class I, class P1, class P2>
+  I* Add(P1 p1, P2 p2) {
+      return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2)));
+  }
+
+  template<class I, class P1, class P2, class P3>
+  I* Add(P1 p1, P2 p2, P3 p3) {
+    return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3)));
+  }
+
   void AddSimulate(BailoutId id,
                    RemovableSimulate removable = FIXED_SIMULATE);
-  HBoundsCheck* AddBoundsCheck(HValue* index, HValue* length);

   HReturn* AddReturn(HValue* value);

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