Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
@@ -14,10 +14,12 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "jrt.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "jrt.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
|
||||
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
|
||||
@@ -51,7 +53,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <=
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_number_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_number (void)
|
||||
{
|
||||
return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t));
|
||||
@@ -71,7 +73,7 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_object (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -99,7 +101,7 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_object (size_t size) /**< size of object */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -128,7 +130,7 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -156,7 +158,7 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -184,7 +186,7 @@ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extende
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_external_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_external_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_external_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -212,7 +214,7 @@ ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< externa
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string_buffer (size_t size) /**< size of string */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -241,7 +243,7 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_property_pair_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_pair_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_property_pair (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "ecma-errors.h"
|
||||
|
||||
@@ -20,114 +20,114 @@
|
||||
/**
|
||||
* Error message, if an argument is has an error flag
|
||||
*/
|
||||
const char * const ecma_error_value_msg_p = "Argument cannot be marked as error";
|
||||
const char* const ecma_error_value_msg_p = "Argument cannot be marked as error";
|
||||
|
||||
/**
|
||||
* Error message, if an argument has a wrong type
|
||||
*/
|
||||
const char * const ecma_error_wrong_args_msg_p = "This type of argument is not allowed";
|
||||
const char* const ecma_error_wrong_args_msg_p = "This type of argument is not allowed";
|
||||
|
||||
#if !JERRY_PARSER
|
||||
/**
|
||||
* Error message, if parsing is disabled
|
||||
*/
|
||||
const char * const ecma_error_parser_not_supported_p = "Source code parsing is disabled";
|
||||
const char* const ecma_error_parser_not_supported_p = "Source code parsing is disabled";
|
||||
#endif /* !JERRY_PARSER */
|
||||
|
||||
#if !JERRY_BUILTIN_JSON
|
||||
/**
|
||||
* Error message, if JSON support is disabled
|
||||
*/
|
||||
const char * const ecma_error_json_not_supported_p = "JSON support is disabled";
|
||||
const char* const ecma_error_json_not_supported_p = "JSON support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_JSON */
|
||||
|
||||
#if !JERRY_ESNEXT
|
||||
/**
|
||||
* Error message, if Symbol support is disabled
|
||||
*/
|
||||
const char * const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
|
||||
const char* const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
|
||||
/**
|
||||
* Error message, if Promise support is disabled
|
||||
*/
|
||||
const char * const ecma_error_promise_not_supported_p = "Promise support is disabled";
|
||||
const char* const ecma_error_promise_not_supported_p = "Promise support is disabled";
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
|
||||
#if !JERRY_BUILTIN_TYPEDARRAY
|
||||
/**
|
||||
* Error message, if TypedArray support is disabled
|
||||
*/
|
||||
const char * const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled";
|
||||
const char* const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
/**
|
||||
* Error message, if SharedArrayBuffer support is disabled
|
||||
*/
|
||||
const char * const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled";
|
||||
const char* const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
|
||||
#if !JERRY_BUILTIN_DATAVIEW
|
||||
/**
|
||||
* Error message, if DataView support is disabled
|
||||
*/
|
||||
const char * const ecma_error_data_view_not_supported_p = "DataView support is disabled";
|
||||
const char* const ecma_error_data_view_not_supported_p = "DataView support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if !JERRY_BUILTIN_BIGINT
|
||||
/**
|
||||
* Error message, if BigInt support is disabled
|
||||
*/
|
||||
const char * const ecma_error_bigint_not_supported_p = "BigInt support is disabled";
|
||||
const char* const ecma_error_bigint_not_supported_p = "BigInt support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if !JERRY_BUILTIN_CONTAINER
|
||||
/**
|
||||
* Error message, if Container support is disabled
|
||||
*/
|
||||
const char * const ecma_error_container_not_supported_p = "Container support is disabled";
|
||||
const char* const ecma_error_container_not_supported_p = "Container support is disabled";
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
/**
|
||||
* Error message, if argument is not a module
|
||||
*/
|
||||
const char * const ecma_error_not_module_p = "Argument is not a module";
|
||||
const char* const ecma_error_not_module_p = "Argument is not a module";
|
||||
|
||||
/**
|
||||
* Error message, if a native module export is not found
|
||||
*/
|
||||
const char * const ecma_error_unknown_export_p = "Native module export not found";
|
||||
const char* const ecma_error_unknown_export_p = "Native module export not found";
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
/**
|
||||
* Error message, if Module support is disabled
|
||||
*/
|
||||
const char * const ecma_error_module_not_supported_p = "Module support is disabled";
|
||||
const char* const ecma_error_module_not_supported_p = "Module support is disabled";
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/**
|
||||
* Error message, if callback function is not callable
|
||||
*/
|
||||
const char * const ecma_error_callback_is_not_callable = "Callback function is not callable";
|
||||
* Error message, if callback function is not callable
|
||||
*/
|
||||
const char* const ecma_error_callback_is_not_callable = "Callback function is not callable";
|
||||
|
||||
/**
|
||||
* Error message, if arrayBuffer is detached
|
||||
*/
|
||||
const char * const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached";
|
||||
const char* const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached";
|
||||
|
||||
/**
|
||||
* Error message, cannot convert undefined or null to object
|
||||
*/
|
||||
const char * const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object";
|
||||
const char* const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object";
|
||||
|
||||
/**
|
||||
* Error message, prototype property of a class is non-configurable
|
||||
*/
|
||||
const char * const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable";
|
||||
const char* const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable";
|
||||
|
||||
/**
|
||||
* Error message, argument is not an object
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_an_object = "Argument is not an object";
|
||||
const char* const ecma_error_argument_is_not_an_object = "Argument is not an object";
|
||||
|
||||
/**
|
||||
* Error message length of 'ecma_error_argument_is_not_an_object'
|
||||
@@ -137,45 +137,45 @@ const int ecma_error_argument_is_not_an_object_length = 25;
|
||||
/**
|
||||
* Error message, argument is not a Proxy object
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object";
|
||||
const char* const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object";
|
||||
|
||||
/**
|
||||
* Error message, target is not a constructor
|
||||
*/
|
||||
const char * const ecma_error_target_is_not_a_constructor = "Target is not a constructor";
|
||||
const char* const ecma_error_target_is_not_a_constructor = "Target is not a constructor";
|
||||
|
||||
/**
|
||||
* Error message, argument is not an regexp
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object";
|
||||
const char* const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object";
|
||||
|
||||
/**
|
||||
* Error message, invalid array length
|
||||
*/
|
||||
const char * const ecma_error_invalid_array_length = "Invalid Array length";
|
||||
const char* const ecma_error_invalid_array_length = "Invalid Array length";
|
||||
|
||||
/**
|
||||
* Error message, local variable is redeclared
|
||||
*/
|
||||
const char * const ecma_error_local_variable_is_redeclared = "Local variable is redeclared";
|
||||
const char* const ecma_error_local_variable_is_redeclared = "Local variable is redeclared";
|
||||
|
||||
/**
|
||||
* Error message, expected a function
|
||||
*/
|
||||
const char * const ecma_error_expected_a_function = "Expected a function";
|
||||
const char* const ecma_error_expected_a_function = "Expected a function";
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/**
|
||||
* Error message, class constructor invoked without new keyword
|
||||
*/
|
||||
const char * const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
|
||||
const char* const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
|
||||
|
||||
/**
|
||||
* Error message, variables declared by let/const must be initialized before reading their value
|
||||
*/
|
||||
const char * const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
|
||||
" initialized before reading their value");
|
||||
const char* const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
|
||||
" initialized before reading their value");
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -186,31 +186,31 @@ const char * const ecma_error_let_const_not_initialized = ("Variables declared b
|
||||
/**
|
||||
* Error message, maximum snapshot size reached
|
||||
*/
|
||||
const char * const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached";
|
||||
const char* const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached";
|
||||
|
||||
/**
|
||||
* Error message, regular expressions literals are not supported
|
||||
*/
|
||||
const char * const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported";
|
||||
const char* const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported";
|
||||
|
||||
/**
|
||||
* Error message, snapshot buffer too small
|
||||
*/
|
||||
const char * const ecma_error_snapshot_buffer_small = "Snapshot buffer too small";
|
||||
const char* const ecma_error_snapshot_buffer_small = "Snapshot buffer too small";
|
||||
|
||||
/**
|
||||
* Error message, Unsupported generate snapshot flags specified
|
||||
*/
|
||||
const char * const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified";
|
||||
const char* const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified";
|
||||
|
||||
/**
|
||||
* Error message, Cannot allocate memory for literals
|
||||
*/
|
||||
const char * const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals";
|
||||
const char* const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals";
|
||||
|
||||
/**
|
||||
* Error message, Unsupported feature: tagged template literals
|
||||
*/
|
||||
const char * const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals";
|
||||
const char* const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals";
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC */
|
||||
|
||||
@@ -20,75 +20,75 @@
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
|
||||
extern const char * const ecma_error_value_msg_p;
|
||||
extern const char * const ecma_error_wrong_args_msg_p;
|
||||
extern const char* const ecma_error_value_msg_p;
|
||||
extern const char* const ecma_error_wrong_args_msg_p;
|
||||
|
||||
#if !JERRY_PARSER
|
||||
extern const char * const ecma_error_parser_not_supported_p;
|
||||
extern const char* const ecma_error_parser_not_supported_p;
|
||||
#endif /* !JERRY_PARSER */
|
||||
|
||||
#if !JERRY_BUILTIN_JSON
|
||||
extern const char * const ecma_error_json_not_supported_p;
|
||||
extern const char* const ecma_error_json_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_JSON */
|
||||
|
||||
#if !JERRY_ESNEXT
|
||||
extern const char * const ecma_error_symbol_not_supported_p;
|
||||
extern const char* const ecma_error_symbol_not_supported_p;
|
||||
|
||||
extern const char * const ecma_error_promise_not_supported_p;
|
||||
extern const char* const ecma_error_promise_not_supported_p;
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
|
||||
#if !JERRY_BUILTIN_TYPEDARRAY
|
||||
extern const char * const ecma_error_typed_array_not_supported_p;
|
||||
extern const char* const ecma_error_typed_array_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
extern const char * const ecma_error_shared_arraybuffer_not_supported_p;
|
||||
extern const char* const ecma_error_shared_arraybuffer_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
|
||||
#if !JERRY_BUILTIN_DATAVIEW
|
||||
extern const char * const ecma_error_data_view_not_supported_p;
|
||||
extern const char* const ecma_error_data_view_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if !JERRY_BUILTIN_BIGINT
|
||||
extern const char * const ecma_error_bigint_not_supported_p;
|
||||
extern const char* const ecma_error_bigint_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if !JERRY_BUILTIN_CONTAINER
|
||||
extern const char * const ecma_error_container_not_supported_p;
|
||||
extern const char* const ecma_error_container_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
extern const char * const ecma_error_not_module_p;
|
||||
extern const char * const ecma_error_unknown_export_p;
|
||||
extern const char* const ecma_error_not_module_p;
|
||||
extern const char* const ecma_error_unknown_export_p;
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
extern const char * const ecma_error_module_not_supported_p;
|
||||
extern const char* const ecma_error_module_not_supported_p;
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
extern const char * const ecma_error_callback_is_not_callable;
|
||||
extern const char * const ecma_error_arraybuffer_is_detached;
|
||||
extern const char * const ecma_error_cannot_convert_to_object;
|
||||
extern const char * const ecma_error_class_is_non_configurable;
|
||||
extern const char * const ecma_error_argument_is_not_an_object;
|
||||
extern const char* const ecma_error_callback_is_not_callable;
|
||||
extern const char* const ecma_error_arraybuffer_is_detached;
|
||||
extern const char* const ecma_error_cannot_convert_to_object;
|
||||
extern const char* const ecma_error_class_is_non_configurable;
|
||||
extern const char* const ecma_error_argument_is_not_an_object;
|
||||
extern const int ecma_error_argument_is_not_an_object_length;
|
||||
extern const char * const ecma_error_argument_is_not_a_proxy;
|
||||
extern const char * const ecma_error_target_is_not_a_constructor;
|
||||
extern const char * const ecma_error_argument_is_not_an_regexp;
|
||||
extern const char * const ecma_error_invalid_array_length;
|
||||
extern const char * const ecma_error_local_variable_is_redeclared;
|
||||
extern const char * const ecma_error_expected_a_function;
|
||||
extern const char* const ecma_error_argument_is_not_a_proxy;
|
||||
extern const char* const ecma_error_target_is_not_a_constructor;
|
||||
extern const char* const ecma_error_argument_is_not_an_regexp;
|
||||
extern const char* const ecma_error_invalid_array_length;
|
||||
extern const char* const ecma_error_local_variable_is_redeclared;
|
||||
extern const char* const ecma_error_expected_a_function;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
extern const char * const ecma_error_class_constructor_new;
|
||||
extern const char * const ecma_error_let_const_not_initialized;
|
||||
extern const char* const ecma_error_class_constructor_new;
|
||||
extern const char* const ecma_error_let_const_not_initialized;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
|
||||
/* snapshot errors */
|
||||
extern const char * const ecma_error_maximum_snapshot_size;
|
||||
extern const char * const ecma_error_regular_expression_not_supported;
|
||||
extern const char * const ecma_error_snapshot_buffer_small;
|
||||
extern const char * const ecma_error_snapshot_flag_not_supported;
|
||||
extern const char * const ecma_error_cannot_allocate_memory_literals;
|
||||
extern const char * const ecma_error_tagged_template_literals;
|
||||
#endif /* !ECMA_ERRORS_H */
|
||||
extern const char* const ecma_error_maximum_snapshot_size;
|
||||
extern const char* const ecma_error_regular_expression_not_supported;
|
||||
extern const char* const ecma_error_snapshot_buffer_small;
|
||||
extern const char* const ecma_error_snapshot_flag_not_supported;
|
||||
extern const char* const ecma_error_cannot_allocate_memory_literals;
|
||||
extern const char* const ecma_error_tagged_template_literals;
|
||||
#endif /* !ECMA_ERRORS_H */
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-extended-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -41,8 +43,7 @@ ecma_extended_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer *
|
||||
{
|
||||
source_p--;
|
||||
value = (value << ECMA_EXTENDED_INFO_VLQ_SHIFT) | (*source_p & ECMA_EXTENDED_INFO_VLQ_MASK);
|
||||
}
|
||||
while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
} while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
@@ -71,8 +72,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
|
||||
{
|
||||
current_value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
}
|
||||
while (current_value > 0);
|
||||
} while (current_value > 0);
|
||||
|
||||
destination_p -= length;
|
||||
*buffer_p = destination_p;
|
||||
@@ -81,8 +81,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
|
||||
{
|
||||
*destination_p++ = (uint8_t) (value | ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
}
|
||||
while (value > 0);
|
||||
} while (value > 0);
|
||||
|
||||
**buffer_p &= ECMA_EXTENDED_INFO_VLQ_MASK;
|
||||
} /* ecma_extended_info_encode_vlq */
|
||||
@@ -101,8 +100,7 @@ ecma_extended_info_get_encoded_length (uint32_t value) /**< encoded value */
|
||||
{
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
}
|
||||
while (value > 0);
|
||||
} while (value > 0);
|
||||
|
||||
return length;
|
||||
} /* ecma_extended_info_get_encoded_length */
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
/**
|
||||
* Vlq encoding: flag which is set for all bytes except the last one.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* Garbage collector implementation
|
||||
*/
|
||||
|
||||
#include "ecma-gc.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
@@ -24,16 +26,16 @@
|
||||
#include "ecma-container-object.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
#include "re-compiler.h"
|
||||
#include "vm-defines.h"
|
||||
#include "vm-stack.h"
|
||||
@@ -300,8 +302,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
|
||||
if (!ECMA_PROPERTY_IS_INTERNAL (property))
|
||||
{
|
||||
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED
|
||||
|| property == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED || property == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -314,8 +315,8 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
case LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD:
|
||||
{
|
||||
ecma_environment_record_t *environment_record_p;
|
||||
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t,
|
||||
property_pair_p->values[index].value);
|
||||
environment_record_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t, property_pair_p->values[index].value);
|
||||
|
||||
if (environment_record_p->this_binding != ECMA_VALUE_UNINITIALIZED)
|
||||
{
|
||||
@@ -397,8 +398,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (*value_p));
|
||||
}
|
||||
}
|
||||
while (++value_p < end_p);
|
||||
} while (++value_p < end_p);
|
||||
|
||||
if (property & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)
|
||||
{
|
||||
@@ -406,8 +406,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
item_p = &(((ecma_native_pointer_chain_t *) item_p)->next_p->data);
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -460,8 +459,8 @@ ecma_gc_mark_bound_function_object (ecma_object_t *object_p) /**< bound function
|
||||
ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) object_p;
|
||||
|
||||
ecma_object_t *target_func_p;
|
||||
target_func_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
bound_func_p->header.u.bound_function.target_function);
|
||||
target_func_p =
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function);
|
||||
|
||||
ecma_gc_set_object_visited (target_func_p);
|
||||
|
||||
@@ -547,12 +546,11 @@ ecma_gc_mark_map_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
|
||||
{
|
||||
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
|
||||
|
||||
@@ -582,12 +580,11 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
|
||||
{
|
||||
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
|
||||
|
||||
@@ -598,8 +595,7 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_object (entry_p->key));
|
||||
|
||||
if (ecma_is_value_object (entry_p->value)
|
||||
&& ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
|
||||
if (ecma_is_value_object (entry_p->value) && ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (entry_p->value));
|
||||
}
|
||||
@@ -615,12 +611,11 @@ ecma_gc_mark_set_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_VALUE_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_VALUE_SIZE)
|
||||
{
|
||||
ecma_value_t *entry_p = start_p + i;
|
||||
|
||||
@@ -728,8 +723,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
do
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (*(--context_top_p)));
|
||||
}
|
||||
while (context_top_p > last_item_p);
|
||||
} while (context_top_p > last_item_p);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -750,8 +744,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
|
||||
JERRY_ASSERT (context_top_p >= context_end_p + offsets);
|
||||
context_top_p -= offsets;
|
||||
}
|
||||
while (context_top_p > context_end_p);
|
||||
} while (context_top_p > context_end_p);
|
||||
}
|
||||
|
||||
register_end_p = executable_object_p->frame_ctx.stack_top_p;
|
||||
@@ -891,8 +884,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_CLASS_SCRIPT:
|
||||
{
|
||||
const ecma_compiled_code_t *compiled_code_p;
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
JERRY_ASSERT (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
|
||||
ecma_gc_mark_compiled_code (((cbc_uint8_arguments_t *) compiled_code_p)->script_value);
|
||||
@@ -910,8 +902,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_CLASS_MODULE_NAMESPACE:
|
||||
{
|
||||
JERRY_ASSERT (proto_cp == JMEM_CP_NULL);
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.cls.u3.value));
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ext_object_p->u.cls.u3.value));
|
||||
ecma_gc_mark_properties (object_p, true);
|
||||
return;
|
||||
}
|
||||
@@ -1114,8 +1105,8 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_TYPE_FUNCTION:
|
||||
{
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
ext_func_p->u.function.scope_cp));
|
||||
ecma_gc_set_object_visited (
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_func_p->u.function.scope_cp));
|
||||
|
||||
const ecma_compiled_code_t *compiled_code_p = ecma_op_function_get_compiled_code (ext_func_p);
|
||||
|
||||
@@ -1249,8 +1240,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_TYPE_NATIVE_FUNCTION:
|
||||
{
|
||||
ecma_native_function_t *native_function_p = (ecma_native_function_t *) object_p;
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
native_function_p->realm_value));
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, native_function_p->realm_value));
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
@@ -1322,8 +1312,7 @@ ecma_gc_free_native_pointer (ecma_property_t property, /**< property descriptor
|
||||
jmem_heap_free_block (item_p, sizeof (ecma_native_pointer_chain_t));
|
||||
|
||||
item_p = next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
} /* ecma_gc_free_native_pointer */
|
||||
|
||||
/**
|
||||
@@ -1347,8 +1336,8 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
|
||||
if (!(mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE))
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
{
|
||||
ecma_compiled_code_t *byte_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
mapped_arguments_p->u.byte_code);
|
||||
ecma_compiled_code_t *byte_code_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, mapped_arguments_p->u.byte_code);
|
||||
|
||||
ecma_bytecode_deref (byte_code_p);
|
||||
}
|
||||
@@ -1363,8 +1352,7 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
|
||||
ecma_free_value_if_not_object (argv_p[i]);
|
||||
}
|
||||
|
||||
uint32_t saved_argument_count = JERRY_MAX (arguments_number,
|
||||
arguments_p->header.u.cls.u2.formal_params_number);
|
||||
uint32_t saved_argument_count = JERRY_MAX (arguments_number, arguments_p->header.u.cls.u2.formal_params_number);
|
||||
|
||||
return object_size + (saved_argument_count * sizeof (ecma_value_t));
|
||||
} /* ecma_free_arguments_object */
|
||||
@@ -1485,8 +1473,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
|
||||
do
|
||||
{
|
||||
ecma_free_value_if_not_object (*(--context_top_p));
|
||||
}
|
||||
while (context_top_p > last_item_p);
|
||||
} while (context_top_p > last_item_p);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -1506,8 +1493,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
|
||||
}
|
||||
|
||||
context_top_p = vm_stack_context_abort (&executable_object_p->frame_ctx, context_top_p);
|
||||
}
|
||||
while (context_top_p > context_end_p);
|
||||
} while (context_top_p > context_end_p);
|
||||
}
|
||||
|
||||
register_end_p = executable_object_p->frame_ctx.stack_top_p;
|
||||
@@ -1526,8 +1512,7 @@ JERRY_STATIC_ASSERT (!ECMA_PROPERTY_IS_RAW (ECMA_PROPERTY_TYPE_DELETED),
|
||||
ecma_property_type_deleted_must_not_be_raw_property);
|
||||
JERRY_STATIC_ASSERT ((ECMA_PROPERTY_TYPE_DELETED & ECMA_PROPERTY_FLAG_LCACHED) == 0,
|
||||
ecma_property_type_deleted_must_not_have_lcached_flag);
|
||||
JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1,
|
||||
ecma_gc_free_second_must_be_one);
|
||||
JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1, ecma_gc_free_second_must_be_one);
|
||||
|
||||
/**
|
||||
* Free property of an object
|
||||
@@ -1575,8 +1560,8 @@ ecma_gc_free_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_pair_p->values[index].getter_setter_pair_cp);
|
||||
getter_setter_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_pair_p->values[index].getter_setter_pair_cp);
|
||||
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
return;
|
||||
@@ -1655,8 +1640,7 @@ ecma_gc_free_properties (ecma_object_t *object_p, /**< object */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
ecma_property_hashmap_free (object_p);
|
||||
@@ -1791,8 +1775,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
case ECMA_OBJECT_CLASS_SCRIPT:
|
||||
{
|
||||
ecma_compiled_code_t *compiled_code_p;
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
ecma_bytecode_deref (compiled_code_p);
|
||||
break;
|
||||
@@ -1813,8 +1796,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
case ECMA_OBJECT_CLASS_REGEXP:
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
ecma_compiled_code_t *bytecode_p =
|
||||
ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
ecma_bytecode_deref (bytecode_p);
|
||||
|
||||
@@ -1886,8 +1869,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
case ECMA_OBJECT_CLASS_CONTAINER:
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_op_container_free_entries (object_p);
|
||||
ecma_collection_destroy (container_p);
|
||||
break;
|
||||
@@ -1978,8 +1961,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
if (ext_func_p->u.function.bytecode_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
ecma_compiled_code_t *byte_code_p = (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_func_p->u.function.bytecode_cp));
|
||||
ecma_compiled_code_t *byte_code_p =
|
||||
(ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_func_p->u.function.bytecode_cp));
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (CBC_FUNCTION_IS_ARROW (byte_code_p->status_flags))
|
||||
@@ -2227,8 +2210,7 @@ ecma_gc_run (void)
|
||||
|
||||
obj_iter_cp = obj_next_cp;
|
||||
}
|
||||
}
|
||||
while (marked_anything_during_current_iteration);
|
||||
} while (marked_anything_during_current_iteration);
|
||||
|
||||
black_end_p->gc_next_cp = JMEM_CP_NULL;
|
||||
JERRY_CONTEXT (ecma_gc_objects_cp) = black_list_head.gc_next_cp;
|
||||
@@ -2320,8 +2302,7 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
|
||||
if (!ecma_is_lexical_environment (obj_iter_p)
|
||||
|| ecma_get_lex_env_type (obj_iter_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
{
|
||||
if (!ecma_is_lexical_environment (obj_iter_p)
|
||||
&& ecma_op_object_is_fast_array (obj_iter_p))
|
||||
if (!ecma_is_lexical_environment (obj_iter_p) && ecma_op_object_is_fast_array (obj_iter_p))
|
||||
{
|
||||
obj_iter_cp = obj_iter_p->gc_next_cp;
|
||||
continue;
|
||||
@@ -2338,7 +2319,6 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
|
||||
ecma_property_hashmap_free (obj_iter_p);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
obj_iter_cp = obj_iter_p->gc_next_cp;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ECMA_GC_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
+136
-170
@@ -17,10 +17,11 @@
|
||||
#define ECMA_GLOBALS_H
|
||||
|
||||
#include "ecma-errors.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "jmem.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -37,7 +38,7 @@
|
||||
*/
|
||||
#define ECMA_NULL_POINTER JMEM_CP_NULL
|
||||
|
||||
#if defined (JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY)
|
||||
#if defined(JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY)
|
||||
|
||||
/**
|
||||
* JMEM_ALIGNMENT_LOG aligned pointers can be stored directly in ecma_value_t
|
||||
@@ -55,16 +56,16 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
|
||||
ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
|
||||
ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
|
||||
ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
ECMA_STATUS_HIGH_PRESSURE_GC = (1u << 2), /**< last gc was under high pressure */
|
||||
ECMA_STATUS_HIGH_PRESSURE_GC = (1u << 2), /**< last gc was under high pressure */
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
|
||||
ECMA_STATUS_ABORT = (1u << 4), /**< last exception is an abort */
|
||||
ECMA_STATUS_ERROR_UPDATE = (1u << 5), /**< the error_object_created_callback_p is called */
|
||||
ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
|
||||
ECMA_STATUS_ABORT = (1u << 4), /**< last exception is an abort */
|
||||
ECMA_STATUS_ERROR_UPDATE = (1u << 5), /**< the error_object_created_callback_p is called */
|
||||
#if JERRY_VM_THROW
|
||||
ECMA_STATUS_ERROR_THROWN = (1u << 6), /**< the vm_throw_callback_p is called */
|
||||
ECMA_STATUS_ERROR_THROWN = (1u << 6), /**< the vm_throw_callback_p is called */
|
||||
#endif /* JERRY_VM_THROW */
|
||||
} ecma_status_flag_t;
|
||||
|
||||
@@ -190,8 +191,7 @@ typedef int32_t ecma_integer_value_t;
|
||||
/**
|
||||
* ECMA make simple value
|
||||
*/
|
||||
#define ECMA_MAKE_VALUE(value) \
|
||||
((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
|
||||
#define ECMA_MAKE_VALUE(value) ((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
|
||||
|
||||
/**
|
||||
* Simple ecma values
|
||||
@@ -237,7 +237,7 @@ enum
|
||||
/**
|
||||
* Maximum integer number for an ecma value
|
||||
*/
|
||||
#define ECMA_INTEGER_NUMBER_MAX 0x7fffff
|
||||
#define ECMA_INTEGER_NUMBER_MAX 0x7fffff
|
||||
/**
|
||||
* Maximum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
|
||||
*/
|
||||
@@ -257,7 +257,7 @@ enum
|
||||
/**
|
||||
* Minimum integer number for an ecma value
|
||||
*/
|
||||
#define ECMA_INTEGER_NUMBER_MIN -0x7fffff
|
||||
#define ECMA_INTEGER_NUMBER_MIN -0x7fffff
|
||||
/**
|
||||
* Minimum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
|
||||
*/
|
||||
@@ -275,13 +275,12 @@ enum
|
||||
|
||||
#if ECMA_DIRECT_SHIFT != 4
|
||||
#error "Please update ECMA_INTEGER_NUMBER_MIN/MAX_SHIFTED according to the new value of ECMA_DIRECT_SHIFT."
|
||||
#endif
|
||||
#endif /* ECMA_DIRECT_SHIFT != 4 */
|
||||
|
||||
/**
|
||||
* Checks whether the integer number is in the integer number range.
|
||||
*/
|
||||
#define ECMA_IS_INTEGER_NUMBER(num) \
|
||||
(ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
|
||||
#define ECMA_IS_INTEGER_NUMBER(num) (ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
|
||||
|
||||
/**
|
||||
* Maximum integer number, which if squared, still fits in ecma_integer_value_t
|
||||
@@ -295,8 +294,7 @@ enum
|
||||
/**
|
||||
* Checks whether the error flag is set.
|
||||
*/
|
||||
#define ECMA_IS_VALUE_ERROR(value) \
|
||||
(JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
|
||||
#define ECMA_IS_VALUE_ERROR(value) (JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
|
||||
|
||||
/**
|
||||
* Callback which tells whether the ECMAScript execution should be stopped.
|
||||
@@ -422,32 +420,27 @@ typedef enum
|
||||
/**
|
||||
* Property flags configurable, enumerable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE \
|
||||
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
|
||||
|
||||
/**
|
||||
* Property flags configurable, enumerable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flag built-in.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_FIXED \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN)
|
||||
#define ECMA_PROPERTY_BUILT_IN_FIXED (ECMA_PROPERTY_FLAG_BUILT_IN)
|
||||
|
||||
/**
|
||||
* Property flags enumerable, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_ENUMERABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_ENUMERABLE_WRITABLE (ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable, enumerable.
|
||||
@@ -458,14 +451,12 @@ typedef enum
|
||||
/**
|
||||
* Property flags built-in, configurable, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable, enumerable, writable.
|
||||
@@ -495,8 +486,7 @@ typedef enum
|
||||
/**
|
||||
* Type of hash-map property.
|
||||
*/
|
||||
#define ECMA_PROPERTY_TYPE_HASHMAP \
|
||||
(ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
#define ECMA_PROPERTY_TYPE_HASHMAP (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
|
||||
/**
|
||||
* Type of deleted property.
|
||||
@@ -523,7 +513,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether a property is not found.
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_FOUND(property) \
|
||||
#define ECMA_PROPERTY_IS_FOUND(property) \
|
||||
(((property) & (ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))) \
|
||||
!= (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
@@ -606,20 +596,17 @@ typedef struct
|
||||
/**
|
||||
* Get property name type.
|
||||
*/
|
||||
#define ECMA_PROPERTY_GET_NAME_TYPE(property) \
|
||||
((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
#define ECMA_PROPERTY_GET_NAME_TYPE(property) ((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
|
||||
/**
|
||||
* Returns true if the property pointer is a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) \
|
||||
((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) ((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
|
||||
/**
|
||||
* Property value of all internal properties
|
||||
*/
|
||||
#define ECMA_PROPERTY_INTERNAL \
|
||||
(ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
#define ECMA_PROPERTY_INTERNAL (ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
/**
|
||||
* Checks whether a property is internal property
|
||||
@@ -629,25 +616,23 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a property is raw data or accessor property
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_RAW(property) \
|
||||
((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
#define ECMA_PROPERTY_IS_RAW(property) ((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
/**
|
||||
* Checks whether a property is raw data property (should only be used in assertions)
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_RAW_DATA(property) \
|
||||
(((property) & ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL)
|
||||
(((property) &ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL)
|
||||
|
||||
/**
|
||||
* Create internal property.
|
||||
*/
|
||||
#define ECMA_CREATE_INTERNAL_PROPERTY(object_p, name_p, property_p, property_value_p) \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_CREATE_INTERNAL_PROPERTY(object_p, name_p, property_p, property_value_p) \
|
||||
do \
|
||||
{ \
|
||||
(property_value_p) = ecma_create_named_data_property ((object_p), (name_p), 0, &(property_p)); \
|
||||
JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \
|
||||
} \
|
||||
while (0)
|
||||
JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Property type of all virtual properties
|
||||
@@ -657,7 +642,7 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a property is virtual property
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL(property)
|
||||
#define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL (property)
|
||||
|
||||
/**
|
||||
* Returns true if the property is named property.
|
||||
@@ -681,8 +666,7 @@ typedef struct
|
||||
* Compute the property data pointer of a property.
|
||||
* The property must be part of a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_VALUE_PTR(property_p) \
|
||||
((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
|
||||
#define ECMA_PROPERTY_VALUE_PTR(property_p) ((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
|
||||
|
||||
/**
|
||||
* Property reference. It contains the value pointer
|
||||
@@ -768,7 +752,7 @@ typedef enum
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE, /**< Module Namespace (ECMAScript v11, 9.4.6) */
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
#if JERRY_ESNEXT
|
||||
ECMA_OBJECT_CLASS_GENERATOR, /**< Generator object (ECMAScript v6, 25.2) */
|
||||
ECMA_OBJECT_CLASS_ASYNC_GENERATOR, /**< Async generator object (ECMAScript v11, 25.3) */
|
||||
@@ -781,7 +765,7 @@ typedef enum
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_OBJECT_CLASS_MODULE, /**< Module (ECMAScript v6, 15.2) */
|
||||
#endif
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_ESNEXT
|
||||
ECMA_OBJECT_CLASS_PROMISE, /**< Promise (ECMAScript v6, 25.4) */
|
||||
ECMA_OBJECT_CLASS_PROMISE_CAPABILITY, /**< Promise capability (ECMAScript v6, 25.4.1.1) */
|
||||
@@ -852,10 +836,10 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ITERATOR_KEYS, /**< keys iterator */
|
||||
ECMA_ITERATOR_VALUES, /**< values iterator */
|
||||
ECMA_ITERATOR_ENTRIES, /**< entries iterator */
|
||||
ECMA_ITERATOR__COUNT, /**< number of iterator kinds */
|
||||
ECMA_ITERATOR_KEYS, /**< keys iterator */
|
||||
ECMA_ITERATOR_VALUES, /**< values iterator */
|
||||
ECMA_ITERATOR_ENTRIES, /**< entries iterator */
|
||||
ECMA_ITERATOR__COUNT, /**< number of iterator kinds */
|
||||
} ecma_iterator_kind_t;
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
@@ -868,9 +852,9 @@ typedef enum
|
||||
/**
|
||||
* Set JERRY_CONTEXT (status_flags) top 8 bits to the specified 'opts'.
|
||||
*/
|
||||
#define ECMA_SET_LOCAL_PARSE_OPTS(opts) \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_SET_LOCAL_PARSE_OPTS(opts) \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) |= ((uint32_t) opts << ECMA_LOCAL_PARSE_OPTS_OFFSET) | ECMA_STATUS_DIRECT_EVAL; \
|
||||
} while (0)
|
||||
|
||||
@@ -883,9 +867,9 @@ typedef enum
|
||||
/**
|
||||
* Clear JERRY_CONTEXT (status_flags) top 8 bits.
|
||||
*/
|
||||
#define ECMA_CLEAR_LOCAL_PARSE_OPTS() \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_CLEAR_LOCAL_PARSE_OPTS() \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) &= ((1 << ECMA_LOCAL_PARSE_OPTS_OFFSET) - 1); \
|
||||
} while (0)
|
||||
|
||||
@@ -971,8 +955,8 @@ typedef struct
|
||||
{
|
||||
jmem_cpointer_t property_list_cp; /**< compressed pointer to object's
|
||||
* or declerative lexical environments's property list */
|
||||
jmem_cpointer_t bound_object_cp; /**< compressed pointer to lexical environments's the bound object */
|
||||
jmem_cpointer_t home_object_cp; /**< compressed pointer to lexical environments's the home object */
|
||||
jmem_cpointer_t bound_object_cp; /**< compressed pointer to lexical environments's the bound object */
|
||||
jmem_cpointer_t home_object_cp; /**< compressed pointer to lexical environments's the home object */
|
||||
} u1;
|
||||
|
||||
/** object prototype or outer reference */
|
||||
@@ -1038,11 +1022,11 @@ typedef ecma_value_t (*ecma_builtin_handler_t) (ecma_object_t *function_obj_p,
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS = 0, /**< No options are provided */
|
||||
ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED = (1u << 0), /**< 'length' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED = (1u << 1), /**< 'name' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_GETTER = (1u << 2), /**< this routine is getter */
|
||||
ECMA_BUILTIN_ROUTINE_SETTER = (1u << 3), /**< this routine is setter */
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS = 0, /**< No options are provided */
|
||||
ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED = (1u << 0), /**< 'length' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED = (1u << 1), /**< 'name' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_GETTER = (1u << 2), /**< this routine is getter */
|
||||
ECMA_BUILTIN_ROUTINE_SETTER = (1u << 3), /**< this routine is setter */
|
||||
} ecma_builtin_routine_flags_t;
|
||||
|
||||
/**
|
||||
@@ -1239,13 +1223,13 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_IS_FUNCTION check tells whether the byte code
|
||||
* is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_IS_FUNCTION check tells whether the byte code
|
||||
* is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
} ecma_compiled_code_t;
|
||||
|
||||
/**
|
||||
@@ -1331,26 +1315,22 @@ typedef struct
|
||||
/**
|
||||
* Size of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_GET_SIZE(container_p) \
|
||||
(container_p->buffer_p[0])
|
||||
#define ECMA_CONTAINER_GET_SIZE(container_p) (container_p->buffer_p[0])
|
||||
|
||||
/**
|
||||
* Remove the size field of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_SET_SIZE(container_p, size) \
|
||||
(container_p->buffer_p[0] = (ecma_value_t) (size))
|
||||
#define ECMA_CONTAINER_SET_SIZE(container_p, size) (container_p->buffer_p[0] = (ecma_value_t) (size))
|
||||
|
||||
/**
|
||||
* Number of entries of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_ENTRY_COUNT(collection_p) \
|
||||
(collection_p->item_count - 1)
|
||||
#define ECMA_CONTAINER_ENTRY_COUNT(collection_p) (collection_p->item_count - 1)
|
||||
|
||||
/**
|
||||
* Pointer to the first entry of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_START(collection_p) \
|
||||
(collection_p->buffer_p + 1)
|
||||
#define ECMA_CONTAINER_START(collection_p) (collection_p->buffer_p + 1)
|
||||
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
@@ -1380,17 +1360,15 @@ typedef struct
|
||||
* - is_value_defined : true
|
||||
* - is_configurable_defined, is_writable_defined, is_enumerable_defined : true
|
||||
*/
|
||||
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS ((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED \
|
||||
| JERRY_PROP_IS_CONFIGURABLE_DEFINED \
|
||||
| JERRY_PROP_IS_ENUMERABLE_DEFINED \
|
||||
| JERRY_PROP_IS_WRITABLE_DEFINED))
|
||||
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS \
|
||||
((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE_DEFINED \
|
||||
| JERRY_PROP_IS_WRITABLE_DEFINED))
|
||||
|
||||
/**
|
||||
* Bitmask to get a the physical property flags from an ecma_property_descriptor
|
||||
*/
|
||||
#define ECMA_PROPERTY_FLAGS_MASK ((uint16_t) (JERRY_PROP_IS_CONFIGURABLE \
|
||||
| JERRY_PROP_IS_ENUMERABLE \
|
||||
| JERRY_PROP_IS_WRITABLE))
|
||||
#define ECMA_PROPERTY_FLAGS_MASK \
|
||||
((uint16_t) (JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_ENUMERABLE | JERRY_PROP_IS_WRITABLE))
|
||||
|
||||
#if !JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
@@ -1412,7 +1390,7 @@ typedef union
|
||||
/**
|
||||
* Maximum number of significant digits that ecma-number can store
|
||||
*/
|
||||
#define ECMA_NUMBER_MAX_DIGITS (9)
|
||||
#define ECMA_NUMBER_MAX_DIGITS (9)
|
||||
|
||||
/**
|
||||
* Width of sign field
|
||||
@@ -1420,7 +1398,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
|
||||
/**
|
||||
* Width of biased exponent field
|
||||
@@ -1436,7 +1414,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (23)
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (23)
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
* Description of an ecma-number
|
||||
@@ -1457,7 +1435,7 @@ typedef union
|
||||
/**
|
||||
* Maximum number of significant digits that ecma-number can store
|
||||
*/
|
||||
#define ECMA_NUMBER_MAX_DIGITS (19)
|
||||
#define ECMA_NUMBER_MAX_DIGITS (19)
|
||||
|
||||
/**
|
||||
* Width of sign field
|
||||
@@ -1465,7 +1443,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
|
||||
/**
|
||||
* Width of biased exponent field
|
||||
@@ -1473,7 +1451,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
|
||||
|
||||
/**
|
||||
* Width of fraction field
|
||||
@@ -1481,7 +1459,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (52)
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (52)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
@@ -1492,12 +1470,12 @@ typedef union
|
||||
/**
|
||||
* Value '1' of ecma_number_t
|
||||
*/
|
||||
#define ECMA_NUMBER_ONE ((ecma_number_t) 1)
|
||||
#define ECMA_NUMBER_ONE ((ecma_number_t) 1)
|
||||
|
||||
/**
|
||||
* Value '2' of ecma_number_t
|
||||
*/
|
||||
#define ECMA_NUMBER_TWO ((ecma_number_t) 2)
|
||||
#define ECMA_NUMBER_TWO ((ecma_number_t) 2)
|
||||
|
||||
/**
|
||||
* Value '0.5' of ecma_number_t
|
||||
@@ -1515,74 +1493,74 @@ typedef union
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.3
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
|
||||
#define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
|
||||
/**
|
||||
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.2
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
|
||||
#define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
|
||||
/**
|
||||
* Number.EPSILON
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.1
|
||||
*/
|
||||
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
|
||||
|
||||
/**
|
||||
* Number.MAX_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.6
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
|
||||
|
||||
/**
|
||||
* Number.MIN_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.8
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.2
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
|
||||
#define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
|
||||
|
||||
/**
|
||||
* Number.MIN_VALUE (i.e., the smallest positive value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.3
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
|
||||
#define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
|
||||
|
||||
/**
|
||||
* Number.EPSILON
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.1
|
||||
*/
|
||||
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
|
||||
|
||||
/**
|
||||
* Number.MAX_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.6
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
|
||||
|
||||
/**
|
||||
* Number.MIN_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.8
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Euler number
|
||||
*/
|
||||
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
|
||||
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
|
||||
|
||||
/**
|
||||
* Natural logarithm of 10
|
||||
@@ -1607,17 +1585,17 @@ typedef union
|
||||
/**
|
||||
* Pi number
|
||||
*/
|
||||
#define ECMA_NUMBER_PI ((ecma_number_t) 3.1415926535897932)
|
||||
#define ECMA_NUMBER_PI ((ecma_number_t) 3.1415926535897932)
|
||||
|
||||
/**
|
||||
* Square root of 0.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SQRT_1_2 ((ecma_number_t) 0.7071067811865476)
|
||||
#define ECMA_NUMBER_SQRT_1_2 ((ecma_number_t) 0.7071067811865476)
|
||||
|
||||
/**
|
||||
* Square root of 2
|
||||
*/
|
||||
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
|
||||
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
|
||||
|
||||
/**
|
||||
* Maximum number of characters in string representation of ecma-number
|
||||
@@ -1657,8 +1635,7 @@ typedef struct
|
||||
/**
|
||||
* Compute the total allocated size of the collection based on it's capacity
|
||||
*/
|
||||
#define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) \
|
||||
(uint32_t) (capacity * sizeof (ecma_value_t))
|
||||
#define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) (uint32_t) (capacity * sizeof (ecma_value_t))
|
||||
|
||||
/**
|
||||
* Initial allocated size of an ecma-collection
|
||||
@@ -1724,8 +1701,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the string is direct.
|
||||
*/
|
||||
#define ECMA_IS_DIRECT_STRING(string_p) \
|
||||
((((uintptr_t) (string_p)) & 0x1) != 0)
|
||||
#define ECMA_IS_DIRECT_STRING(string_p) ((((uintptr_t) (string_p)) & 0x1) != 0)
|
||||
|
||||
/**
|
||||
* Checks whether the string is direct.
|
||||
@@ -1736,8 +1712,7 @@ typedef enum
|
||||
/**
|
||||
* Returns the type of a direct string.
|
||||
*/
|
||||
#define ECMA_GET_DIRECT_STRING_TYPE(string_p) \
|
||||
((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
|
||||
#define ECMA_GET_DIRECT_STRING_TYPE(string_p) ((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
|
||||
|
||||
/**
|
||||
* Shift applied to type conversions.
|
||||
@@ -1753,8 +1728,7 @@ typedef enum
|
||||
/**
|
||||
* Returns the value of a direct string.
|
||||
*/
|
||||
#define ECMA_GET_DIRECT_STRING_VALUE(string_p) \
|
||||
(((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
|
||||
#define ECMA_GET_DIRECT_STRING_VALUE(string_p) (((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
|
||||
|
||||
/**
|
||||
* Maximum number of bytes that a long-utf8-string is able to store
|
||||
@@ -1799,14 +1773,12 @@ typedef enum
|
||||
/**
|
||||
* Set an ecma-string as static string
|
||||
*/
|
||||
#define ECMA_SET_STRING_AS_STATIC(string_p) \
|
||||
(string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
|
||||
#define ECMA_SET_STRING_AS_STATIC(string_p) (string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
|
||||
|
||||
/**
|
||||
* Checks whether the ecma-string is static string
|
||||
*/
|
||||
#define ECMA_STRING_IS_STATIC(string_p) \
|
||||
((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
|
||||
#define ECMA_STRING_IS_STATIC(string_p) ((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
|
||||
|
||||
/**
|
||||
* Returns with the container type of a string.
|
||||
@@ -1817,8 +1789,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the reference counter is 1 of a string.
|
||||
*/
|
||||
#define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) \
|
||||
(((string_desc_p)->refs_and_container >> 4) == 1)
|
||||
#define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) (((string_desc_p)->refs_and_container >> 4) == 1)
|
||||
|
||||
/**
|
||||
* Checks whether the reference counter is 1 of an extended primitive.
|
||||
@@ -1878,38 +1849,34 @@ typedef struct
|
||||
/**
|
||||
* Header size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_HEADER_SIZE \
|
||||
((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
|
||||
#define ECMA_ASCII_STRING_HEADER_SIZE ((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
|
||||
|
||||
/**
|
||||
* Get the size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_GET_SIZE(string_p) \
|
||||
((lit_utf8_size_t) *((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1)
|
||||
((lit_utf8_size_t) * ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1)
|
||||
|
||||
/**
|
||||
* Set the size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_SET_SIZE(string_p, size) \
|
||||
(*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) - 1))
|
||||
(*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) -1))
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_GET_BUFFER(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
|
||||
#define ECMA_ASCII_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma UTF8 string
|
||||
*/
|
||||
#define ECMA_SHORT_STRING_GET_BUFFER(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
|
||||
#define ECMA_SHORT_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma long CESU8 string
|
||||
*/
|
||||
#define ECMA_LONG_STRING_BUFFER_START(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
|
||||
#define ECMA_LONG_STRING_BUFFER_START(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
|
||||
|
||||
/**
|
||||
* ECMA extended string-value descriptor
|
||||
@@ -2074,18 +2041,18 @@ typedef ecma_value_t (*ecma_typedarray_setter_fn_t) (lit_utf8_byte_t *src, ecma_
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_INT8_ARRAY, /**< Int8Array */
|
||||
ECMA_UINT8_ARRAY, /**< Uint8Array */
|
||||
ECMA_INT8_ARRAY, /**< Int8Array */
|
||||
ECMA_UINT8_ARRAY, /**< Uint8Array */
|
||||
ECMA_UINT8_CLAMPED_ARRAY, /**< Uint8ClampedArray */
|
||||
ECMA_INT16_ARRAY, /**< Int16Array */
|
||||
ECMA_UINT16_ARRAY, /**< Uint16Array */
|
||||
ECMA_INT32_ARRAY, /**< Int32Array */
|
||||
ECMA_UINT32_ARRAY, /**< Uint32Array */
|
||||
ECMA_FLOAT32_ARRAY, /**< Float32Array */
|
||||
ECMA_FLOAT64_ARRAY, /**< Float64Array */
|
||||
ECMA_INT16_ARRAY, /**< Int16Array */
|
||||
ECMA_UINT16_ARRAY, /**< Uint16Array */
|
||||
ECMA_INT32_ARRAY, /**< Int32Array */
|
||||
ECMA_UINT32_ARRAY, /**< Uint32Array */
|
||||
ECMA_FLOAT32_ARRAY, /**< Float32Array */
|
||||
ECMA_FLOAT64_ARRAY, /**< Float64Array */
|
||||
/* ECMA_TYPEDARRAY_IS_BIGINT_TYPE macro should be updated when new types are added */
|
||||
ECMA_BIGINT64_ARRAY, /**< BigInt64Array */
|
||||
ECMA_BIGUINT64_ARRAY, /**< BigUInt64Array */
|
||||
ECMA_BIGINT64_ARRAY, /**< BigInt64Array */
|
||||
ECMA_BIGUINT64_ARRAY, /**< BigUInt64Array */
|
||||
} ecma_typedarray_type_t;
|
||||
|
||||
/**
|
||||
@@ -2145,8 +2112,7 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a given typedarray is BigInt type or not.
|
||||
**/
|
||||
#define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) \
|
||||
((id) >= ECMA_BIGINT64_ARRAY)
|
||||
#define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) ((id) >= ECMA_BIGINT64_ARRAY)
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
@@ -2187,7 +2153,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the executable object is waiting for resuming.
|
||||
*/
|
||||
#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \
|
||||
#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \
|
||||
(!((executable_object_p)->extended_object.u.cls.u2.executable_obj_flags \
|
||||
& (ECMA_EXECUTABLE_OBJECT_COMPLETED | ECMA_EXECUTABLE_OBJECT_RUNNING)))
|
||||
|
||||
@@ -2306,21 +2272,21 @@ typedef struct
|
||||
* Check the current stack usage. If the limit is reached a RangeError is raised.
|
||||
* The macro argument specifies the return value which is usally ECMA_VALUE_ERROR or NULL.
|
||||
*/
|
||||
#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
|
||||
{ \
|
||||
ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
|
||||
return RETURN_VALUE; \
|
||||
} \
|
||||
} while (0)
|
||||
#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
|
||||
{ \
|
||||
ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
|
||||
return RETURN_VALUE; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Specialized version of ECMA_CHECK_STACK_USAGE_RETURN which returns ECMA_VALUE_ERROR.
|
||||
* This version should be used in most cases.
|
||||
*/
|
||||
#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN(ECMA_VALUE_ERROR)
|
||||
#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN (ECMA_VALUE_ERROR)
|
||||
#else /* JERRY_STACK_LIMIT == 0) */
|
||||
/**
|
||||
* If the stack limit is unlimited, this check is an empty macro.
|
||||
@@ -2446,11 +2412,11 @@ typedef struct
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ARGUMENTS_OBJECT_NO_FLAGS = 0, /* unmapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_MAPPED = (1 << 0), /* mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE = (1 << 1), /* static mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED = (1 << 2), /* 'callee' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED = (1 << 3), /* 'length' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_NO_FLAGS = 0, /* unmapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_MAPPED = (1 << 0), /* mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE = (1 << 1), /* static mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED = (1 << 2), /* 'callee' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED = (1 << 3), /* 'length' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED = (1 << 4), /* 'Symbol.iterator' property has been lazy initialized */
|
||||
} ecma_arguments_object_flags_t;
|
||||
|
||||
@@ -2522,4 +2488,4 @@ typedef struct
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_GLOBALS_H */
|
||||
#endif /* !ECMA_GLOBALS_H */
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
@@ -55,8 +56,7 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
uint64_t masked_lo = num_p->lo & ~(1ULL << 63u);
|
||||
uint64_t masked_hi = num_p->hi & 0x1;
|
||||
|
||||
if ((num_p->lo >> 63u != 0)
|
||||
&& (masked_lo > 0 || masked_hi != 0))
|
||||
if ((num_p->lo >> 63u != 0) && (masked_lo > 0 || masked_hi != 0))
|
||||
{
|
||||
return (num_p->hi + 1);
|
||||
}
|
||||
@@ -66,53 +66,52 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
/**
|
||||
* Check if 128-bit integer is zero
|
||||
*/
|
||||
#define ECMA_UINT128_IS_ZERO(name) \
|
||||
(name.hi == 0 && name.lo == 0)
|
||||
#define ECMA_UINT128_IS_ZERO(name) (name.hi == 0 && name.lo == 0)
|
||||
|
||||
/**
|
||||
* Left shift 128-bit integer by max 63 bits
|
||||
*/
|
||||
#define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \
|
||||
name.lo <<= (shift); \
|
||||
}
|
||||
#define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \
|
||||
name.lo <<= (shift); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Right shift 128-bit integer by max 63 bits
|
||||
*/
|
||||
#define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \
|
||||
name.hi >>= (shift); \
|
||||
}
|
||||
#define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \
|
||||
name.hi >>= (shift); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 128-bit integer
|
||||
*/
|
||||
#define ECMA_UINT128_ADD(name_add_to, name_to_add) \
|
||||
{ \
|
||||
name_add_to.hi += name_to_add.hi; \
|
||||
name_add_to.lo += name_to_add.lo; \
|
||||
if (name_add_to.lo < name_to_add.lo) \
|
||||
{ \
|
||||
name_add_to.hi++; \
|
||||
} \
|
||||
}
|
||||
{ \
|
||||
name_add_to.hi += name_to_add.hi; \
|
||||
name_add_to.lo += name_to_add.lo; \
|
||||
if (name_add_to.lo < name_to_add.lo) \
|
||||
{ \
|
||||
name_add_to.hi++; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply 128-bit integer by 10
|
||||
*/
|
||||
#define ECMA_UINT128_MUL10(name) \
|
||||
{ \
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \
|
||||
\
|
||||
ecma_uint128_t name ## _tmp = name; \
|
||||
\
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name ## _tmp, 2u); \
|
||||
\
|
||||
ECMA_UINT128_ADD (name, name ## _tmp); \
|
||||
}
|
||||
#define ECMA_UINT128_MUL10(name) \
|
||||
{ \
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \
|
||||
\
|
||||
ecma_uint128_t name##_tmp = name; \
|
||||
\
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name##_tmp, 2u); \
|
||||
\
|
||||
ECMA_UINT128_ADD (name, name##_tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide 128-bit integer by 10
|
||||
@@ -129,84 +128,82 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
*
|
||||
* Q = Q3 *2^96 + Q2 *2^64 + Q1 *2^32 + Q0 *2^0 // 128-bit quotient
|
||||
*/
|
||||
#define ECMA_UINT128_DIV10(name) \
|
||||
{ \
|
||||
/* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \
|
||||
const uint64_t tenth_l = 0x9999999aul; \
|
||||
const uint64_t tenth_m = 0x99999999ul; \
|
||||
const uint64_t tenth_h = 0x19999999ul; \
|
||||
\
|
||||
uint64_t l0 = ((uint32_t) name.lo) * tenth_l; \
|
||||
uint64_t l1 = (name.lo >> 32u) * tenth_l; \
|
||||
uint64_t l2 = ((uint32_t) name.hi) * tenth_l; \
|
||||
uint64_t l3 = (name.hi >> 32u) * tenth_l; \
|
||||
uint64_t m0 = ((uint32_t) name.lo) * tenth_m; \
|
||||
uint64_t m1 = (name.lo >> 32u) * tenth_m; \
|
||||
uint64_t m2 = ((uint32_t) name.hi) * tenth_m; \
|
||||
uint64_t m3 = (name.hi >> 32u) * tenth_m; \
|
||||
uint64_t h0 = ((uint32_t) name.lo) * tenth_h; \
|
||||
uint64_t h1 = (name.lo >> 32u) * tenth_h; \
|
||||
uint64_t h2 = ((uint32_t) name.hi) * tenth_h; \
|
||||
uint64_t h3 = (name.hi >> 32u) * tenth_h; \
|
||||
\
|
||||
uint64_t q0 = l0 >> 32u; \
|
||||
q0 += (uint32_t) l1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) h0; \
|
||||
\
|
||||
q0 >>=32u; \
|
||||
q0 += l3 >> 32u; \
|
||||
q0 += m2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += h0 >> 32u; \
|
||||
q0 += (uint32_t) m3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) h1; \
|
||||
\
|
||||
uint64_t q1 = q0 >> 32u; \
|
||||
q1 += m3 >> 32u; \
|
||||
q1 += m2 >> 32u; \
|
||||
q1 += h1 >> 32u; \
|
||||
q1 += (uint32_t) m3; \
|
||||
q1 += (uint32_t) h2; \
|
||||
\
|
||||
uint64_t q32 = q1 >> 32u; \
|
||||
q32 += m3 >> 32u; \
|
||||
q32 += h2 >> 32u; \
|
||||
q32 += h3; \
|
||||
\
|
||||
name.lo = (q1 << 32u) | ((uint32_t) q0); \
|
||||
name.hi = q32; \
|
||||
}
|
||||
#define ECMA_UINT128_DIV10(name) \
|
||||
{ \
|
||||
/* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \
|
||||
const uint64_t tenth_l = 0x9999999aul; \
|
||||
const uint64_t tenth_m = 0x99999999ul; \
|
||||
const uint64_t tenth_h = 0x19999999ul; \
|
||||
\
|
||||
uint64_t l0 = ((uint32_t) name.lo) * tenth_l; \
|
||||
uint64_t l1 = (name.lo >> 32u) * tenth_l; \
|
||||
uint64_t l2 = ((uint32_t) name.hi) * tenth_l; \
|
||||
uint64_t l3 = (name.hi >> 32u) * tenth_l; \
|
||||
uint64_t m0 = ((uint32_t) name.lo) * tenth_m; \
|
||||
uint64_t m1 = (name.lo >> 32u) * tenth_m; \
|
||||
uint64_t m2 = ((uint32_t) name.hi) * tenth_m; \
|
||||
uint64_t m3 = (name.hi >> 32u) * tenth_m; \
|
||||
uint64_t h0 = ((uint32_t) name.lo) * tenth_h; \
|
||||
uint64_t h1 = (name.lo >> 32u) * tenth_h; \
|
||||
uint64_t h2 = ((uint32_t) name.hi) * tenth_h; \
|
||||
uint64_t h3 = (name.hi >> 32u) * tenth_h; \
|
||||
\
|
||||
uint64_t q0 = l0 >> 32u; \
|
||||
q0 += (uint32_t) l1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) h0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l3 >> 32u; \
|
||||
q0 += m2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += h0 >> 32u; \
|
||||
q0 += (uint32_t) m3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) h1; \
|
||||
\
|
||||
uint64_t q1 = q0 >> 32u; \
|
||||
q1 += m3 >> 32u; \
|
||||
q1 += m2 >> 32u; \
|
||||
q1 += h1 >> 32u; \
|
||||
q1 += (uint32_t) m3; \
|
||||
q1 += (uint32_t) h2; \
|
||||
\
|
||||
uint64_t q32 = q1 >> 32u; \
|
||||
q32 += m3 >> 32u; \
|
||||
q32 += h2 >> 32u; \
|
||||
q32 += h3; \
|
||||
\
|
||||
name.lo = (q1 << 32u) | ((uint32_t) q0); \
|
||||
name.hi = q32; \
|
||||
}
|
||||
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 64 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) \
|
||||
__builtin_clzll (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) __builtin_clzll (name.hi)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 4 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) \
|
||||
__builtin_clzll (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) __builtin_clzll (name.hi)
|
||||
|
||||
#else /* !__GNUC__ && !__clang__ */
|
||||
|
||||
@@ -238,14 +235,12 @@ static const uint8_t ecma_uint4_clz[] = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||
/**
|
||||
* Count leading zeros in the topmost 64 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) \
|
||||
ecma_uint64_clz (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) ecma_uint64_clz (name.hi)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 4 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) \
|
||||
ecma_uint4_clz[name.hi >> 60]
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) ecma_uint4_clz[name.hi >> 60]
|
||||
|
||||
#endif /* __GNUC__ || __clang__ */
|
||||
|
||||
@@ -308,7 +303,7 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
{
|
||||
lit_code_point_t upper_limit = LIT_CHAR_0 + radix;
|
||||
|
||||
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
@@ -328,22 +323,19 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*iter_p >= LIT_CHAR_0
|
||||
&& *iter_p <= LIT_CHAR_9)
|
||||
if (*iter_p >= LIT_CHAR_0 && *iter_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_value = (*iter_p - LIT_CHAR_0);
|
||||
}
|
||||
else if (*iter_p >= LIT_CHAR_LOWERCASE_A
|
||||
&& *iter_p <= LIT_CHAR_LOWERCASE_F)
|
||||
else if (*iter_p >= LIT_CHAR_LOWERCASE_A && *iter_p <= LIT_CHAR_LOWERCASE_F)
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_LOWERCASE_A);
|
||||
}
|
||||
else if (*iter_p >= LIT_CHAR_UPPERCASE_A
|
||||
&& *iter_p <= LIT_CHAR_UPPERCASE_F)
|
||||
else if (*iter_p >= LIT_CHAR_UPPERCASE_A && *iter_p <= LIT_CHAR_UPPERCASE_F)
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
|
||||
}
|
||||
@@ -393,20 +385,19 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
return ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
if (end_p >= str_p + 2
|
||||
&& str_p[0] == LIT_CHAR_0)
|
||||
if (end_p >= str_p + 2 && str_p[0] == LIT_CHAR_0)
|
||||
{
|
||||
switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
|
||||
{
|
||||
case LIT_CHAR_LOWERCASE_X :
|
||||
case LIT_CHAR_LOWERCASE_X:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_O :
|
||||
case LIT_CHAR_LOWERCASE_O:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_B :
|
||||
case LIT_CHAR_LOWERCASE_B:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options);
|
||||
}
|
||||
@@ -455,8 +446,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
@@ -489,8 +479,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
str_p++;
|
||||
}
|
||||
|
||||
if (str_p <= end_p
|
||||
&& *str_p == LIT_CHAR_DOT)
|
||||
if (str_p <= end_p && *str_p == LIT_CHAR_DOT)
|
||||
{
|
||||
str_p++;
|
||||
|
||||
@@ -504,8 +493,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
@@ -539,9 +527,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
int32_t e_in_lit = 0;
|
||||
bool e_in_lit_sign = false;
|
||||
|
||||
if (str_p <= end_p
|
||||
&& (*str_p == LIT_CHAR_LOWERCASE_E
|
||||
|| *str_p == LIT_CHAR_UPPERCASE_E))
|
||||
if (str_p <= end_p && (*str_p == LIT_CHAR_LOWERCASE_E || *str_p == LIT_CHAR_UPPERCASE_E))
|
||||
{
|
||||
str_p++;
|
||||
|
||||
@@ -569,8 +555,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
@@ -587,7 +572,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
}
|
||||
|
||||
e_in_lit = e_in_lit * 10 + digit_value;
|
||||
int32_t e_check = e + (int32_t) digits - 1 + (e_in_lit_sign ? -e_in_lit : e_in_lit);
|
||||
int32_t e_check = e + (int32_t) digits - 1 + (e_in_lit_sign ? -e_in_lit : e_in_lit);
|
||||
|
||||
if (e_check > NUMBER_MAX_DECIMAL_EXPONENT)
|
||||
{
|
||||
@@ -764,8 +749,7 @@ ecma_uint32_to_utf8_string (uint32_t value, /**< value to convert */
|
||||
buf_p--;
|
||||
*buf_p = (lit_utf8_byte_t) ((value % 10) + LIT_CHAR_0);
|
||||
value /= 10;
|
||||
}
|
||||
while (value != 0);
|
||||
} while (value != 0);
|
||||
|
||||
JERRY_ASSERT (buf_p >= out_buffer_p);
|
||||
|
||||
@@ -807,8 +791,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
if (abs_num >= num_2_pow_32)
|
||||
{
|
||||
num_in_uint32_range = ecma_number_calc_remainder (abs_num,
|
||||
num_2_pow_32);
|
||||
num_in_uint32_range = ecma_number_calc_remainder (abs_num, num_2_pow_32);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -822,8 +805,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
|
||||
const uint32_t ret = sign ? -uint32_num : uint32_num;
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
if (sign
|
||||
&& uint32_num != 0)
|
||||
if (sign && uint32_num != 0)
|
||||
{
|
||||
JERRY_ASSERT (ret == uint64_2_pow_32 - uint32_num);
|
||||
}
|
||||
@@ -885,16 +867,16 @@ ecma_number_to_int32 (ecma_number_t num) /**< ecma-number */
|
||||
} /* ecma_number_to_int32 */
|
||||
|
||||
/**
|
||||
* Perform conversion of ecma-number to decimal representation with decimal exponent.
|
||||
*
|
||||
* Note:
|
||||
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
|
||||
* - parameter out_digits_p corresponds to s, the digits of the number;
|
||||
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
|
||||
* - return value corresponds to k, the number of digits.
|
||||
*
|
||||
* @return the number of digits
|
||||
*/
|
||||
* Perform conversion of ecma-number to decimal representation with decimal exponent.
|
||||
*
|
||||
* Note:
|
||||
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
|
||||
* - parameter out_digits_p corresponds to s, the digits of the number;
|
||||
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
|
||||
* - return value corresponds to k, the number of digits.
|
||||
*
|
||||
* @return the number of digits
|
||||
*/
|
||||
lit_utf8_size_t
|
||||
ecma_number_to_decimal (ecma_number_t num, /**< ecma-number */
|
||||
lit_utf8_byte_t *out_digits_p, /**< [out] buffer to fill with digits */
|
||||
@@ -951,7 +933,8 @@ ecma_number_to_utf8_string (ecma_number_t num, /**< ecma-number */
|
||||
if (ecma_number_is_infinity (num))
|
||||
{
|
||||
/* 4. */
|
||||
dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL, dst_p,
|
||||
dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL,
|
||||
dst_p,
|
||||
(lit_utf8_size_t) (buffer_p + buffer_size - dst_p));
|
||||
JERRY_ASSERT (dst_p <= buffer_p + buffer_size);
|
||||
return (lit_utf8_size_t) (dst_p - buffer_p);
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -185,8 +185,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
|
||||
value_p->value);
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
if (native_pointer_p->native_info_p == native_info_p)
|
||||
{
|
||||
@@ -215,8 +214,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
}
|
||||
|
||||
item_p = item_p->next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_get_native_pointer_value */
|
||||
@@ -259,8 +257,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
|
||||
value_p->value);
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
if (native_pointer_p->native_info_p != native_info_p)
|
||||
{
|
||||
@@ -326,8 +323,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
|
||||
prev_p = item_p;
|
||||
item_p = item_p->next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
return false;
|
||||
} /* ecma_delete_native_pointer_property */
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "ecma-conversion.h"
|
||||
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -28,20 +29,17 @@
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) == sizeof (ecma_integer_value_t),
|
||||
size_of_ecma_value_t_must_be_equal_to_the_size_of_ecma_integer_value_t);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1,
|
||||
currently_directly_encoded_values_has_one_extra_flag);
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1, currently_directly_encoded_values_has_one_extra_flag);
|
||||
|
||||
JERRY_STATIC_ASSERT (((1 << (ECMA_DIRECT_SHIFT - 1)) | ECMA_TYPE_DIRECT) == ECMA_DIRECT_TYPE_SIMPLE_VALUE,
|
||||
currently_directly_encoded_values_start_after_direct_type_simple_value);
|
||||
/**
|
||||
* Position of the sign bit in ecma-numbers
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + \
|
||||
ECMA_NUMBER_BIASED_EXP_WIDTH)
|
||||
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + ECMA_NUMBER_BIASED_EXP_WIDTH)
|
||||
|
||||
#if !JERRY_NUMBER_TYPE_FLOAT64
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t),
|
||||
size_of_ecma_number_t_must_be_equal_to_4_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t), size_of_ecma_number_t_must_be_equal_to_4_bytes);
|
||||
|
||||
/**
|
||||
* Packing sign, fraction and biased exponent to ecma-number
|
||||
@@ -56,9 +54,8 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
|
||||
uint32_t packed_value = (((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) |
|
||||
(biased_exp << ECMA_NUMBER_FRACTION_WIDTH) |
|
||||
((uint32_t) fraction));
|
||||
uint32_t packed_value =
|
||||
(((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) | (biased_exp << ECMA_NUMBER_FRACTION_WIDTH) | ((uint32_t) fraction));
|
||||
|
||||
ecma_number_accessor_t u;
|
||||
u.as_uint32_t = packed_value;
|
||||
@@ -103,8 +100,7 @@ ecma_number_unpack (ecma_number_t num, /**< ecma-number */
|
||||
const int32_t ecma_number_exponent_bias = 127;
|
||||
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t),
|
||||
size_of_ecma_number_t_must_be_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t), size_of_ecma_number_t_must_be_equal_to_8_bytes);
|
||||
|
||||
/**
|
||||
* Packing sign, fraction and biased exponent to ecma-number
|
||||
@@ -116,9 +112,8 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
uint32_t biased_exp, /**< biased exponent */
|
||||
uint64_t fraction) /**< fraction */
|
||||
{
|
||||
uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS) |
|
||||
(((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) |
|
||||
fraction);
|
||||
uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS)
|
||||
| (((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) | fraction);
|
||||
|
||||
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
@@ -228,9 +223,8 @@ ecma_number_is_nan (ecma_number_t num) /**< ecma-number */
|
||||
uint32_t biased_exp = ecma_number_get_biased_exponent_field (num);
|
||||
uint64_t fraction = ecma_number_get_fraction_field (num);
|
||||
|
||||
/* IEEE-754 2008, 3.4, a */
|
||||
bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)
|
||||
&& (fraction != 0));
|
||||
/* IEEE-754 2008, 3.4, a */
|
||||
bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction != 0));
|
||||
|
||||
JERRY_ASSERT (is_nan == is_nan_ieee754);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@@ -251,7 +245,7 @@ ecma_number_make_nan (void)
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
f.as_uint64_t = 0x7ff8000000000000ull; /* double QNaN, same as the C99 nan("") returns. */
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
f.as_uint32_t = 0x7fc00000u; /* float QNaN, same as the C99 nanf("") returns. */
|
||||
f.as_uint32_t = 0x7fc00000u; /* float QNaN, same as the C99 nanf("") returns. */
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
return f.as_ecma_number_t;
|
||||
} /* ecma_number_make_nan */
|
||||
@@ -304,8 +298,8 @@ ecma_number_is_zero (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* IEEE-754 2008, 3.4, e */
|
||||
bool is_zero_ieee754 = (ecma_number_get_fraction_field (num) == 0
|
||||
&& ecma_number_get_biased_exponent_field (num) == 0);
|
||||
bool is_zero_ieee754 =
|
||||
(ecma_number_get_fraction_field (num) == 0 && ecma_number_get_biased_exponent_field (num) == 0);
|
||||
|
||||
JERRY_ASSERT (is_zero == is_zero_ieee754);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@@ -327,8 +321,7 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
|
||||
uint64_t fraction = ecma_number_get_fraction_field (num);
|
||||
|
||||
/* IEEE-754 2008, 3.4, b */
|
||||
return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)
|
||||
&& (fraction == 0));
|
||||
return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction == 0));
|
||||
} /* ecma_number_is_infinity */
|
||||
|
||||
/**
|
||||
@@ -340,11 +333,11 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_number_is_finite (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_isfinite (num);
|
||||
#elif defined (_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
return isfinite (num);
|
||||
#else
|
||||
#else /* !(defined(__GNUC__) || defined(__clang__) || defined(_WIN32)) */
|
||||
return !ecma_number_is_nan (num) && !ecma_number_is_infinity (num);
|
||||
#endif /* defined (__GNUC__) || defined (__clang__) */
|
||||
} /* ecma_number_is_finite */
|
||||
@@ -422,9 +415,7 @@ ecma_number_make_normal_positive_from_fraction_and_exponent (uint64_t fraction,
|
||||
JERRY_ASSERT ((fraction & ~((1ull << (ECMA_NUMBER_FRACTION_WIDTH + 1)) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) != 0);
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
|
||||
return ecma_number_pack (false, biased_exp, fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
|
||||
} /* ecma_number_make_normal_positive_from_fraction_and_exponent */
|
||||
|
||||
/**
|
||||
@@ -463,8 +454,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
|
||||
}
|
||||
|
||||
/* Normalizing mantissa */
|
||||
while (mantissa != 0
|
||||
&& ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
|
||||
while (mantissa != 0 && ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
|
||||
{
|
||||
exponent--;
|
||||
mantissa <<= 1;
|
||||
@@ -507,9 +497,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
|
||||
JERRY_ASSERT (biased_exp < (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1);
|
||||
JERRY_ASSERT ((mantissa & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
|
||||
return ecma_number_pack (sign,
|
||||
biased_exp,
|
||||
mantissa);
|
||||
return ecma_number_pack (sign, biased_exp, mantissa);
|
||||
} /* ecma_number_make_from_sign_mantissa_and_exponent */
|
||||
|
||||
/**
|
||||
@@ -542,9 +530,7 @@ ecma_number_get_prev (ecma_number_t num) /**< ecma-number */
|
||||
fraction--;
|
||||
}
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction);
|
||||
return ecma_number_pack (false, biased_exp, fraction);
|
||||
} /* ecma_number_get_prev */
|
||||
|
||||
/**
|
||||
@@ -581,9 +567,7 @@ ecma_number_get_next (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
fraction &= ~(1ull << ECMA_NUMBER_FRACTION_WIDTH);
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction);
|
||||
return ecma_number_pack (false, biased_exp, fraction);
|
||||
} /* ecma_number_get_next */
|
||||
|
||||
/**
|
||||
@@ -609,8 +593,7 @@ ecma_number_trunc (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
fraction &= ~((1ull << (dot_shift - exponent)) - 1);
|
||||
|
||||
ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction,
|
||||
exponent);
|
||||
ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction, exponent);
|
||||
if (sign)
|
||||
{
|
||||
return -tmp;
|
||||
@@ -639,18 +622,15 @@ ecma_number_t
|
||||
ecma_number_calc_remainder (ecma_number_t left_num, /**< left operand */
|
||||
ecma_number_t right_num) /**< right operand */
|
||||
{
|
||||
JERRY_ASSERT (!ecma_number_is_nan (left_num)
|
||||
&& !ecma_number_is_zero (left_num)
|
||||
JERRY_ASSERT (!ecma_number_is_nan (left_num) && !ecma_number_is_zero (left_num)
|
||||
&& !ecma_number_is_infinity (left_num));
|
||||
JERRY_ASSERT (!ecma_number_is_nan (right_num)
|
||||
&& !ecma_number_is_zero (right_num)
|
||||
JERRY_ASSERT (!ecma_number_is_nan (right_num) && !ecma_number_is_zero (right_num)
|
||||
&& !ecma_number_is_infinity (right_num));
|
||||
|
||||
const ecma_number_t q = ecma_number_trunc (left_num / right_num);
|
||||
ecma_number_t r = left_num - right_num * q;
|
||||
|
||||
if (ecma_number_is_zero (r)
|
||||
&& ecma_number_is_negative (left_num))
|
||||
if (ecma_number_is_zero (r) && ecma_number_is_negative (left_num))
|
||||
{
|
||||
r = -r;
|
||||
}
|
||||
@@ -667,8 +647,7 @@ ecma_number_t
|
||||
ecma_number_pow (ecma_number_t x, /**< left operand */
|
||||
ecma_number_t y) /**< right operand */
|
||||
{
|
||||
if (ecma_number_is_nan (y) ||
|
||||
(ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
|
||||
if (ecma_number_is_nan (y) || (ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
|
||||
{
|
||||
/* Handle differences between ES5.1 and ISO C standards for pow. */
|
||||
return ecma_number_make_nan ();
|
||||
@@ -692,7 +671,7 @@ extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
|
||||
ecma_integer_value_t right_integer) /**< right operand */
|
||||
{
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
/* Check if left_integer is power of 2 */
|
||||
if (JERRY_UNLIKELY ((left_integer & (left_integer - 1)) == 0))
|
||||
{
|
||||
@@ -720,16 +699,16 @@ ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
|
||||
ecma_value_t
|
||||
ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
|
||||
* string buffer */
|
||||
lit_utf8_size_t string_buff_size, /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
ecma_value_t radix) /**< routine's second argument */
|
||||
lit_utf8_size_t string_buff_size, /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
ecma_value_t radix) /**< routine's second argument */
|
||||
{
|
||||
if (string_buff_size == 0)
|
||||
{
|
||||
return ecma_make_nan_value ();
|
||||
}
|
||||
|
||||
/* 2. Remove leading whitespace. */
|
||||
/* 2. Remove leading whitespace. */
|
||||
|
||||
const lit_utf8_byte_t *string_end_p = string_buff + string_buff_size;
|
||||
const lit_utf8_byte_t *start_p = ecma_string_trim_front (string_buff, string_end_p);
|
||||
@@ -796,9 +775,7 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
}
|
||||
|
||||
/* 10. */
|
||||
if (strip_prefix
|
||||
&& ((end_p - start_p) >= 2)
|
||||
&& (current == LIT_CHAR_0))
|
||||
if (strip_prefix && ((end_p - start_p) >= 2) && (current == LIT_CHAR_0))
|
||||
{
|
||||
ecma_char_t next = *string_curr_p;
|
||||
if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X)
|
||||
@@ -896,8 +873,8 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
ecma_value_t
|
||||
ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
|
||||
* string buffer */
|
||||
lit_utf8_size_t string_buff_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
lit_utf8_size_t string_buff_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
{
|
||||
if (string_buff_size == 0)
|
||||
{
|
||||
@@ -937,8 +914,7 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
/* The input string should be at least the length of "Infinity" to be correctly processed as
|
||||
* the infinity value.
|
||||
*/
|
||||
if ((str_end_p - str_curr_p) >= (int) infinity_length
|
||||
&& memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
|
||||
if ((str_end_p - str_curr_p) >= (int) infinity_length && memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
|
||||
{
|
||||
/* String matched Infinity. */
|
||||
return ecma_make_number_value (ecma_number_make_infinity (sign));
|
||||
@@ -1021,15 +997,13 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
}
|
||||
|
||||
/* Check exponent. */
|
||||
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E)
|
||||
&& (has_whole_part || has_fraction_part)
|
||||
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E) && (has_whole_part || has_fraction_part)
|
||||
&& str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
|
||||
/* Check sign of exponent. */
|
||||
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS)
|
||||
&& str_curr_p < str_end_p)
|
||||
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS) && str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
@@ -41,8 +42,7 @@ JERRY_STATIC_ASSERT ((ECMA_STRING_MAX_REF | ECMA_STRING_CONTAINER_MASK | ECMA_ST
|
||||
JERRY_STATIC_ASSERT (ECMA_STRING_NOT_ARRAY_INDEX == UINT32_MAX,
|
||||
ecma_string_not_array_index_must_be_equal_to_uint32_max);
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0,
|
||||
ecma_type_direct_string_must_be_odd_number);
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0, ecma_type_direct_string_must_be_odd_number);
|
||||
|
||||
JERRY_STATIC_ASSERT (LIT_MAGIC_STRING__COUNT <= ECMA_DIRECT_STRING_MAX_IMM,
|
||||
all_magic_strings_must_be_encoded_as_direct_string);
|
||||
@@ -96,8 +96,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
|
||||
}
|
||||
|
||||
index = (index * 10) + (uint32_t) (*string_p++ - LIT_CHAR_0);
|
||||
}
|
||||
while (string_p < string_end_p);
|
||||
} while (string_p < string_end_p);
|
||||
|
||||
if (string_size < ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32)
|
||||
{
|
||||
@@ -107,9 +106,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
|
||||
|
||||
/* Overflow must be checked as well when size is
|
||||
* equal to ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32. */
|
||||
if (*string_p > LIT_CHAR_9
|
||||
|| *string_p < LIT_CHAR_0
|
||||
|| index > (UINT32_MAX / 10)
|
||||
if (*string_p > LIT_CHAR_9 || *string_p < LIT_CHAR_0 || index > (UINT32_MAX / 10)
|
||||
|| (index == (UINT32_MAX / 10) && *string_p > LIT_CHAR_5))
|
||||
{
|
||||
return false;
|
||||
@@ -241,8 +238,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
|
||||
{
|
||||
JERRY_ASSERT (string_p != NULL);
|
||||
|
||||
return (!ECMA_IS_DIRECT_STRING (string_p)
|
||||
&& ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
|
||||
return (!ECMA_IS_DIRECT_STRING (string_p) && ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
|
||||
} /* ecma_prop_name_is_symbol */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -251,7 +247,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_size_t length, /**< length of the buffer */
|
||||
lit_utf8_size_t size, /**< size of the buffer */
|
||||
lit_utf8_byte_t **data_p) /**< [out] pointer to the start of the string buffer */
|
||||
@@ -382,9 +378,8 @@ ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, /**< utf-8 stri
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size),
|
||||
string_size,
|
||||
&data_p);
|
||||
string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size), string_size, &data_p);
|
||||
|
||||
string_desc_p->u.hash = lit_utf8_string_calc_hash (string_p, string_size);
|
||||
memcpy (data_p, string_p, string_size);
|
||||
@@ -446,9 +441,8 @@ ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string
|
||||
JERRY_ASSERT (lit_is_valid_utf8_string (string_p, string_size, false));
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (converted_string_length,
|
||||
converted_string_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (converted_string_length, converted_string_size, &data_p);
|
||||
|
||||
const lit_utf8_byte_t *const begin_data_p = data_p;
|
||||
pos = 0;
|
||||
@@ -661,8 +655,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
if (ecma_number_is_infinity (num))
|
||||
{
|
||||
lit_magic_string_id_t id = (ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
|
||||
: LIT_MAGIC_STRING_INFINITY_UL);
|
||||
lit_magic_string_id_t id =
|
||||
(ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL : LIT_MAGIC_STRING_INFINITY_UL);
|
||||
return ecma_get_magic_string (id);
|
||||
}
|
||||
|
||||
@@ -676,9 +670,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size),
|
||||
str_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size), str_size, &data_p);
|
||||
|
||||
string_desc_p->u.hash = lit_utf8_string_calc_hash (str_buf, str_size);
|
||||
memcpy (data_p, str_buf, str_size);
|
||||
@@ -694,7 +687,7 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string */
|
||||
{
|
||||
JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT);
|
||||
@@ -709,7 +702,7 @@ ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_internal_string (lit_magic_string_id_t id) /**< identifier of magic string */
|
||||
{
|
||||
JERRY_ASSERT (id >= LIT_NON_INTERNAL_MAGIC_STRING__COUNT && id < LIT_MAGIC_STRING__COUNT);
|
||||
@@ -743,11 +736,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
|
||||
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
|
||||
const lit_utf8_byte_t *cesu8_string1_p = ecma_string_get_chars (string1_p,
|
||||
&cesu8_string1_size,
|
||||
&cesu8_string1_length,
|
||||
uint32_to_string_buffer,
|
||||
&flags);
|
||||
const lit_utf8_byte_t *cesu8_string1_p =
|
||||
ecma_string_get_chars (string1_p, &cesu8_string1_size, &cesu8_string1_length, uint32_to_string_buffer, &flags);
|
||||
|
||||
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
|
||||
JERRY_ASSERT (cesu8_string1_length > 0);
|
||||
@@ -762,10 +752,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
}
|
||||
|
||||
lit_magic_string_id_t magic_string_id;
|
||||
magic_string_id = lit_is_utf8_string_pair_magic (cesu8_string1_p,
|
||||
cesu8_string1_size,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size);
|
||||
magic_string_id =
|
||||
lit_is_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
|
||||
|
||||
if (magic_string_id != LIT_MAGIC_STRING__COUNT)
|
||||
{
|
||||
@@ -789,10 +777,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
if (lit_get_magic_string_ex_count () > 0)
|
||||
{
|
||||
lit_magic_string_ex_id_t magic_string_ex_id;
|
||||
magic_string_ex_id = lit_is_ex_utf8_string_pair_magic (cesu8_string1_p,
|
||||
cesu8_string1_size,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size);
|
||||
magic_string_ex_id =
|
||||
lit_is_ex_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
|
||||
|
||||
if (magic_string_ex_id < lit_get_magic_string_ex_count ())
|
||||
{
|
||||
@@ -802,9 +788,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length,
|
||||
new_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length, new_size, &data_p);
|
||||
|
||||
lit_string_hash_t hash_start;
|
||||
|
||||
@@ -857,18 +842,13 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
|
||||
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
|
||||
|
||||
const lit_utf8_byte_t *cesu8_string2_p = ecma_string_get_chars (string2_p,
|
||||
&cesu8_string2_size,
|
||||
&cesu8_string2_length,
|
||||
uint32_to_string_buffer,
|
||||
&flags);
|
||||
const lit_utf8_byte_t *cesu8_string2_p =
|
||||
ecma_string_get_chars (string2_p, &cesu8_string2_size, &cesu8_string2_length, uint32_to_string_buffer, &flags);
|
||||
|
||||
JERRY_ASSERT (cesu8_string2_p != NULL);
|
||||
|
||||
ecma_string_t *result_p = ecma_append_chars_to_string (string1_p,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size,
|
||||
cesu8_string2_length);
|
||||
ecma_string_t *result_p =
|
||||
ecma_append_chars_to_string (string1_p, cesu8_string2_p, cesu8_string2_size, cesu8_string2_length);
|
||||
|
||||
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
|
||||
|
||||
@@ -1200,10 +1180,7 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_p, /**< ecma-string
|
||||
return size;
|
||||
}
|
||||
|
||||
size = lit_convert_cesu8_string_to_utf8_string (chars_p,
|
||||
size,
|
||||
buffer_p,
|
||||
buffer_size);
|
||||
size = lit_convert_cesu8_string_to_utf8_string (chars_p, size, buffer_p, buffer_size);
|
||||
|
||||
if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
|
||||
{
|
||||
@@ -1606,7 +1583,6 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
JERRY_ASSERT (length == size);
|
||||
*flags_p |= ECMA_STRING_FLAG_IS_UINT32 | ECMA_STRING_FLAG_REHASH_NEEDED;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
@@ -1634,8 +1610,7 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
*length_p = length;
|
||||
}
|
||||
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII)
|
||||
&& length != size)
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII) && length != size)
|
||||
{
|
||||
*flags_p = (uint8_t) (*flags_p & (uint8_t) ~ECMA_STRING_FLAG_IS_ASCII);
|
||||
}
|
||||
@@ -1685,7 +1660,7 @@ ecma_string_is_length (const ecma_string_t *string_p) /**< property name */
|
||||
*
|
||||
* @return pointer to the converted ecma string
|
||||
*/
|
||||
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_property_to_string (ecma_property_t property, /**< property name type */
|
||||
jmem_cpointer_t prop_name_cp) /**< property name compressed pointer */
|
||||
{
|
||||
@@ -1964,8 +1939,7 @@ bool
|
||||
ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-string */
|
||||
const ecma_string_t *string2_p) /**< ecma-string */
|
||||
{
|
||||
if (ecma_compare_ecma_strings (string1_p,
|
||||
string2_p))
|
||||
if (ecma_compare_ecma_strings (string1_p, string2_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -2038,10 +2012,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
|
||||
}
|
||||
}
|
||||
|
||||
return lit_compare_utf8_strings_relational (utf8_string1_p,
|
||||
utf8_string1_size,
|
||||
utf8_string2_p,
|
||||
utf8_string2_size);
|
||||
return lit_compare_utf8_strings_relational (utf8_string1_p, utf8_string1_size, utf8_string2_p, utf8_string2_size);
|
||||
} /* ecma_compare_ecma_strings_relational */
|
||||
|
||||
/**
|
||||
@@ -2071,8 +2042,7 @@ ecma_string_get_ascii_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
return ECMA_STRING_NO_ASCII_SIZE;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id),
|
||||
lit_get_magic_string_size (id)));
|
||||
JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id), lit_get_magic_string_size (id)));
|
||||
|
||||
return lit_get_magic_string_size (id);
|
||||
}
|
||||
@@ -2120,8 +2090,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@@ -2137,8 +2106,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_length */
|
||||
|
||||
/**
|
||||
@@ -2162,8 +2130,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@@ -2196,8 +2163,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_utf8_length */
|
||||
|
||||
/**
|
||||
@@ -2259,8 +2225,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@@ -2291,8 +2256,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_utf8_size */
|
||||
|
||||
/**
|
||||
@@ -2511,7 +2475,7 @@ ecma_string_substr (const ecma_string_t *string_p, /**< pointer to an ecma strin
|
||||
*/
|
||||
const lit_utf8_byte_t *
|
||||
ecma_string_trim_front (const lit_utf8_byte_t *start_p, /**< current string's start position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
{
|
||||
ecma_char_t ch;
|
||||
|
||||
@@ -2540,7 +2504,7 @@ ecma_string_trim_front (const lit_utf8_byte_t *start_p, /**< current string's st
|
||||
*/
|
||||
const lit_utf8_byte_t *
|
||||
ecma_string_trim_back (const lit_utf8_byte_t *start_p, /**< current string's start position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
{
|
||||
ecma_char_t ch;
|
||||
|
||||
@@ -2568,7 +2532,7 @@ ecma_string_trim_back (const lit_utf8_byte_t *start_p, /**< current string's sta
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, /**< [in, out] current string position */
|
||||
lit_utf8_size_t *utf8_str_size) /**< [in, out] size of the given string */
|
||||
lit_utf8_size_t *utf8_str_size) /**< [in, out] size of the given string */
|
||||
{
|
||||
const lit_utf8_byte_t *end_p = *utf8_str_p + *utf8_str_size;
|
||||
const lit_utf8_byte_t *start_p = *utf8_str_p;
|
||||
@@ -2622,11 +2586,10 @@ ecma_string_trim (const ecma_string_t *string_p) /**< pointer to an ecma string
|
||||
ecma_value_t
|
||||
ecma_string_pad (ecma_value_t original_string_p, /**< Input ecma string */
|
||||
ecma_value_t max_length, /**< Length to pad to, including original length */
|
||||
ecma_value_t fill_string, /**< The string to pad with */
|
||||
ecma_value_t fill_string, /**< The string to pad with */
|
||||
bool pad_on_start) /**< true - if we are padding to the start, calling with padStart
|
||||
false - if we are padding to the end, calling with padEnd */
|
||||
{
|
||||
|
||||
/* 3 */
|
||||
ecma_length_t int_max_length;
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (max_length, &int_max_length)))
|
||||
@@ -2723,7 +2686,7 @@ ecma_stringbuilder_create (void)
|
||||
jmem_stats_allocate_string_bytes (initial_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create */
|
||||
|
||||
@@ -2744,12 +2707,11 @@ ecma_stringbuilder_create_from (ecma_string_t *string_p) /**< ecma string */
|
||||
jmem_stats_allocate_string_bytes (initial_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p,
|
||||
ECMA_STRINGBUILDER_STRING_PTR (header_p),
|
||||
string_size);
|
||||
size_t copied_size =
|
||||
ecma_string_copy_to_cesu8_buffer (string_p, ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
|
||||
JERRY_ASSERT (copied_size == string_size);
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create_from */
|
||||
|
||||
@@ -2772,7 +2734,7 @@ ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, /**< pointer to da
|
||||
|
||||
memcpy (ECMA_STRINGBUILDER_STRING_PTR (header_p), data_p, data_size);
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create_raw */
|
||||
|
||||
@@ -2797,7 +2759,7 @@ ecma_stringbuilder_grow (ecma_stringbuilder_t *builder_p, /**< string builder */
|
||||
jmem_stats_allocate_string_bytes (required_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return ((lit_utf8_byte_t *) header_p) + header_p->current_size - required_size;
|
||||
return ((lit_utf8_byte_t *) header_p) + header_p->current_size - required_size;
|
||||
} /* ecma_stringbuilder_grow */
|
||||
|
||||
/**
|
||||
@@ -2860,9 +2822,7 @@ ecma_stringbuilder_append (ecma_stringbuilder_t *builder_p, /**< string builder
|
||||
const lit_utf8_size_t string_size = ecma_string_get_size (string_p);
|
||||
lit_utf8_byte_t *dest_p = ecma_stringbuilder_grow (builder_p, string_size);
|
||||
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p,
|
||||
dest_p,
|
||||
string_size);
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p, dest_p, string_size);
|
||||
JERRY_ASSERT (copied_size == string_size);
|
||||
} /* ecma_stringbuilder_append */
|
||||
|
||||
@@ -2953,7 +2913,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
builder_p->header_p = NULL;
|
||||
#endif
|
||||
#endif /* !defined (JERRY_NDEBUG) */
|
||||
|
||||
size_t container_size = sizeof (ecma_short_string_t);
|
||||
const lit_string_hash_t hash = lit_utf8_string_calc_hash (string_begin_p, string_size);
|
||||
@@ -2978,9 +2938,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
|
||||
|
||||
const size_t utf8_string_size = string_size + container_size;
|
||||
header_p = jmem_heap_realloc_block (header_p, header_p->current_size, utf8_string_size);
|
||||
memmove (((lit_utf8_byte_t *) header_p + container_size),
|
||||
ECMA_STRINGBUILDER_STRING_PTR (header_p),
|
||||
string_size);
|
||||
memmove (((lit_utf8_byte_t *) header_p + container_size), ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
|
||||
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (container_size - ECMA_ASCII_STRING_HEADER_SIZE);
|
||||
@@ -3021,7 +2979,7 @@ ecma_stringbuilder_destroy (ecma_stringbuilder_t *builder_p) /**< string builder
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
builder_p->header_p = NULL;
|
||||
#endif
|
||||
#endif /* !defined (JERRY_NDEBUG) */
|
||||
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (size);
|
||||
|
||||
@@ -15,20 +15,18 @@
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
#include "ecma-function-object.h"
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK,
|
||||
ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT),
|
||||
ecma_value_part_must_start_after_flags);
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT), ecma_value_part_must_start_after_flags);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
|
||||
ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log);
|
||||
@@ -42,18 +40,16 @@ JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (jmem_cpointer_tag_t),
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
/* cppcheck-suppress zerodiv */
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t),
|
||||
uintptr_t_must_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), uintptr_t_must_fit_in_ecma_value_t);
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t),
|
||||
uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE_TRUE
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
only_the_lowest_bit_must_be_different_for_simple_value_true_and_false);
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
@@ -110,7 +106,7 @@ ecma_pointer_to_ecma_value (const void *ptr) /**< pointer */
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
static inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline void *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
|
||||
{
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@@ -277,8 +273,7 @@ extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */
|
||||
ecma_value_t second_value) /**< second ecma value */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0,
|
||||
ecma_direct_type_integer_value_must_be_zero);
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, ecma_direct_type_integer_value_must_be_zero);
|
||||
|
||||
return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
|
||||
} /* ecma_are_values_integer_numbers */
|
||||
@@ -304,8 +299,7 @@ ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_number (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_is_value_integer_number (value)
|
||||
|| ecma_is_value_float_number (value));
|
||||
return (ecma_is_value_integer_number (value) || ecma_is_value_float_number (value));
|
||||
} /* ecma_is_value_number */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING,
|
||||
@@ -362,12 +356,12 @@ ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_bigint (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
|
||||
#else /* !JERRY_BUILTIN_BIGINT */
|
||||
#else /* !JERRY_BUILTIN_BIGINT */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
} /* ecma_is_value_bigint */
|
||||
|
||||
/**
|
||||
@@ -441,14 +435,9 @@ ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
|
||||
void
|
||||
ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value)
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_string (value)
|
||||
|| ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value)
|
||||
|| ecma_is_value_object (value));
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value) || ecma_is_value_null (value) || ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value) || ecma_is_value_string (value) || ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value) || ecma_is_value_object (value));
|
||||
} /* ecma_check_value_type_is_spec_defined */
|
||||
|
||||
/**
|
||||
@@ -768,7 +757,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return floating point value
|
||||
*/
|
||||
extern inline ecma_number_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
|
||||
@@ -797,7 +786,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_string (value));
|
||||
@@ -816,7 +805,7 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_symbol (value));
|
||||
@@ -830,7 +819,7 @@ ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_prop_name (value));
|
||||
@@ -848,7 +837,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (value));
|
||||
@@ -861,7 +850,7 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern inline ecma_extended_primitive_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_primitive_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
@@ -892,7 +881,7 @@ ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
@@ -951,7 +940,7 @@ ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT) ? value : ecma_copy_value (value);
|
||||
} /* ecma_fast_copy_value */
|
||||
@@ -1006,8 +995,7 @@ void
|
||||
ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
ecma_value_t ecma_value) /**< value to assign */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0,
|
||||
ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
|
||||
if (*value_p == ecma_value)
|
||||
{
|
||||
@@ -1018,8 +1006,7 @@ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
{
|
||||
*value_p = ecma_value;
|
||||
}
|
||||
else if (ecma_is_value_float_number (ecma_value)
|
||||
&& ecma_is_value_float_number (*value_p))
|
||||
else if (ecma_is_value_float_number (ecma_value) && ecma_is_value_float_number (*value_p))
|
||||
{
|
||||
const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value);
|
||||
ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p);
|
||||
|
||||
@@ -13,20 +13,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "ecma-line-info.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "jcontext.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "byte-code.h"
|
||||
#include "re-compiler.h"
|
||||
#include "ecma-builtins.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
#include "debugger.h"
|
||||
@@ -62,13 +64,13 @@ JERRY_STATIC_ASSERT (ECMA_PROPERTY_FLAGS_MASK == ECMA_PROPERTY_CONFIGURABLE_ENUM
|
||||
|
||||
/* These checks are needed by ecma_get_object_base_type. */
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_GENERAL == ((int) ECMA_OBJECT_TYPE_GENERAL | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_GENERAL & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_GENERAL & 0x1) == 0,
|
||||
ecma_object_type_built_in_general_has_unexpected_value);
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_CLASS == ((int) ECMA_OBJECT_TYPE_CLASS | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_CLASS & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_CLASS & 0x1) == 0,
|
||||
ecma_object_type_built_in_class_has_unexpected_value);
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_ARRAY == ((int) ECMA_OBJECT_TYPE_ARRAY | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_ARRAY & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_ARRAY & 0x1) == 0,
|
||||
ecma_object_type_built_in_array_has_unexpected_value);
|
||||
|
||||
/**
|
||||
@@ -147,8 +149,7 @@ ecma_object_t *
|
||||
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
|
||||
ecma_object_t *binding_obj_p) /**< binding object */
|
||||
{
|
||||
JERRY_ASSERT (binding_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (binding_obj_p));
|
||||
JERRY_ASSERT (binding_obj_p != NULL && !ecma_is_lexical_environment (binding_obj_p));
|
||||
|
||||
ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
|
||||
|
||||
@@ -156,8 +157,7 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
|
||||
|
||||
ecma_init_gc_info (new_lexical_environment_p);
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp,
|
||||
binding_obj_p);
|
||||
ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp, binding_obj_p);
|
||||
|
||||
ECMA_SET_POINTER (new_lexical_environment_p->u2.outer_reference_cp, outer_lexical_environment_p);
|
||||
|
||||
@@ -298,7 +298,7 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
|
||||
*
|
||||
* @return pointer to ecma object
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_PURE
|
||||
extern inline ecma_object_t *JERRY_ATTR_PURE
|
||||
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -381,8 +381,7 @@ ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, /**< declarative
|
||||
}
|
||||
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
}
|
||||
while (prop_iter_cp != JMEM_CP_NULL);
|
||||
} while (prop_iter_cp != JMEM_CP_NULL);
|
||||
|
||||
ecma_deref_object (lex_env_p);
|
||||
return new_lex_env_p;
|
||||
@@ -411,8 +410,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
if (*property_list_head_p != ECMA_NULL_POINTER)
|
||||
{
|
||||
/* If the first entry is free (deleted), it is reused. */
|
||||
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
ecma_property_header_t *first_property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
bool has_hashmap = false;
|
||||
@@ -420,8 +419,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
property_list_head_p = &first_property_p->next_property_cp;
|
||||
first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
has_hashmap = true;
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
@@ -433,8 +431,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_property_pair_t *first_property_pair_p = (ecma_property_pair_t *) first_property_p;
|
||||
|
||||
ecma_property_t name_type;
|
||||
first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p,
|
||||
&name_type);
|
||||
first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p, &name_type);
|
||||
first_property_p->types[0] = (ecma_property_t) (type_and_flags | name_type);
|
||||
|
||||
ecma_property_t *property_p = first_property_p->types + 0;
|
||||
@@ -456,10 +453,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (has_hashmap)
|
||||
{
|
||||
ecma_property_hashmap_insert (object_p,
|
||||
name_p,
|
||||
first_property_pair_p,
|
||||
0);
|
||||
ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 0);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@@ -478,8 +472,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (*property_list_head_p != ECMA_NULL_POINTER)
|
||||
{
|
||||
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
ecma_property_header_t *first_property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
|
||||
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
@@ -495,8 +489,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
first_property_pair_p->names_cp[0] = LIT_INTERNAL_MAGIC_STRING_DELETED;
|
||||
|
||||
ecma_property_t name_type;
|
||||
first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p,
|
||||
&name_type);
|
||||
first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p, &name_type);
|
||||
|
||||
first_property_pair_p->header.types[1] = (ecma_property_t) (type_and_flags | name_type);
|
||||
|
||||
@@ -518,10 +511,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (has_hashmap)
|
||||
{
|
||||
ecma_property_hashmap_insert (object_p,
|
||||
name_p,
|
||||
first_property_pair_p,
|
||||
1);
|
||||
ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 1);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@@ -542,8 +532,7 @@ ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
|
||||
* if this field is non-NULL */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|
||||
|| !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
|
||||
|
||||
@@ -570,8 +559,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
* if this field is non-NULL */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|
||||
|| !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE) == 0);
|
||||
|
||||
@@ -630,8 +618,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL);
|
||||
JERRY_ASSERT (name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|
||||
|| !ecma_op_object_is_fast_array (obj_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|
||||
|
||||
#if JERRY_LCACHE
|
||||
ecma_property_t *property_p = ecma_lcache_lookup (obj_p, name_p);
|
||||
@@ -648,17 +635,13 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
jmem_cpointer_t property_real_name_cp;
|
||||
property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p,
|
||||
name_p,
|
||||
&property_real_name_cp);
|
||||
property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p, name_p, &property_real_name_cp);
|
||||
#if JERRY_LCACHE
|
||||
if (property_p != NULL
|
||||
&& !ecma_is_property_lcached (property_p))
|
||||
if (property_p != NULL && !ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_insert (obj_p, property_real_name_cp, property_p);
|
||||
}
|
||||
@@ -682,8 +665,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
@@ -717,8 +699,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
{
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
@@ -763,8 +744,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
#if JERRY_LCACHE
|
||||
if (property_p != NULL
|
||||
&& !ecma_is_property_lcached (property_p))
|
||||
if (property_p != NULL && !ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_insert (obj_p, property_name_cp, property_p);
|
||||
}
|
||||
@@ -788,8 +768,7 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL);
|
||||
JERRY_ASSERT (name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|
||||
|| !ecma_op_object_is_fast_array (obj_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
@@ -816,8 +795,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
if (cur_prop_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
cur_prop_cp);
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
|
||||
|
||||
if (cur_prop_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
@@ -830,8 +808,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
while (cur_prop_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
cur_prop_cp);
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (cur_prop_p));
|
||||
|
||||
@@ -846,9 +823,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP)
|
||||
{
|
||||
hashmap_status = ecma_property_hashmap_delete (object_p,
|
||||
prop_pair_p->names_cp[i],
|
||||
cur_prop_p->types + i);
|
||||
hashmap_status = ecma_property_hashmap_delete (object_p, prop_pair_p->names_cp[i], cur_prop_p->types + i);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@@ -988,8 +963,7 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_value_p->getter_setter_pair_cp);
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->getter_cp, getter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.getter_cp, getter_p);
|
||||
@@ -1008,8 +982,7 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_value_p->getter_setter_pair_cp);
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->setter_cp, setter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.setter_cp, setter_p);
|
||||
@@ -1059,7 +1032,7 @@ ecma_property_to_reference (ecma_property_t *property_p) /**< data or reference
|
||||
*
|
||||
* @return pointer to the value
|
||||
*/
|
||||
extern inline ecma_property_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_value_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_property_value_from_named_reference (ecma_property_value_t *reference_p) /**< data property reference */
|
||||
{
|
||||
ecma_value_t value = reference_p->value;
|
||||
@@ -1248,14 +1221,12 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
|
||||
ecma_free_value (prop_desc_p->value);
|
||||
}
|
||||
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED)
|
||||
&& prop_desc_p->get_p != NULL)
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) && prop_desc_p->get_p != NULL)
|
||||
{
|
||||
ecma_deref_object (prop_desc_p->get_p);
|
||||
}
|
||||
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED)
|
||||
&& prop_desc_p->set_p != NULL)
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED) && prop_desc_p->set_p != NULL)
|
||||
{
|
||||
ecma_deref_object (prop_desc_p->set_p);
|
||||
}
|
||||
@@ -1551,8 +1522,8 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
|
||||
for (uint32_t i = const_literal_end; i < literal_end; i++)
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_literal_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_start_p[i]);
|
||||
ecma_compiled_code_t *bytecode_literal_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
|
||||
|
||||
/* Self references are ignored. */
|
||||
if (bytecode_literal_p != bytecode_p)
|
||||
@@ -1606,8 +1577,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
jerry_debugger_byte_code_free_t *first_byte_code_free_p;
|
||||
|
||||
first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t,
|
||||
byte_code_free_head);
|
||||
first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_head);
|
||||
first_byte_code_free_p->prev_cp = byte_code_free_cp;
|
||||
}
|
||||
|
||||
@@ -1629,8 +1599,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
}
|
||||
|
||||
jmem_heap_free_block (bytecode_p,
|
||||
((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
jmem_heap_free_block (bytecode_p, ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
} /* ecma_bytecode_deref */
|
||||
|
||||
/**
|
||||
@@ -1659,8 +1628,7 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
|
||||
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT)
|
||||
{
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1687,8 +1655,8 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
object_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
ext_object_p->u.bound_function.target_function);
|
||||
object_p =
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_object_p->u.bound_function.target_function);
|
||||
continue;
|
||||
}
|
||||
#if JERRY_ESNEXT
|
||||
@@ -1741,7 +1709,7 @@ ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode
|
||||
*
|
||||
* @return position of the function name of the compiled code
|
||||
*/
|
||||
extern inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ECMA_HELPERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-strings.h"
|
||||
|
||||
@@ -47,8 +48,8 @@
|
||||
* Set value of non-null compressed pointer so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \
|
||||
non_compressed_pointer)
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||
JMEM_CP_SET_NON_NULL_POINTER (field, non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Set value of pointer-tag value so that it will correspond
|
||||
@@ -88,42 +89,38 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_REHASH_NEEDED = (1 << 1), /**< The hash of the string must be recalculated.
|
||||
* For more details see ecma_append_chars_to_string */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
|
||||
} ecma_string_flag_t;
|
||||
|
||||
/**
|
||||
* Underscore is ignored when this option is passed.
|
||||
*/
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
|
||||
/**
|
||||
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
|
||||
*/
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
utf8_str_size) /**< [out] output buffer size */ \
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr ## flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, \
|
||||
&utf8_str_size, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
&utf8_ptr ## flags);
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr##flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, &utf8_str_size, NULL, NULL, &utf8_ptr##flags);
|
||||
|
||||
/**
|
||||
* Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
|
||||
*/
|
||||
#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr ## flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr##flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
}
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@@ -131,64 +128,54 @@ typedef enum
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ((type *) field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ((type *) field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) NULL))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) NULL))
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
ECMA_SET_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ECMA_SET_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
ECMA_GET_POINTER (type, field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ECMA_GET_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@@ -264,7 +251,7 @@ ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_exte
|
||||
uint32_t type);
|
||||
ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value);
|
||||
ecma_number_t * ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t *ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value);
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value);
|
||||
#if JERRY_ESNEXT
|
||||
@@ -299,14 +286,12 @@ ecma_length_t ecma_op_advance_string_index (ecma_string_t *str_p, ecma_length_t
|
||||
ecma_string_t *ecma_new_map_key_string (ecma_value_t value);
|
||||
bool ecma_prop_name_is_map_key (ecma_string_t *string_p);
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size,
|
||||
void *user_p);
|
||||
ecma_string_t *
|
||||
ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size, void *user_p);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
|
||||
#if JERRY_ESNEXT
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
|
||||
@@ -331,28 +316,24 @@ void ecma_destroy_ecma_string (ecma_string_t *string_p);
|
||||
ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
|
||||
uint32_t ecma_string_get_array_index (const ecma_string_t *str_p);
|
||||
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
void
|
||||
ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size);
|
||||
const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p,
|
||||
lit_utf8_size_t *size_p,
|
||||
lit_utf8_size_t *length_p,
|
||||
@@ -369,7 +350,8 @@ jmem_cpointer_t ecma_string_to_property_name (ecma_string_t *prop_name_p, ecma_p
|
||||
ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp,
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property,
|
||||
jmem_cpointer_t prop_name_cp,
|
||||
const ecma_string_t *string_p);
|
||||
|
||||
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
@@ -387,20 +369,16 @@ lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
|
||||
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
|
||||
const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p,
|
||||
lit_utf8_size_t *utf8_str_size);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, lit_utf8_size_t *utf8_str_size);
|
||||
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
|
||||
#if JERRY_ESNEXT
|
||||
ecma_value_t ecma_string_pad (ecma_value_t original_string_p,
|
||||
ecma_value_t max_length,
|
||||
ecma_value_t fill_string,
|
||||
bool pad_on_start);
|
||||
ecma_value_t
|
||||
ecma_string_pad (ecma_value_t original_string_p, ecma_value_t max_length, ecma_value_t fill_string, bool pad_on_start);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create (void);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p,
|
||||
const lit_utf8_size_t data_size);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, const lit_utf8_size_t data_size);
|
||||
lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p);
|
||||
lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p);
|
||||
void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size);
|
||||
@@ -425,18 +403,15 @@ 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);
|
||||
bool ecma_number_is_finite (ecma_number_t num);
|
||||
ecma_number_t
|
||||
ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, 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);
|
||||
ecma_number_t ecma_number_get_next (ecma_number_t num);
|
||||
ecma_number_t ecma_number_trunc (ecma_number_t num);
|
||||
ecma_number_t ecma_number_calc_remainder (ecma_number_t left_num, ecma_number_t right_num);
|
||||
ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y);
|
||||
ecma_value_t ecma_number_parse_int (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size,
|
||||
ecma_value_t radix);
|
||||
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size);
|
||||
ecma_value_t
|
||||
ecma_number_parse_int (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size, ecma_value_t radix);
|
||||
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size);
|
||||
ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer);
|
||||
lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p);
|
||||
|
||||
@@ -476,30 +451,33 @@ ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecm
|
||||
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
|
||||
ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values);
|
||||
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_accessor_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_object_t *get_p,
|
||||
ecma_object_t *set_p, uint8_t prop_attributes, ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *ecma_create_named_data_property (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *ecma_create_named_accessor_property (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_object_t *get_p,
|
||||
ecma_object_t *set_p,
|
||||
uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
void ecma_create_named_reference_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_value_t reference);
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ecma_property_t *
|
||||
ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_value_t *
|
||||
ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_value_t *ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
|
||||
void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p);
|
||||
|
||||
void ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_value_t value);
|
||||
void
|
||||
ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, ecma_value_t value);
|
||||
|
||||
ecma_getter_setter_pointers_t *
|
||||
ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_getter_setter_pointers_t *ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *getter_p);
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *setter_p);
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ecma_value_t ecma_property_to_reference (ecma_property_t *property_p);
|
||||
@@ -549,15 +527,15 @@ uintptr_t ecma_get_current_stack_usage (void);
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
|
||||
/* ecma-helpers-external-pointers.c */
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p, void *native_p,
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p,
|
||||
void *native_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_object_native_info_t *native_info_p);
|
||||
|
||||
/* ecma-helpers-conversion.c */
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size,
|
||||
uint32_t option);
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, uint32_t option);
|
||||
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
|
||||
uint32_t ecma_number_to_uint32 (ecma_number_t num);
|
||||
int32_t ecma_number_to_int32 (ecma_number_t num);
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-init-finalize.h"
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-init-finalize.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
#include "jmem.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -89,8 +91,7 @@ ecma_finalize (void)
|
||||
{
|
||||
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS);
|
||||
}
|
||||
}
|
||||
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
} while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp);
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -98,7 +100,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
|
||||
do
|
||||
@@ -109,8 +111,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
ecma_lcache_invalidate_entry (--entry_p);
|
||||
@@ -136,7 +137,7 @@ insert:
|
||||
* @return a pointer to an ecma_property_t if the lookup is successful
|
||||
* NULL otherwise
|
||||
*/
|
||||
extern inline ecma_property_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
const ecma_string_t *prop_name_p) /**< property's name */
|
||||
{
|
||||
@@ -161,7 +162,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp);
|
||||
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp);
|
||||
|
||||
@@ -173,8 +174,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
return entry_p->prop_p;
|
||||
}
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_lcache_lookup */
|
||||
@@ -195,12 +195,12 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
|
||||
while (true)
|
||||
{
|
||||
/* The property must be present. */
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache)[row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
|
||||
if (entry_p->id != 0 && entry_p->prop_p == prop_p)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_LCACHE
|
||||
void ecma_lcache_insert (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p);
|
||||
ecma_property_t *ecma_lcache_lookup (const ecma_object_t *object_p, const ecma_string_t *prop_name_p);
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-line-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#if JERRY_LINE_INFO
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -45,8 +46,7 @@ ecma_line_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
|
||||
do
|
||||
{
|
||||
value = (value << ECMA_LINE_INFO_VLQ_SHIFT) | (*source_p & ECMA_LINE_INFO_VLQ_MASK);
|
||||
}
|
||||
while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
|
||||
} while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
@@ -169,8 +169,7 @@ ecma_line_info_get (uint8_t *line_info_p, /**< line info buffer */
|
||||
column = ecma_line_info_difference_update (column, value);
|
||||
|
||||
end_offset += end_offset_increase;
|
||||
}
|
||||
while (end_offset_increase != 0 && end_offset <= offset);
|
||||
} while (end_offset_increase != 0 && end_offset <= offset);
|
||||
|
||||
location_p->line = line;
|
||||
location_p->column = column;
|
||||
|
||||
@@ -90,8 +90,7 @@
|
||||
/**
|
||||
* Minimum size of a stream (except the last one).
|
||||
*/
|
||||
#define ECMA_LINE_INFO_STREAM_SIZE_MIN \
|
||||
((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
|
||||
#define ECMA_LINE_INFO_STREAM_SIZE_MIN ((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
|
||||
|
||||
/* Helper functions for parser/js/js-parser-line-info-create.c. */
|
||||
uint32_t ecma_line_info_decode_vlq (uint8_t **buffer_p);
|
||||
@@ -99,8 +98,7 @@ uint32_t ecma_line_info_difference_update (uint32_t current_value, uint32_t diff
|
||||
|
||||
/* General functions. */
|
||||
void ecma_line_info_free (uint8_t *line_info_p);
|
||||
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset,
|
||||
jerry_backtrace_location_t *location_p);
|
||||
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset, jerry_backtrace_location_t *location_p);
|
||||
|
||||
#if JERRY_PARSER_DUMP_BYTE_CODE
|
||||
void ecma_line_info_dump (uint8_t *line_info_p);
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -42,8 +44,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
|
||||
{
|
||||
if (symbol_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
symbol_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, symbol_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_deref_ecma_string (string_p);
|
||||
@@ -71,8 +72,7 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
|
||||
{
|
||||
if (string_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_destroy_ecma_string (string_p);
|
||||
@@ -93,8 +93,7 @@ ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
|
||||
{
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@@ -120,15 +119,14 @@ ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
|
||||
{
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (bigint_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_extended_primitive_t *bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
ecma_extended_primitive_t *bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p));
|
||||
ecma_deref_bigint (bigint_p);
|
||||
}
|
||||
@@ -168,8 +166,8 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
lit_utf8_size_t size, /**< size of the string */
|
||||
bool is_ascii) /**< encode of the string */
|
||||
{
|
||||
ecma_string_t *string_p = (is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size)
|
||||
: ecma_new_ecma_string_from_utf8 (chars_p, size));
|
||||
ecma_string_t *string_p =
|
||||
(is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size) : ecma_new_ecma_string_from_utf8 (chars_p, size));
|
||||
|
||||
if (ECMA_IS_DIRECT_STRING (string_p))
|
||||
{
|
||||
@@ -194,8 +192,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (string_p, value_p))
|
||||
{
|
||||
@@ -256,8 +253,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@@ -270,8 +266,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t,
|
||||
number_list_p->values[i]);
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]);
|
||||
|
||||
if (*number_p == number_arg)
|
||||
{
|
||||
@@ -330,8 +325,7 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@@ -344,8 +338,8 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
ecma_extended_primitive_t *other_bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);
|
||||
|
||||
if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
|
||||
@@ -417,8 +411,9 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
/**
|
||||
* Append the value at the end of the appropriate list if it is not present there.
|
||||
*/
|
||||
void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
void
|
||||
ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
{
|
||||
/* Unlike direct numbers, direct strings are converted to character literals. */
|
||||
if (!ecma_is_value_string (value)
|
||||
@@ -498,11 +493,9 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
|
||||
|
||||
for (uint32_t i = const_literal_end; i < literal_end; i++)
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_p[i]);
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_p[i]);
|
||||
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& bytecode_p != compiled_code_p)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags) && bytecode_p != compiled_code_p)
|
||||
{
|
||||
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ECMA_LIT_STORAGE_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-globals.h"
|
||||
|
||||
@@ -48,18 +49,19 @@ ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
|
||||
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p,
|
||||
uint32_t *buffer_p,
|
||||
size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p,
|
||||
lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
uint32_t *out_map_len_p);
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
#if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
|
||||
ecma_value_t
|
||||
ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
|
||||
ecma_value_t *
|
||||
ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p, uint8_t *byte_code_end_p);
|
||||
ecma_value_t ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
|
||||
ecma_value_t *ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p,
|
||||
uint8_t *byte_code_end_p);
|
||||
#endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "ecma-module.h"
|
||||
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
@@ -21,8 +21,9 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-module.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "vm.h"
|
||||
|
||||
@@ -104,15 +105,15 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_ERROR;
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL
|
||||
&& !jcontext_has_pending_abort ())
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL && !jcontext_has_pending_abort ())
|
||||
{
|
||||
jerry_value_t exception = jcontext_take_exception ();
|
||||
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_ERROR,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
exception,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_ERROR,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
exception,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
jcontext_raise_exception (exception);
|
||||
}
|
||||
} /* ecma_module_set_error_state */
|
||||
@@ -122,7 +123,7 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
|
||||
*
|
||||
* @return module pointer
|
||||
*/
|
||||
static inline ecma_module_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_module_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_module_get_from_object (ecma_value_t module_val) /**< module */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (module_val));
|
||||
@@ -210,8 +211,7 @@ ecma_module_resolve_set_append (ecma_module_resolve_set_t *set_p, /**< resolve s
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (current_p->module_p == module_p
|
||||
&& ecma_compare_ecma_strings (current_p->name_p, export_name_p))
|
||||
if (current_p->module_p == module_p && ecma_compare_ecma_strings (current_p->name_p, export_name_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -339,16 +339,14 @@ ecma_module_resolve_import (ecma_module_resolve_result_t *resolve_result_p, /**<
|
||||
{
|
||||
JERRY_ASSERT (import_node_p != NULL);
|
||||
|
||||
for (ecma_module_names_t *import_names_p = import_node_p->module_names_p;
|
||||
import_names_p != NULL;
|
||||
for (ecma_module_names_t *import_names_p = import_node_p->module_names_p; import_names_p != NULL;
|
||||
import_names_p = import_names_p->next_p)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (local_name_p, import_names_p->local_name_p))
|
||||
{
|
||||
ecma_module_t *imported_module_p = ecma_module_get_from_object (import_node_p->u.path_or_module);
|
||||
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace import. */
|
||||
ecma_value_t namespace = ecma_make_object_value (imported_module_p->namespace_object_p);
|
||||
@@ -401,19 +399,18 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
|
||||
if (current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE)
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (current_module_p->namespace_object_p,
|
||||
current_export_name_p);
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (current_module_p->namespace_object_p, current_export_name_p);
|
||||
|
||||
if (property_p != NULL)
|
||||
{
|
||||
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
JERRY_ASSERT ((!(*property_p & ECMA_PROPERTY_FLAG_DATA)
|
||||
&& !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG))
|
||||
|| ((*property_p & ECMA_PROPERTY_FLAG_DATA)
|
||||
&& ecma_is_value_object (property_value_p->value)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (property_value_p->value),
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE)));
|
||||
JERRY_ASSERT (
|
||||
(!(*property_p & ECMA_PROPERTY_FLAG_DATA) && !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG))
|
||||
|| ((*property_p & ECMA_PROPERTY_FLAG_DATA) && ecma_is_value_object (property_value_p->value)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (property_value_p->value),
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE)));
|
||||
|
||||
if (!ecma_module_resolve_update (resolve_result_p, property_value_p->value))
|
||||
{
|
||||
@@ -432,8 +429,8 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
{
|
||||
if (ecma_compare_ecma_strings (current_export_name_p, export_names_p->imex_name_p))
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (current_module_p->scope_p,
|
||||
export_names_p->local_name_p);
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (current_module_p->scope_p, export_names_p->local_name_p);
|
||||
|
||||
if (property_p != NULL)
|
||||
{
|
||||
@@ -473,8 +470,7 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
{
|
||||
ecma_module_t *target_module_p = ecma_module_get_from_object (*indirect_export_p->u.module_object_p);
|
||||
|
||||
if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace export. */
|
||||
ecma_value_t namespace = ecma_make_object_value (target_module_p->namespace_object_p);
|
||||
@@ -525,10 +521,9 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
star_export_p = star_export_p->next_p;
|
||||
}
|
||||
|
||||
next_iteration:
|
||||
next_iteration:
|
||||
current_set_p = current_set_p->next_p;
|
||||
}
|
||||
while (current_set_p != NULL);
|
||||
} while (current_set_p != NULL);
|
||||
|
||||
exit:
|
||||
ecma_module_resolve_set_cleanup (resolve_set_p);
|
||||
@@ -586,10 +581,11 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
|
||||
{
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_EVALUATED,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
ret_value,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_EVALUATED,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
ret_value,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -746,8 +742,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
@@ -802,8 +797,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
export_names_p = export_names_p->next_p;
|
||||
}
|
||||
while (export_names_p != NULL);
|
||||
} while (export_names_p != NULL);
|
||||
}
|
||||
|
||||
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
|
||||
@@ -848,8 +842,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
current_set_p = current_set_p->next_p;
|
||||
}
|
||||
while (current_set_p != NULL);
|
||||
} while (current_set_p != NULL);
|
||||
|
||||
ecma_value_t *buffer_p = properties_p->buffer_p;
|
||||
uint32_t item_count = properties_p->item_count;
|
||||
@@ -863,8 +856,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
end -= 2;
|
||||
ecma_module_heap_sort_shift_down (buffer_p, item_count, end);
|
||||
}
|
||||
while (end > 0);
|
||||
} while (end > 0);
|
||||
|
||||
end = item_count - 2;
|
||||
|
||||
@@ -880,8 +872,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
|
||||
ecma_module_heap_sort_shift_down (buffer_p, end, 0);
|
||||
end -= 2;
|
||||
}
|
||||
while (end > 0);
|
||||
} while (end > 0);
|
||||
}
|
||||
|
||||
ecma_value_t *buffer_end_p = properties_p->buffer_p + item_count;
|
||||
@@ -989,15 +980,12 @@ ecma_module_connect_imports (ecma_module_t *module_p)
|
||||
|
||||
while (import_names_p != NULL)
|
||||
{
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace import. */
|
||||
ecma_property_value_t *value_p;
|
||||
value_p = ecma_create_named_data_property (module_p->scope_p,
|
||||
import_names_p->local_name_p,
|
||||
ECMA_PROPERTY_FIXED,
|
||||
NULL);
|
||||
value_p =
|
||||
ecma_create_named_data_property (module_p->scope_p, import_names_p->local_name_p, ECMA_PROPERTY_FIXED, NULL);
|
||||
value_p->value = ecma_make_object_value (imported_module_p->namespace_object_p);
|
||||
}
|
||||
else
|
||||
@@ -1021,9 +1009,7 @@ ecma_module_connect_imports (ecma_module_t *module_p)
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_create_named_reference_property (module_p->scope_p,
|
||||
import_names_p->local_name_p,
|
||||
resolve_result.result);
|
||||
ecma_create_named_reference_property (module_p->scope_p, import_names_p->local_name_p, resolve_result.result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1253,9 +1239,8 @@ restart:
|
||||
|
||||
if (current_module_p->namespace_object_p == NULL)
|
||||
{
|
||||
ecma_object_t *namespace_object_p = ecma_create_object (NULL,
|
||||
sizeof (ecma_extended_object_t),
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_object_t *namespace_object_p =
|
||||
ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
namespace_object_p->type_flags_refs &= (ecma_object_descriptor_t) ~ECMA_OBJECT_FLAG_EXTENSIBLE;
|
||||
|
||||
@@ -1297,8 +1282,7 @@ restart:
|
||||
}
|
||||
|
||||
iterator_p = iterator_p->prev_p;
|
||||
}
|
||||
while (iterator_p != end_p);
|
||||
} while (iterator_p != end_p);
|
||||
|
||||
iterator_p = last_p;
|
||||
|
||||
@@ -1313,8 +1297,7 @@ restart:
|
||||
}
|
||||
|
||||
iterator_p = iterator_p->prev_p;
|
||||
}
|
||||
while (iterator_p != end_p);
|
||||
} while (iterator_p != end_p);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -1325,16 +1308,16 @@ restart:
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
|
||||
{
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_LINKED,
|
||||
ecma_make_object_value (&last_p->module_p->header.object),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_LINKED,
|
||||
ecma_make_object_value (&last_p->module_p->header.object),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
}
|
||||
|
||||
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
|
||||
last_p = prev_p;
|
||||
}
|
||||
while (last_p != end_p);
|
||||
} while (last_p != end_p);
|
||||
|
||||
if (current_p == NULL)
|
||||
{
|
||||
@@ -1357,8 +1340,7 @@ error:
|
||||
|
||||
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
|
||||
last_p = prev_p;
|
||||
}
|
||||
while (last_p != NULL);
|
||||
} while (last_p != NULL);
|
||||
|
||||
return ECMA_VALUE_ERROR;
|
||||
} /* ecma_module_link */
|
||||
@@ -1397,8 +1379,7 @@ ecma_module_import (ecma_value_t specifier, /**< module specifier */
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ecma_is_value_object (result)
|
||||
&& ecma_is_promise (ecma_get_object_from_value (result)))
|
||||
if (ecma_is_value_object (result) && ecma_is_promise (ecma_get_object_from_value (result)))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
#ifndef ECMA_MODULE_H
|
||||
#define ECMA_MODULE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
|
||||
#define ECMA_MODULE_MAX_PATH 255u
|
||||
@@ -40,8 +41,8 @@ typedef enum
|
||||
typedef struct ecma_module_names
|
||||
{
|
||||
struct ecma_module_names *next_p; /**< next linked list node */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
} ecma_module_names_t;
|
||||
|
||||
/**
|
||||
@@ -54,19 +55,19 @@ typedef struct ecma_module_names
|
||||
typedef struct ecma_module
|
||||
{
|
||||
/* Note: state is stored in header.u.class_prop.extra_info */
|
||||
ecma_extended_object_t header; /**< header part */
|
||||
ecma_extended_object_t header; /**< header part */
|
||||
/* TODO(dbatyai): These could be compressed pointers */
|
||||
ecma_object_t *scope_p; /**< lexical lenvironment of the module */
|
||||
ecma_object_t *namespace_object_p; /**< namespace object of the module */
|
||||
struct ecma_module_node *imports_p; /**< import requests of the module */
|
||||
ecma_module_names_t *local_exports_p; /**< local exports of the module */
|
||||
struct ecma_module_node *indirect_exports_p; /**< indirect exports of the module */
|
||||
struct ecma_module_node *star_exports_p; /**< star exports of the module */
|
||||
ecma_object_t *scope_p; /**< lexical lenvironment of the module */
|
||||
ecma_object_t *namespace_object_p; /**< namespace object of the module */
|
||||
struct ecma_module_node *imports_p; /**< import requests of the module */
|
||||
ecma_module_names_t *local_exports_p; /**< local exports of the module */
|
||||
struct ecma_module_node *indirect_exports_p; /**< indirect exports of the module */
|
||||
struct ecma_module_node *star_exports_p; /**< star exports of the module */
|
||||
|
||||
/* Code used for evaluating a module */
|
||||
union
|
||||
{
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
|
||||
jerry_native_module_evaluate_callback_t callback; /**< callback for evaluating native modules */
|
||||
} u;
|
||||
} ecma_module_t;
|
||||
@@ -98,8 +99,8 @@ typedef struct ecma_module_node
|
||||
typedef struct ecma_module_resolve_set
|
||||
{
|
||||
struct ecma_module_resolve_set *next_p; /**< next in linked list */
|
||||
ecma_module_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
ecma_module_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
} ecma_module_resolve_set_t;
|
||||
|
||||
/**
|
||||
@@ -108,17 +109,15 @@ typedef struct ecma_module_resolve_set
|
||||
typedef struct ecma_module_resolve_stack
|
||||
{
|
||||
struct ecma_module_resolve_stack *next_p; /**< next in linked list */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
} ecma_module_resolve_stack_t;
|
||||
|
||||
ecma_value_t ecma_module_initialize (ecma_module_t *module_p);
|
||||
ecma_module_t *ecma_module_get_resolved_module (ecma_value_t module_val);
|
||||
|
||||
ecma_value_t ecma_module_link (ecma_module_t *module_p,
|
||||
jerry_module_resolve_callback_t callback_p,
|
||||
void *user_p);
|
||||
ecma_value_t ecma_module_link (ecma_module_t *module_p, jerry_module_resolve_callback_t callback_p, void *user_p);
|
||||
ecma_value_t ecma_module_evaluate (ecma_module_t *module_p);
|
||||
ecma_value_t ecma_module_import (ecma_value_t specifier, ecma_value_t user_value);
|
||||
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -42,28 +44,26 @@
|
||||
/**
|
||||
* Stepping values for searching items in the hashmap.
|
||||
*/
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA =
|
||||
{
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = {
|
||||
3, 5, 7, 11, 13, 17, 19, 23
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] & (1 << ((index) & 0x7)))
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) ((byte_p)[(index) >> 3] & (1 << ((index) &0x7)))
|
||||
|
||||
/**
|
||||
* Clear the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Set the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Create a new property hashmap for the object.
|
||||
@@ -156,8 +156,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
|
||||
ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i],
|
||||
property_pair_p->names_cp[i]);
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], property_pair_p->names_cp[i]);
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
|
||||
entry_index &= mask;
|
||||
@@ -202,8 +201,8 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
/* Property hash must be exists and must be the first property. */
|
||||
JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL);
|
||||
|
||||
ecma_property_header_t *property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_header_t *property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -211,8 +210,7 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
|
||||
object_p->u1.property_list_cp = property_p->next_property_cp;
|
||||
|
||||
jmem_heap_free_block (hashmap_p,
|
||||
ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
jmem_heap_free_block (hashmap_p, ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
} /* ecma_property_hashmap_free */
|
||||
|
||||
/**
|
||||
@@ -226,8 +224,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT (property_pair_p != NULL);
|
||||
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -300,8 +298,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
jmem_cpointer_t name_cp, /**< property name */
|
||||
ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -337,8 +335,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
if ((property_pair_p->header.types + offset) == property_p)
|
||||
{
|
||||
@@ -393,9 +391,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
{
|
||||
if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
|
||||
{
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i],
|
||||
prop_pair_p->names_cp[i],
|
||||
name_p))
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i], name_p))
|
||||
{
|
||||
/* Property is found */
|
||||
property_found = true;
|
||||
@@ -437,8 +433,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
@@ -486,8 +482,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef ECMA_PROPERTY_HASHMAP_H
|
||||
#define ECMA_PROPERTY_HASHMAP_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
@@ -67,12 +69,15 @@ typedef enum
|
||||
|
||||
void ecma_property_hashmap_create (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_free (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p, int property_index);
|
||||
ecma_property_hashmap_delete_status ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp,
|
||||
ecma_property_t *property_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p,
|
||||
int property_index);
|
||||
ecma_property_hashmap_delete_status
|
||||
ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p);
|
||||
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, ecma_string_t *name_p,
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p,
|
||||
ecma_string_t *name_p,
|
||||
jmem_cpointer_t *property_real_name_cp);
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user