Chromium Code Reviews| Index: src/compiler/bytecode-loop-analysis.h |
| diff --git a/src/compiler/bytecode-loop-analysis.h b/src/compiler/bytecode-loop-analysis.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d29dd557f62ae561348990f9d795fdc63d15d2a2 |
| --- /dev/null |
| +++ b/src/compiler/bytecode-loop-analysis.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef V8_COMPILER_BYTECODE_LOOP_ANALYSIS_H_ |
| +#define V8_COMPILER_BYTECODE_LOOP_ANALYSIS_H_ |
| + |
| +#include "src/bit-vector.h" |
|
Michael Starzinger
2016/07/29 08:54:46
nit: Seems the BitVector is not needed in the head
Jarin
2016/07/29 11:36:46
Done.
|
| +#include "src/handles.h" |
| +#include "src/zone-containers.h" |
| + |
| +namespace v8 { |
| +namespace internal { |
| + |
| +class BytecodeArray; |
| + |
| +namespace compiler { |
| + |
| +class BytecodeBranchAnalysis; |
| + |
| +class BytecodeLoopAnalysis BASE_EMBEDDED { |
| + public: |
| + BytecodeLoopAnalysis(Handle<BytecodeArray> bytecode_array, |
| + const BytecodeBranchAnalysis* branch_analysis, |
| + Zone* zone); |
| + |
| + // Analyze the bytecodes to find the branch sites and their |
| + // targets. No other methods in this class return valid information |
| + // until this has been called. |
| + void Analyze(); |
| + |
| + // Get the loop header offset of the containing loop for arbitrary |
| + // {offset}, or -1 if the {offset} is not inside any loop. |
| + int GetLoopOffsetFor(int offset) const; |
| + // Gets the loop header offset of the parent loop of the loop header |
| + // at {header_offset}, or -1 for outer-most loops. |
| + int GetParentLoopFor(int header_offset) const; |
| + |
| + private: |
| + void AddLoopEntry(int entry_offset); |
| + void AddBranch(int origin_offset, int target_offset); |
| + |
| + Zone* zone() const { return zone_; } |
| + Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; } |
| + |
| + Handle<BytecodeArray> bytecode_array_; |
| + const BytecodeBranchAnalysis* branch_analysis_; |
| + Zone* zone_; |
| + |
| + int current_loop_offset_; |
| + |
| + ZoneMap<int, int> backedge_to_header_; |
|
Michael Starzinger
2016/07/29 08:54:46
nit: Can we leave a comment here that both of thes
Jarin
2016/07/29 11:36:46
Done.
|
| + ZoneMap<int, int> loop_header_to_parent_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BytecodeLoopAnalysis); |
| +}; |
| + |
| +} // namespace compiler |
| +} // namespace internal |
| +} // namespace v8 |
| + |
| +#endif // V8_COMPILER_BYTECODE_LOOP_ANALYSIS_H_ |