Previously _Varmap was kept if any slow path accesses were made. Improve this
behavior so that, in the absence of eval() etc, safe slow path accesses are
allowed while still dropping the _Varmap. A safe slow path access is one that
doesn't match any of the statically declared variables in the function so that
(again assuming no new variables are declared by e.g. eval()) the varmap won't
be needed at runtime.
Allow dropping of _Formals even in presence of eval() or a potentially
dangerous slow path access if _Formals is empty *and* _Formals.length matches
nargs so that .length computation works out even without _Formals.
Also reduce initial bytecode allocation from 2kB to 256 bytes when
DUK_USE_PREFER_SIZE is defined (in absence of a more specific define).
String output must either (a) eval() back as an equivalent object, OR
(b) eval() to a SyntaxError.
Previous Duktape output, conformant to ES5/ES5.1, matched FunctionDeclaration
syntax but didn't parse back as an equivalent function.
Rename and reuse a previously internal duk_push_object_internal() which just
pushes a bare object (= object without an internal prototype) which is useful
for various dict / tracking map purposes.
* Remove 'enumerate' trap.
* Use 'ownKeys' trap for "for-in" too, as specified in ES7.
* Add enumerability check for 'ownKeys' result when used in for-in or
Object.keys(). Because there's no support for 'getOwnPropertyDescriptor'
trap yet, the check will always operate directly on the target object.
* Callstack index is required for most debug commands which accept one
* Index comes before other parameters, e.g. Eval has the signature:
REQ 0x1e <index> <code>
* Eval accepts null for the callstack index, indicating an indirect
eval.
Side effects may include finalizers which operate on the object and may thus
invalidate the 'e_idx' we've looked up. Fix by operating with NORZ macros and
using a single refzero check.
Also provide explicit fast / slow (small) variants for fastint downgrade
check: it doesn't make sense to inline the very large check except in the
hot paths of executor and call handling. Elsewhere it's better to save
footprint and thus code cache.
Uses Kahan summation combined with normalization to avoid overflow and
minimize rounding errors. The algorithm is based on V8's implementation
(without actually sharing any code).
Also some small performance optimization, e.g. when getting enumerates keys
(Object.keys() et al) write the keys into a preallocated dense array which is
allocated directly to size.
These can be used whenever we're 100% certain that the value stack index
exists and the type matches expected type. When these are true, a
duk_hstring, duk_hbuffer, or duk_hobject pointer fetch can be inlined to
small code.