summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Heap/Heap.cpp
AgeCommit message (Collapse)Author
2020-05-23LibJS: Use __APPLE__ instead of __MACH__ for MacOS buildMarcin Gasperowicz
This is regarding PR #234. Sergey pointed out that not every Mach is Darwin.
2020-05-23Build: Make Lagom build under macOS (#2341)Marcin Gasperowicz
Lagom now builds under macOS. Only two minor adjustments were required: * LibCore TCP/UDP code can't use `SOCK_{NONBLOCK,CLOEXEC}` on macOS, use ioctl() and fcntl() instead * LibJS `Heap` code pthread usage ported to MacOS
2020-05-08LibJS: Be a bit more explicit about sizeof(buf) / sizeof(FlatPtr)AnotherTest
This (seemingly) no-op cast communicates our intention to clang
2020-05-05LibJS: run clang-format on all the filesEmanuele Torre
2020-04-19LibJS: Add MarkedValueList and use it for argument passingAndreas Kling
A MarkedValueList is basically a Vector<JS::Value> that registers with the Heap and makes sure that the stored values don't get GC'd. Before this change, we were unsafely keeping Vector<JS::Value> in some places, which is out-of-reach for the live reference finding logic since Vector puts its elements on the heap by default. We now pass all the JavaScript tests even when running with "js -g", which does a GC on every heap allocation.
2020-04-19LibJS: Add DeferGC, a RAII way to prevent GC temporarilyAndreas Kling
2020-04-16LibJS: Allow cells to mark null pointersAndreas Kling
This simplifies the cell visiting functions by letting them not worry about the pointers they pass to the visitor being null.
2020-04-10LibJS: Throw real TypeError, ReferenceError, etc objectsAndreas Kling
Instead of just throwing Error objects with a name string, we now throw the real Error subclass types. :^)
2020-04-06LibJS: Do a garbage collection every N allocations (N=10'000)Andreas Kling
To prevent the heap from growing infinitely large, we now do a full GC every 10'000 allocations. :^)
2020-03-25LibJS: Disable HEAP_DEBUG logging on non-SerenityOS platformsAndreas Kling
This makes it a bit easier to work with LibJS on Linux for now.
2020-03-23LibJS: Always collect all garbage when destroying HeapAndreas Kling
When the Heap is going down, it's our last chance to run destructors, so add a separate collector mode where we simply skip over the marking phase and go directly to sweeping. This causes everything to get swept and all live cells get destroyed. This way, valgrind reports 0 leaks on exit. :^)
2020-03-23LibJS: Put some more Heap debug logging behind HEAP_DEBUGAndreas Kling
2020-03-23LibJS: Port garbage collector to LinuxAndreas Kling
Well that was easy. LibJS can now run on Linux :^)
2020-03-21LibJS: Round cell sizes up to a multiple of 16 bytesAndreas Kling
This increases HeapBlock utilization significantly (and reduces overall memory usage.)
2020-03-21LibJS: Delete fully-empty HeapBlocks after garbage collectionAndreas Kling
We now deallocate GC blocks when they are found to have no live cells inside them.
2020-03-18LibJS: Add Handle<T>, a strong C++ handle for keeping GC objects aliveAndreas Kling
This is pretty heavy and unoptimized, but it will do the trick for now. Basically, Heap now has a HashTable<HandleImpl*> and you can call JS::make_handle(T*) to construct a Handle<T> that guarantees that the pointee will always survive GC until the Handle<T> is destroyed.
2020-03-16LibJS+js: Add a debug option (js -g) to GC after every allocationAndreas Kling
This is very useful for discovering collector bugs.
2020-03-16LibJS: Implement basic conservative garbage collectionAndreas Kling
We now scan the stack and CPU registers for potential pointers into the GC heap, and include any valid Cell pointers in the set of roots. This works pretty well but we'll also need to solve marking of things passed to native functions, since those are currently in Vector<Value> and the Vector storage is on the heap (not scanned.)
2020-03-16LibJS: Add "Heap" and "Runtime" subdirectoriesAndreas Kling
Let's try to keep LibJS tidy as it expands. :^)