Add internal duk_push_tval_readable() which summarizes a duk_tval into a human
readable, limited length sanitized string without side effects. It is useful
for summarizing values safely in e.g. error messages. The internal call is a
candidate for the public API later on (in a slightly different form).
Forcing tm_isdst to 0 before mktime() and removing a previous DST check
after mktime() seems to work on Linux and should (potentially) fix a
RISC OS issue.
- Bug testcase for GH-413
- Testcase for removing octal autodetection in parseInt()
Fix expect string of numconv parseInt() testcase to match E5.1 behavior.
Figuring out an effective 'this' value happens for every call. The previous
implementation for non-strict functions used stack API calls. The reworked
implementation accesses the value stack directly which matters for this
performance critical code path.
Reorder tags to accommodate a separate 'unused' tag so that 'undefined' can
become a single tag write (instead of tag + value like booleans). This is
good because 'undefined' values are involved in e.g. value stack resizes and
are performance relevant.
Also reorder tags so that "is heap allocated" check can be a single bit test
instead of a comparison when using non-packed duk_tval. This makes every
DECREF potentially faster because an "is heap allocated" test appears in
every DECREF.
Because "unused" is not intended to appear anywhere in actual use (e.g. as
a value stack value, as a property value, etc), "unused" values will fall
into the default clause of DUK_TAG_xxx switch case statements. Add an assert
to every such default clause that the value is not intended to be "unused".
Remove duk_push_unused() as it should no longer be used. It was only used
by the debugger protocol; refuse an inbound "unused" value in the debugger.
This is not breaking compatibility because there was no legitimate usage for
the debug client sending requests with "unused" values.
'Leave as undefined' seems to be the best overall value stack initialization
policy. While 'leave as garbage' is marginally better in a few cases (mostly
when refcounting is disabled) it's probably not worth keeping two policies
around.
Change the current value stack policy from "unused above top" to either
"undefined above top" or "garbage above top", depending on a config
option. Change mark-and-sweep and debug print code to only process
entries between [0,top[ in either case.
Both policies have potential upsides and downsides based on performance
measurement. This commit provides both policies; "undefined above top"
will probably be the only policy left however, because "garbage above
top" is only better in a few cases and mostly without refcounts.
Other minor improvements:
- Rework index validation to use duk_uidx_t and more shared code.
- Add cached thr->valstack_size value