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

Side by Side Diff: src/compiler/bytecode-liveness-map.h

Issue 2552723004: [ignition/turbofan] Wrap bytecode liveness bitvectors (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 | « src/compiler/bytecode-graph-builder.cc ('k') | src/compiler/bytecode-liveness-map.cc » ('j') | no next file with comments »
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_LIVENESS_MAP_H_ 5 #ifndef V8_COMPILER_BYTECODE_LIVENESS_MAP_H_
6 #define V8_COMPILER_BYTECODE_LIVENESS_MAP_H_ 6 #define V8_COMPILER_BYTECODE_LIVENESS_MAP_H_
7 7
8 #include "src/base/hashmap.h" 8 #include "src/base/hashmap.h"
9 #include "src/bit-vector.h" 9 #include "src/bit-vector.h"
10 #include "src/zone/zone.h" 10 #include "src/zone/zone.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 class Zone; 15 class Zone;
16 16
17 namespace compiler { 17 namespace compiler {
18 18
19 struct Liveness { 19 class BytecodeLivenessState : public ZoneObject {
20 BitVector* in; 20 public:
21 BitVector* out; 21 BytecodeLivenessState(int register_count, Zone* zone)
22 : bit_vector_(register_count + 1, zone) {}
22 23
23 Liveness(int size, Zone* zone); 24 const BitVector& bit_vector() const { return bit_vector_; }
25
26 BitVector& bit_vector() { return bit_vector_; }
27
28 bool RegisterIsLive(int index) const {
29 DCHECK_GE(index, 0);
30 DCHECK_LT(index, bit_vector_.length() - 1);
31 return bit_vector_.Contains(index);
32 }
33
34 bool AccumulatorIsLive() const {
35 return bit_vector_.Contains(bit_vector_.length() - 1);
36 }
37
38 bool Equals(const BytecodeLivenessState& other) const {
39 return bit_vector_.Equals(other.bit_vector_);
40 }
41
42 void MarkRegisterLive(int index) {
43 DCHECK_GE(index, 0);
44 DCHECK_LT(index, bit_vector_.length() - 1);
45 bit_vector_.Add(index);
46 }
47
48 void MarkRegisterDead(int index) {
49 DCHECK_GE(index, 0);
50 DCHECK_LT(index, bit_vector_.length() - 1);
51 bit_vector_.Remove(index);
52 }
53
54 void MarkAccumulatorLive() { bit_vector_.Add(bit_vector_.length() - 1); }
55
56 void MarkAccumulatorDead() { bit_vector_.Remove(bit_vector_.length() - 1); }
57
58 void MarkAllLive() { bit_vector_.AddAll(); }
59
60 void Union(const BytecodeLivenessState& other) {
61 bit_vector_.Union(other.bit_vector_);
62 }
63
64 bool UnionIsChanged(const BytecodeLivenessState& other) {
65 return bit_vector_.UnionIsChanged(other.bit_vector_);
66 }
67
68 void CopyFrom(const BytecodeLivenessState& other) {
69 bit_vector_.CopyFrom(other.bit_vector_);
70 }
71
72 private:
73 BitVector bit_vector_;
74
75 DISALLOW_COPY_AND_ASSIGN(BytecodeLivenessState);
76 };
77
78 struct BytecodeLiveness {
79 BytecodeLivenessState* in;
80 BytecodeLivenessState* out;
81
82 BytecodeLiveness(int register_count, Zone* zone);
24 }; 83 };
25 84
26 class V8_EXPORT_PRIVATE BytecodeLivenessMap { 85 class V8_EXPORT_PRIVATE BytecodeLivenessMap {
27 public: 86 public:
28 BytecodeLivenessMap(int size, Zone* zone); 87 BytecodeLivenessMap(int size, Zone* zone);
29 88
30 Liveness& InitializeLiveness(int offset, int size, Zone* zone); 89 BytecodeLiveness& InitializeLiveness(int offset, int register_count,
90 Zone* zone);
31 91
32 Liveness& GetLiveness(int offset); 92 BytecodeLiveness& GetLiveness(int offset);
33 const Liveness& GetLiveness(int offset) const; 93 const BytecodeLiveness& GetLiveness(int offset) const;
34 94
35 BitVector* GetInLiveness(int offset) { return GetLiveness(offset).in; } 95 BytecodeLivenessState* GetInLiveness(int offset) {
36 const BitVector* GetInLiveness(int offset) const { 96 return GetLiveness(offset).in;
97 }
98 const BytecodeLivenessState* GetInLiveness(int offset) const {
37 return GetLiveness(offset).in; 99 return GetLiveness(offset).in;
38 } 100 }
39 101
40 BitVector* GetOutLiveness(int offset) { return GetLiveness(offset).out; } 102 BytecodeLivenessState* GetOutLiveness(int offset) {
41 const BitVector* GetOutLiveness(int offset) const { 103 return GetLiveness(offset).out;
104 }
105 const BytecodeLivenessState* GetOutLiveness(int offset) const {
42 return GetLiveness(offset).out; 106 return GetLiveness(offset).out;
43 } 107 }
44 108
45 private: 109 private:
46 base::TemplateHashMapImpl<int, Liveness, base::KeyEqualityMatcher<int>, 110 base::TemplateHashMapImpl<int, BytecodeLiveness,
47 ZoneAllocationPolicy> 111 base::KeyEqualityMatcher<int>, ZoneAllocationPolicy>
48 liveness_map_; 112 liveness_map_;
49 }; 113 };
50 114
51 } // namespace compiler 115 } // namespace compiler
52 } // namespace internal 116 } // namespace internal
53 } // namespace v8 117 } // namespace v8
54 118
55 #endif // V8_COMPILER_BYTECODE_LIVENESS_MAP_H_ 119 #endif // V8_COMPILER_BYTECODE_LIVENESS_MAP_H_
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | src/compiler/bytecode-liveness-map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698