[heap] Add proper rebind support to StrongRootBlockAllocator
MSVC's STL in debug mode rebinds the allocator passed to vectors to allocate helper structures, so we need StrongRootBlockAllocator to have proper rebind support rather than assuming it always rebinds to Address. Bug: v8:11241 Change-Id: I15688e43fe2c71ec4ff0c287a03e36ca57427417 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2622915 Auto-Submit: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#72060}
This commit is contained in:
parent
e61272a4b7
commit
deb0813166
@ -2649,10 +2649,7 @@ class StrongRootBlockAllocator {
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
template <class U>
|
||||
struct rebind {
|
||||
STATIC_ASSERT((std::is_same<Address, U>::value));
|
||||
using other = StrongRootBlockAllocator;
|
||||
};
|
||||
struct rebind;
|
||||
|
||||
explicit StrongRootBlockAllocator(Heap* heap) : heap_(heap) {}
|
||||
|
||||
@ -2663,6 +2660,23 @@ class StrongRootBlockAllocator {
|
||||
Heap* heap_;
|
||||
};
|
||||
|
||||
// Rebinding to Address gives another StrongRootBlockAllocator.
|
||||
template <>
|
||||
struct StrongRootBlockAllocator::rebind<Address> {
|
||||
using other = StrongRootBlockAllocator;
|
||||
};
|
||||
|
||||
// Rebinding to something other than Address gives a std::allocator that
|
||||
// is copy-constructable from StrongRootBlockAllocator.
|
||||
template <class U>
|
||||
struct StrongRootBlockAllocator::rebind {
|
||||
class other : public std::allocator<U> {
|
||||
public:
|
||||
// NOLINTNEXTLINE
|
||||
other(const StrongRootBlockAllocator&) {}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user