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 #include "src/compiler/bytecode-liveness-map.h" | 5 #include "src/compiler/bytecode-liveness-map.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
11 Liveness::Liveness(int size, Zone* zone) | 11 BytecodeLiveness::BytecodeLiveness(int register_count, Zone* zone) |
12 : in(new (zone) BitVector(size, zone)), | 12 : in(new (zone) BytecodeLivenessState(register_count, zone)), |
13 out(new (zone) BitVector(size, zone)) {} | 13 out(new (zone) BytecodeLivenessState(register_count, zone)) {} |
14 | 14 |
15 BytecodeLivenessMap::BytecodeLivenessMap(int bytecode_size, Zone* zone) | 15 BytecodeLivenessMap::BytecodeLivenessMap(int bytecode_size, Zone* zone) |
16 : liveness_map_(base::bits::RoundUpToPowerOfTwo32(bytecode_size / 4 + 1), | 16 : liveness_map_(base::bits::RoundUpToPowerOfTwo32(bytecode_size / 4 + 1), |
17 base::KeyEqualityMatcher<int>(), | 17 base::KeyEqualityMatcher<int>(), |
18 ZoneAllocationPolicy(zone)) {} | 18 ZoneAllocationPolicy(zone)) {} |
19 | 19 |
20 uint32_t OffsetHash(int offset) { return offset; } | 20 uint32_t OffsetHash(int offset) { return offset; } |
21 | 21 |
22 Liveness& BytecodeLivenessMap::InitializeLiveness(int offset, int size, | 22 BytecodeLiveness& BytecodeLivenessMap::InitializeLiveness(int offset, |
23 Zone* zone) { | 23 int register_count, |
| 24 Zone* zone) { |
24 return liveness_map_ | 25 return liveness_map_ |
25 .LookupOrInsert(offset, OffsetHash(offset), | 26 .LookupOrInsert(offset, OffsetHash(offset), |
26 [&]() { return Liveness(size, zone); }, | 27 [&]() { return BytecodeLiveness(register_count, zone); }, |
27 ZoneAllocationPolicy(zone)) | 28 ZoneAllocationPolicy(zone)) |
28 ->value; | 29 ->value; |
29 } | 30 } |
30 | 31 |
31 Liveness& BytecodeLivenessMap::GetLiveness(int offset) { | 32 BytecodeLiveness& BytecodeLivenessMap::GetLiveness(int offset) { |
32 return liveness_map_.Lookup(offset, OffsetHash(offset))->value; | 33 return liveness_map_.Lookup(offset, OffsetHash(offset))->value; |
33 } | 34 } |
34 | 35 |
35 const Liveness& BytecodeLivenessMap::GetLiveness(int offset) const { | 36 const BytecodeLiveness& BytecodeLivenessMap::GetLiveness(int offset) const { |
36 return liveness_map_.Lookup(offset, OffsetHash(offset))->value; | 37 return liveness_map_.Lookup(offset, OffsetHash(offset))->value; |
37 } | 38 } |
38 | 39 |
39 } // namespace compiler | 40 } // namespace compiler |
40 } // namespace internal | 41 } // namespace internal |
41 } // namespace v8 | 42 } // namespace v8 |
OLD | NEW |