Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1 | // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_COMPILER_JUMP_THREADING_H_ |
| 6 | #define V8_COMPILER_JUMP_THREADING_H_ |
| 7 | |
| 8 | #include "src/compiler/instruction.h" |
| 9 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | namespace compiler { |
| 13 | |
| 14 | // Forwards jumps to empty basic blocks that end with a second jump to the |
| 15 | // destination of the second jump, transitively. |
| 16 | class JumpThreading { |
| 17 | public: |
| 18 | // Compute the forwarding map of basic blocks to their ultimate destination. |
| 19 | // Returns {true} if there is at least one block that is forwarded. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 20 | static bool ComputeForwarding(Zone* local_zone, ZoneVector<RpoNumber>& result, |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 21 | InstructionSequence* code, bool frame_at_start); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 22 | |
| 23 | // Rewrite the instructions to forward jumps and branches. |
| 24 | // May also negate some branches. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 25 | static void ApplyForwarding(ZoneVector<RpoNumber>& forwarding, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 26 | InstructionSequence* code); |
| 27 | }; |
| 28 | |
| 29 | } // namespace compiler |
| 30 | } // namespace internal |
| 31 | } // namespace v8 |
| 32 | |
| 33 | #endif // V8_COMPILER_JUMP_THREADING_H |