summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/bytecode-liveness-map.cc
blob: 7050ec385e7a57a3741e1b749cb240438958b832 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 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.

#include "src/compiler/bytecode-liveness-map.h"

namespace v8 {
namespace internal {
namespace compiler {

BytecodeLiveness::BytecodeLiveness(int register_count, Zone* zone)
    : in(zone->New<BytecodeLivenessState>(register_count, zone)),
      out(zone->New<BytecodeLivenessState>(register_count, zone)) {}

BytecodeLivenessMap::BytecodeLivenessMap(int bytecode_size, Zone* zone)
    : liveness_map_(base::bits::RoundUpToPowerOfTwo32(bytecode_size / 4 + 1),
                    base::KeyEqualityMatcher<int>(),
                    ZoneAllocationPolicy(zone)) {}

uint32_t OffsetHash(int offset) { return offset; }

BytecodeLiveness& BytecodeLivenessMap::InitializeLiveness(int offset,
                                                          int register_count,
                                                          Zone* zone) {
  return liveness_map_
      .LookupOrInsert(offset, OffsetHash(offset),
                      [&]() { return BytecodeLiveness(register_count, zone); })
      ->value;
}

BytecodeLiveness& BytecodeLivenessMap::GetLiveness(int offset) {
  return liveness_map_.Lookup(offset, OffsetHash(offset))->value;
}

const BytecodeLiveness& BytecodeLivenessMap::GetLiveness(int offset) const {
  return liveness_map_.Lookup(offset, OffsetHash(offset))->value;
}

}  // namespace compiler
}  // namespace internal
}  // namespace v8