From 077eaeb4e7d61d5b18fd44744d3b2650fb34fad1 Mon Sep 17 00:00:00 2001 From: mnegyokru <69792667+mnegyokru@users.noreply.github.com> Date: Thu, 23 Dec 2021 11:30:19 +0100 Subject: [PATCH] Update build profile to es.next on esp8266 (#4913) - fix amalgam build issue with es.next profile - update esp linker script according to: Table 4-1. in https://www.espressif.com/sites/default/files/documentation/2a-esp8266-sdk_getting_started_guide_en.pdf JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru negyokru@inf.u-szeged.hu --- jerry-core/parser/js/js-parser.c | 98 +++++++++++-------- .../esp8266-rtos-sdk/Makefile.esp8266 | 2 +- .../esp8266-rtos-sdk/ld/eagle.app.v6.ld | 2 +- 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index f1a139870..4872e4c47 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -1971,6 +1971,59 @@ JERRY_STATIC_ASSERT (PARSER_SCANNING_SUCCESSFUL == PARSER_HAS_LATE_LIT_INIT, parser_scanning_successful_should_share_the_bit_position_with_parser_has_late_lit_init); #endif /* !JERRY_NDEBUG */ +/** + * Parser script size + */ +static size_t +parser_script_size (parser_context_t *context_p) /**< context */ +{ + size_t script_size = sizeof (cbc_script_t); + + if (context_p->user_value != ECMA_VALUE_EMPTY) + { + script_size += sizeof (ecma_value_t); + } + +#if JERRY_FUNCTION_TO_STRING + if (context_p->argument_list != ECMA_VALUE_EMPTY) + { + script_size += sizeof (ecma_value_t); + } +#endif /* JERRY_FUNCTION_TO_STRING */ + +#if JERRY_MODULE_SYSTEM + if (context_p->global_status_flags & ECMA_PARSE_INTERNAL_HAS_IMPORT_META) + { + script_size += sizeof (ecma_value_t); + } +#endif /* JERRY_MODULE_SYSTEM */ + return script_size; +} /* parser_script_size */ + +#if JERRY_SOURCE_NAME +/** + * Parser resource name + */ +static ecma_value_t +parser_source_name (parser_context_t *context_p) /**< context */ +{ + if (context_p->options_p != NULL && (context_p->options_p->options & JERRY_PARSE_HAS_SOURCE_NAME)) + { + JERRY_ASSERT (ecma_is_value_string (context_p->options_p->source_name)); + + ecma_ref_ecma_string (ecma_get_string_from_value (context_p->options_p->source_name)); + return context_p->options_p->source_name; + } + + if (context_p->global_status_flags & ECMA_PARSE_EVAL) + { + return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_EVAL); + } + + return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); +} /* parser_source_name */ +#endif /* JERRY_SOURCE_NAME */ + /** * Parse and compile EcmaScript source code * @@ -2108,22 +2161,6 @@ parser_parse_source (void *source_p, /**< source code */ context.user_value = context.options_p->user_value; } -#if JERRY_SOURCE_NAME - ecma_value_t source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); - - if (context.options_p != NULL && (context.options_p->options & JERRY_PARSE_HAS_SOURCE_NAME)) - { - JERRY_ASSERT (ecma_is_value_string (context.options_p->source_name)); - - ecma_ref_ecma_string (ecma_get_string_from_value (context.options_p->source_name)); - source_name = context.options_p->source_name; - } - else if (context.global_status_flags & ECMA_PARSE_EVAL) - { - source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_EVAL); - } -#endif /* JERRY_SOURCE_NAME */ - context.last_context_p = NULL; context.last_statement.current_p = NULL; context.token.flags = 0; @@ -2197,27 +2234,6 @@ parser_parse_source (void *source_p, /**< source code */ return NULL; } - size_t script_size = sizeof (cbc_script_t); - - if (context.user_value != ECMA_VALUE_EMPTY) - { - script_size += sizeof (ecma_value_t); - } - -#if JERRY_FUNCTION_TO_STRING - if (context.argument_list != ECMA_VALUE_EMPTY) - { - script_size += sizeof (ecma_value_t); - } -#endif /* JERRY_FUNCTION_TO_STRING */ - -#if JERRY_MODULE_SYSTEM - if (context.global_status_flags & ECMA_PARSE_INTERNAL_HAS_IMPORT_META) - { - script_size += sizeof (ecma_value_t); - } -#endif /* JERRY_MODULE_SYSTEM */ - if (context.arguments_start_p == NULL) { context.source_p = context.source_start_p; @@ -2249,7 +2265,7 @@ parser_parse_source (void *source_p, /**< source code */ PARSER_TRY (context.try_buffer) { - context.script_p = parser_malloc (&context, script_size); + context.script_p = parser_malloc (&context, parser_script_size (&context)); CBC_SCRIPT_SET_TYPE (context.script_p, context.user_value, CBC_SCRIPT_REF_ONE); @@ -2263,7 +2279,7 @@ parser_parse_source (void *source_p, /**< source code */ #endif /* JERRY_BUILTIN_REALMS */ #if JERRY_SOURCE_NAME - context.script_p->source_name = source_name; + context.script_p->source_name = parser_source_name (&context); #endif /* JERRY_SOURCE_NAME */ ECMA_SET_INTERNAL_VALUE_POINTER (context.script_value, context.script_p); @@ -2437,7 +2453,7 @@ parser_parse_source (void *source_p, /**< source code */ if (context.script_p != NULL) { JERRY_ASSERT (context.script_p->refs_and_type >= CBC_SCRIPT_REF_ONE); - jmem_heap_free_block (context.script_p, script_size); + jmem_heap_free_block (context.script_p, parser_script_size (&context)); } } PARSER_TRY_END @@ -2512,6 +2528,7 @@ parser_parse_source (void *source_p, /**< source code */ ecma_value_t err_str_val = ecma_make_string_value (err_str_p); ecma_value_t line_str_val = ecma_make_uint32_value (context.token.line); ecma_value_t col_str_val = ecma_make_uint32_value (context.token.column); + ecma_value_t source_name = parser_source_name (&context); ecma_raise_standard_error_with_format (JERRY_ERROR_SYNTAX, "% [%:%:%]", @@ -2520,6 +2537,7 @@ parser_parse_source (void *source_p, /**< source code */ line_str_val, col_str_val); + ecma_free_value (source_name); ecma_free_value (col_str_val); ecma_free_value (line_str_val); ecma_deref_ecma_string (err_str_p); diff --git a/targets/baremetal-sdk/esp8266-rtos-sdk/Makefile.esp8266 b/targets/baremetal-sdk/esp8266-rtos-sdk/Makefile.esp8266 index f29583994..a2a7277ba 100644 --- a/targets/baremetal-sdk/esp8266-rtos-sdk/Makefile.esp8266 +++ b/targets/baremetal-sdk/esp8266-rtos-sdk/Makefile.esp8266 @@ -52,7 +52,7 @@ jerry: -DENABLE_AMALGAM=ON \ -DJERRY_MATH=ON \ -DJERRY_CMDLINE=OFF \ - -DJERRY_PROFILE="es5.1" \ + -DJERRY_PROFILE="es.next" \ -DEXTERNAL_COMPILE_FLAGS="$(ESP_CFLAGS)" \ -DJERRY_GLOBAL_HEAP_SIZE=$(JERRYHEAP) diff --git a/targets/baremetal-sdk/esp8266-rtos-sdk/ld/eagle.app.v6.ld b/targets/baremetal-sdk/esp8266-rtos-sdk/ld/eagle.app.v6.ld index 07942c68a..b52bd4d00 100644 --- a/targets/baremetal-sdk/esp8266-rtos-sdk/ld/eagle.app.v6.ld +++ b/targets/baremetal-sdk/esp8266-rtos-sdk/ld/eagle.app.v6.ld @@ -26,7 +26,7 @@ MEMORY dport0_0_seg : org = 0x3FF00000, len = 0x10 dram0_0_seg : org = 0x3FFE8000, len = 0x18000 iram1_0_seg : org = 0x40100000, len = 0x8000 - irom0_0_seg : org = 0x40220000, len = 0x7C000 + irom0_0_seg : org = 0x40220000, len = 0xBC000 } INCLUDE ../ld/eagle.app.v6.common.ld