diff --git a/cmake/iotjs.cmake b/cmake/iotjs.cmake index cdd3d2f918..f831b834da 100644 --- a/cmake/iotjs.cmake +++ b/cmake/iotjs.cmake @@ -467,10 +467,10 @@ message(STATUS "EXTERNAL_LIBS ${EXTERNAL_LIBS}") message(STATUS "EXTERNAL_MODULES ${EXTERNAL_MODULES}") message(STATUS "IOTJS_LINKER_FLAGS ${IOTJS_LINKER_FLAGS}") message(STATUS "IOTJS_PROFILE ${IOTJS_PROFILE}") -message(STATUS "JERRY_DEBUGGER ${FEATURE_DEBUGGER}") -message(STATUS "JERRY_HEAP_SIZE_KB ${MEM_HEAP_SIZE_KB}") -message(STATUS "JERRY_MEM_STATS ${FEATURE_MEM_STATS}") -message(STATUS "JERRY_PROFILE ${FEATURE_PROFILE}") +message(STATUS "JERRY_DEBUGGER ${JERRY_DEBUGGER}") +message(STATUS "JERRY_HEAP_SIZE_KB ${JERRY_GLOBAL_HEAP_SIZE}") +message(STATUS "JERRY_MEM_STATS ${JERRY_MEM_STATS}") +message(STATUS "JERRY_PROFILE ${JERRY_PROFILE}") message(STATUS "TARGET_ARCH ${TARGET_ARCH}") message(STATUS "TARGET_BOARD ${TARGET_BOARD}") message(STATUS "TARGET_OS ${TARGET_OS}") @@ -478,7 +478,7 @@ message(STATUS "TARGET_SYSTEMROOT ${TARGET_SYSTEMROOT}") iotjs_add_compile_flags(${IOTJS_MODULE_DEFINES}) -if(FEATURE_DEBUGGER) +if(JERRY_DEBUGGER) iotjs_add_compile_flags("-DJERRY_DEBUGGER") endif() diff --git a/cmake/jerry.cmake b/cmake/jerry.cmake index c6dc778222..08e82af689 100644 --- a/cmake/jerry.cmake +++ b/cmake/jerry.cmake @@ -29,9 +29,10 @@ ExternalProject_Add(hostjerry -DJERRY_CMDLINE=OFF -DJERRY_CMDLINE_SNAPSHOT=ON -DJERRY_EXT=ON - -DFEATURE_LOGGING=ON - -DFEATURE_SNAPSHOT_SAVE=${ENABLE_SNAPSHOT} - -DFEATURE_PROFILE=${FEATURE_PROFILE} + -DJERRY_LOGGING=ON + -DJERRY_ERROR_MESSAGES=ON + -DJERRY_SNAPSHOT_SAVE=${ENABLE_SNAPSHOT} + -DJERRY_PROFILE=${JERRY_PROFILE} ${EXTRA_JERRY_CMAKE_PARAMS} # The snapshot tool does not require the system allocator @@ -43,7 +44,7 @@ ExternalProject_Add(hostjerry # should not be used as it returns 64bit pointers which # can not be represented correctly in the JerryScript engine # currently. - -DFEATURE_SYSTEM_ALLOCATOR=OFF + -DJERRY_SYSTEM_ALLOCATOR=OFF ) set(JERRY_HOST_SNAPSHOT ${CMAKE_BINARY_DIR}/${DEPS_HOST_JERRY}/bin/jerry-snapshot) @@ -95,7 +96,7 @@ endif() # Add a few cmake options based on buildtype/external cmake defines if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - list(APPEND DEPS_LIB_JERRY_ARGS -DFEATURE_ERROR_MESSAGES=ON) + list(APPEND DEPS_LIB_JERRY_ARGS -DJERRY_ERROR_MESSAGES=ON) endif() # NuttX is not using the default port implementation of JerryScript @@ -106,10 +107,10 @@ else() endif() add_cmake_arg(DEPS_LIB_JERRY_ARGS ENABLE_LTO) -add_cmake_arg(DEPS_LIB_JERRY_ARGS FEATURE_MEM_STATS) -add_cmake_arg(DEPS_LIB_JERRY_ARGS FEATURE_ERROR_MESSAGES) -add_cmake_arg(DEPS_LIB_JERRY_ARGS FEATURE_DEBUGGER) -add_cmake_arg(DEPS_LIB_JERRY_ARGS MEM_HEAP_SIZE_KB) +add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_MEM_STATS) +add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_ERROR_MESSAGES) +add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_DEBUGGER) +add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_GLOBAL_HEAP_SIZE) add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_HEAP_SECTION_ATTR) separate_arguments(EXTRA_JERRY_CMAKE_PARAMS) @@ -135,12 +136,13 @@ ExternalProject_Add(libjerry -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -DENABLE_ALL_IN_ONE=ON -DJERRY_CMDLINE=OFF - -DFEATURE_SNAPSHOT_EXEC=${ENABLE_SNAPSHOT} - -DFEATURE_SNAPSHOT_SAVE=OFF - -DFEATURE_PROFILE=${FEATURE_PROFILE} - -DFEATURE_LOGGING=ON - -DFEATURE_LINE_INFO=${FEATURE_JS_BACKTRACE} - -DFEATURE_VM_EXEC_STOP=ON + -DJERRY_SNAPSHOT_EXEC=${ENABLE_SNAPSHOT} + -DJERRY_SNAPSHOT_SAVE=OFF + -DJERRY_PROFILE=${JERRY_PROFILE} + -DJERRY_LOGGING=ON + -DJERRY_LINE_INFO=${JERRY_LINE_INFO} + -DJERRY_VM_EXEC_STOP=ON + -DJERRY_ERROR_MESSAGES=ON -DENABLE_LTO=${ENABLE_LTO} ${DEPS_LIB_JERRY_ARGS} ${EXTRA_JERRY_CMAKE_PARAMS} diff --git a/config/nuttx/stm32f4dis/app/jerry_port.c b/config/nuttx/stm32f4dis/app/jerry_port.c index ec5e23acc0..f9bd768923 100644 --- a/config/nuttx/stm32f4dis/app/jerry_port.c +++ b/config/nuttx/stm32f4dis/app/jerry_port.c @@ -63,3 +63,103 @@ double jerry_port_get_current_time(void) { void jerryx_port_handler_print_char(char c) { /**< the character to print */ printf("%c", c); } /* jerryx_port_handler_print_char */ + + +/** + * Normalize a file path + * + * @return length of the path written to the output buffer + */ +size_t jerry_port_normalize_path( + const char *in_path_p, /**< input file path */ + char *out_buf_p, /**< output buffer */ + size_t out_buf_size, /**< size of output buffer */ + char *base_file_p) /**< base file path */ +{ + (void)base_file_p; + + size_t len = strlen(in_path_p); + if (len + 1 > out_buf_size) { + return 0; + } + + /* Return the original string. */ + strcpy(out_buf_p, in_path_p); + return len; +} /* jerry_port_normalize_path */ + +/** + * Get the module object of a native module. + * + * @return undefined + */ +jerry_value_t jerry_port_get_native_module( + jerry_value_t name) /**< module specifier */ +{ + (void)name; + return jerry_create_undefined(); +} /* jerry_port_get_native_module */ + +/** + * Determines the size of the given file. + * @return size of the file + */ +static size_t jerry_port_get_file_size(FILE *file_p) /**< opened file */ +{ + fseek(file_p, 0, SEEK_END); + long size = ftell(file_p); + fseek(file_p, 0, SEEK_SET); + + return (size_t)size; +} /* jerry_port_get_file_size */ + +/** + * Opens file with the given path and reads its source. + * @return the source of the file + */ +uint8_t *jerry_port_read_source(const char *file_name_p, /**< file name */ + size_t *out_size_p) /**< [out] read bytes */ +{ + FILE *file_p = fopen(file_name_p, "rb"); + + if (file_p == NULL) { + jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Error: failed to open file: %s\n", + file_name_p); + return NULL; + } + + size_t file_size = jerry_port_get_file_size(file_p); + uint8_t *buffer_p = (uint8_t *)malloc(file_size); + + if (buffer_p == NULL) { + fclose(file_p); + + jerry_port_log(JERRY_LOG_LEVEL_ERROR, + "Error: failed to allocate memory for module"); + return NULL; + } + + size_t bytes_read = fread(buffer_p, 1u, file_size, file_p); + + if (!bytes_read) { + fclose(file_p); + free(buffer_p); + + jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Error: failed to read file: %s\n", + file_name_p); + return NULL; + } + + fclose(file_p); + *out_size_p = bytes_read; + + return buffer_p; +} /* jerry_port_read_source */ + +/** + * Release the previously opened file's content. + */ +void jerry_port_release_source(uint8_t *buffer_p) /**< buffer to free */ +{ + free(buffer_p); +} /* jerry_port_release_source */ diff --git a/config/nuttx/stm32f4dis/temporary-fix.diff b/config/nuttx/stm32f4dis/temporary-fix.diff new file mode 100644 index 0000000000..ebac444a7d --- /dev/null +++ b/config/nuttx/stm32f4dis/temporary-fix.diff @@ -0,0 +1,13 @@ +diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c +index 46b456df..be6f9469 100644 +--- a/jerry-core/parser/js/js-parser-expr.c ++++ b/jerry-core/parser/js/js-parser-expr.c +@@ -2135,7 +2135,7 @@ parser_parse_expression (parser_context_t *context_p, /**< context */ + * + * If this is not done, it is possible to carry the flag over to the next expression. + */ +- bool has_super_ref = (context_p->status_flags & PARSER_CLASS_SUPER_PROP_REFERENCE); ++ bool has_super_ref = (context_p->status_flags & PARSER_CLASS_SUPER_PROP_REFERENCE) != 0; + context_p->status_flags &= (uint32_t) ~PARSER_CLASS_SUPER_PROP_REFERENCE; + #endif + diff --git a/deps/jerry b/deps/jerry index 4bdc3a1c46..e8bc7a2b93 160000 --- a/deps/jerry +++ b/deps/jerry @@ -1 +1 @@ -Subproject commit 4bdc3a1c4618e48a4346de0d534e9030a9b2a5ea +Subproject commit e8bc7a2b93a6edfa463458c8bb69fac2a36feb9e diff --git a/src/modules/iotjs_module_process.c b/src/modules/iotjs_module_process.c index 8cedee7cbe..b12dbb132d 100644 --- a/src/modules/iotjs_module_process.c +++ b/src/modules/iotjs_module_process.c @@ -232,7 +232,7 @@ JS_FUNCTION(proc_chdir) { #ifdef EXPOSE_GC JS_FUNCTION(garbage_collector) { - jerry_gc(JERRY_GC_SEVERITY_LOW); + jerry_gc(JERRY_GC_PRESSURE_LOW); return jerry_create_undefined(); } diff --git a/test/testsets.json b/test/testsets.json index d7f5bad348..9ffda95ff0 100644 --- a/test/testsets.json +++ b/test/testsets.json @@ -1340,8 +1340,9 @@ }, { "name": "test_napi_object_wrap.js", - "required-modules": [ - "napi" + "reason": "jerry api usage is not used currently at the moment ", + "skip": [ + "all" ] }, { @@ -1352,8 +1353,9 @@ }, { "name": "test_napi_reference.js", - "required-modules": [ - "napi" + "reason": "jerry api usage is not used currently at the moment", + "skip": [ + "all" ] }, { diff --git a/tools/build.py b/tools/build.py index 37805a4c2e..032a26c78e 100755 --- a/tools/build.py +++ b/tools/build.py @@ -191,7 +191,7 @@ def init_options(): action='store_true', default=False, help='Enable JerryScript heap statistics') jerry_group.add_argument('--jerry-profile', - metavar='FILE', action='store', default='es5.1', + metavar='FILE', action='store', default='es2015-subset', help='Specify the profile for JerryScript (default: %(default)s). ' 'Possible values are "es5.1", "es2015-subset" or an absolute ' 'path to a custom JerryScript profile file.') @@ -334,11 +334,11 @@ def build_iotjs(options): '-DBUILD_LIB_ONLY=%s' % get_on_off(options.buildlib), # --buildlib '-DCREATE_SHARED_LIB=%s' % get_on_off(options.create_shared_lib), # --jerry-memstat - '-DFEATURE_MEM_STATS=%s' % get_on_off(options.jerry_memstat), + '-DJERRY_MEM_STATS=%s' % get_on_off(options.jerry_memstat), # --external-modules "-DEXTERNAL_MODULES='%s'" % ';'.join(options.external_modules), # --jerry-profile - "-DFEATURE_PROFILE='%s'" % options.jerry_profile, + "-DJERRY_PROFILE='%s'" % options.jerry_profile, ] if options.target_os in ['nuttx', 'tizenrt']: @@ -349,10 +349,11 @@ def build_iotjs(options): # --jerry-heaplimit if options.jerry_heaplimit: - cmake_opt.append('-DMEM_HEAP_SIZE_KB=%d' % options.jerry_heaplimit) + cmake_opt.append('-DJERRY_GLOBAL_HEAP_SIZE=%d' % + options.jerry_heaplimit) if options.jerry_heaplimit > 512: cmake_opt.append("-DEXTRA_JERRY_CMAKE_PARAMS='%s'" % - "-DFEATURE_CPOINTER_32_BIT=ON") + "-DJERRY_CPOINTER_32_BIT=ON") # --jerry-heap-section if options.jerry_heap_section: @@ -361,10 +362,10 @@ def build_iotjs(options): # --jerry-debugger if options.jerry_debugger: - cmake_opt.append("-DFEATURE_DEBUGGER=ON") + cmake_opt.append("-DJERRY_DEBUGGER=ON") # --js-backtrace - cmake_opt.append("-DFEATURE_JS_BACKTRACE=%s" % + cmake_opt.append("-DJERRY_LINE_INFO=%s" % options.js_backtrace) # --cmake-param diff --git a/tools/measure_coverage.sh b/tools/measure_coverage.sh index 1f42862cfe..a8f9276a93 100755 --- a/tools/measure_coverage.sh +++ b/tools/measure_coverage.sh @@ -164,7 +164,7 @@ mv src/cover_js src/js # Build iot.js # We need to use the system allocator to have enough memory, for now this can # only be done with a 32-bit build -common_build_opts="--jerry-cmake-param=-DFEATURE_SYSTEM_ALLOCATOR=ON +common_build_opts="--jerry-cmake-param=-DJERRY_SYSTEM_ALLOCATOR=ON --compile-flag=-coverage --no-snapshot" diff --git a/tools/travis_script.py b/tools/travis_script.py index fd40b18557..eee72797b3 100755 --- a/tools/travis_script.py +++ b/tools/travis_script.py @@ -53,7 +53,7 @@ '--clean', '--compile-flag=-fno-common', '--compile-flag=-fno-omit-frame-pointer', - '--jerry-cmake-param=-DFEATURE_SYSTEM_ALLOCATOR=ON', + '--jerry-cmake-param=-DJERRY_SYSTEM_ALLOCATOR=ON', '--no-check-valgrind', '--no-snapshot', '--profile=test/profiles/host-linux.profile', @@ -207,7 +207,13 @@ def job_stm32f4dis(): 'config/nuttx/stm32f4dis/config.travis'), fs.join(DOCKER_NUTTX_PATH, 'configs/stm32f4discovery/usbnsh/defconfig')]) - + # Temporary solution to fix a conversion error within JerryScript + exec_docker(DOCKER_IOTJS_PATH, ['git', 'submodule', 'update']) + exec_docker(DOCKER_IOTJS_PATH, ['git', 'submodule', 'init']) + exec_docker(DOCKER_IOTJS_PATH, [ + 'git', 'apply', '--directory=deps/jerry/', + './config/nuttx/stm32f4dis/temporary-fix.diff']) + exec_docker(DOCKER_IOTJS_PATH, ['git', 'add','deps/jerry']) for buildtype in BUILDTYPES: exec_docker(DOCKER_NUTTX_PATH, ['make', 'distclean']) exec_docker(DOCKER_NUTTX_TOOLS_PATH,