In before, each function reference created 5 functions needed only
for equals/hashcode properties. It contributed arround 3.5% of code size
on several sample projects. This is now replaced by passing constant
object to base class constructor.
The existing threshold for determining between medium and large page
does not take the dummy block into account, meaning that an allocation
on the threshold will lead to a loop that only terminates when the
process goes out of memory.
Co-authored-by: Troels Lund <troels@google.com>
Merge-request: KOTLIN-MR-618
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
* Make CustomFinalizerProcessor mirror the existing FinalizerProcessor
* Fix Heap::PrepareForGC in custom allocator
Merge-request: KOTLIN-MR-616
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
This commit adds finalizers to the custom allocator. Compared to the
existing solution:
* The finalizer queue is replaced by an AtomicStack<ExtraObjectData>.
* All objects with finalizers get meta objects attached. This was not
previously the case for CleanerImpl, but is now needed to link objects
together in the finalization queue.
* The finalizer queue is built during SweepExtraObjects, instead of
during regular sweeping.
* Cleaners are executed by the finalizer thread, and no longer by a
separate worker thread.
Co-authored-by: Troels Lund <troels@google.com>
Merge-request: KOTLIN-MR-592
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
This change avoids looping through the source stack, looking for the
last element, in the case where the target stack is empty. This could
matter in two places:
* when merging ready_ and used_ into unswept_ in PrepareForGC. The first
of these will be faster with this change.
* when merging finalizer queues (in CR-592, not merged yet), where we
expect the target queue to be empty.
Since we can expect used_ to be larger than ready_, since we are about
to do a GC, the order of these two has also been reversed.
Co-authored-by: Troels Lund <troels@google.com>
Merge-request: KOTLIN-MR-599
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
The default behavior on a sweep is to push empty pages into a separate
stack, which will be freed if not used before the next GC starts. This
serves two purposes: it reduces the number of system allocations, and it
avoids a race condition inside AtomicStack::Pop.
Neither of these are relevant for LargePages, since LargePages are never
reused and it is only the GC thread that calls
AtomicStack<LargePage>::Pop. The change is to free LargePages
immediately instead of waiting for the next GC cycle.
Co-authored-by: Troels Lund <troels@google.com>
Merge-request: KOTLIN-MR-598
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
In before thread waiting for finalizers done could be unsuspended
before statistics about finalization is written.
Probably it doesn't affect real code, but it can lead to test failures.
Enable custom allocator with -Xallocator=custom.
If the gc is cms (default):
* a patched version of the memory manager is used that does not build a
list of allocated objects.
* a patched version of the cms is used that defers to the allocator for
sweeping.
Otherwise, a warning is printed, and the allocator is used using the
standard api.
Design doc:
https://docs.google.com/document/d/15xMp-nE-DWL8OrtOc8DoXB80AHUphFICEGjj5K0aNFc
Co-authored-by: Troels Lund <troels@google.com>
Merge-request: KOTLIN-MR-546
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
Calls checker was trying to read thread state while unlocking mutex in
unregister thread function. At this point thread is already
unregistered and reference to current thread node is dangling.
To avoid this, we nullify this reference in advance, as its anyway
explicitly passed to unregister function, not read from global.
If the count argument is above 2**29, then memberSize does not fit in
uint32_t.
Co-authored-by: Troels Lund <troels@google.com>
Merge-request: KOTLIN-MR-533
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
* Add fallible push to intrusive_forward_list.
* Add fallible pop to intrusive_forward_list.
* Get rid of size_ member in intrusive_forward_list.
* Force all intrusive_forward_list items to have non-null next().
* Get rid of explicit colors in STMS and CMS.
* Do not queue weak reference for later processing in Mark.
Merge-request: KT-MR-7263
Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
- Introduce ComparableTimeMark interface extending TimeMark,
and TimeSource.WithComparableMarks - a time source that returns such time marks.
- Implement ComparableTimeMark in ValueTimeMark and AbstractLong/DoubleTimeMark classes.