diff options
21 files changed, 204 insertions, 293 deletions
diff --git a/jerry-core/ecma/base/ecma-alloc.c b/jerry-core/ecma/base/ecma-alloc.c index c41456a3..27ab234c 100644 --- a/jerry-core/ecma/base/ecma-alloc.c +++ b/jerry-core/ecma/base/ecma-alloc.c @@ -185,35 +185,6 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */ } /* ecma_dealloc_string_buffer */ /** - * Allocate memory for getter-setter pointer pair - * - * @return pointer to allocated memory - */ -inline ecma_getter_setter_pointers_t * JERRY_ATTR_ALWAYS_INLINE -ecma_alloc_getter_setter_pointers (void) -{ -#ifdef JMEM_STATS - jmem_stats_allocate_property_bytes (sizeof (ecma_property_pair_t)); -#endif /* JMEM_STATS */ - - return (ecma_getter_setter_pointers_t *) jmem_pools_alloc (sizeof (ecma_getter_setter_pointers_t)); -} /* ecma_alloc_getter_setter_pointers */ - -/** - * Dealloc memory from getter-setter pointer pair - */ -inline void JERRY_ATTR_ALWAYS_INLINE -ecma_dealloc_getter_setter_pointers (ecma_getter_setter_pointers_t *getter_setter_pointers_p) /**< pointer pair - * to be freed */ -{ -#ifdef JMEM_STATS - jmem_stats_free_property_bytes (sizeof (ecma_property_pair_t)); -#endif /* JMEM_STATS */ - - jmem_pools_free (getter_setter_pointers_p, sizeof (ecma_getter_setter_pointers_t)); -} /* ecma_dealloc_getter_setter_pointers */ - -/** * Allocate memory for ecma-property pair * * @return pointer to allocated memory diff --git a/jerry-core/ecma/base/ecma-alloc.h b/jerry-core/ecma/base/ecma-alloc.h index 512aee84..da75f690 100644 --- a/jerry-core/ecma/base/ecma-alloc.h +++ b/jerry-core/ecma/base/ecma-alloc.h @@ -86,18 +86,6 @@ ecma_string_t *ecma_alloc_string_buffer (size_t size); void ecma_dealloc_string_buffer (ecma_string_t *string_p, size_t size); /** - * Allocate memory for getter-setter pointer pair - * - * @return pointer to allocated memory - */ -ecma_getter_setter_pointers_t *ecma_alloc_getter_setter_pointers (void); - -/** - * Dealloc memory from getter-setter pointer pair - */ -void ecma_dealloc_getter_setter_pointers (ecma_getter_setter_pointers_t *getter_setter_pointers_p); - -/** * Allocate memory for ecma-property pair * * @return pointer to allocated memory diff --git a/jerry-core/ecma/base/ecma-helpers-number.c b/jerry-core/ecma/base/ecma-helpers-number.c index aee96c7f..ddc96842 100644 --- a/jerry-core/ecma/base/ecma-helpers-number.c +++ b/jerry-core/ecma/base/ecma-helpers-number.c @@ -351,7 +351,7 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */ * * @return shift of dot in the fraction */ -int32_t +static int32_t ecma_number_get_fraction_and_exponent (ecma_number_t num, /**< ecma-number */ uint64_t *out_fraction_p, /**< [out] fraction of the number */ int32_t *out_exponent_p) /**< [out] exponent of the number */ @@ -410,7 +410,7 @@ ecma_number_get_fraction_and_exponent (ecma_number_t num, /**< ecma-number */ * * @return ecma-number */ -ecma_number_t +static ecma_number_t ecma_number_make_normal_positive_from_fraction_and_exponent (uint64_t fraction, /**< fraction */ int32_t exponent) /**< exponent */ { diff --git a/jerry-core/ecma/base/ecma-helpers-string.c b/jerry-core/ecma/base/ecma-helpers-string.c index ac5a403e..5a183a85 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.c +++ b/jerry-core/ecma/base/ecma-helpers-string.c @@ -176,6 +176,30 @@ ecma_string_get_chars_fast (const ecma_string_t *string_p, /**< ecma-string */ } /* ecma_string_get_chars_fast */ /** + * Allocate new ecma-string and fill it with reference to ECMA magic string + * + * @return pointer to ecma-string descriptor + */ +static ecma_string_t * +ecma_new_ecma_string_from_magic_string_ex_id (lit_magic_string_ex_id_t id) /**< identifier of externl magic string */ +{ + JERRY_ASSERT (id < lit_get_magic_string_ex_count ()); + + if (JERRY_LIKELY (id <= ECMA_DIRECT_STRING_MAX_IMM)) + { + return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC_EX, (uintptr_t) id); + } + + ecma_string_t *string_desc_p = ecma_alloc_string (); + + string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING_EX | ECMA_STRING_REF_ONE; + string_desc_p->hash = (lit_string_hash_t) (LIT_MAGIC_STRING__COUNT + id); + string_desc_p->u.magic_string_ex_id = id; + + return string_desc_p; +} /* ecma_new_ecma_string_from_magic_string_ex_id */ + +/** * Allocate new ecma-string and fill it with characters from the utf8 string * * @return pointer to ecma-string descriptor @@ -481,30 +505,6 @@ ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string } /* ecma_get_magic_string */ /** - * Allocate new ecma-string and fill it with reference to ECMA magic string - * - * @return pointer to ecma-string descriptor - */ -ecma_string_t * -ecma_new_ecma_string_from_magic_string_ex_id (lit_magic_string_ex_id_t id) /**< identifier of externl magic string */ -{ - JERRY_ASSERT (id < lit_get_magic_string_ex_count ()); - - if (JERRY_LIKELY (id <= ECMA_DIRECT_STRING_MAX_IMM)) - { - return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC_EX, (uintptr_t) id); - } - - ecma_string_t *string_desc_p = ecma_alloc_string (); - - string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING_EX | ECMA_STRING_REF_ONE; - string_desc_p->hash = (lit_string_hash_t) (LIT_MAGIC_STRING__COUNT + id); - string_desc_p->u.magic_string_ex_id = id; - - return string_desc_p; -} /* ecma_new_ecma_string_from_magic_string_ex_id */ - -/** * Append a cesu8 string after an ecma-string * * Note: diff --git a/jerry-core/ecma/base/ecma-helpers.h b/jerry-core/ecma/base/ecma-helpers.h index 7476d377..dfffd496 100644 --- a/jerry-core/ecma/base/ecma-helpers.h +++ b/jerry-core/ecma/base/ecma-helpers.h @@ -200,7 +200,6 @@ ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number); ecma_string_t *ecma_get_ecma_string_from_uint32 (uint32_t uint32_number); ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num); ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id); -ecma_string_t *ecma_new_ecma_string_from_magic_string_ex_id (lit_magic_string_ex_id_t id); ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p, const lit_utf8_byte_t *cesu8_string2_p, lit_utf8_size_t cesu8_string2_size, @@ -268,10 +267,6 @@ bool ecma_number_is_nan (ecma_number_t num); bool ecma_number_is_negative (ecma_number_t num); bool ecma_number_is_zero (ecma_number_t num); bool ecma_number_is_infinity (ecma_number_t num); -int32_t -ecma_number_get_fraction_and_exponent (ecma_number_t num, uint64_t *out_fraction_p, int32_t *out_exponent_p); -ecma_number_t -ecma_number_make_normal_positive_from_fraction_and_exponent (uint64_t fraction, int32_t exponent); ecma_number_t ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent); ecma_number_t ecma_number_get_prev (ecma_number_t num); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.c index 6147d3c0..2acdda9a 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.c @@ -100,7 +100,7 @@ ecma_has_string_value_in_collection (ecma_collection_header_t *collection_p, /** * @return pointer to ecma-string * Returned value must be freed with ecma_deref_ecma_string. */ -ecma_string_t * +static ecma_string_t * ecma_builtin_helper_json_create_separated_properties (ecma_collection_header_t *partial_p, /**< key-value pairs*/ ecma_string_t *separator_p) /**< separator*/ { diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h index 1e14a86a..41cc4b8f 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h @@ -158,8 +158,6 @@ ecma_value_t ecma_builtin_json_string_from_object (const ecma_value_t arg1); bool ecma_json_has_object_in_stack (ecma_json_occurence_stack_item_t *stack_p, ecma_object_t *object_p); bool ecma_has_string_value_in_collection (ecma_collection_header_t *collection_p, ecma_value_t string_value); -ecma_string_t * -ecma_builtin_helper_json_create_separated_properties (ecma_collection_header_t *partial_p, ecma_string_t *separator_p); ecma_value_t ecma_builtin_helper_json_create_formatted_json (lit_utf8_byte_t left_bracket, lit_utf8_byte_t right_bracket, ecma_string_t *stepback_p, ecma_collection_header_t *partial_p, diff --git a/jerry-core/ecma/operations/ecma-exceptions.c b/jerry-core/ecma/operations/ecma-exceptions.c index 997b17e1..8af42667 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.c +++ b/jerry-core/ecma/operations/ecma-exceptions.c @@ -218,7 +218,7 @@ ecma_new_standard_error_with_message (ecma_standard_error_t error_type, /**< nat * @return ecma value * Returned value must be freed with ecma_free_value */ -ecma_value_t +static ecma_value_t ecma_raise_standard_error (ecma_standard_error_t error_type, /**< error type */ const lit_utf8_byte_t *msg_p) /**< error message */ { @@ -344,20 +344,6 @@ ecma_raise_common_error (const char *msg_p) /**< error message */ } /* ecma_raise_common_error */ /** - * Raise an EvalError with the given message. - * - * See also: ECMA-262 v5, 15.11.6.1 - * - * @return ecma value - * Returned value must be freed with ecma_free_value - */ -ecma_value_t -ecma_raise_eval_error (const char *msg_p) /**< error message */ -{ - return ecma_raise_standard_error (ECMA_ERROR_EVAL, (const lit_utf8_byte_t *) msg_p); -} /* ecma_raise_eval_error */ - -/** * Raise a RangeError with the given message. * * See also: ECMA-262 v5, 15.11.6.2 diff --git a/jerry-core/ecma/operations/ecma-exceptions.h b/jerry-core/ecma/operations/ecma-exceptions.h index c11c53a6..11ae8cab 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.h +++ b/jerry-core/ecma/operations/ecma-exceptions.h @@ -53,12 +53,10 @@ typedef enum ecma_standard_error_t ecma_get_error_type (ecma_object_t *error_object); ecma_object_t *ecma_new_standard_error (ecma_standard_error_t error_type); ecma_object_t *ecma_new_standard_error_with_message (ecma_standard_error_t error_type, ecma_string_t *message_string_p); -ecma_value_t ecma_raise_standard_error (ecma_standard_error_t error_type, const lit_utf8_byte_t *msg_p); #ifdef JERRY_ENABLE_ERROR_MESSAGES ecma_value_t ecma_raise_standard_error_with_format (ecma_standard_error_t error_type, const char *msg_p, ...); #endif /* JERRY_ENABLE_ERROR_MESSAGES */ ecma_value_t ecma_raise_common_error (const char *msg_p); -ecma_value_t ecma_raise_eval_error (const char *msg_p); ecma_value_t ecma_raise_range_error (const char *msg_p); ecma_value_t ecma_raise_reference_error (const char *msg_p); ecma_value_t ecma_raise_syntax_error (const char *msg_p); diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index 6685cb6a..adfdd62c 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -312,7 +312,7 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ * @return pointer to a property - if it exists, * NULL (i.e. ecma-undefined) - otherwise. */ -ecma_property_t +static ecma_property_t ecma_op_object_get_property (ecma_object_t *object_p, /**< the object */ ecma_string_t *property_name_p, /**< property name */ ecma_property_ref_t *property_ref_p, /**< property reference */ diff --git a/jerry-core/ecma/operations/ecma-objects.h b/jerry-core/ecma/operations/ecma-objects.h index 92e932eb..4692837b 100644 --- a/jerry-core/ecma/operations/ecma-objects.h +++ b/jerry-core/ecma/operations/ecma-objects.h @@ -28,8 +28,6 @@ ecma_property_t ecma_op_object_get_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, ecma_property_ref_t *property_ref_p, uint32_t options); -ecma_property_t ecma_op_object_get_property (ecma_object_t *object_p, ecma_string_t *property_name_p, - ecma_property_ref_t *property_ref_p, uint32_t options); bool ecma_op_object_has_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p); bool ecma_op_object_has_property (ecma_object_t *object_p, ecma_string_t *property_name_p); ecma_value_t ecma_op_object_find_own (ecma_value_t base_value, ecma_object_t *object_p, ecma_string_t *property_name_p); diff --git a/jerry-core/ecma/operations/ecma-promise-object.c b/jerry-core/ecma/operations/ecma-promise-object.c index f454ff4e..869bffc8 100644 --- a/jerry-core/ecma/operations/ecma-promise-object.c +++ b/jerry-core/ecma/operations/ecma-promise-object.c @@ -53,7 +53,7 @@ ecma_is_promise (ecma_object_t *obj_p) /**< points to object */ * @return ecma value of the promise result. * Returned value must be freed with ecma_free_value */ -inline ecma_value_t +static inline ecma_value_t ecma_promise_get_result (ecma_object_t *obj_p) /**< points to promise object */ { JERRY_ASSERT (ecma_is_promise (obj_p)); @@ -66,7 +66,7 @@ ecma_promise_get_result (ecma_object_t *obj_p) /**< points to promise object */ /** * Set the PromiseResult of promise. */ -inline void JERRY_ATTR_ALWAYS_INLINE +static inline void JERRY_ATTR_ALWAYS_INLINE ecma_promise_set_result (ecma_object_t *obj_p, /**< points to promise object */ ecma_value_t result) /**< the result value */ { @@ -84,7 +84,7 @@ ecma_promise_set_result (ecma_object_t *obj_p, /**< points to promise object */ * * @return the state's enum value */ -inline uint8_t JERRY_ATTR_ALWAYS_INLINE +static inline uint8_t JERRY_ATTR_ALWAYS_INLINE ecma_promise_get_state (ecma_object_t *obj_p) /**< points to promise object */ { JERRY_ASSERT (ecma_is_promise (obj_p)); @@ -95,7 +95,7 @@ ecma_promise_get_state (ecma_object_t *obj_p) /**< points to promise object */ /** * Set the PromiseState of promise. */ -inline void JERRY_ATTR_ALWAYS_INLINE +static inline void JERRY_ATTR_ALWAYS_INLINE ecma_promise_set_state (ecma_object_t *obj_p, /**< points to promise object */ uint8_t state) /**< the state */ { diff --git a/jerry-core/ecma/operations/ecma-promise-object.h b/jerry-core/ecma/operations/ecma-promise-object.h index d688be1d..a32018b6 100644 --- a/jerry-core/ecma/operations/ecma-promise-object.h +++ b/jerry-core/ecma/operations/ecma-promise-object.h @@ -86,10 +86,6 @@ typedef enum } ecma_promise_property_symbolic_constant_t; bool ecma_is_promise (ecma_object_t *obj_p); -ecma_value_t ecma_promise_get_result (ecma_object_t *obj_p); -void ecma_promise_set_result (ecma_object_t *obj_p, ecma_value_t result); -uint8_t ecma_promise_get_state (ecma_object_t *obj_p); -void ecma_promise_set_state (ecma_object_t *obj_p, uint8_t state); ecma_value_t ecma_op_create_promise_object (ecma_value_t executor, ecma_promise_executor_type_t type); ecma_value_t ecma_promise_new_capability (void); diff --git a/jerry-core/jmem/jmem-allocator.c b/jerry-core/jmem/jmem-allocator.c index f6bc9a4c..10f880f8 100644 --- a/jerry-core/jmem/jmem-allocator.c +++ b/jerry-core/jmem/jmem-allocator.c @@ -24,138 +24,11 @@ #define JMEM_ALLOCATOR_INTERNAL #include "jmem-allocator-internal.h" -/** - * Initialize memory allocators. - */ -void -jmem_init (void) -{ - jmem_heap_init (); -} /* jmem_init */ - -/** - * Finalize memory allocators. - */ -void -jmem_finalize (void) -{ - jmem_pools_finalize (); - -#ifdef JMEM_STATS - if (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_MEM_STATS) - { - jmem_stats_print (); - } -#endif /* JMEM_STATS */ - - jmem_heap_finalize (); -} /* jmem_finalize */ - -/** - * Compress pointer - * - * @return packed pointer - */ -inline jmem_cpointer_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE -jmem_compress_pointer (const void *pointer_p) /**< pointer to compress */ -{ - JERRY_ASSERT (pointer_p != NULL); - JERRY_ASSERT (jmem_is_heap_pointer (pointer_p)); - - uintptr_t uint_ptr = (uintptr_t) pointer_p; - - JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0); - -#if defined (ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY) && defined (JERRY_CPOINTER_32_BIT) - JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr); -#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY || !JERRY_CPOINTER_32_BIT */ - const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first); - - uint_ptr -= heap_start; - uint_ptr >>= JMEM_ALIGNMENT_LOG; - -#ifdef JERRY_CPOINTER_32_BIT - JERRY_ASSERT (uint_ptr <= UINT32_MAX); -#else /* !JERRY_CPOINTER_32_BIT */ - JERRY_ASSERT (uint_ptr <= UINT16_MAX); -#endif /* JERRY_CPOINTER_32_BIT */ - JERRY_ASSERT (uint_ptr != JMEM_CP_NULL); -#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY && JERRY_CPOINTER_32_BIT */ - - return (jmem_cpointer_t) uint_ptr; -} /* jmem_compress_pointer */ - -/** - * Decompress pointer - * - * @return unpacked pointer - */ -inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE -jmem_decompress_pointer (uintptr_t compressed_pointer) /**< pointer to decompress */ -{ - JERRY_ASSERT (compressed_pointer != JMEM_CP_NULL); - - uintptr_t uint_ptr = compressed_pointer; - - JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr); - -#if defined (ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY) && defined (JERRY_CPOINTER_32_BIT) - JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0); -#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY || !JERRY_CPOINTER_32_BIT */ - const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first); - - uint_ptr <<= JMEM_ALIGNMENT_LOG; - uint_ptr += heap_start; - - JERRY_ASSERT (jmem_is_heap_pointer ((void *) uint_ptr)); -#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY && JERRY_CPOINTER_32_BIT */ - - return (void *) uint_ptr; -} /* jmem_decompress_pointer */ - -/** - * Register specified 'try to give memory back' callback routine - */ -void -jmem_register_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback) /**< callback routine */ -{ - /* Currently only one callback is supported */ - JERRY_ASSERT (JERRY_CONTEXT (jmem_free_unused_memory_callback) == NULL); - - JERRY_CONTEXT (jmem_free_unused_memory_callback) = callback; -} /* jmem_register_free_unused_memory_callback */ - -/** - * Unregister specified 'try to give memory back' callback routine - */ -void -jmem_unregister_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback) /**< callback routine */ -{ - /* Currently only one callback is supported */ - JERRY_ASSERT (JERRY_CONTEXT (jmem_free_unused_memory_callback) == callback); - - JERRY_CONTEXT (jmem_free_unused_memory_callback) = NULL; -} /* jmem_unregister_free_unused_memory_callback */ - -/** - * Run 'try to give memory back' callbacks with specified severity - */ -void -jmem_run_free_unused_memory_callbacks (jmem_free_unused_memory_severity_t severity) /**< severity of the request */ -{ - if (JERRY_CONTEXT (jmem_free_unused_memory_callback) != NULL) - { - JERRY_CONTEXT (jmem_free_unused_memory_callback) (severity); - } - - jmem_pools_collect_empty (); -} /* jmem_run_free_unused_memory_callbacks */ - #ifdef JMEM_STATS /** * Print memory usage statistics */ -void +static void jmem_stats_print (void) { jmem_heap_stats_print (); @@ -278,3 +151,130 @@ jmem_stats_free_property_bytes (size_t property_size) } /* jmem_stats_free_property_bytes */ #endif /* JMEM_STATS */ + +/** + * Initialize memory allocators. + */ +void +jmem_init (void) +{ + jmem_heap_init (); +} /* jmem_init */ + +/** + * Finalize memory allocators. + */ +void +jmem_finalize (void) +{ + jmem_pools_finalize (); + +#ifdef JMEM_STATS + if (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_MEM_STATS) + { + jmem_stats_print (); + } +#endif /* JMEM_STATS */ + + jmem_heap_finalize (); +} /* jmem_finalize */ + +/** + * Compress pointer + * + * @return packed pointer + */ +inline jmem_cpointer_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE +jmem_compress_pointer (const void *pointer_p) /**< pointer to compress */ +{ + JERRY_ASSERT (pointer_p != NULL); + JERRY_ASSERT (jmem_is_heap_pointer (pointer_p)); + + uintptr_t uint_ptr = (uintptr_t) pointer_p; + + JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0); + +#if defined (ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY) && defined (JERRY_CPOINTER_32_BIT) + JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr); +#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY || !JERRY_CPOINTER_32_BIT */ + const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first); + + uint_ptr -= heap_start; + uint_ptr >>= JMEM_ALIGNMENT_LOG; + +#ifdef JERRY_CPOINTER_32_BIT + JERRY_ASSERT (uint_ptr <= UINT32_MAX); +#else /* !JERRY_CPOINTER_32_BIT */ + JERRY_ASSERT (uint_ptr <= UINT16_MAX); +#endif /* JERRY_CPOINTER_32_BIT */ + JERRY_ASSERT (uint_ptr != JMEM_CP_NULL); +#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY && JERRY_CPOINTER_32_BIT */ + + return (jmem_cpointer_t) uint_ptr; +} /* jmem_compress_pointer */ + +/** + * Decompress pointer + * + * @return unpacked pointer + */ +inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE +jmem_decompress_pointer (uintptr_t compressed_pointer) /**< pointer to decompress */ +{ + JERRY_ASSERT (compressed_pointer != JMEM_CP_NULL); + + uintptr_t uint_ptr = compressed_pointer; + + JERRY_ASSERT (((jmem_cpointer_t) uint_ptr) == uint_ptr); + +#if defined (ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY) && defined (JERRY_CPOINTER_32_BIT) + JERRY_ASSERT (uint_ptr % JMEM_ALIGNMENT == 0); +#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY || !JERRY_CPOINTER_32_BIT */ + const uintptr_t heap_start = (uintptr_t) &JERRY_HEAP_CONTEXT (first); + + uint_ptr <<= JMEM_ALIGNMENT_LOG; + uint_ptr += heap_start; + + JERRY_ASSERT (jmem_is_heap_pointer ((void *) uint_ptr)); +#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY && JERRY_CPOINTER_32_BIT */ + + return (void *) uint_ptr; +} /* jmem_decompress_pointer */ + +/** + * Register specified 'try to give memory back' callback routine + */ +void +jmem_register_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback) /**< callback routine */ +{ + /* Currently only one callback is supported */ + JERRY_ASSERT (JERRY_CONTEXT (jmem_free_unused_memory_callback) == NULL); + + JERRY_CONTEXT (jmem_free_unused_memory_callback) = callback; +} /* jmem_register_free_unused_memory_callback */ + +/** + * Unregister specified 'try to give memory back' callback routine + */ +void +jmem_unregister_free_unused_memory_callback (jmem_free_unused_memory_callback_t callback) /**< callback routine */ +{ + /* Currently only one callback is supported */ + JERRY_ASSERT (JERRY_CONTEXT (jmem_free_unused_memory_callback) == callback); + + JERRY_CONTEXT (jmem_free_unused_memory_callback) = NULL; +} /* jmem_unregister_free_unused_memory_callback */ + +/** + * Run 'try to give memory back' callbacks with specified severity + */ +void +jmem_run_free_unused_memory_callbacks (jmem_free_unused_memory_severity_t severity) /**< severity of the request */ +{ + if (JERRY_CONTEXT (jmem_free_unused_memory_callback) != NULL) + { + JERRY_CONTEXT (jmem_free_unused_memory_callback) (severity); + } + + jmem_pools_collect_empty (); +} /* jmem_run_free_unused_memory_callbacks */ diff --git a/jerry-core/jmem/jmem.h b/jerry-core/jmem/jmem.h index 206dba9c..a6caa093 100644 --- a/jerry-core/jmem/jmem.h +++ b/jerry-core/jmem/jmem.h @@ -151,7 +151,6 @@ typedef struct size_t free_iter_count; /**< Number of iterations required for inserting free blocks */ } jmem_heap_stats_t; -void jmem_stats_print (void); void jmem_stats_allocate_byte_code_bytes (size_t property_size); void jmem_stats_free_byte_code_bytes (size_t property_size); void jmem_stats_allocate_string_bytes (size_t string_size); diff --git a/jerry-core/lit/lit-char-helpers.c b/jerry-core/lit/lit-char-helpers.c index cb790fc5..e0026ab6 100644 --- a/jerry-core/lit/lit-char-helpers.c +++ b/jerry-core/lit/lit-char-helpers.c @@ -102,20 +102,6 @@ search_char_in_interval_array (ecma_char_t c, /**< code unit */ } /* search_char_in_interval_array */ /** - * Check if specified character is one of the Format-Control characters - * - * @return true - if the character is one of characters, listed in ECMA-262 v5, Table 1, - * false - otherwise - */ -bool -lit_char_is_format_control (ecma_char_t c) /**< code unit */ -{ - return (c == LIT_CHAR_ZWNJ - || c == LIT_CHAR_ZWJ - || c == LIT_CHAR_BOM); -} /* lit_char_is_format_control */ - -/** * Check if specified character is one of the Whitespace characters including those * that fall into "Space, Separator" ("Zs") Unicode character category. * diff --git a/jerry-core/lit/lit-char-helpers.h b/jerry-core/lit/lit-char-helpers.h index ae018c91..fdaec1d3 100644 --- a/jerry-core/lit/lit-char-helpers.h +++ b/jerry-core/lit/lit-char-helpers.h @@ -27,8 +27,6 @@ #define LIT_CHAR_ZWJ ((ecma_char_t) 0x200D) /* zero width joiner */ #define LIT_CHAR_BOM ((ecma_char_t) 0xFEFF) /* byte order mark */ -bool lit_char_is_format_control (ecma_char_t c); - /* * Whitespace characters (ECMA-262 v5, Table 2) */ diff --git a/jerry-core/lit/lit-magic-strings.c b/jerry-core/lit/lit-magic-strings.c index aee9837e..08cd5a41 100644 --- a/jerry-core/lit/lit-magic-strings.c +++ b/jerry-core/lit/lit-magic-strings.c @@ -81,7 +81,7 @@ lit_get_magic_string_size (lit_magic_string_id_t id) /**< magic string id */ * * @return magic string id */ -lit_magic_string_id_t +static lit_magic_string_id_t lit_get_magic_string_size_block_start (lit_utf8_size_t size) /**< magic string size */ { static const lit_magic_string_id_t lit_magic_string_size_block_starts[] JERRY_CONST_DATA = diff --git a/jerry-core/lit/lit-magic-strings.h b/jerry-core/lit/lit-magic-strings.h index c4a40107..8f31b974 100644 --- a/jerry-core/lit/lit-magic-strings.h +++ b/jerry-core/lit/lit-magic-strings.h @@ -52,7 +52,6 @@ uint32_t lit_get_magic_string_ex_count (void); const lit_utf8_byte_t *lit_get_magic_string_utf8 (lit_magic_string_id_t id); lit_utf8_size_t lit_get_magic_string_size (lit_magic_string_id_t id); -lit_magic_string_id_t lit_get_magic_string_size_block_start (lit_utf8_size_t size); const lit_utf8_byte_t *lit_get_magic_string_ex_utf8 (lit_magic_string_ex_id_t id); lit_utf8_size_t lit_get_magic_string_ex_size (lit_magic_string_ex_id_t id); diff --git a/jerry-core/parser/js/js-parser-internal.h b/jerry-core/parser/js/js-parser-internal.h index f32c9f88..ae4ff030 100644 --- a/jerry-core/parser/js/js-parser-internal.h +++ b/jerry-core/parser/js/js-parser-internal.h @@ -514,7 +514,6 @@ void parser_raise_error (parser_context_t *context_p, parser_error_t error); #ifdef JERRY_DEBUGGER void parser_append_breakpoint_info (parser_context_t *context_p, jerry_debugger_header_type_t type, uint32_t value); -void parser_send_breakpoints (parser_context_t *context_p, jerry_debugger_header_type_t type); #endif /* JERRY_DEBUGGER */ diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index 6771e6a3..f5d572bc 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -1356,6 +1356,48 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code #endif /* PARSER_DUMP_BYTE_CODE */ +#ifdef JERRY_DEBUGGER + +/** + * Send current breakpoint list. + */ +static void +parser_send_breakpoints (parser_context_t *context_p, /**< context */ + jerry_debugger_header_type_t type) /**< message type */ +{ + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); + JERRY_ASSERT (context_p->breakpoint_info_count > 0); + + jerry_debugger_send_data (type, + context_p->breakpoint_info, + context_p->breakpoint_info_count * sizeof (parser_breakpoint_info_t)); + + context_p->breakpoint_info_count = 0; +} /* parser_send_breakpoints */ + +/** + * Append a breakpoint info. + */ +void +parser_append_breakpoint_info (parser_context_t *context_p, /**< context */ + jerry_debugger_header_type_t type, /**< message type */ + uint32_t value) /**< line or offset of the breakpoint */ +{ + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); + + context_p->status_flags |= PARSER_DEBUGGER_BREAKPOINT_APPENDED; + + if (context_p->breakpoint_info_count >= JERRY_DEBUGGER_SEND_MAX (parser_breakpoint_info_t)) + { + parser_send_breakpoints (context_p, type); + } + + context_p->breakpoint_info[context_p->breakpoint_info_count].value = value; + context_p->breakpoint_info_count = (uint16_t) (context_p->breakpoint_info_count + 1); +} /* parser_append_breakpoint_info */ + +#endif /* JERRY_DEBUGGER */ + /** * Forward iterator: move to the next byte code * @@ -2803,48 +2845,6 @@ parser_raise_error (parser_context_t *context_p, /**< context */ JERRY_ASSERT (0); } /* parser_raise_error */ -#ifdef JERRY_DEBUGGER - -/** - * Append a breakpoint info. - */ -void -parser_append_breakpoint_info (parser_context_t *context_p, /**< context */ - jerry_debugger_header_type_t type, /**< message type */ - uint32_t value) /**< line or offset of the breakpoint */ -{ - JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); - - context_p->status_flags |= PARSER_DEBUGGER_BREAKPOINT_APPENDED; - - if (context_p->breakpoint_info_count >= JERRY_DEBUGGER_SEND_MAX (parser_breakpoint_info_t)) - { - parser_send_breakpoints (context_p, type); - } - - context_p->breakpoint_info[context_p->breakpoint_info_count].value = value; - context_p->breakpoint_info_count = (uint16_t) (context_p->breakpoint_info_count + 1); -} /* parser_append_breakpoint_info */ - -/** - * Send current breakpoint list. - */ -void -parser_send_breakpoints (parser_context_t *context_p, /**< context */ - jerry_debugger_header_type_t type) /**< message type */ -{ - JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); - JERRY_ASSERT (context_p->breakpoint_info_count > 0); - - jerry_debugger_send_data (type, - context_p->breakpoint_info, - context_p->breakpoint_info_count * sizeof (parser_breakpoint_info_t)); - - context_p->breakpoint_info_count = 0; -} /* parser_send_breakpoints */ - -#endif /* JERRY_DEBUGGER */ - #endif /* !JERRY_DISABLE_JS_PARSER */ /** |