After upgrading to V8 8.6.337, with a 20 MB heap limit, the
near-heap-limit callback never gets called before V8 runs out of memory.
It turns out that this test exhibits memory allocation behavior which
produces so little actual garbage that 'scavenge' type garbage
collections make memory usage go up rather than down. Because of this,
V8 runs out of memory in the middle of a garbage collection cycle, after
it has already decided that there's no need to run the near-heap-limit
callback.
The issue is fixed by making sure that some actual garbage is produced
alongside with the retained objects that will eventually fill up the
heap.
Certain callbacks (e.g. `WasmLoadSourceMapCallback`) expect the
embedder to return a local handle (a `Local<String>` in this case), but
do not provide a `Local<Context>` as an argument, nor does it provide
any other argument that we might obtain a context from. This is not
unexpected - WASM execution as such is not tied to a context, and a
`Local<String>` can be created without a context too because it's a
primitive value that has no JavaScript prototype.
It turns out that using `v8::internal::MaybeObject` was, although
harmless, not appropriate here, because this function does not deal
deal with (potentially) weak handles.
* Merged all handle type implementations into one file ('handle.h').
* Made it so that `Global` handles cannot be empty.
* Renamed the `AsHandle` trait to `Handle`, and made it more generally
useful.
* Simplified how `PartialEq` is implemented for V8 heap objects and/or
the `Local`/`Global` handles that reference them.
Local handles never need to be mutable. This patch also rounds up the
last few places where we were still asking the user to pass an `&mut T`
to an API method.