• Hernando Castano's avatar
    Add Bump Allocator (#831) · 5fd8f876
    Hernando Castano authored
    * Add bump allocator skeleton
    * Implement `alloc` for our bump allocator
    * Make the allocator usable globally
    * Remove unused `init()` function
    * Nightly RustFmt
    * Use global mutable static instead of Mutex
    This will reduce our use of dependencies which will hopefully
    reduce our final Wasm binary size.
    Also, apparently spinlocks aren't actually all that efficient.
    See: https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html
    * Stop assuming that memory is allocated at address `0`
    * Remove semicolon
    * Use correct address when checking if we're OOM
    * Remove unnecessary unsafe block
    * Return null pointers instead of panicking
    Panicking in the global allocator is considered undefined behaviour.
    * Use `checked_add` when getting upper limit memory address
    * Use `MAX` associated const instead of `max_value`
    * Inline `GlobalAlloc` methods
    * Turns out I can't early return from `unwrap_or_else` 🤦
    * Rollback my build script hacks
    * Add initialization function to allocator
    * Add some docs
    * Make the bump allocator the default allocator
    * Allow bump allocator to be tested on Unix platforms
    * Remove unecessary checked_add
    * Add error messages to unrecoverable errors
    * Remove `init` function from allocator
    Instead we now request a new page whenver we need it, regardless
    of whether or not it's the first time we're allocating memory.
    * Try switching from `mmap` to `malloc` when in `std` env
    * Fix `is_null()` check when requesting memory
    * Stop requesting real memory for `std` testing
    Instead this tracks pages internally in the same way that the Wasm
    environment would. This means we can test our allocator implementation
    instead of fighting with `libc`.
    * Gate the global bump allocator when not in `std`
    * Allow for multi-page allocations
    * Update the module documentation
    * Override `alloc_zeroed` implementation
    * Forgot to update Wasm target function name
    * Appease the spellchecker
    * Use proper English I guess
    * Get rid of `page_requests` field
    * Explicitly allow test builds to use test implementation
    * All link to zero'd Wasm memory reference
    * Check that our initial pointer is 0 in a test
    * Add `cfg_if` branch for non-test, `std` enabled builds
    * Simplify `cfg_if` statement
This project manages its dependencies using Cargo. Learn more