Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2606 if (!in_worklist.Contains(use->id())) { | 2606 if (!in_worklist.Contains(use->id())) { |
| 2607 in_worklist.Add(use->id()); | 2607 in_worklist.Add(use->id()); |
| 2608 worklist->Add(use, zone()); | 2608 worklist->Add(use, zone()); |
| 2609 } | 2609 } |
| 2610 } | 2610 } |
| 2611 } | 2611 } |
| 2612 } | 2612 } |
| 2613 } | 2613 } |
| 2614 | 2614 |
| 2615 | 2615 |
| 2616 class HEscapeAnalysis BASE_EMBEDDED { | |
| 2617 public: | |
| 2618 explicit HEscapeAnalysis(HGraph* graph) | |
| 2619 : graph_(graph), zone_(graph->zone()), captured_(0, zone_) { } | |
| 2620 | |
| 2621 void Analyze(); | |
| 2622 | |
| 2623 private: | |
| 2624 void CollectCapturedValues(); | |
| 2625 void CollectIfNoEscapingUses(HInstruction* instr); | |
| 2626 | |
| 2627 HGraph* graph_; | |
| 2628 Zone* zone_; | |
| 2629 ZoneList<HValue*> captured_; | |
| 2630 }; | |
| 2631 | |
| 2632 | |
| 2633 void HEscapeAnalysis::CollectIfNoEscapingUses(HInstruction* instr) { | |
| 2634 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | |
| 2635 HValue* use = it.value(); | |
| 2636 if (use->HasEscapingOperandAt(it.index())) { | |
| 2637 if (FLAG_trace_escape_analysis) { | |
| 2638 PrintF("#%d (%s) escapes through #%d (%s) @%d\n", instr->id(), | |
| 2639 instr->Mnemonic(), use->id(), use->Mnemonic(), it.index()); | |
| 2640 } | |
| 2641 return; | |
| 2642 } | |
| 2643 } | |
| 2644 if (FLAG_trace_escape_analysis) { | |
| 2645 PrintF("#%d (%s) is being captured\n", instr->id(), instr->Mnemonic()); | |
| 2646 } | |
| 2647 captured_.Add(instr, zone_); | |
| 2648 } | |
| 2649 | |
| 2650 | |
| 2651 void HEscapeAnalysis::CollectCapturedValues() { | |
| 2652 int block_count = graph_->blocks()->length(); | |
| 2653 for (int i = 0; i < block_count; ++i) { | |
| 2654 HBasicBlock* block = graph_->blocks()->at(i); | |
| 2655 HInstruction* instr = block->first(); | |
| 2656 while (instr != block->end()) { | |
|
Sven Panne
2013/06/27 07:18:23
A for-loop would be more readable. We really need
Michael Starzinger
2013/06/27 08:17:13
Done. You want an iterator? I give you an iterator
| |
| 2657 if (instr->IsAllocate() || instr->IsAllocateObject()) { | |
| 2658 CollectIfNoEscapingUses(instr); | |
| 2659 } | |
| 2660 instr = instr->next(); | |
| 2661 } | |
| 2662 } | |
| 2663 } | |
| 2664 | |
| 2665 | |
| 2666 void HEscapeAnalysis::Analyze() { | |
| 2667 HPhase phase("H_Escape analysis", graph_); | |
| 2668 CollectCapturedValues(); | |
| 2669 } | |
| 2670 | |
| 2671 | |
| 2616 class HRangeAnalysis BASE_EMBEDDED { | 2672 class HRangeAnalysis BASE_EMBEDDED { |
| 2617 public: | 2673 public: |
| 2618 explicit HRangeAnalysis(HGraph* graph) : | 2674 explicit HRangeAnalysis(HGraph* graph) : |
| 2619 graph_(graph), zone_(graph->zone()), changed_ranges_(16, zone_) { } | 2675 graph_(graph), zone_(graph->zone()), changed_ranges_(16, zone_) { } |
| 2620 | 2676 |
| 2621 void Analyze(); | 2677 void Analyze(); |
| 2622 | 2678 |
| 2623 private: | 2679 private: |
| 2624 void TraceRange(const char* msg, ...); | 2680 void TraceRange(const char* msg, ...); |
| 2625 void Analyze(HBasicBlock* block); | 2681 void Analyze(HBasicBlock* block); |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3976 // Do a full verify after building the graph and computing dominators. | 4032 // Do a full verify after building the graph and computing dominators. |
| 3977 Verify(true); | 4033 Verify(true); |
| 3978 #endif | 4034 #endif |
| 3979 | 4035 |
| 3980 if (FLAG_analyze_environment_liveness) { | 4036 if (FLAG_analyze_environment_liveness) { |
| 3981 EnvironmentSlotLivenessAnalyzer esla(this); | 4037 EnvironmentSlotLivenessAnalyzer esla(this); |
| 3982 esla.AnalyzeAndTrim(); | 4038 esla.AnalyzeAndTrim(); |
| 3983 } | 4039 } |
| 3984 | 4040 |
| 3985 PropagateDeoptimizingMark(); | 4041 PropagateDeoptimizingMark(); |
| 4042 | |
| 3986 if (!CheckConstPhiUses()) { | 4043 if (!CheckConstPhiUses()) { |
| 3987 *bailout_reason = SmartArrayPointer<char>(StrDup( | 4044 *bailout_reason = SmartArrayPointer<char>(StrDup( |
| 3988 "Unsupported phi use of const variable")); | 4045 "Unsupported phi use of const variable")); |
| 3989 return false; | 4046 return false; |
| 3990 } | 4047 } |
| 3991 EliminateRedundantPhis(); | 4048 EliminateRedundantPhis(); |
| 3992 if (!CheckArgumentsPhiUses()) { | 4049 if (!CheckArgumentsPhiUses()) { |
| 3993 *bailout_reason = SmartArrayPointer<char>(StrDup( | 4050 *bailout_reason = SmartArrayPointer<char>(StrDup( |
| 3994 "Unsupported phi use of arguments")); | 4051 "Unsupported phi use of arguments")); |
| 3995 return false; | 4052 return false; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 4022 | 4079 |
| 4023 InitializeInferredTypes(); | 4080 InitializeInferredTypes(); |
| 4024 | 4081 |
| 4025 // Must be performed before canonicalization to ensure that Canonicalize | 4082 // Must be performed before canonicalization to ensure that Canonicalize |
| 4026 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with | 4083 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with |
| 4027 // zero. | 4084 // zero. |
| 4028 if (FLAG_opt_safe_uint32_operations) ComputeSafeUint32Operations(); | 4085 if (FLAG_opt_safe_uint32_operations) ComputeSafeUint32Operations(); |
| 4029 | 4086 |
| 4030 if (FLAG_use_canonicalizing) Canonicalize(); | 4087 if (FLAG_use_canonicalizing) Canonicalize(); |
| 4031 | 4088 |
| 4089 if (FLAG_use_escape_analysis) { | |
| 4090 HEscapeAnalysis escapeAnalysis(this); | |
| 4091 escapeAnalysis.Analyze(); | |
| 4092 } | |
| 4093 | |
| 4032 if (FLAG_use_gvn) GlobalValueNumbering(); | 4094 if (FLAG_use_gvn) GlobalValueNumbering(); |
| 4033 | 4095 |
| 4034 if (FLAG_use_range) { | 4096 if (FLAG_use_range) { |
| 4035 HRangeAnalysis rangeAnalysis(this); | 4097 HRangeAnalysis rangeAnalysis(this); |
| 4036 rangeAnalysis.Analyze(); | 4098 rangeAnalysis.Analyze(); |
| 4037 } | 4099 } |
| 4038 ComputeMinusZeroChecks(); | 4100 ComputeMinusZeroChecks(); |
| 4039 | 4101 |
| 4040 // Eliminate redundant stack checks on backwards branches. | 4102 // Eliminate redundant stack checks on backwards branches. |
| 4041 HStackCheckEliminator sce(this); | 4103 HStackCheckEliminator sce(this); |
| (...skipping 7512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11554 if (ShouldProduceTraceOutput()) { | 11616 if (ShouldProduceTraceOutput()) { |
| 11555 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11617 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 11556 } | 11618 } |
| 11557 | 11619 |
| 11558 #ifdef DEBUG | 11620 #ifdef DEBUG |
| 11559 graph_->Verify(false); // No full verify. | 11621 graph_->Verify(false); // No full verify. |
| 11560 #endif | 11622 #endif |
| 11561 } | 11623 } |
| 11562 | 11624 |
| 11563 } } // namespace v8::internal | 11625 } } // namespace v8::internal |
| OLD | NEW |