Revision: 19751
Author: [email protected]
Date: Mon Mar 10 11:49:29 2014 UTC
Log: Merge the "Compute Minus Zero Checks" phase into the range
analysis.
It is not safe to access the range for an SSA value
after range analysis.
BUG=v8:3204
LOG=y
[email protected]
Review URL: https://codereview.chromium.org/192673002
http://code.google.com/p/v8/source/detail?r=19751
Deleted:
/branches/bleeding_edge/src/hydrogen-minus-zero.cc
/branches/bleeding_edge/src/hydrogen-minus-zero.h
Modified:
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/hydrogen-range-analysis.cc
/branches/bleeding_edge/src/hydrogen-range-analysis.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/tools/gyp/v8.gyp
=======================================
--- /branches/bleeding_edge/src/hydrogen-minus-zero.cc Mon Mar 10 05:52:03
2014 UTC
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "hydrogen-minus-zero.h"
-
-namespace v8 {
-namespace internal {
-
-void HComputeMinusZeroChecksPhase::Run() {
- const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
- for (int i = 0; i < blocks->length(); ++i) {
- for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance())
{
- HInstruction* current = it.Current();
- if (current->IsChange()) {
- HChange* change = HChange::cast(current);
- // Propagate flags for negative zero checks upwards from
conversions
- // int32-to-tagged and int32-to-double.
- Representation from = change->value()->representation();
- ASSERT(from.Equals(change->from()));
- if (from.IsSmiOrInteger32()) {
- ASSERT(change->to().IsTagged() ||
- change->to().IsDouble() ||
- change->to().IsSmiOrInteger32());
- PropagateMinusZeroChecks(change->value());
- }
- } else if (current->IsCompareMinusZeroAndBranch()) {
- HCompareMinusZeroAndBranch* check =
- HCompareMinusZeroAndBranch::cast(current);
- if (check->value()->representation().IsSmiOrInteger32()) {
- PropagateMinusZeroChecks(check->value());
- }
- }
- }
- }
-}
-
-
-void HComputeMinusZeroChecksPhase::PropagateMinusZeroChecks(HValue* value)
{
- ASSERT(worklist_.is_empty());
- ASSERT(in_worklist_.IsEmpty());
-
- AddToWorklist(value);
- while (!worklist_.is_empty()) {
- value = worklist_.RemoveLast();
-
- if (value->IsPhi()) {
- // For phis, we must propagate the check to all of its inputs.
- HPhi* phi = HPhi::cast(value);
- for (int i = 0; i < phi->OperandCount(); ++i) {
- AddToWorklist(phi->OperandAt(i));
- }
- } else if (value->IsUnaryMathOperation()) {
- HUnaryMathOperation* instr = HUnaryMathOperation::cast(value);
- if (instr->representation().IsSmiOrInteger32() &&
- !instr->value()->representation().Equals(instr->representation()))
{
- if (instr->value()->range() == NULL ||
- instr->value()->range()->CanBeMinusZero()) {
- instr->SetFlag(HValue::kBailoutOnMinusZero);
- }
- }
- if (instr->RequiredInputRepresentation(0).IsSmiOrInteger32() &&
- instr->representation().Equals(
- instr->RequiredInputRepresentation(0))) {
- AddToWorklist(instr->value());
- }
- } else if (value->IsChange()) {
- HChange* instr = HChange::cast(value);
- if (!instr->from().IsSmiOrInteger32() &&
- !instr->CanTruncateToInt32() &&
- (instr->value()->range() == NULL ||
- instr->value()->range()->CanBeMinusZero())) {
- instr->SetFlag(HValue::kBailoutOnMinusZero);
- }
- } else if (value->IsForceRepresentation()) {
- HForceRepresentation* instr = HForceRepresentation::cast(value);
- AddToWorklist(instr->value());
- } else if (value->IsMod()) {
- HMod* instr = HMod::cast(value);
- if (instr->range() == NULL || instr->range()->CanBeMinusZero()) {
- instr->SetFlag(HValue::kBailoutOnMinusZero);
- AddToWorklist(instr->left());
- }
- } else if (value->IsDiv() || value->IsMul()) {
- HBinaryOperation* instr = HBinaryOperation::cast(value);
- if (instr->range() == NULL || instr->range()->CanBeMinusZero()) {
- instr->SetFlag(HValue::kBailoutOnMinusZero);
- }
- AddToWorklist(instr->right());
- AddToWorklist(instr->left());
- } else if (value->IsMathFloorOfDiv()) {
- HMathFloorOfDiv* instr = HMathFloorOfDiv::cast(value);
- instr->SetFlag(HValue::kBailoutOnMinusZero);
- } else if (value->IsAdd() || value->IsSub()) {
- HBinaryOperation* instr = HBinaryOperation::cast(value);
- if (instr->range() == NULL || instr->range()->CanBeMinusZero()) {
- // Propagate to the left argument. If the left argument cannot be
-0,
- // then the result of the add/sub operation cannot be either.
- AddToWorklist(instr->left());
- }
- } else if (value->IsMathMinMax()) {
- HMathMinMax* instr = HMathMinMax::cast(value);
- AddToWorklist(instr->right());
- AddToWorklist(instr->left());
- }
- }
-
- in_worklist_.Clear();
- ASSERT(in_worklist_.IsEmpty());
- ASSERT(worklist_.is_empty());
-}
-
-} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/hydrogen-minus-zero.h Mon Mar 10 05:52:03
2014 UTC
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef V8_HYDROGEN_MINUS_ZERO_H_
-#define V8_HYDROGEN_MINUS_ZERO_H_
-
-#include "hydrogen.h"
-
-namespace v8 {
-namespace internal {
-
-
-class HComputeMinusZeroChecksPhase : public HPhase {
- public:
- explicit HComputeMinusZeroChecksPhase(HGraph* graph)
- : HPhase("H_Compute minus zero checks", graph),
- in_worklist_(graph->GetMaximumValueID(), zone()),
- worklist_(32, zone()) {}
-
- void Run();
-
- private:
- void AddToWorklist(HValue* value) {
- if (value->CheckFlag(HValue::kBailoutOnMinusZero)) return;
- if (in_worklist_.Contains(value->id())) return;
- in_worklist_.Add(value->id());
- worklist_.Add(value, zone());
- }
- void PropagateMinusZeroChecks(HValue* value);
-
- BitVector in_worklist_;
- ZoneList<HValue*> worklist_;
-
- DISALLOW_COPY_AND_ASSIGN(HComputeMinusZeroChecksPhase);
-};
-
-
-} } // namespace v8::internal
-
-#endif // V8_HYDROGEN_MINUS_ZERO_H_
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Sat Mar 8 04:41:06 2014
UTC
+++ /branches/bleeding_edge/src/flag-definitions.h Mon Mar 10 11:49:29 2014
UTC
@@ -241,7 +241,6 @@
// Flags for Crankshaft.
DEFINE_bool(crankshaft, true, "use crankshaft")
DEFINE_string(hydrogen_filter, "*", "optimization filter")
-DEFINE_bool(use_range, true, "use hydrogen range analysis")
DEFINE_bool(use_gvn, true, "use hydrogen global value numbering")
DEFINE_int(gvn_iterations, 3, "maximum number of GVN fix-point iterations")
DEFINE_bool(use_canonicalizing, true, "use hydrogen instruction
canonicalizing")
=======================================
--- /branches/bleeding_edge/src/hydrogen-range-analysis.cc Mon Jul 15
09:53:46 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-range-analysis.cc Mon Mar 10
11:49:29 2014 UTC
@@ -78,7 +78,29 @@
// Go through all instructions of the current block.
for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
- InferRange(it.Current());
+ HValue* value = it.Current();
+ InferRange(value);
+
+ // Compute the bailout-on-minus-zero flag.
+ if (value->IsChange()) {
+ HChange* instr = HChange::cast(value);
+ // Propagate flags for negative zero checks upwards from
conversions
+ // int32-to-tagged and int32-to-double.
+ Representation from = instr->value()->representation();
+ ASSERT(from.Equals(instr->from()));
+ if (from.IsSmiOrInteger32()) {
+ ASSERT(instr->to().IsTagged() ||
+ instr->to().IsDouble() ||
+ instr->to().IsSmiOrInteger32());
+ PropagateMinusZeroChecks(instr->value());
+ }
+ } else if (value->IsCompareMinusZeroAndBranch()) {
+ HCompareMinusZeroAndBranch* instr =
+ HCompareMinusZeroAndBranch::cast(value);
+ if (instr->value()->representation().IsSmiOrInteger32()) {
+ PropagateMinusZeroChecks(instr->value());
+ }
+ }
}
// Continue analysis in all dominated blocks.
@@ -195,6 +217,81 @@
range->lower(),
range->upper());
}
+
+
+void HRangeAnalysisPhase::PropagateMinusZeroChecks(HValue* value) {
+ ASSERT(worklist_.is_empty());
+ ASSERT(in_worklist_.IsEmpty());
+
+ AddToWorklist(value);
+ while (!worklist_.is_empty()) {
+ value = worklist_.RemoveLast();
+
+ if (value->IsPhi()) {
+ // For phis, we must propagate the check to all of its inputs.
+ HPhi* phi = HPhi::cast(value);
+ for (int i = 0; i < phi->OperandCount(); ++i) {
+ AddToWorklist(phi->OperandAt(i));
+ }
+ } else if (value->IsUnaryMathOperation()) {
+ HUnaryMathOperation* instr = HUnaryMathOperation::cast(value);
+ if (instr->representation().IsSmiOrInteger32() &&
+ !instr->value()->representation().Equals(instr->representation()))
{
+ if (instr->value()->range() == NULL ||
+ instr->value()->range()->CanBeMinusZero()) {
+ instr->SetFlag(HValue::kBailoutOnMinusZero);
+ }
+ }
+ if (instr->RequiredInputRepresentation(0).IsSmiOrInteger32() &&
+ instr->representation().Equals(
+ instr->RequiredInputRepresentation(0))) {
+ AddToWorklist(instr->value());
+ }
+ } else if (value->IsChange()) {
+ HChange* instr = HChange::cast(value);
+ if (!instr->from().IsSmiOrInteger32() &&
+ !instr->CanTruncateToInt32() &&
+ (instr->value()->range() == NULL ||
+ instr->value()->range()->CanBeMinusZero())) {
+ instr->SetFlag(HValue::kBailoutOnMinusZero);
+ }
+ } else if (value->IsForceRepresentation()) {
+ HForceRepresentation* instr = HForceRepresentation::cast(value);
+ AddToWorklist(instr->value());
+ } else if (value->IsMod()) {
+ HMod* instr = HMod::cast(value);
+ if (instr->range() == NULL || instr->range()->CanBeMinusZero()) {
+ instr->SetFlag(HValue::kBailoutOnMinusZero);
+ AddToWorklist(instr->left());
+ }
+ } else if (value->IsDiv() || value->IsMul()) {
+ HBinaryOperation* instr = HBinaryOperation::cast(value);
+ if (instr->range() == NULL || instr->range()->CanBeMinusZero()) {
+ instr->SetFlag(HValue::kBailoutOnMinusZero);
+ }
+ AddToWorklist(instr->right());
+ AddToWorklist(instr->left());
+ } else if (value->IsMathFloorOfDiv()) {
+ HMathFloorOfDiv* instr = HMathFloorOfDiv::cast(value);
+ instr->SetFlag(HValue::kBailoutOnMinusZero);
+ } else if (value->IsAdd() || value->IsSub()) {
+ HBinaryOperation* instr = HBinaryOperation::cast(value);
+ if (instr->range() == NULL || instr->range()->CanBeMinusZero()) {
+ // Propagate to the left argument. If the left argument cannot be
-0,
+ // then the result of the add/sub operation cannot be either.
+ AddToWorklist(instr->left());
+ }
+ } else if (value->IsMathMinMax()) {
+ HMathMinMax* instr = HMathMinMax::cast(value);
+ AddToWorklist(instr->right());
+ AddToWorklist(instr->left());
+ }
+ }
+
+ in_worklist_.Clear();
+ ASSERT(in_worklist_.IsEmpty());
+ ASSERT(worklist_.is_empty());
+}
} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/hydrogen-range-analysis.h Mon Jul 15
09:53:46 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-range-analysis.h Mon Mar 10
11:49:29 2014 UTC
@@ -37,7 +37,9 @@
class HRangeAnalysisPhase : public HPhase {
public:
explicit HRangeAnalysisPhase(HGraph* graph)
- : HPhase("H_Range analysis", graph), changed_ranges_(16, zone()) { }
+ : HPhase("H_Range analysis", graph), changed_ranges_(16, zone()),
+ in_worklist_(graph->GetMaximumValueID(), zone()),
+ worklist_(32, zone()) {}
void Run();
@@ -49,8 +51,19 @@
void InferRange(HValue* value);
void RollBackTo(int index);
void AddRange(HValue* value, Range* range);
+ void AddToWorklist(HValue* value) {
+ if (in_worklist_.Contains(value->id())) return;
+ in_worklist_.Add(value->id());
+ worklist_.Add(value, zone());
+ }
+ void PropagateMinusZeroChecks(HValue* value);
ZoneList<HValue*> changed_ranges_;
+
+ BitVector in_worklist_;
+ ZoneList<HValue*> worklist_;
+
+ DISALLOW_COPY_AND_ASSIGN(HRangeAnalysisPhase);
};
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Mar 7 14:58:41 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc Mon Mar 10 11:49:29 2014 UTC
@@ -48,7 +48,6 @@
#include "hydrogen-gvn.h"
#include "hydrogen-mark-deoptimize.h"
#include "hydrogen-mark-unreachable.h"
-#include "hydrogen-minus-zero.h"
#include "hydrogen-osr.h"
#include "hydrogen-range-analysis.h"
#include "hydrogen-redundant-phi.h"
@@ -4049,10 +4048,9 @@
if (FLAG_check_elimination) Run<HCheckEliminationPhase>();
- if (FLAG_use_range) Run<HRangeAnalysisPhase>();
+ Run<HRangeAnalysisPhase>();
Run<HComputeChangeUndefinedToNaN>();
- Run<HComputeMinusZeroChecksPhase>();
// Eliminate redundant stack checks on backwards branches.
Run<HStackCheckEliminationPhase>();
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp Sat Mar 8 04:41:06 2014 UTC
+++ /branches/bleeding_edge/tools/gyp/v8.gyp Mon Mar 10 11:49:29 2014 UTC
@@ -407,8 +407,6 @@
'../../src/hydrogen-mark-deoptimize.h',
'../../src/hydrogen-mark-unreachable.cc',
'../../src/hydrogen-mark-unreachable.h',
- '../../src/hydrogen-minus-zero.cc',
- '../../src/hydrogen-minus-zero.h',
'../../src/hydrogen-osr.cc',
'../../src/hydrogen-osr.h',
'../../src/hydrogen-range-analysis.cc',
--
--
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.