Index: src/hydrogen-mark-deoptimize.cc |
diff --git a/src/hydrogen-escape-analysis.cc b/src/hydrogen-mark-deoptimize.cc |
similarity index 59% |
copy from src/hydrogen-escape-analysis.cc |
copy to src/hydrogen-mark-deoptimize.cc |
index 961bb94e9c1dbafa7e4a7f2b87528aedb78ca79c..111fcd2ce9ba30e7923ca4cdd7af952746499573 100644 |
--- a/src/hydrogen-escape-analysis.cc |
+++ b/src/hydrogen-mark-deoptimize.cc |
@@ -25,42 +25,47 @@ |
// (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-escape-analysis.h" |
+#include "hydrogen-mark-deoptimize.h" |
namespace v8 { |
namespace internal { |
- |
-void HEscapeAnalysisPhase::CollectIfNoEscapingUses(HInstruction* instr) { |
- for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
- HValue* use = it.value(); |
- if (use->HasEscapingOperandAt(it.index())) { |
- if (FLAG_trace_escape_analysis) { |
- PrintF("#%d (%s) escapes through #%d (%s) @%d\n", instr->id(), |
- instr->Mnemonic(), use->id(), use->Mnemonic(), it.index()); |
+void HMarkDeoptimizeOnUndefinedPhase::Run() { |
+ const ZoneList<HPhi*>* phi_list = graph()->phi_list(); |
+ for (int i = 0; i < phi_list->length(); i++) { |
+ HPhi* phi = phi_list->at(i); |
+ if (phi->CheckFlag(HValue::kAllowUndefinedAsNaN)) { |
+ for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) { |
+ HValue* use_value = it.value(); |
+ if (!use_value->CheckFlag(HValue::kAllowUndefinedAsNaN)) { |
+ ProcessPhi(phi); |
+ break; |
+ } |
} |
- return; |
} |
} |
- if (FLAG_trace_escape_analysis) { |
- PrintF("#%d (%s) is being captured\n", instr->id(), instr->Mnemonic()); |
- } |
- captured_.Add(instr, zone()); |
} |
-void HEscapeAnalysisPhase::CollectCapturedValues() { |
- int block_count = graph()->blocks()->length(); |
- for (int i = 0; i < block_count; ++i) { |
- HBasicBlock* block = graph()->blocks()->at(i); |
- for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
- HInstruction* instr = it.Current(); |
- if (instr->IsAllocate()) { |
- CollectIfNoEscapingUses(instr); |
+void HMarkDeoptimizeOnUndefinedPhase::ProcessPhi(HPhi* phi) { |
+ ASSERT(phi->CheckFlag(HValue::kAllowUndefinedAsNaN)); |
+ ASSERT(worklist_.is_empty()); |
+ |
+ // Push the phi onto the worklist |
+ phi->ClearFlag(HValue::kAllowUndefinedAsNaN); |
+ worklist_.Add(phi, zone()); |
+ |
+ // Process all phis that can reach this phi |
+ while (!worklist_.is_empty()) { |
+ phi = worklist_.RemoveLast(); |
+ for (int i = phi->OperandCount() - 1; i >= 0; --i) { |
+ HValue* input = phi->OperandAt(i); |
+ if (input->IsPhi() && input->CheckFlag(HValue::kAllowUndefinedAsNaN)) { |
+ input->ClearFlag(HValue::kAllowUndefinedAsNaN); |
+ worklist_.Add(HPhi::cast(input), zone()); |
} |
} |
} |
} |
- |
} } // namespace v8::internal |