Skip to content

Changes from local repository #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
cmake_minimum_required (VERSION 2.8.12)
project (Jerry CXX C ASM)

# Require g++ of version >= 4.8.0
# Require g++ of version >= 4.7.0
if(NOT CMAKE_COMPILER_IS_GNUCXX)
message(FATAL_ERROR "g++ compiler is required")
else()
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GNU_CXX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(${GNU_CXX_VERSION} VERSION_LESS 4.8.0)
message(FATAL_ERROR "g++ compiler version 4.8.0 or higher required")
if(${GNU_CXX_VERSION} VERSION_LESS 4.7.0)
message(FATAL_ERROR "g++ compiler version 4.7.0 or higher required")
endif()
endif()

Expand Down Expand Up @@ -119,6 +119,7 @@ project (Jerry CXX C ASM)
COMPACT_PROFILE
COMPACT_PROFILE_MINIMAL
FULL_PROFILE
MINIMAL_FOOTPRINT
MEMORY_STATISTICS)

# Profiles
Expand All @@ -131,6 +132,9 @@ project (Jerry CXX C ASM)
# Minimal compact profile
set(MODIFIER_SUFFIX_COMPACT_PROFILE_MINIMAL -cp_minimal)

# Minimal footprint
set(MODIFIER_SUFFIX_MINIMAL_FOOTPRINT -mfp)

# Memory statistics
set(MODIFIER_SUFFIX_MEMORY_STATISTICS -mem_stats)

Expand All @@ -140,7 +144,10 @@ project (Jerry CXX C ASM)
"FULL_PROFILE"
"COMPACT_PROFILE"
"COMPACT_PROFILE_MINIMAL"
"FULL_PROFILE MINIMAL_FOOTPRINT"
"FULL_PROFILE MINIMAL_FOOTPRINT MEMORY_STATISTICS"
"FULL_PROFILE MEMORY_STATISTICS"
"COMPACT_PROFILE_MINIMAL MINIMAL_FOOTPRINT"
"COMPACT_PROFILE_MINIMAL MEMORY_STATISTICS")

# MCU
Expand All @@ -162,7 +169,7 @@ project (Jerry CXX C ASM)

# Compiler / Linker flags
set(COMPILE_FLAGS_JERRY "-fno-builtin")
set(LINKER_FLAGS_COMMON "")
set(LINKER_FLAGS_COMMON "-Wl,-z,noexecstack")

# LTO
if("${ENABLE_LTO}" STREQUAL "ON")
Expand All @@ -177,7 +184,7 @@ project (Jerry CXX C ASM)
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -g -gdwarf-4")

# Warnings
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wall -Wextra -Wpedantic -Wlogical-op")
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wall -Wextra -pedantic -Wlogical-op")
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wformat-nonliteral -Winit-self -Wno-stack-protector")
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wconversion -Wsign-conversion -Wformat-security")
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -Wmissing-declarations -Wno-attributes")
Expand Down Expand Up @@ -250,6 +257,19 @@ project (Jerry CXX C ASM)
OUTPUT_STRIP_TRAILING_WHITESPACE)
set_property(TARGET ${PREFIX_IMPORTED_LIB}libgcc
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION})
# libgcc_eh
add_library(${PREFIX_IMPORTED_LIB}libgcc_eh STATIC IMPORTED)
execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=libgcc_eh.a
OUTPUT_VARIABLE IMPORTED_LIBGCC_EH_LOCATION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(EXISTS "${IMPORTED_LIBGCC_EH_LOCATION}")
set_property(TARGET ${PREFIX_IMPORTED_LIB}libgcc_eh
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_EH_LOCATION})
else()
# If libgcc_eh not found, reference libgcc instead
set_property(TARGET ${PREFIX_IMPORTED_LIB}libgcc_eh
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION})
endif()

# Platform-specific configuration
set(MODIFIERS_LISTS ${MODIFIERS_LISTS_${PLATFORM_EXT}})
Expand Down Expand Up @@ -307,7 +327,8 @@ project (Jerry CXX C ASM)
target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY})
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_INTERFACE})
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
target_link_libraries(${TARGET_NAME} ${PLUGINS_TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc)
target_link_libraries(${TARGET_NAME} ${PLUGINS_TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME}
${PREFIX_IMPORTED_LIB}libgcc ${PREFIX_IMPORTED_LIB}libgcc_eh)

add_cppcheck_target(${TARGET_NAME})

Expand Down Expand Up @@ -387,7 +408,8 @@ project (Jerry CXX C ASM)
set_property(TARGET ${TARGET_NAME}
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS} ${LINKER_FLAGS_COMMON}")
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_INTERFACE})
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libc ${PREFIX_IMPORTED_LIB}libgcc)
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libc
${PREFIX_IMPORTED_LIB}libgcc ${PREFIX_IMPORTED_LIB}libgcc_eh)

add_cppcheck_target(${TARGET_NAME})

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export TARGET_RELEASE_MODES = release
export TARGET_PC_SYSTEMS = linux
export TARGET_NUTTX_SYSTEMS = nuttx

export TARGET_PC_MODS = cp cp_minimal mem_stats
export TARGET_PC_MODS = cp cp_minimal mem_stats mfp cp_minimal-mfp mfp-mem_stats
export TARGET_NUTTX_MODS = $(TARGET_PC_MODS)

export TARGET_MCU_MODS = cp cp_minimal
Expand Down
5 changes: 5 additions & 0 deletions jerry-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ project (JerryCore CXX C ASM)
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_JSON_BUILTIN
CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN)

# Minimal footprint
set(DEFINES_MINIMAL_FOOTPRINT
CONFIG_ECMA_LCACHE_DISABLE
CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE)

# Memory statistics
set(DEFINES_MEMORY_STATISTICS MEM_STATS)

Expand Down
15 changes: 15 additions & 0 deletions jerry-core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
# define CONFIG_MEM_HEAP_AREA_SIZE (256 * 1024)
#endif /* !CONFIG_MEM_HEAP_AREA_SIZE */

/**
* Desired limit of heap usage
*/
#define CONFIG_MEM_HEAP_DESIRED_LIMIT (CONFIG_MEM_HEAP_AREA_SIZE / 32)

/**
* Log2 of maximum possible offset in the heap
*
Expand Down Expand Up @@ -127,6 +132,11 @@
*/
#define CONFIG_ECMA_STACK_FRAME_INLINED_VALUES_NUMBER (16)

/**
* Disable ECMA lookup cache
*/
// #define CONFIG_ECMA_LCACHE_DISABLE

/**
* Link Global Environment to an empty declarative lexical environment
* instead of lexical environment bound to Global Object.
Expand Down Expand Up @@ -170,4 +180,9 @@
*/
#define CONFIG_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION 16

/**
* Run GC after execution of each opcode
*/
// #define CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE

#endif /* !CONFIG_H */
22 changes: 22 additions & 0 deletions jerry-core/ecma/base/ecma-lcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @{
*/

#ifndef CONFIG_ECMA_LCACHE_DISABLE
/**
* Entry of LCache hash table
*/
Expand Down Expand Up @@ -65,16 +66,20 @@ JERRY_STATIC_ASSERT (sizeof (ecma_lcache_hash_entry_t) == sizeof (uint64_t));
* LCache's hash table
*/
static ecma_lcache_hash_entry_t ecma_lcache_hash_table[ ECMA_LCACHE_HASH_ROWS_COUNT ][ ECMA_LCACHE_HASH_ROW_LENGTH ];
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */

/**
* Initialize LCache
*/
void
ecma_lcache_init (void)
{
#ifndef CONFIG_ECMA_LCACHE_DISABLE
memset (ecma_lcache_hash_table, 0, sizeof (ecma_lcache_hash_table));
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
} /* ecma_lcache_init */

#ifndef CONFIG_ECMA_LCACHE_DISABLE
/**
* Invalidate specified LCache entry
*/
Expand All @@ -98,13 +103,15 @@ ecma_lcache_invalidate_entry (ecma_lcache_hash_entry_t *entry_p) /**< entry to i
false);
}
} /* ecma_lcache_invalidate_entry */
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */

/**
* Invalidate all entries in LCache
*/
void
ecma_lcache_invalidate_all (void)
{
#ifndef CONFIG_ECMA_LCACHE_DISABLE
for (uint32_t row_index = 0; row_index < ECMA_LCACHE_HASH_ROWS_COUNT; row_index++)
{
for (uint32_t entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
Expand All @@ -115,8 +122,10 @@ ecma_lcache_invalidate_all (void)
}
}
}
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
} /* ecma_lcache_invalidate_all */

#ifndef CONFIG_ECMA_LCACHE_DISABLE
/**
* Invalidate entries of LCache's row that correspond to given (object, property) pair
*/
Expand All @@ -137,6 +146,7 @@ ecma_lcache_invalidate_row_for_object_property_pair (uint32_t row_index, /**< in
}
}
} /* ecma_lcache_invalidate_row_for_object_property_pair */
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */

/**
* Insert an entry into LCache
Expand All @@ -151,6 +161,7 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (prop_name_p != NULL);

#ifndef CONFIG_ECMA_LCACHE_DISABLE
prop_name_p = ecma_copy_or_ref_ecma_string (prop_name_p);

ecma_string_hash_t hash_key = ecma_string_hash (prop_name_p);
Expand Down Expand Up @@ -210,6 +221,9 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].object_cp, object_p);
ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_name_cp, prop_name_p);
ECMA_SET_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_cp, prop_p);
#else /* CONFIG_ECMA_LCACHE_DISABLE */
(void) prop_p;
#endif /* CONFIG_ECMA_LCACHE_DISABLE */
} /* ecma_lcache_insert */

/**
Expand All @@ -228,6 +242,7 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
* if return value is false,
* then the output parameter is not set */
{
#ifndef CONFIG_ECMA_LCACHE_DISABLE
ecma_string_hash_t hash_key = ecma_string_hash (prop_name_p);

unsigned int object_cp;
Expand Down Expand Up @@ -255,6 +270,11 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
}
}
}
#else /* CONFIG_ECMA_LCACHE_DISABLE */
(void) object_p;
(void) prop_name_p;
(void) prop_p_p;
#endif /* CONFIG_ECMA_LCACHE_DISABLE */

return false;
} /* ecma_lcache_lookup */
Expand All @@ -276,6 +296,7 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (prop_p != NULL || prop_name_arg_p != NULL);

#ifndef CONFIG_ECMA_LCACHE_DISABLE
ecma_string_t *prop_name_p = NULL;

if (prop_p != NULL)
Expand Down Expand Up @@ -318,6 +339,7 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
* Given (object, property name) pair should be in the row corresponding to computed hash.
*/
ecma_lcache_invalidate_row_for_object_property_pair (hash_key, object_cp, prop_cp);
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
} /* ecma_lcache_invalidate */

/**
Expand Down
10 changes: 5 additions & 5 deletions jerry-core/jerry-extension.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ enum
static const jerry_extension_field_t jerry_extension_fields [JERRY_EXTENSION_FIELDS_NUMBER + 1] =
{
#define EXTENSION_FIELD(_field_name, _type, _value) \
{ # _field_name, JERRY_API_DATA_TYPE_ ## _type, _value },
{ # _field_name, JERRY_API_DATA_TYPE_ ## _type, { _value } },
# include EXTENSION_DESCRIPTION_HEADER
#undef EXTENSION_FIELD
#define EMPTY_FIELD_ENTRY { NULL, JERRY_API_DATA_TYPE_UNDEFINED, NULL }
#define EMPTY_FIELD_ENTRY { NULL, JERRY_API_DATA_TYPE_UNDEFINED, { NULL } }
EMPTY_FIELD_ENTRY
#undef EMPTY_FIELD_ENTRY
};
Expand Down Expand Up @@ -87,7 +87,7 @@ static const jerry_extension_field_t jerry_extension_fields [JERRY_EXTENSION_FIE
/* Functions' arguments description */
#define EXTENSION_ARG(_arg_index, _type) [_arg_index] = { \
(JERRY_API_DATA_TYPE_ ## _type), \
false /* just for initialization, should be overwritten upon call */ \
{ false } /* just for initialization, should be overwritten upon call */ \
}
#define EXTENSION_FUNCTION(_function_name, _function_to_call, _ret_value_type, _args_number, ...) \
static jerry_api_value_t jerry_extension_function_ ## _function_name ## _args [_args_number] = { \
Expand All @@ -103,13 +103,13 @@ static jerry_extension_function_t jerry_extension_functions [JERRY_EXTENSION_FUN
#define EXTENSION_FUNCTION(_function_name, _function_to_call, _ret_value_type, _args_number, ...) \
{ \
# _function_name, jerry_extension_ ## _function_name ## _wrapper, \
{ JERRY_API_DATA_TYPE_ ## _ret_value_type, false }, \
{ JERRY_API_DATA_TYPE_ ## _ret_value_type, { false } }, \
jerry_extension_function_ ## _function_name ## _args, \
_args_number \
},
# include EXTENSION_DESCRIPTION_HEADER
#undef EXTENSION_FUNCTION
#define EMPTY_FUNCTION_ENTRY { NULL, NULL, { JERRY_API_DATA_TYPE_VOID, false }, NULL, 0 }
#define EMPTY_FUNCTION_ENTRY { NULL, NULL, { JERRY_API_DATA_TYPE_VOID, { false } }, NULL, 0 }
EMPTY_FUNCTION_ENTRY
#undef EMPTY_FUNCTION_ENTRY
};
Expand Down
35 changes: 28 additions & 7 deletions jerry-core/jerry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "ecma-objects-general.h"
#include "jerry.h"
#include "jrt.h"
#include "mem-heap.h"
#include "mem-poolman.h"
#include "parser.h"
#include "serializer.h"
#include "vm.h"
Expand Down Expand Up @@ -901,14 +903,24 @@ jerry_api_eval (const char *source_p, /**< source code */
void
jerry_init (jerry_flag_t flags) /**< combination of Jerry flags */
{
jerry_flags = flags;

#ifndef MEM_STATS
if (flags & JERRY_FLAG_MEM_STATS)
if (flags & (JERRY_FLAG_MEM_STATS))
{
#ifndef MEM_STATS
flags &= ~(JERRY_FLAG_MEM_STATS
| JERRY_FLAG_MEM_STATS_PER_OPCODE
| JERRY_FLAG_MEM_STATS_SEPARATE);

printf ("Ignoring memory statistics option because of '!MEM_STATS' build configuration.\n");
}
#endif /* !MEM_STATS */
}
else if (flags & (JERRY_FLAG_MEM_STATS_PER_OPCODE | JERRY_FLAG_MEM_STATS_SEPARATE))
{
flags &= ~(JERRY_FLAG_MEM_STATS_PER_OPCODE | JERRY_FLAG_MEM_STATS_SEPARATE);

printf ("Ignoring detailed memory statistics options because memory statistics dump mode is not enabled.\n");
}

jerry_flags = flags;

mem_init ();
serializer_init ();
Expand Down Expand Up @@ -966,8 +978,17 @@ jerry_parse (const char* source_p, /**< script source */
serializer_print_opcodes ();
parser_free ();

bool is_show_mem_stats = ((jerry_flags & JERRY_FLAG_MEM_STATS) != 0);
init_int (opcodes, is_show_mem_stats);
#ifdef MEM_STATS
if (jerry_flags & JERRY_FLAG_MEM_STATS_SEPARATE)
{
mem_stats_print ();
mem_stats_reset_peak ();
}
#endif /* MEM_STATS */

bool is_show_mem_stats_per_opcode = ((jerry_flags & JERRY_FLAG_MEM_STATS_PER_OPCODE) != 0);

init_int (opcodes, is_show_mem_stats_per_opcode);

return true;
} /* jerry_parse */
Expand Down
14 changes: 8 additions & 6 deletions jerry-core/jerry.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
*/
typedef uint32_t jerry_flag_t;

#define JERRY_FLAG_EMPTY (0) /**< empty flag set */
#define JERRY_FLAG_SHOW_OPCODES (1 << 0) /**< dump opcodes to stdout after parse */
#define JERRY_FLAG_MEM_STATS (1 << 1) /**< dump per-opcode memory statistics during execution
* (in the mode full GC is performed after each opcode handler) */
#define JERRY_FLAG_PARSE_ONLY (1 << 2) /**< parse only, prevents script execution (only for testing)
* FIXME: Remove. */
#define JERRY_FLAG_EMPTY (0u) /**< empty flag set */
#define JERRY_FLAG_SHOW_OPCODES (1u << 0) /**< dump opcodes to stdout after parse */
#define JERRY_FLAG_MEM_STATS (1u << 1) /**< dump memory statistics */
#define JERRY_FLAG_MEM_STATS_PER_OPCODE (1u << 2) /**< dump per-opcode memory statistics during execution
* (in the mode full GC is performed after each opcode handler) */
#define JERRY_FLAG_MEM_STATS_SEPARATE (1u << 3) /**< dump memory statistics and reset peak values after parse */
#define JERRY_FLAG_PARSE_ONLY (1u << 4) /**< parse only, prevents script execution (only for testing)
* FIXME: Remove. */

/**
* Error codes
Expand Down
Loading