Add Windows support. (#2306)
JerryScript-DCO-1.0-Signed-off-by: PKarics karicska@gmail.com JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
@@ -43,3 +43,4 @@ docs/doxygen
|
|||||||
# Tests
|
# Tests
|
||||||
tests/test262/
|
tests/test262/
|
||||||
tests/unit-doc/*.c
|
tests/unit-doc/*.c
|
||||||
|
.vs
|
||||||
|
|||||||
+26
-2
@@ -32,6 +32,10 @@ if(CMAKE_C_COMPILER_ID MATCHES "TI")
|
|||||||
set(USING_TI 1)
|
set(USING_TI 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||||
|
set(USING_MSVC 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Determining build type
|
# Determining build type
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "MinSizeRel")
|
set(CMAKE_BUILD_TYPE "MinSizeRel")
|
||||||
@@ -94,8 +98,21 @@ if(USING_TI)
|
|||||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
|
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USING_MSVC)
|
||||||
|
set(JERRY_LIBC OFF)
|
||||||
|
set(JERRY_LIBM OFF)
|
||||||
|
set(ENABLE_ALL_IN_ONE ON)
|
||||||
|
set(ENABLE_STRIP OFF)
|
||||||
|
|
||||||
|
set(JERRY_LIBC_MESSAGE " (FORCED BY COMPILER)")
|
||||||
|
set(JERRY_LIBM_MESSAGE " (FORCED BY COMPILER)")
|
||||||
|
set(ENABLE_ALL_IN_ONE_MESSAGE " (FORCED BY COMPILER)")
|
||||||
|
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Status messages
|
# Status messages
|
||||||
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||||
|
message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID})
|
||||||
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
|
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
|
||||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
|
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
|
||||||
message(STATUS "ENABLE_ALL_IN_ONE " ${ENABLE_ALL_IN_ONE} ${ENABLE_ALL_IN_ONE_MESSAGE})
|
message(STATUS "ENABLE_ALL_IN_ONE " ${ENABLE_ALL_IN_ONE} ${ENABLE_ALL_IN_ONE_MESSAGE})
|
||||||
@@ -190,7 +207,7 @@ if(("${PLATFORM}" STREQUAL "DARWIN"))
|
|||||||
jerry_add_link_flags(-lSystem)
|
jerry_add_link_flags(-lSystem)
|
||||||
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
|
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||||
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
|
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
|
||||||
else()
|
elseif(NOT USING_MSVC)
|
||||||
jerry_add_link_flags(-Wl,-z,noexecstack)
|
jerry_add_link_flags(-Wl,-z,noexecstack)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -199,9 +216,16 @@ if(JERRY_LIBC)
|
|||||||
jerry_add_link_flags(-nostdlib)
|
jerry_add_link_flags(-nostdlib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USING_MSVC)
|
||||||
|
jerry_add_link_flags(/OPT:NOREF)
|
||||||
|
# Disable MSVC warning 4996 globally because it stops us from using
|
||||||
|
# standard C functions.
|
||||||
|
jerry_add_compile_flags(/wd4996)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Turn off stack protector
|
# Turn off stack protector
|
||||||
if (USING_GCC OR USING_CLANG)
|
if (USING_GCC OR USING_CLANG)
|
||||||
jerry_add_compile_flags(-fno-stack-protector)
|
jerry_add_compile_flags(-fno-stack-protector)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USING_GCC OR USING_CLANG)
|
if (USING_GCC OR USING_CLANG)
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
version: 1.0.{build}
|
||||||
|
pull_requests:
|
||||||
|
do_not_increment_build_number: true
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- coverity_scan
|
||||||
|
- gh_pages
|
||||||
|
skip_tags: true
|
||||||
|
image:
|
||||||
|
- Visual Studio 2017
|
||||||
|
configuration:
|
||||||
|
- Debug
|
||||||
|
- Release
|
||||||
|
platform:
|
||||||
|
- x64
|
||||||
|
- Win32
|
||||||
|
init:
|
||||||
|
- cmd: |
|
||||||
|
cmake -version
|
||||||
|
before_build:
|
||||||
|
- cmd: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
if "%PLATFORM%"=="Win32" cmake -G"Visual Studio 15 2017" ..
|
||||||
|
if "%PLATFORM%"=="x64" cmake -G"Visual Studio 15 2017 Win64" ..
|
||||||
|
|
||||||
|
build:
|
||||||
|
project: build\Jerry.sln
|
||||||
|
parallel: true
|
||||||
|
verbosity: minimal
|
||||||
@@ -146,9 +146,7 @@ endif()
|
|||||||
set(INCLUDE_THIRD_PARTY_VALGRIND "${CMAKE_SOURCE_DIR}/third-party/valgrind")
|
set(INCLUDE_THIRD_PARTY_VALGRIND "${CMAKE_SOURCE_DIR}/third-party/valgrind")
|
||||||
|
|
||||||
# build mode specific compile/link flags
|
# build mode specific compile/link flags
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
set(DEFINES_JERRY ${DEFINES_JERRY} $<$<NOT:$<CONFIG:Debug>>:JERRY_NDEBUG>)
|
||||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_NDEBUG)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Jerry heap-section
|
# Jerry heap-section
|
||||||
if(DEFINED JERRY_HEAP_SECTION_ATTR)
|
if(DEFINED JERRY_HEAP_SECTION_ATTR)
|
||||||
|
|||||||
@@ -639,7 +639,7 @@ ecma_date_to_string_format (ecma_number_t datetime_number, /**< datetime */
|
|||||||
};
|
};
|
||||||
|
|
||||||
const uint32_t date_buffer_length = 34;
|
const uint32_t date_buffer_length = 34;
|
||||||
lit_utf8_byte_t date_buffer[date_buffer_length];
|
JERRY_VLA (lit_utf8_byte_t, date_buffer, date_buffer_length);
|
||||||
|
|
||||||
lit_utf8_byte_t *dest_p = date_buffer;
|
lit_utf8_byte_t *dest_p = date_buffer;
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ ecma_builtin_helper_object_to_string (const ecma_value_t this_arg) /**< this arg
|
|||||||
'Null' or one of possible object's classes.
|
'Null' or one of possible object's classes.
|
||||||
The string with null character is maximum 27 characters long. */
|
The string with null character is maximum 27 characters long. */
|
||||||
const lit_utf8_size_t buffer_size = 27;
|
const lit_utf8_size_t buffer_size = 27;
|
||||||
lit_utf8_byte_t str_buffer[buffer_size];
|
JERRY_VLA (lit_utf8_byte_t, str_buffer, buffer_size);
|
||||||
|
|
||||||
lit_utf8_byte_t *buffer_ptr = str_buffer;
|
lit_utf8_byte_t *buffer_ptr = str_buffer;
|
||||||
|
|
||||||
|
|||||||
@@ -1365,9 +1365,10 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
|||||||
const bool obj_is_builtin = ecma_get_object_is_builtin (obj_p);
|
const bool obj_is_builtin = ecma_get_object_is_builtin (obj_p);
|
||||||
|
|
||||||
const size_t bitmap_row_size = sizeof (uint32_t) * JERRY_BITSINBYTE;
|
const size_t bitmap_row_size = sizeof (uint32_t) * JERRY_BITSINBYTE;
|
||||||
uint32_t names_hashes_bitmap[ECMA_OBJECT_HASH_BITMAP_SIZE / bitmap_row_size];
|
const size_t names_hashes_bitmap_size = ECMA_OBJECT_HASH_BITMAP_SIZE / bitmap_row_size;
|
||||||
|
JERRY_VLA (uint32_t, names_hashes_bitmap, names_hashes_bitmap_size);
|
||||||
|
|
||||||
memset (names_hashes_bitmap, 0, sizeof (names_hashes_bitmap));
|
memset (names_hashes_bitmap, 0, names_hashes_bitmap_size * sizeof (names_hashes_bitmap[0]));
|
||||||
|
|
||||||
for (ecma_object_t *prototype_chain_iter_p = obj_p;
|
for (ecma_object_t *prototype_chain_iter_p = obj_p;
|
||||||
prototype_chain_iter_p != NULL;
|
prototype_chain_iter_p != NULL;
|
||||||
@@ -1461,8 +1462,9 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
|||||||
|
|
||||||
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
ecma_value_t *ecma_value_p = ecma_collection_iterator_init (prop_names_p);
|
||||||
|
|
||||||
uint32_t own_names_hashes_bitmap[ECMA_OBJECT_HASH_BITMAP_SIZE / bitmap_row_size];
|
const size_t own_names_hashes_bitmap_size = ECMA_OBJECT_HASH_BITMAP_SIZE / bitmap_row_size;
|
||||||
memset (own_names_hashes_bitmap, 0, sizeof (own_names_hashes_bitmap));
|
JERRY_VLA (uint32_t, own_names_hashes_bitmap, own_names_hashes_bitmap_size);
|
||||||
|
memset (own_names_hashes_bitmap, 0, own_names_hashes_bitmap_size * sizeof (own_names_hashes_bitmap[0]));
|
||||||
|
|
||||||
while (ecma_value_p != NULL)
|
while (ecma_value_p != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,24 @@ extern "C"
|
|||||||
|
|
||||||
#endif /* __GNUC__ */
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compiler-specific macros relevant for Microsoft Visual C/C++ Compiler.
|
||||||
|
*/
|
||||||
|
#define JERRY_ATTR_DEPRECATED __declspec(deprecated)
|
||||||
|
#define JERRY_ATTR_NOINLINE __declspec(noinline)
|
||||||
|
#define JERRY_ATTR_NORETURN __declspec(noreturn)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Microsoft Visual C/C++ Compiler doesn't support for VLA, using _alloca
|
||||||
|
* instead.
|
||||||
|
*/
|
||||||
|
void * __cdecl _alloca (size_t _Size);
|
||||||
|
#define JERRY_VLA(type, name, size) type *name = (type *) (_alloca (sizeof (type) * size))
|
||||||
|
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default empty definitions for all compiler-specific macros. Define any of
|
* Default empty definitions for all compiler-specific macros. Define any of
|
||||||
* these in a guarded block above (e.g., as for GCC) to fine tune compilation
|
* these in a guarded block above (e.g., as for GCC) to fine tune compilation
|
||||||
@@ -110,6 +128,10 @@ extern "C"
|
|||||||
#define JERRY_UNLIKELY(x) (x)
|
#define JERRY_UNLIKELY(x) (x)
|
||||||
#endif /* !JERRY_UNLIKELY */
|
#endif /* !JERRY_UNLIKELY */
|
||||||
|
|
||||||
|
#ifndef JERRY_VLA
|
||||||
|
#define JERRY_VLA(type, name, size) type name[size]
|
||||||
|
#endif /* !JERRY_VLA */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
@@ -3081,7 +3081,7 @@ vm_run (const ecma_compiled_code_t *bytecode_header_p, /**< byte-code data heade
|
|||||||
frame_ctx.call_operation = VM_NO_EXEC_OP;
|
frame_ctx.call_operation = VM_NO_EXEC_OP;
|
||||||
|
|
||||||
/* Use JERRY_MAX() to avoid array declaration with size 0. */
|
/* Use JERRY_MAX() to avoid array declaration with size 0. */
|
||||||
ecma_value_t stack[JERRY_MAX (call_stack_size, 1)];
|
JERRY_VLA (ecma_value_t, stack, JERRY_MAX (call_stack_size, 1));
|
||||||
frame_ctx.registers_p = stack;
|
frame_ctx.registers_p = stack;
|
||||||
|
|
||||||
return vm_execute (&frame_ctx, arg_list_p, arg_list_len);
|
return vm_execute (&frame_ctx, arg_list_p, arg_list_len);
|
||||||
|
|||||||
+2
-2
@@ -115,7 +115,7 @@ jerryx_arg_transform_object_properties (const jerry_value_t obj_val,/**< the JS
|
|||||||
return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "Not an object.");
|
return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "Not an object.");
|
||||||
}
|
}
|
||||||
|
|
||||||
jerry_value_t prop[name_cnt];
|
JERRY_VLA (jerry_value_t, prop, name_cnt);
|
||||||
|
|
||||||
for (jerry_length_t i = 0; i < name_cnt; i++, name_p++)
|
for (jerry_length_t i = 0; i < name_cnt; i++, name_p++)
|
||||||
{
|
{
|
||||||
@@ -160,7 +160,7 @@ jerryx_arg_transform_array (const jerry_value_t array_val, /**< points to the JS
|
|||||||
return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "Not an array.");
|
return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "Not an array.");
|
||||||
}
|
}
|
||||||
|
|
||||||
jerry_value_t arr[c_arg_cnt];
|
JERRY_VLA (jerry_value_t, arr, c_arg_cnt);
|
||||||
|
|
||||||
for (jerry_length_t i = 0; i < c_arg_cnt; i++)
|
for (jerry_length_t i = 0; i < c_arg_cnt; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ jerryx_resolve_native_module (const jerry_value_t canonical_name, /**< canonical
|
|||||||
const jerryx_native_module_t *module_p = NULL;
|
const jerryx_native_module_t *module_p = NULL;
|
||||||
|
|
||||||
jerry_size_t name_size = jerry_get_utf8_string_size (canonical_name);
|
jerry_size_t name_size = jerry_get_utf8_string_size (canonical_name);
|
||||||
jerry_char_t name_string[name_size];
|
JERRY_VLA (jerry_char_t, name_string, name_size);
|
||||||
jerry_string_to_utf8_char_buffer (canonical_name, name_string, name_size);
|
jerry_string_to_utf8_char_buffer (canonical_name, name_string, name_size);
|
||||||
|
|
||||||
/* Look for the module by its name in the list of module definitions. */
|
/* Look for the module by its name in the list of module definitions. */
|
||||||
@@ -214,7 +214,7 @@ jerryx_module_resolve_local (const jerry_value_t name, /**< name of the module t
|
|||||||
size_t index;
|
size_t index;
|
||||||
size_t canonical_names_used = 0;
|
size_t canonical_names_used = 0;
|
||||||
jerry_value_t instances;
|
jerry_value_t instances;
|
||||||
jerry_value_t canonical_names[resolver_count];
|
JERRY_VLA (jerry_value_t, canonical_names, resolver_count);
|
||||||
jerry_value_t (*get_canonical_name_p) (const jerry_value_t name);
|
jerry_value_t (*get_canonical_name_p) (const jerry_value_t name);
|
||||||
bool (*resolve_p) (const jerry_value_t canonical_name,
|
bool (*resolve_p) (const jerry_value_t canonical_name,
|
||||||
jerry_value_t *result);
|
jerry_value_t *result);
|
||||||
|
|||||||
@@ -417,13 +417,13 @@ main (int argc,
|
|||||||
char **argv)
|
char **argv)
|
||||||
{
|
{
|
||||||
srand ((unsigned) jerry_port_get_current_time ());
|
srand ((unsigned) jerry_port_get_current_time ());
|
||||||
const char *file_names[argc];
|
JERRY_VLA (const char *, file_names, argc);
|
||||||
int files_counter = 0;
|
int files_counter = 0;
|
||||||
|
|
||||||
jerry_init_flag_t flags = JERRY_INIT_EMPTY;
|
jerry_init_flag_t flags = JERRY_INIT_EMPTY;
|
||||||
|
|
||||||
const char *exec_snapshot_file_names[argc];
|
JERRY_VLA (const char *, exec_snapshot_file_names, argc);
|
||||||
uint32_t exec_snapshot_file_indices[argc];
|
JERRY_VLA (uint32_t, exec_snapshot_file_indices, argc);
|
||||||
int exec_snapshots_count = 0;
|
int exec_snapshots_count = 0;
|
||||||
|
|
||||||
bool is_parse_only = false;
|
bool is_parse_only = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user