Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: src/compiler/bytecode-analysis.h

Issue 2523893003: Reland of [ignition/turbo] Perform liveness analysis on the bytecodes (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/compiler/bytecode-analysis.cc » ('j') | src/compiler/bytecode-analysis.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8 #include "src/handles.h" 10 #include "src/handles.h"
9 #include "src/zone/zone-containers.h" 11 #include "src/zone/zone-containers.h"
10 12
11 namespace v8 { 13 namespace v8 {
12 namespace internal { 14 namespace internal {
13 15
14 class BytecodeArray; 16 class BytecodeArray;
15 17
16 namespace compiler { 18 namespace compiler {
17 19
18 class BytecodeAnalysis BASE_EMBEDDED { 20 class BytecodeAnalysis BASE_EMBEDDED {
19 public: 21 public:
20 BytecodeAnalysis(Handle<BytecodeArray> bytecode_array, Zone* zone); 22 BytecodeAnalysis(Handle<BytecodeArray> bytecode_array, Zone* zone);
21 23
22 // Analyze the bytecodes to find the loop ranges and nesting. No other 24 // 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. 25 // methods in this class return valid information until this has been called.
24 void Analyze(); 26 void Analyze();
25 27
26 // Return true if the given offset is a loop header 28 // Return true if the given offset is a loop header
27 bool IsLoopHeader(int offset) const; 29 bool IsLoopHeader(int offset) const;
28 // Get the loop header offset of the containing loop for arbitrary 30 // Get the loop header offset of the containing loop for arbitrary
29 // {offset}, or -1 if the {offset} is not inside any loop. 31 // {offset}, or -1 if the {offset} is not inside any loop.
30 int GetLoopOffsetFor(int offset) const; 32 int GetLoopOffsetFor(int offset) const;
31 // Gets the loop header offset of the parent loop of the loop header 33 // Gets the loop header offset of the parent loop of the loop header
32 // at {header_offset}, or -1 for outer-most loops. 34 // at {header_offset}, or -1 for outer-most loops.
33 int GetParentLoopFor(int header_offset) const; 35 int GetParentLoopFor(int header_offset) const;
34 36
37 const BitVector* GetInLivenessFor(int offset) const;
38
39 const BitVector* GetOutLivenessFor(int offset) const;
40
41 struct Liveness {
42 BitVector* in;
43 BitVector* out;
44
45 Liveness(int size, Zone* zone);
46 };
47
48 typedef base::TemplateHashMapImpl<
49 int, Liveness, base::KeyEqualityMatcher<int>, ZoneAllocationPolicy>
50 LivenessMap;
Jarin 2016/11/24 12:47:17 Does this offer significant advantage over std::un
Leszek Swirski 2016/11/25 17:31:27 I haven't measured here, but I've measured advanta
51
35 private: 52 private:
36 void PushLoop(int loop_header, int loop_end); 53 void PushLoop(int loop_header, int loop_end);
37 54
38 Zone* zone() const { return zone_; } 55 Zone* zone() const { return zone_; }
39 Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; } 56 Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
40 57
41 Handle<BytecodeArray> bytecode_array_; 58 Handle<BytecodeArray> bytecode_array_;
42 Zone* zone_; 59 Zone* zone_;
43 60
44 ZoneStack<int> loop_stack_; 61 ZoneStack<int> loop_stack_;
45 62
46 ZoneMap<int, int> end_to_header_; 63 ZoneMap<int, int> end_to_header_;
47 ZoneMap<int, int> header_to_parent_; 64 ZoneMap<int, int> header_to_parent_;
48 65
66 LivenessMap liveness_;
67
49 DISALLOW_COPY_AND_ASSIGN(BytecodeAnalysis); 68 DISALLOW_COPY_AND_ASSIGN(BytecodeAnalysis);
50 }; 69 };
51 70
52 } // namespace compiler 71 } // namespace compiler
53 } // namespace internal 72 } // namespace internal
54 } // namespace v8 73 } // namespace v8
55 74
56 #endif // V8_COMPILER_BYTECODE_ANALYSIS_H_ 75 #endif // V8_COMPILER_BYTECODE_ANALYSIS_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/bytecode-analysis.cc » ('j') | src/compiler/bytecode-analysis.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698