Rework the engine's internal recursion limit (#2969)

This patch unifies the recursion limit checking for RegExp, function call and JSON as well.
Until now the limit was only a counter which was increased/decreased at certain points.
This counter has been substituted with a numeric limit which allows to restrict the stack usage.

This patch fixes #2963 and resolves the closed #2258 issue.

Co-authored-by: Gabor Loki loki@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-07-23 15:31:37 +02:00
committed by GitHub
parent f53dba1a3a
commit 4a9e185840
20 changed files with 156 additions and 216 deletions
+8 -3
View File
@@ -42,6 +42,11 @@
*/
#define CONFIG_MEM_HEAP_SIZE (JERRY_GLOBAL_HEAP_SIZE * 1024)
/**
* Maximum stack usage size in bytes
*/
#define CONFIG_MEM_STACK_LIMIT (JERRY_STACK_LIMIT * 1024)
/**
* Max heap usage limit
*/
@@ -169,9 +174,9 @@ struct jerry_context_t
* ECMAScript execution should be stopped */
#endif /* ENABLED (JERRY_VM_EXEC_STOP) */
#if defined (JERRY_CALL_STACK_LIMIT) && (JERRY_CALL_STACK_LIMIT != 0)
uint32_t function_call_counter; /**< Function call recursion counter */
#endif /* defined (JERRY_CALL_STACK_LIMIT) && (JERRY_CALL_STACK_LIMIT != 0) */
#if (JERRY_STACK_LIMIT != 0)
uintptr_t stack_base; /**< stack base marker */
#endif /* (JERRY_STACK_LIMIT != 0) */
#if ENABLED (JERRY_DEBUGGER)
uint8_t debugger_send_buffer[JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE]; /**< buffer for sending messages */