OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_BYTECODE_ANALYSIS_H_ | 5 #ifndef V8_COMPILER_BYTECODE_ANALYSIS_H_ |
6 #define V8_COMPILER_BYTECODE_ANALYSIS_H_ | 6 #define V8_COMPILER_BYTECODE_ANALYSIS_H_ |
7 | 7 |
8 #include "src/base/hashmap.h" | |
9 #include "src/bit-vector.h" | |
10 #include "src/compiler/bytecode-liveness-map.h" | |
8 #include "src/handles.h" | 11 #include "src/handles.h" |
9 #include "src/zone/zone-containers.h" | 12 #include "src/zone/zone-containers.h" |
10 | 13 |
11 namespace v8 { | 14 namespace v8 { |
12 namespace internal { | 15 namespace internal { |
13 | 16 |
14 class BytecodeArray; | 17 class BytecodeArray; |
15 | 18 |
16 namespace compiler { | 19 namespace compiler { |
17 | 20 |
18 class BytecodeAnalysis BASE_EMBEDDED { | 21 class V8_EXPORT_PRIVATE BytecodeAnalysis BASE_EMBEDDED { |
19 public: | 22 public: |
20 BytecodeAnalysis(Handle<BytecodeArray> bytecode_array, Zone* zone); | 23 BytecodeAnalysis(Handle<BytecodeArray> bytecode_array, Zone* zone, |
24 bool do_liveness_analysis); | |
21 | 25 |
22 // Analyze the bytecodes to find the loop ranges and nesting. No other | 26 // Analyze the bytecodes to find the loop ranges and nesting. No other |
23 // methods in this class return valid information until this has been called. | 27 // methods in this class return valid information until this has been called. |
24 void Analyze(); | 28 void Analyze(); |
25 | 29 |
26 // Return true if the given offset is a loop header | 30 // Return true if the given offset is a loop header |
27 bool IsLoopHeader(int offset) const; | 31 bool IsLoopHeader(int offset) const; |
28 // Get the loop header offset of the containing loop for arbitrary | 32 // Get the loop header offset of the containing loop for arbitrary |
29 // {offset}, or -1 if the {offset} is not inside any loop. | 33 // {offset}, or -1 if the {offset} is not inside any loop. |
30 int GetLoopOffsetFor(int offset) const; | 34 int GetLoopOffsetFor(int offset) const; |
31 // Gets the loop header offset of the parent loop of the loop header | 35 // Gets the loop header offset of the parent loop of the loop header |
32 // at {header_offset}, or -1 for outer-most loops. | 36 // at {header_offset}, or -1 for outer-most loops. |
33 int GetParentLoopFor(int header_offset) const; | 37 int GetParentLoopFor(int header_offset) const; |
34 | 38 |
39 const BitVector* GetInLivenessFor(int offset) const; | |
rmcilroy
2016/11/28 15:16:37
nit - comments for these functions
Leszek Swirski
2016/11/28 16:31:11
Done (also the location of the accumulator comment
| |
40 | |
41 const BitVector* GetOutLivenessFor(int offset) const; | |
42 | |
43 std::ostream& PrintLivenessTo(std::ostream& os) const; | |
44 | |
35 private: | 45 private: |
36 void PushLoop(int loop_header, int loop_end); | 46 void PushLoop(int loop_header, int loop_end); |
37 | 47 |
48 #if DEBUG | |
49 bool LivenessIsValid(); | |
50 #endif | |
51 | |
38 Zone* zone() const { return zone_; } | 52 Zone* zone() const { return zone_; } |
39 Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; } | 53 Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; } |
40 | 54 |
55 private: | |
41 Handle<BytecodeArray> bytecode_array_; | 56 Handle<BytecodeArray> bytecode_array_; |
57 bool do_liveness_analysis_; | |
42 Zone* zone_; | 58 Zone* zone_; |
43 | 59 |
44 ZoneStack<int> loop_stack_; | 60 ZoneStack<int> loop_stack_; |
45 | 61 |
46 ZoneMap<int, int> end_to_header_; | 62 ZoneMap<int, int> end_to_header_; |
47 ZoneMap<int, int> header_to_parent_; | 63 ZoneMap<int, int> header_to_parent_; |
48 | 64 |
65 BytecodeLivenessMap liveness_map_; | |
66 | |
49 DISALLOW_COPY_AND_ASSIGN(BytecodeAnalysis); | 67 DISALLOW_COPY_AND_ASSIGN(BytecodeAnalysis); |
50 }; | 68 }; |
51 | 69 |
52 } // namespace compiler | 70 } // namespace compiler |
53 } // namespace internal | 71 } // namespace internal |
54 } // namespace v8 | 72 } // namespace v8 |
55 | 73 |
56 #endif // V8_COMPILER_BYTECODE_ANALYSIS_H_ | 74 #endif // V8_COMPILER_BYTECODE_ANALYSIS_H_ |
OLD | NEW |