blob: b801fecc0a2fbac65cc35126c8b5f6d62ae0ca10 [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14// Forwards jumps to empty basic blocks that end with a second jump to the
15// destination of the second jump, transitively.
16class 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.
20 static bool ComputeForwarding(Zone* local_zone,
21 ZoneVector<BasicBlock::RpoNumber>& result,
22 InstructionSequence* code);
23
24 // Rewrite the instructions to forward jumps and branches.
25 // May also negate some branches.
26 static void ApplyForwarding(ZoneVector<BasicBlock::RpoNumber>& forwarding,
27 InstructionSequence* code);
28};
29
30} // namespace compiler
31} // namespace internal
32} // namespace v8
33
34#endif // V8_COMPILER_JUMP_THREADING_H