Reviewers: yurys, alph, Sven Panne,

Message:
PTAL

Description:
CpuProfiler: do not calculate positions if it is not necessary (first part).

BUG=452067
LOG=n

Please review this at https://codereview.chromium.org/961283002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+21, -23 lines):
  M src/hydrogen.h
  M src/hydrogen.cc
  M src/hydrogen-instructions.h


Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index a9eb57d22d91f5aac14620d4ccbd6e694a8ec26f..54e66e1221a489e2be5e53497b0d1d7364f64e9e 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -1191,6 +1191,13 @@ class HControlInstruction : public HInstruction {
     SetSuccessorAt(1, swap);
   }

+  void SetOperandPositions(Zone* zone, SourcePosition left_pos,
+                           SourcePosition right_pos) {
+    set_operand_position(zone, 0, left_pos);
+    set_operand_position(zone, 1, right_pos);
+  }
+
+
   DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction)
 };

@@ -4266,12 +4273,6 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {

   std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE;  // NOLINT

-  void SetOperandPositions(Zone* zone, SourcePosition left_pos,
-                           SourcePosition right_pos) {
-    set_operand_position(zone, 0, left_pos);
-    set_operand_position(zone, 1, right_pos);
-  }
-
   DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)

  private:
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index e37a1cee9a48534007617df4bb11b93b01f6bd2e..6e103684c8c4b71f5f75988563a4564b8223d36a 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4818,10 +4818,13 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
     HControlInstruction* compare = BuildCompareInstruction(
         Token::EQ_STRICT, tag_value, label_value, tag_type, label_type,
         combined_type,
-        ScriptPositionToSourcePosition(stmt->tag()->position()),
-        ScriptPositionToSourcePosition(clause->label()->position()),
         PUSH_BEFORE_SIMULATE, clause->id());

+    if (FLAG_hydrogen_track_positions) {
+      compare->SetOperandPositions(
+          zone(), ScriptPositionToSourcePosition(stmt->tag()->position()),
+          ScriptPositionToSourcePosition(clause->label()->position()));
+    }
     HBasicBlock* next_test_block = graph()->CreateBasicBlock();
     HBasicBlock* body_block = graph()->CreateBasicBlock();
     body_blocks.Add(body_block, zone());
@@ -10923,19 +10926,21 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
                               : PUSH_BEFORE_SIMULATE;
   HControlInstruction* compare = BuildCompareInstruction(
       op, left, right, left_type, right_type, combined_type,
-      ScriptPositionToSourcePosition(expr->left()->position()),
-      ScriptPositionToSourcePosition(expr->right()->position()),
       push_behavior, expr->id());
   if (compare == NULL) return;  // Bailed out.
+  if (FLAG_hydrogen_track_positions) {
+    compare->SetOperandPositions(
+        zone(), ScriptPositionToSourcePosition(expr->left()->position()),
+        ScriptPositionToSourcePosition(expr->right()->position()));
+  }
   return ast_context()->ReturnControl(compare, expr->id());
 }


 HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
     Token::Value op, HValue* left, HValue* right, Type* left_type,
-    Type* right_type, Type* combined_type, SourcePosition left_position,
- SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result,
-    BailoutId bailout_id) {
+    Type* right_type, Type* combined_type,
+    PushBeforeSimulateBehavior push_sim_result, BailoutId bailout_id) {
   // Cases handled below depend on collected type feedback. They should
   // soft deoptimize when there is no type feedback.
   if (!combined_type->IsInhabited()) {
@@ -10970,10 +10975,6 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
         AddCheckMap(operand_to_check, map);
         HCompareObjectEqAndBranch* result =
             New<HCompareObjectEqAndBranch>(left, right);
-        if (FLAG_hydrogen_track_positions) {
-          result->set_operand_position(zone(), 0, left_position);
-          result->set_operand_position(zone(), 1, right_position);
-        }
         return result;
       } else {
         BuildCheckHeapObject(operand_to_check);
@@ -11036,9 +11037,6 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
       HCompareNumericAndBranch* result =
           New<HCompareNumericAndBranch>(left, right, op);
       result->set_observed_input_representation(left_rep, right_rep);
-      if (FLAG_hydrogen_track_positions) {
-        result->SetOperandPositions(zone(), left_position, right_position);
-      }
       return result;
     }
   }
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index d5e3abe954fb4a572a9db6bc5a076d280a9c6e31..05270f565a1e6db27afb28ecada3f187c8cced67 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -2641,9 +2641,8 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {

   HControlInstruction* BuildCompareInstruction(
       Token::Value op, HValue* left, HValue* right, Type* left_type,
-      Type* right_type, Type* combined_type, SourcePosition left_position,
- SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result,
-      BailoutId bailout_id);
+      Type* right_type, Type* combined_type,
+      PushBeforeSimulateBehavior push_sim_result, BailoutId bailout_id);

   HInstruction* BuildStringCharCodeAt(HValue* string,
                                       HValue* index);


--
--
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/d/optout.

Reply via email to