Remove the special ecma-to-ecma call setup code and just use the normal
unprotected call setup code for that instead. Most of the code is the
same; just before calling into the bytecode executor check if the current
executor can be reused, and if so, indicate the situation using a special
return code.
Also remove internal duk_handle_call_protected() and implement all
protected API calls via duk_safe_call(). This reduces footprint and code
duplication further.
Rework call handling to use helpers more to make the call handling code
easier to follow.
Various other minor changer, e.g. DUK_OP_NEW is now DUK_OP_CONSCALL and
bytecode sets up the initial default instance.
Replaced #ifdefs with DUK_U64_CONSTANT and DUK_I64_CONSTANT macros for cleaner
code and to prevent future breakage, as suggested by svaarala.
Missed a few replacements. Added.
Last one.
Changed parameter name from x to a.
Split MinGW and MSVC typedefs for 64-bit types.
Added myself to list of code contributors.
Add support for 'new.target' expression without yet adding support for an
explicit newTarget which may differ from the constructor function being
called.
* Wrap checks to duk_require_stack() and variants.
* Wrap check to value stack grow.
* Add internal helper duk_set_top_and_wipe(); for now it's just two
duk_set_top() calls but can be optimized later.
* Make value stack and call stack limits configurable via DUK_USE_xxx
options. Also make value stack grow/shrink constants configurable.
* Rewrite value stack grow/shrink check primitives for better hot/cold path
handling.
* Use a proportional spare for grow and shrink sizes so that applications
needing a large value stack have fewer value stack resizes.
* Grow value stack allocation when entering a call or when explicitly requested
via e.g. duk_require_stack().
* Never shrink the value stack when entering a call, so that the unwind path
is guaranteed to have value stack to handle a protected call return. This
guarantee is only needed for protected call but is now applied to all calls
for simplicity.
* Don't perform a value stack shrink check at all in function return anymore.
It would be OK from protected call semantics perspective to do a shrink
attempt without throwing if it fails.
* Perform a value stack shrink check in mark-and-sweep only for now. When
emergency GC is running, shrink to a minimal size respecting current value
stack reserve.
The distinction matters when loading back: if _Formals was omitted, we don't
want to load back an empty _Formals array for a function template because it
then breaks function instance .length computation.
Move handling of the following opcodes into NOINLINE helpers to make the
main dispatch function smaller and a bit better performing:
* INITSET and INITGET
* TRYCATCH
* ENDTRY
* ENDCATCH
* ENDFIN
* INITENUM and NEXTENUM
duk_hbufobj validity assertions require that if the buf pointer is NULL,
the buffer length and offset are zero. This is violated by the shared
slice code because it sets ->length before allocating a buffer, and since an
allocation may trigger side effects, the assert may trigger in mark-and-sweep.
I don't think this causes issues besides an assert failure.
With ROM objects having REACHABLE always set, mark-and-sweep doesn't need a
specific ROM object check when deciding whether to mark an object or not:
the REACHABLE check causes the object not to be marked.