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:
+3
-11
@@ -120,6 +120,8 @@ def get_arguments():
|
||||
help='enable logging (%(choices)s)')
|
||||
coregrp.add_argument('--mem-heap', metavar='SIZE', type=int,
|
||||
help='size of memory heap (in kilobytes)')
|
||||
coregrp.add_argument('--stack-limit', metavar='SIZE', type=int,
|
||||
help='maximum stack usage (in kilobytes)')
|
||||
coregrp.add_argument('--mem-stats', metavar='X', choices=['ON', 'OFF'], type=str.upper,
|
||||
help=devhelp('enable memory statistics (%(choices)s)'))
|
||||
coregrp.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], type=str.upper,
|
||||
@@ -128,10 +130,6 @@ def get_arguments():
|
||||
help='specify profile file')
|
||||
coregrp.add_argument('--regexp-strict-mode', metavar='X', choices=['ON', 'OFF'], type=str.upper,
|
||||
help=devhelp('enable regexp strict mode (%(choices)s)'))
|
||||
coregrp.add_argument('--regexp-recursion-limit', metavar='N', type=int,
|
||||
help='regexp recursion depth limit')
|
||||
coregrp.add_argument('--call-stack-limit', metavar='N', type=int,
|
||||
help='Function call recursion depth limit')
|
||||
coregrp.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], type=str.upper,
|
||||
help=devhelp('enable parser byte-code dumps (%(choices)s)'))
|
||||
coregrp.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], type=str.upper,
|
||||
@@ -156,11 +154,6 @@ def get_arguments():
|
||||
parser.print_help()
|
||||
sys.exit(0)
|
||||
|
||||
if arguments.call_stack_limit:
|
||||
if arguments.call_stack_limit < 0:
|
||||
print ('Configuration error: Function call recursion limit must be greater or equal than 0')
|
||||
sys.exit(1)
|
||||
|
||||
return arguments
|
||||
|
||||
def generate_build_options(arguments):
|
||||
@@ -202,12 +195,11 @@ def generate_build_options(arguments):
|
||||
build_options_append('JERRY_LINE_INFO', arguments.line_info)
|
||||
build_options_append('JERRY_LOGGING', arguments.logging)
|
||||
build_options_append('JERRY_GLOBAL_HEAP_SIZE', arguments.mem_heap)
|
||||
build_options_append('JERRY_STACK_LIMIT', arguments.stack_limit)
|
||||
build_options_append('JERRY_MEM_STATS', arguments.mem_stats)
|
||||
build_options_append('JERRY_MEM_GC_BEFORE_EACH_ALLOC', arguments.mem_stress_test)
|
||||
build_options_append('JERRY_PROFILE', arguments.profile)
|
||||
build_options_append('JERRY_REGEXP_STRICT_MODE', arguments.regexp_strict_mode)
|
||||
build_options_append('JERRY_REGEXP_RECURSION_LIMIT', arguments.regexp_recursion_limit)
|
||||
build_options_append('JERRY_CALL_STACK_LIMIT', arguments.call_stack_limit)
|
||||
build_options_append('JERRY_PARSER_DUMP_BYTE_CODE', arguments.show_opcodes)
|
||||
build_options_append('JERRY_REGEXP_DUMP_BYTE_CODE', arguments.show_regexp_opcodes)
|
||||
build_options_append('JERRY_SNAPSHOT_EXEC', arguments.snapshot_exec)
|
||||
|
||||
+10
-12
@@ -36,7 +36,7 @@ def skip_if(condition, desc):
|
||||
OPTIONS_PROFILE_MIN = ['--profile=minimal']
|
||||
OPTIONS_PROFILE_ES51 = [] # NOTE: same as ['--profile=es5.1']
|
||||
OPTIONS_PROFILE_ES2015 = ['--profile=es2015-subset']
|
||||
OPTIONS_CALL_STACK_LIMIT = ['--call-stack-limit=100']
|
||||
OPTIONS_STACK_LIMIT = ['--stack-limit=128']
|
||||
OPTIONS_DEBUG = ['--debug']
|
||||
OPTIONS_SNAPSHOT = ['--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on']
|
||||
OPTIONS_UNITTESTS = ['--unittests=on', '--jerry-cmdline=off', '--error-messages=on',
|
||||
@@ -68,22 +68,22 @@ JERRY_UNITTESTS_OPTIONS = [
|
||||
# Test options for jerry-tests
|
||||
JERRY_TESTS_OPTIONS = [
|
||||
Options('jerry_tests-es5.1',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_CALL_STACK_LIMIT),
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_STACK_LIMIT),
|
||||
Options('jerry_tests-es5.1-snapshot',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT + OPTIONS_CALL_STACK_LIMIT,
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT + OPTIONS_STACK_LIMIT,
|
||||
['--snapshot']),
|
||||
Options('jerry_tests-es5.1-debug',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_CALL_STACK_LIMIT),
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_STACK_LIMIT),
|
||||
Options('jerry_tests-es5.1-debug-snapshot',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT + OPTIONS_DEBUG + OPTIONS_CALL_STACK_LIMIT,
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_SNAPSHOT + OPTIONS_DEBUG + OPTIONS_STACK_LIMIT,
|
||||
['--snapshot']),
|
||||
Options('jerry_tests-es5.1-debug-cpointer_32bit',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_CALL_STACK_LIMIT
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_STACK_LIMIT
|
||||
+ ['--cpointer-32bit=on', '--mem-heap=1024']),
|
||||
Options('jerry_tests-es5.1-debug-external_context',
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_CALL_STACK_LIMIT + ['--external-context=on']),
|
||||
OPTIONS_PROFILE_ES51 + OPTIONS_DEBUG + OPTIONS_STACK_LIMIT + ['--external-context=on']),
|
||||
Options('jerry_tests-es2015_subset-debug',
|
||||
OPTIONS_PROFILE_ES2015 + OPTIONS_DEBUG + OPTIONS_CALL_STACK_LIMIT),
|
||||
OPTIONS_PROFILE_ES2015 + OPTIONS_DEBUG + OPTIONS_STACK_LIMIT),
|
||||
]
|
||||
|
||||
# Test options for jerry-test-suite
|
||||
@@ -157,10 +157,8 @@ JERRY_BUILDOPTIONS = [
|
||||
['--jerry-cmdline-test=on']),
|
||||
Options('buildoption_test-cmdline_snapshot',
|
||||
['--jerry-cmdline-snapshot=on']),
|
||||
Options('buildoption_test-regexp_recursion_limit',
|
||||
['--regexp-recursion-limit=1000']),
|
||||
Options('buildoption_test-vm_recursion_limit',
|
||||
OPTIONS_CALL_STACK_LIMIT),
|
||||
Options('buildoption_test-recursion_limit',
|
||||
OPTIONS_STACK_LIMIT),
|
||||
Options('buildoption_test-single-source',
|
||||
['--cmake-param=-DENABLE_ALL_IN_ONE_SOURCE=ON']),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user