aboutsummaryrefslogtreecommitdiff
path: root/jerry-core/ecma/base/ecma-globals.h
diff options
context:
space:
mode:
authorPéter Gál <pgal.usz@partner.samsung.com>2021-07-15 14:02:53 +0200
committerGitHub <noreply@github.com>2021-07-15 14:02:53 +0200
commitd5a78396326cb03537d0d9d5bb9520dad2e417ee (patch)
treec5f62df45683ddbb61b05b12d127ca20cb953739 /jerry-core/ecma/base/ecma-globals.h
parent998e49a969d0ff38e9ccebc6dfb7937d2a006afc (diff)
Improve Proxy recrusion check in their internal methods. (#4568)
In some parts of Proxy internal methods the compiler can do a bit of tail call optimalization which would be ok, but the current stack limit check framework in Jerry uses the stack pointer to calculate the stack depth. This way of stack depth calculation is affected by the tail call optimalization (as the stack does not increase). By disabling the tail call optimalization at given points the stack limit calculation will work as expected. This causes a bit of stack overhead, but the Proxy in it self is a fairly big chunk of code and this stack limit would only be relevant if the Proxy already does recusion which already very edge case. The stack limit (--stack-limit=..) should be enabled to correctly report such stack depth errors. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
Diffstat (limited to 'jerry-core/ecma/base/ecma-globals.h')
-rw-r--r--jerry-core/ecma/base/ecma-globals.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h
index e9bb2497..7b2f70cf 100644
--- a/jerry-core/ecma/base/ecma-globals.h
+++ b/jerry-core/ecma/base/ecma-globals.h
@@ -2242,19 +2242,32 @@ typedef struct
#if (JERRY_STACK_LIMIT != 0)
/**
* Check the current stack usage. If the limit is reached a RangeError is raised.
+ * The macro argument specifies the return value which is usally ECMA_VALUE_ERROR or NULL.
*/
-#define ECMA_CHECK_STACK_USAGE() \
+#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
do \
{ \
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
{ \
- return ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
+ ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
+ return RETURN_VALUE; \
} \
} while (0)
+
+/**
+ * Specialized version of ECMA_CHECK_STACK_USAGE_RETURN which returns ECMA_VALUE_ERROR.
+ * This version should be used in most cases.
+ */
+#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN(ECMA_VALUE_ERROR)
#else /* JERRY_STACK_LIMIT == 0) */
/**
* If the stack limit is unlimited, this check is an empty macro.
*/
+#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE)
+
+/**
+ * If the stack limit is unlimited, this check is an empty macro.
+ */
#define ECMA_CHECK_STACK_USAGE()
#endif /* (JERRY_STACK_LIMIT != 0) */