c9f6e669f9
Fixes an assumption that CompressedStackMapsIterator::Find() is never
passed a PC offset of 0. Adds back an ASSERT that was dropped which checks
for specific cases where a given PC offset does not have a stack map entry.
Original commit message:
Lifting the PC offset in a2bb730 was a small, lightweight change that
gave us big gains, at least on 32-bit architectures. Here, we make
much more invasive changes that will improve the amount of memory used
by the information previously stored in StackMap objects.
Instead of allocating separate objects for StackMaps, we instead compress
all StackMap information for a given Code object into a single object
(CompressedStackMaps, or CSM for short). This replaces the Array used to
store PC offsets (as Smis) and the individual StackMap objects.
While we lose all canonicalization for individual StackMap entries, the
drop in space required to store stack map information more than offsets that.
-----
The impact on AOT snapshot size when compiling the Flutter Gallery
in release mode:
armv7: Total size -2.58% (Isolate RO: +14.46%, Isolate snapshot: -22.93%)
armv8: Total size -1.85% (Isolate RO: +15.69%, Isolate snapshot: -22.97%)
The impact on in-memory, not on-disk, size for the Flutter Gallery as seen
in the Observatory while running a profile (not release) build:
armv7: Drops from 7.1 MB to 6.2MB (-0.9 MB)
armv8: Drops from 13.5MB to 11.7MB (-1.8 MB)
-----
Bug: https://github.com/dart-lang/sdk/issues/35274, https://github.com/dart-lang/sdk/issues/38873
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-mac-debug-simdbc64-try
Change-Id: I111b129b0ed64f03184370bceb7cda69d5d4b3c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121700
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_VM_BITMAP_H_
|
|
#define RUNTIME_VM_BITMAP_H_
|
|
|
|
#include "vm/allocation.h"
|
|
#include "vm/growable_array.h"
|
|
#include "vm/thread_state.h"
|
|
#include "vm/zone.h"
|
|
|
|
namespace dart {
|
|
|
|
// BitmapBuilder is used to build a bitmap. The implementation is optimized
|
|
// for a dense set of small bit maps without a fixed upper bound (e.g: a
|
|
// pointer map description of a stack).
|
|
class BitmapBuilder : public ZoneAllocated {
|
|
public:
|
|
BitmapBuilder()
|
|
: length_(0),
|
|
data_size_in_bytes_(kInitialSizeInBytes),
|
|
data_(ThreadState::Current()->zone()->Alloc<uint8_t>(
|
|
kInitialSizeInBytes)) {
|
|
memset(data_, 0, kInitialSizeInBytes);
|
|
}
|
|
|
|
intptr_t Length() const { return length_; }
|
|
void SetLength(intptr_t length);
|
|
|
|
// Get/Set individual bits in the bitmap, setting bits beyond the bitmap's
|
|
// length increases the length and expands the underlying bitmap if
|
|
// needed.
|
|
bool Get(intptr_t bit_offset) const;
|
|
void Set(intptr_t bit_offset, bool value);
|
|
|
|
// Return the bit offset of the highest bit set.
|
|
intptr_t Maximum() const;
|
|
|
|
// Return the bit offset of the lowest bit set.
|
|
intptr_t Minimum() const;
|
|
|
|
// Sets min..max (inclusive) to value.
|
|
void SetRange(intptr_t min, intptr_t max, bool value);
|
|
|
|
void Print() const;
|
|
void AppendAsBytesTo(GrowableArray<uint8_t>* bytes) const;
|
|
|
|
private:
|
|
static const intptr_t kInitialSizeInBytes = 16;
|
|
static const intptr_t kIncrementSizeInBytes = 16;
|
|
|
|
bool InRange(intptr_t offset) const {
|
|
if (offset < 0) {
|
|
FATAL1(
|
|
"Fatal error in BitmapBuilder::InRange :"
|
|
" invalid bit_offset, %" Pd "\n",
|
|
offset);
|
|
}
|
|
return (offset < length_);
|
|
}
|
|
|
|
// Get/Set a bit that is known to be covered by the backing store.
|
|
bool GetBit(intptr_t bit_offset) const;
|
|
void SetBit(intptr_t bit_offset, bool value);
|
|
|
|
intptr_t length_;
|
|
|
|
// Backing store for the bitmap. Reading bits beyond the backing store
|
|
// (up to length_) is allowed and they are assumed to be false.
|
|
intptr_t data_size_in_bytes_;
|
|
uint8_t* data_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BitmapBuilder);
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_BITMAP_H_
|