mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.2 KiB
28 lines
1.2 KiB
define: DUK_USE_NATIVE_STACK_CHECK
|
|
introduced: 2.4.0
|
|
default: false
|
|
tags:
|
|
- portability
|
|
- execution
|
|
description: >
|
|
Provide a macro hook to check for available native stack space for the
|
|
currently executing native thread. The macro must evaluate to zero if
|
|
there is enough stack space available and non-zero otherwise; a RangeError
|
|
will then be thrown.
|
|
|
|
The macro is performance sensitive. It should ideally have a fast path,
|
|
e.g. a stack pointer range comparison, and a slow path handling
|
|
initialization, detecting stack resizes, thread changes, etc.
|
|
|
|
The definition of "enough space" depends on the target platform and the
|
|
compiler because the size of native stack frames cannot be easily known
|
|
in advance. As a relatively safe estimate, one can check for 8kB of
|
|
available stack.
|
|
|
|
Duktape doesn't call this macro for every internal native call. The macro
|
|
is called in code paths that are involved in potentially unlimited
|
|
recursion (such as making Ecmascript/native function calls, invoking
|
|
getters and Proxy traps, and resolving Proxy chains) and code paths
|
|
requiring a lot of stack space temporarily. Even so the macro is called
|
|
very frequently, and unless the check is fast, performance will be visibly
|
|
impacted.
|
|
|