| Index: src/hydrogen-canonicalize.cc
|
| diff --git a/src/hydrogen-escape-analysis.cc b/src/hydrogen-canonicalize.cc
|
| similarity index 62%
|
| copy from src/hydrogen-escape-analysis.cc
|
| copy to src/hydrogen-canonicalize.cc
|
| index e852fb8d6d75d7756df6e4e03399bfb8789d4c76..40cbe4c0655d4cd315d761fbf0d63b3aa0530a95 100644
|
| --- a/src/hydrogen-escape-analysis.cc
|
| +++ b/src/hydrogen-canonicalize.cc
|
| @@ -25,42 +25,35 @@
|
| // (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-canonicalize.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 HCanonicalizePhase::Run() {
|
| + const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
|
| + // Before removing no-op instructions, save their semantic value.
|
| + // We must be careful not to set the flag unnecessarily, because GVN
|
| + // cannot identify two instructions when their flag value differs.
|
| + for (int i = 0; i < blocks->length(); ++i) {
|
| + for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
|
| + HInstruction* instr = it.Current();
|
| + if (instr->IsArithmeticBinaryOperation() &&
|
| + instr->representation().IsInteger32() &&
|
| + instr->HasAtLeastOneUseWithFlagAndNoneWithout(
|
| + HInstruction::kTruncatingToInt32)) {
|
| + instr->SetFlag(HInstruction::kAllUsesTruncatingToInt32);
|
| }
|
| - 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()) {
|
| + // Perform actual Canonicalization pass.
|
| + for (int i = 0; i < blocks->length(); ++i) {
|
| + for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
|
| HInstruction* instr = it.Current();
|
| - if (instr->IsAllocate() || instr->IsAllocateObject()) {
|
| - CollectIfNoEscapingUses(instr);
|
| - }
|
| + HValue* value = instr->Canonicalize();
|
| + if (value != instr) instr->DeleteAndReplaceWith(value);
|
| }
|
| }
|
| }
|
|
|
| -
|
| } } // namespace v8::internal
|
|
|