blob: 7050ec385e7a57a3741e1b749cb240438958b832 [file] [log] [blame]
// 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