Previously, each pair of promise resolving functions allocated a
dedicated AlreadyResolved GC cell to hold a single shared bool. Move the
bit onto the resolve function as a plain member, and have the reject
function reach it through a GC::Ptr back to its paired resolve function.
Every Promise allocates two PromiseResolvingFunction cells (resolve and
reject). Each cell stored an AK::Function holding a closure, but neither
closure captured anything beyond the Promise and AlreadyResolved already
present as cell fields.
Hoist the two closure bodies into static functions on Promise and
dispatch by a Kind enum on the cell. This removes the AK::Function
storage embedded in each cell along with its off-GC malloc'd closure
capture.
The special empty value (that we use for array holes, Optional<Value>
when empty and a few other other placeholder/sentinel tasks) still
exists, but you now create one via JS::js_special_empty_value() and
check for it with Value::is_special_empty_value().
The main idea here is to make it very unlikely to accidentally create an
unexpected special empty value.
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:
* JS::NonnullGCPtr -> GC::Ref
* JS::GCPtr -> GC::Ptr
* JS::HeapFunction -> GC::Function
* JS::CellImpl -> GC::Cell
* JS::Handle -> GC::Root
Now that the heap has no knowledge about a JavaScript realm and is
purely for managing the memory of the heap, it does not make sense
to name this function to say that it is a non-realm variant.
The main motivation behind this is to remove JS specifics of the Realm
from the implementation of the Heap.
As a side effect of this change, this is a bit nicer to read than the
previous approach, and in my opinion, also makes it a little more clear
that this method is specific to a JavaScript Realm.