Commit ee98c06
Replace hermes Allocator with LLVM Allocator and add pushScope/popScope support
Summary:
Replace our BumpPtrAllocator with the one from LLVM, since it supports
dynamically changing slab size and has support of ASAN/MSAN. I made
some changes to add back the functionality of our own allocator:
1. A State struct to record the current pointer into the current
stab and its index when the State instance is created.
2. `pushScope()` method to create a new State and linked to previous
State.
3. `popScope()` method to delete the current State and restore to
previous State.
4. A RAII type `AllocationScope` to automatically call
`pushScope()`/`popScope()` when its lifetime begins/ends.
5. Change the initial Slab size to 16KB, since modern OSs commonly use
16KB page.
The scope support is slightly different from our own allocator in three
aspects:
1. The new implementation stores custom slabs (for huge allocations)
in BumpPtrAllocator, while in old implementation it's stored in each
State object.
2. The new State works like a snapshot, i.e., recording the status of
BumpPtrAllocator when the state is created, and restore to this status
when the State is out of scope. In old implementation, the current
active slab index and allocation offset is stored directly into State.
When a State is destroyed, previous State becomes the current and its
fields are used in new allocation.
3. The old implementation has slow path for allocation while everything
is inline in the new version.
I kept these changes in order to not change the original LLVM
implementation too much.
Reviewed By: avp
Differential Revision: D91661188
fbshipit-source-id: 2e7e86863a544f9f5a0ac1753af91b64b68806781 parent 6c23501 commit ee98c06
File tree
3 files changed
+551
-142
lines changed- include/hermes/Support
- lib/Support
3 files changed
+551
-142
lines changed
0 commit comments