| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 block_side_effects_[id].Add(side_effects); | 406 block_side_effects_[id].Add(side_effects); |
| 407 | 407 |
| 408 // Loop headers are part of their loop. | 408 // Loop headers are part of their loop. |
| 409 if (block->IsLoopHeader()) { | 409 if (block->IsLoopHeader()) { |
| 410 loop_side_effects_[id].Add(side_effects); | 410 loop_side_effects_[id].Add(side_effects); |
| 411 } | 411 } |
| 412 | 412 |
| 413 // Propagate loop side effects upwards. | 413 // Propagate loop side effects upwards. |
| 414 if (block->HasParentLoopHeader()) { | 414 if (block->HasParentLoopHeader()) { |
| 415 int header_id = block->parent_loop_header()->block_id(); | 415 HBasicBlock* with_parent = block; |
| 416 loop_side_effects_[header_id].Add(block->IsLoopHeader() | 416 if (block->IsLoopHeader()) side_effects = loop_side_effects_[id]; |
| 417 ? loop_side_effects_[id] | 417 do { |
| 418 : side_effects); | 418 HBasicBlock* parent_block = with_parent->parent_loop_header(); |
| 419 loop_side_effects_[parent_block->block_id()].Add(side_effects); |
| 420 with_parent = parent_block; |
| 421 } while (with_parent->HasParentLoopHeader()); |
| 419 } | 422 } |
| 420 } | 423 } |
| 421 } | 424 } |
| 422 } | 425 } |
| 423 | 426 |
| 424 | 427 |
| 425 SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) { | 428 SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) { |
| 426 char underlying_buffer[kLastFlag * 128]; | 429 char underlying_buffer[kLastFlag * 128]; |
| 427 Vector<char> buffer(underlying_buffer, sizeof(underlying_buffer)); | 430 Vector<char> buffer(underlying_buffer, sizeof(underlying_buffer)); |
| 428 #if DEBUG | 431 #if DEBUG |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 563 |
| 561 if (can_hoist) { | 564 if (can_hoist) { |
| 562 bool inputs_loop_invariant = true; | 565 bool inputs_loop_invariant = true; |
| 563 for (int i = 0; i < instr->OperandCount(); ++i) { | 566 for (int i = 0; i < instr->OperandCount(); ++i) { |
| 564 if (instr->OperandAt(i)->IsDefinedAfter(pre_header)) { | 567 if (instr->OperandAt(i)->IsDefinedAfter(pre_header)) { |
| 565 inputs_loop_invariant = false; | 568 inputs_loop_invariant = false; |
| 566 } | 569 } |
| 567 } | 570 } |
| 568 | 571 |
| 569 if (inputs_loop_invariant && ShouldMove(instr, loop_header)) { | 572 if (inputs_loop_invariant && ShouldMove(instr, loop_header)) { |
| 570 TRACE_GVN_1("Hoisting loop invariant instruction %d\n", instr->id()); | 573 TRACE_GVN_2("Hoisting loop invariant instruction i%d to block B%d\n", |
| 574 instr->id(), pre_header->block_id()); |
| 571 // Move the instruction out of the loop. | 575 // Move the instruction out of the loop. |
| 572 instr->Unlink(); | 576 instr->Unlink(); |
| 573 instr->InsertBefore(pre_header->end()); | 577 instr->InsertBefore(pre_header->end()); |
| 574 if (instr->HasSideEffects()) removed_side_effects_ = true; | 578 if (instr->HasSideEffects()) removed_side_effects_ = true; |
| 575 hoisted = true; | 579 hoisted = true; |
| 576 } | 580 } |
| 577 } | 581 } |
| 578 } | 582 } |
| 579 if (!hoisted) { | 583 if (!hoisted) { |
| 580 // If an instruction is not hoisted, we have to account for its side | 584 // If an instruction is not hoisted, we have to account for its side |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 dominated); | 848 dominated); |
| 845 successor_map->Kill(side_effects_on_all_paths); | 849 successor_map->Kill(side_effects_on_all_paths); |
| 846 successor_dominators->Kill(side_effects_on_all_paths); | 850 successor_dominators->Kill(side_effects_on_all_paths); |
| 847 } | 851 } |
| 848 } | 852 } |
| 849 current = next; | 853 current = next; |
| 850 } | 854 } |
| 851 } | 855 } |
| 852 | 856 |
| 853 } } // namespace v8::internal | 857 } } // namespace v8::internal |
| OLD | NEW |