| Index: src/hydrogen.cc
|
| ===================================================================
|
| --- src/hydrogen.cc (revision 8253)
|
| +++ src/hydrogen.cc (working copy)
|
| @@ -1765,6 +1765,7 @@
|
| // change instructions for them.
|
| HInstruction* new_value = NULL;
|
| bool is_truncating = use->CheckFlag(HValue::kTruncatingToInt32);
|
| + bool deoptimize_on_undefined = use->CheckFlag(HValue::kDeoptimizeOnUndefined);
|
| if (value->IsConstant()) {
|
| HConstant* constant = HConstant::cast(value);
|
| // Try to create a new copy of the constant with the new representation.
|
| @@ -1774,8 +1775,8 @@
|
| }
|
|
|
| if (new_value == NULL) {
|
| - new_value =
|
| - new(zone()) HChange(value, value->representation(), to, is_truncating);
|
| + new_value = new(zone()) HChange(value, value->representation(), to,
|
| + is_truncating, deoptimize_on_undefined);
|
| }
|
|
|
| new_value->InsertBefore(next);
|
| @@ -1916,6 +1917,41 @@
|
| }
|
|
|
|
|
| +void HGraph::RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi) {
|
| + if (phi->CheckFlag(HValue::kDeoptimizeOnUndefined)) return;
|
| + phi->SetFlag(HValue::kDeoptimizeOnUndefined);
|
| + for (int i = 0; i < phi->OperandCount(); ++i) {
|
| + HValue* input = phi->OperandAt(i);
|
| + if (input->IsPhi()) {
|
| + RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi::cast(input));
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| +void HGraph::MarkDeoptimizeOnUndefined() {
|
| + HPhase phase("MarkDeoptimizeOnUndefined", this);
|
| + // Compute DeoptimizeOnUndefined flag for phis.
|
| + // Any phi that can reach a use with DeoptimizeOnUndefined set must
|
| + // have DeoptimizeOnUndefined set. Currently only HCompare, with
|
| + // double input representation, has this flag set.
|
| + // The flag is used by HChange tagged->double, which must deoptimize
|
| + // if one of its uses has this flag set.
|
| + for (int i = 0; i < phi_list()->length(); i++) {
|
| + HPhi* phi = phi_list()->at(i);
|
| + if (phi->representation().IsDouble()) {
|
| + for (int j = 0; j < phi->uses()->length(); j++) {
|
| + HValue* use = phi->uses()->at(j);
|
| + if (use->CheckFlag(HValue::kDeoptimizeOnUndefined)) {
|
| + RecursivelyMarkPhiDeoptimizeOnUndefined(phi);
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| void HGraph::ComputeMinusZeroChecks() {
|
| BitVector visited(GetMaximumValueID());
|
| for (int i = 0; i < blocks_.length(); ++i) {
|
| @@ -2234,6 +2270,7 @@
|
|
|
| graph()->InitializeInferredTypes();
|
| graph()->Canonicalize();
|
| + graph()->MarkDeoptimizeOnUndefined();
|
| graph()->InsertRepresentationChanges();
|
| graph()->ComputeMinusZeroChecks();
|
|
|
|
|