The temporary array we use for sorting cannot be seen by the GC, and that
violates the constraint that all js_Value values must always be reachable
from the stack or global environment.
Temporarily turning off the GC will let us use the temporary array for
fast sorting using qsort(), without tripping over this violation.
Reduce memory use per property by not keeping the properties in two
parallel data structures. Maintaining the order of insertion is not
required by the spec, and is not a very useful feature.
Make sure to make a copy of the source pattern string.
A case we missed when adding short and memory strings to the runtime.
The code assumed all strings passed to it were either literal or interned.
When a userdata object is garbage collected, we should invoke a callback
to client code to let it know that the associated userdata pointer is no
longer in use.
Separate literal/interned and garbage collected string types in js_Value.
js_pushintern/js_tointern are convenience functions to push/pop strings and
automatically intern them (so that the string pointers are guaranteed to be
stable).
js_pushliteral should push stable strings (either interned or actual literals).
js_pushstring will copy the string into garbage collected memory.
The pointer returned by js_tostring is guaranteed to be stable only for as long as
the stack slot it came from remains untouched.
Some uses will always cause a string to be interned:
* Using it as a property name.
* Wrapping it in a new String() object.
* Strings returned by toString().
ToPrimitive must not clobber the stack, so the result has to be unrooted.
* Numbers converted to strings (by js_tostring)
Likewise, we have nowhere to store the temporary string here.
Passing in a scratch buffer to js_tostring could help this problem.
Mostly an issue with array accesses (OP_GETPROP, etc) so an auxiliary
function and we don't have to clutter the API needlessly.
Environments when calling a function were saved in a local variable.
Therefore the garbage collector did not see them in its list of roots
to follow, resulting in environments being freed while still in use.
When a function does not use eval, arguments, with and has no inner
functions it does not need a closure. We can call it without creating
a variable object if we store local variables on the stack instead.
A temporary measure, since POSIX regexes (a) don't have the same
syntax as javascript's regexes, and (b) don't work on UTF-8 (unless
the setlocale crap is configured correctly, and the implementation
supports it), and (c) doesn't work on windows.