| Index: src/hydrogen-minus-zero.cc
|
| diff --git a/src/hydrogen-redundant-phi.cc b/src/hydrogen-minus-zero.cc
|
| similarity index 50%
|
| copy from src/hydrogen-redundant-phi.cc
|
| copy to src/hydrogen-minus-zero.cc
|
| index 9c38200577d4994e79f5e1925039ca10a8c8a8c2..e9628959deeec1b9d3159f397bdd1a9ba9fc49a0 100644
|
| --- a/src/hydrogen-redundant-phi.cc
|
| +++ b/src/hydrogen-minus-zero.cc
|
| @@ -25,52 +25,59 @@
|
| // (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-redundant-phi.h"
|
| +#include "hydrogen-minus-zero.h"
|
|
|
| namespace v8 {
|
| namespace internal {
|
|
|
| -void HRedundantPhiEliminationPhase::Run() {
|
| - // We do a simple fixed point iteration without any work list, because
|
| - // machine-generated JavaScript can lead to a very dense Hydrogen graph with
|
| - // an enormous work list and will consequently result in OOM. Experiments
|
| - // showed that this simple algorithm is good enough, and even e.g. tracking
|
| - // the set or range of blocks to consider is not a real improvement.
|
| - bool need_another_iteration;
|
| +void HComputeMinusZeroChecksPhase::Run() {
|
| const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
|
| - ZoneList<HPhi*> redundant_phis(blocks->length(), zone());
|
| - do {
|
| - need_another_iteration = false;
|
| - for (int i = 0; i < blocks->length(); ++i) {
|
| - HBasicBlock* block = blocks->at(i);
|
| - for (int j = 0; j < block->phis()->length(); j++) {
|
| - HPhi* phi = block->phis()->at(j);
|
| - HValue* replacement = phi->GetRedundantReplacement();
|
| - if (replacement != NULL) {
|
| - // Remember phi to avoid concurrent modification of the block's phis.
|
| - redundant_phis.Add(phi, zone());
|
| - for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) {
|
| - HValue* value = it.value();
|
| - value->SetOperandAt(it.index(), replacement);
|
| - need_another_iteration |= value->IsPhi();
|
| - }
|
| + 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.IsInteger32()) {
|
| + ASSERT(change->to().IsTagged() ||
|
| + change->to().IsDouble() ||
|
| + change->to().IsSmi());
|
| + ASSERT(visited_.IsEmpty());
|
| + PropagateMinusZeroChecks(change->value());
|
| + visited_.Clear();
|
| }
|
| }
|
| - for (int i = 0; i < redundant_phis.length(); i++) {
|
| - block->RemovePhi(redundant_phis[i]);
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| +void HComputeMinusZeroChecksPhase::PropagateMinusZeroChecks(HValue* value) {
|
| + for (HValue* current = value;
|
| + current != NULL && !visited_.Contains(current->id());
|
| + current = current->EnsureAndPropagateNotMinusZero(&visited_)) {
|
| + // For phis, we must propagate the check to all of its inputs.
|
| + if (current->IsPhi()) {
|
| + visited_.Add(current->id());
|
| + HPhi* phi = HPhi::cast(current);
|
| + for (int i = 0; i < phi->OperandCount(); ++i) {
|
| + PropagateMinusZeroChecks(phi->OperandAt(i));
|
| }
|
| - redundant_phis.Clear();
|
| + break;
|
| }
|
| - } while (need_another_iteration);
|
|
|
| -#if DEBUG
|
| - // Make sure that we *really* removed all redundant phis.
|
| - for (int i = 0; i < blocks->length(); ++i) {
|
| - for (int j = 0; j < blocks->at(i)->phis()->length(); j++) {
|
| - ASSERT(blocks->at(i)->phis()->at(j)->GetRedundantReplacement() == NULL);
|
| + // For multiplication, division, and Math.min/max(), we must propagate
|
| + // to the left and the right side.
|
| + if (current->IsMul() || current->IsDiv() || current->IsMathMinMax()) {
|
| + HBinaryOperation* operation = HBinaryOperation::cast(current);
|
| + operation->EnsureAndPropagateNotMinusZero(&visited_);
|
| + PropagateMinusZeroChecks(operation->left());
|
| + PropagateMinusZeroChecks(operation->right());
|
| }
|
| }
|
| -#endif
|
| }
|
|
|
| } } // namespace v8::internal
|
|
|