LibJS: Always prefer freelist over lazy freelist if possible
If we're able to allocate cells from a freelist, we should always prefer that over the lazy freelist, since this may further defer faulting in additional memory for the HeapBlock. Thanks to @gunnarbeutner for pointing this out. :^)
This commit is contained in:
parent
6714cf3631
commit
aa857bcdeb
Notes:
sideshowbarker
2024-07-18 17:55:57 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/aa857bcdebc
1 changed files with 5 additions and 4 deletions
|
@ -29,12 +29,13 @@ public:
|
|||
|
||||
ALWAYS_INLINE Cell* allocate()
|
||||
{
|
||||
if (m_freelist) {
|
||||
VERIFY(is_valid_cell_pointer(m_freelist));
|
||||
return exchange(m_freelist, m_freelist->next);
|
||||
}
|
||||
if (has_lazy_freelist())
|
||||
return cell(m_next_lazy_freelist_index++);
|
||||
if (!m_freelist)
|
||||
return nullptr;
|
||||
VERIFY(is_valid_cell_pointer(m_freelist));
|
||||
return exchange(m_freelist, m_freelist->next);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void deallocate(Cell*);
|
||||
|
|
Loading…
Add table
Reference in a new issue