I've been looking into how we represent JS objects (needed in various
cases like callbacks) in DOM bindings. Right now we extract a JSObject*
from the JS::Value and then pass it into the C++ method. This is
clearly suboptimal in the moving GC world.
I believe I have several options at this point:
1) Just pass in the JS::Value& (after verifying that it's isObject()).
Pros: it's already rooted, nothing else to do. Cons: On the callee
side it's not obvious that this is guaranteed to be an ObjectValue. Or
maybe it's an ObjectOrNullValue? The callee has to rely on some sort of
out-of-band information to tell.
2) Put a RootedObject on the stack and pass a HandleObject to my
callee. This incurs a bit more of a performance penalty, and it's still
not clear how I make a distinction between "object" and "object or null".
Does it make any sense to make things like ObjectValue subclasses of
Value instead of just functions, so I could use ObjectValue& or
ObjectOrNullValue& or whatnot as an argument? Or should I just stick
with RootedObject? If I do that, what are my options for being able to
distinguish between nullable and non-nullable objects?