Chromium Code Reviews| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 GVNFlagSet side_effects; | 399 GVNFlagSet side_effects; |
| 400 if (block->IsReachable() && !block->IsDeoptimizing()) { | 400 if (block->IsReachable() && !block->IsDeoptimizing()) { |
| 401 int id = block->block_id(); | 401 int id = block->block_id(); |
| 402 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | 402 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 403 HInstruction* instr = it.Current(); | 403 HInstruction* instr = it.Current(); |
| 404 side_effects.Add(instr->ChangesFlags()); | 404 side_effects.Add(instr->ChangesFlags()); |
| 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()) { |
|
titzer
2013/12/05 17:52:09
Can you turn this whole thing into a do {} while()
| |
| 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 while (with_parent->HasParentLoopHeader()) { |
| 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 } | |
| 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_3("Hoisting loop invariant instruction %d %d %s\n", |
|
titzer
2013/12/05 17:52:09
would like to see
"Hoisting loop invariant instru
| |
| 574 instr->id(), pre_header->block_id(), | |
| 575 *GetGVNFlagsString(loop_kills)); | |
| 571 // Move the instruction out of the loop. | 576 // Move the instruction out of the loop. |
| 572 instr->Unlink(); | 577 instr->Unlink(); |
| 573 instr->InsertBefore(pre_header->end()); | 578 instr->InsertBefore(pre_header->end()); |
| 574 if (instr->HasSideEffects()) removed_side_effects_ = true; | 579 if (instr->HasSideEffects()) removed_side_effects_ = true; |
| 575 hoisted = true; | 580 hoisted = true; |
| 576 } | 581 } |
| 577 } | 582 } |
| 578 } | 583 } |
| 579 if (!hoisted) { | 584 if (!hoisted) { |
| 580 // If an instruction is not hoisted, we have to account for its side | 585 // 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); | 849 dominated); |
| 845 successor_map->Kill(side_effects_on_all_paths); | 850 successor_map->Kill(side_effects_on_all_paths); |
| 846 successor_dominators->Kill(side_effects_on_all_paths); | 851 successor_dominators->Kill(side_effects_on_all_paths); |
| 847 } | 852 } |
| 848 } | 853 } |
| 849 current = next; | 854 current = next; |
| 850 } | 855 } |
| 851 } | 856 } |
| 852 | 857 |
| 853 } } // namespace v8::internal | 858 } } // namespace v8::internal |
| OLD | NEW |