Switching to g++ and corresponding changes according to C++ requirements.

This commit is contained in:
Ruben Ayrapetyan 2015-01-16 12:53:41 +03:00
parent 557df54f9d
commit 005b5370fc
57 changed files with 883 additions and 666 deletions

View File

@ -7,7 +7,7 @@ endif
ENGINE_NAME ?= jerry
CROSS_COMPILE ?= arm-none-eabi-
CC = gcc
CC = g++
LD = ld
OBJDUMP = objdump
OBJCOPY = objcopy
@ -206,8 +206,7 @@ TARGET_CPU = $(strip $(if $(filter linux,$(TARGET_SYSTEM)), x64, \
# Warnings
CFLAGS_WARNINGS ?= -Wall -Wextra -Wpedantic -Wlogical-op -Winline \
-Wformat-nonliteral -Winit-self -Wstack-protector \
-Wconversion -Wsign-conversion -Wformat-security \
-Wstrict-prototypes -Wmissing-prototypes
-Wconversion -Wsign-conversion -Wformat-security
CFLAGS_WERROR ?= -Werror
CFLAGS_WFATAL_ERRORS ?= -Wfatal-errors
@ -235,7 +234,7 @@ CFLAGS_CORTEXM4 ?= -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb \
# Common
#
CFLAGS_COMMON ?= $(INCLUDES) -std=c99 -nostdlib
CFLAGS_COMMON ?= $(INCLUDES) -std=c++11 -nostdlib -fno-exceptions -fno-rtti
LDFLAGS ?= -lgcc
ifeq ($(OPTION_OPTIMIZE),enable)

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,13 +19,13 @@
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
#include <float.h>
/**
* Types
*/
typedef unsigned long mword_t;
typedef signed long ssize_t;
/**
* Attributes
@ -35,8 +35,9 @@ typedef signed long ssize_t;
#define __packed __attribute__((packed))
#define __noreturn __attribute__((noreturn))
#define __noinline __attribute__((noinline))
#define __used __attribute__((used))
#ifndef __attribute_always_inline__
# define __attribute_always_inline__ __attribute__((always_inline))
# define __attribute_always_inline__ __attribute__((always_inline)) __used
#endif /* !__attribute_always_inline__ */
#ifndef __attribute_const__
# define __attribute_const__ __attribute__((const))

View File

@ -185,7 +185,7 @@ mem_run_try_to_give_memory_back_callbacks (mem_try_give_memory_back_severity_t s
bool
mem_is_heap_pointer (void *pointer) /**< pointer */
{
uint8_t *uint8_pointer = pointer;
uint8_t *uint8_pointer = (uint8_t*) pointer;
return (uint8_pointer >= mem_heap_area && uint8_pointer <= (mem_heap_area + MEM_HEAP_AREA_SIZE));
} /* mem_is_heap_pointer */

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -593,7 +593,7 @@ mem_heap_alloc_block (size_t size_in_bytes, /**< size of region to a
for (mem_try_give_memory_back_severity_t severity = MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_LOW;
severity <= MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_CRITICAL;
severity++)
severity = (mem_try_give_memory_back_severity_t) (severity + 1))
{
mem_run_try_to_give_memory_back_callbacks (severity);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -89,7 +89,7 @@ extern void mem_heap_stats_reset_peak (void);
#define MEM_DEFINE_LOCAL_ARRAY(var_name, number, type) \
{ \
size_t var_name ## ___size = (size_t) (number) * sizeof (type); \
type *var_name = mem_heap_alloc_block (var_name ## ___size, MEM_HEAP_ALLOC_SHORT_TERM);
type *var_name = (type *) mem_heap_alloc_block (var_name ## ___size, MEM_HEAP_ALLOC_SHORT_TERM);
/**
* Free the previously defined local array variable, freeing corresponding block on the heap,

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -137,7 +137,7 @@ mem_pools_alloc_longpath (void)
while (pool_state->first_free_chunk == MEM_POOL_CHUNKS_NUMBER)
{
prev_pool_state_p = pool_state;
pool_state = mem_decompress_pointer (pool_state->next_pool_cp);
pool_state = (mem_pool_state_t*) mem_decompress_pointer (pool_state->next_pool_cp);
JERRY_ASSERT(pool_state != NULL);
}
@ -195,7 +195,7 @@ mem_pools_free (uint8_t *chunk_p) /**< pointer to the chunk */
while (!mem_pool_is_chunk_inside (pool_state, chunk_p))
{
prev_pool_state_p = pool_state;
pool_state = mem_decompress_pointer (pool_state->next_pool_cp);
pool_state = (mem_pool_state_t*) mem_decompress_pointer (pool_state->next_pool_cp);
JERRY_ASSERT(pool_state != NULL);
}
@ -225,7 +225,7 @@ mem_pools_free (uint8_t *chunk_p) /**< pointer to the chunk */
}
else
{
mem_pools = mem_decompress_pointer (pool_state->next_pool_cp);
mem_pools = (mem_pool_state_t*) mem_decompress_pointer (pool_state->next_pool_cp);
}
}

View File

@ -45,6 +45,8 @@ static const char *__op_names[LAST_OP] =
};
#undef __OP_FUNC_NAME
#define INTERP_MEM_PRINT_INDENTATION_STEP (5)
#define INTERP_MEM_PRINT_INDENTATION_MAX (125)
static uint32_t interp_mem_stats_print_indentation = 0;
static bool interp_mem_stats_enabled = false;
@ -108,10 +110,13 @@ interp_mem_stats_context_enter (int_data_t *int_data_p,
return;
}
char indent_prefix[interp_mem_stats_print_indentation + 2];
const uint32_t indentation = JERRY_MIN (interp_mem_stats_print_indentation,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [interp_mem_stats_print_indentation] = '|';
indent_prefix [interp_mem_stats_print_indentation + 1] = '\0';
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
int_data_p->context_peak_allocated_heap_bytes = 0;
int_data_p->context_peak_waste_heap_bytes = 0;
@ -143,10 +148,13 @@ interp_mem_stats_context_exit (int_data_t *int_data_p,
return;
}
char indent_prefix[interp_mem_stats_print_indentation + 2];
const uint32_t indentation = JERRY_MIN (interp_mem_stats_print_indentation,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [interp_mem_stats_print_indentation] = '|';
indent_prefix [interp_mem_stats_print_indentation + 1] = '\0';
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
mem_heap_stats_t heap_stats_context_exit;
mem_pools_stats_t pools_stats_context_exit;
@ -210,10 +218,13 @@ interp_mem_stats_opcode_enter (opcode_counter_t opcode_position,
return;
}
char indent_prefix[interp_mem_stats_print_indentation + 2];
const uint32_t indentation = JERRY_MIN (interp_mem_stats_print_indentation,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [interp_mem_stats_print_indentation] = '|';
indent_prefix [interp_mem_stats_print_indentation + 1] = '\0';
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
interp_mem_get_stats (out_heap_stats_p,
out_pools_stats_p,
@ -224,7 +235,7 @@ interp_mem_stats_opcode_enter (opcode_counter_t opcode_position,
__printf ("%s-- Opcode: %s (position %u) --\n",
indent_prefix, __op_names [opcode.op_idx], (uint32_t) opcode_position);
interp_mem_stats_print_indentation += 5;
interp_mem_stats_print_indentation += INTERP_MEM_PRINT_INDENTATION_STEP;
}
static void
@ -238,12 +249,15 @@ interp_mem_stats_opcode_exit (int_data_t *int_data_p,
return;
}
interp_mem_stats_print_indentation -= 5;
interp_mem_stats_print_indentation -= INTERP_MEM_PRINT_INDENTATION_STEP;
char indent_prefix[interp_mem_stats_print_indentation + 2];
const uint32_t indentation = JERRY_MIN (interp_mem_stats_print_indentation,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [interp_mem_stats_print_indentation] = '|';
indent_prefix [interp_mem_stats_print_indentation + 1] = '\0';
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
mem_heap_stats_t heap_stats_after;
mem_pools_stats_t pools_stats_after;

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,11 +27,11 @@
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_try (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
opfunc_try_block (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
{
const idx_t block_end_oc_idx_1 = opdata.data.try.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.try.oc_idx_2;
const idx_t block_end_oc_idx_1 = opdata.data.try_block.oc_idx_1;
const idx_t block_end_oc_idx_2 = opdata.data.try_block.oc_idx_2;
const opcode_counter_t try_end_oc = (opcode_counter_t) (
calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + int_data->pos);
@ -129,4 +129,4 @@ opfunc_try (opcode_t opdata, /**< operation data */
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY);
return try_completion;
} /* opfunc_try */
} /* opfunc_try_block */

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -124,8 +124,8 @@ opfunc_native_call (opcode_t opdata, /**< operation data */
JERRY_ASSERT (chars >= 0);
ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (chars + 1);
ecma_char_t *zt_str_p = mem_heap_alloc_block ((size_t) zt_str_size,
MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *zt_str_p = (ecma_char_t*) mem_heap_alloc_block ((size_t) zt_str_size,
MEM_HEAP_ALLOC_SHORT_TERM);
if (zt_str_p == NULL)
{
jerry_exit (ERR_OUT_OF_MEMORY);

View File

@ -84,7 +84,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.assignment.var_left;
const opcode_arg_type_operand type_value_right = opdata.data.assignment.type_value_right;
const opcode_arg_type_operand type_value_right = (opcode_arg_type_operand) opdata.data.assignment.type_value_right;
const idx_t src_val_descr = opdata.data.assignment.value_right;
ecma_completion_value_t ret_value;
@ -94,7 +94,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
ret_value = set_variable_value (int_data,
int_data->pos,
dst_var_idx,
ecma_make_simple_value (src_val_descr));
ecma_make_simple_value ((ecma_simple_value_t) src_val_descr));
}
else if (type_value_right == OPCODE_ARG_TYPE_STRING)
{
@ -911,7 +911,7 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
opcode_t next_opcode = read_opcode (int_data->pos);
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
const opcode_meta_type type = next_opcode.data.meta.type;
const opcode_meta_type type = (opcode_meta_type) next_opcode.data.meta.type;
JERRY_ASSERT (type == OPCODE_META_TYPE_VARG_PROP_DATA
|| type == OPCODE_META_TYPE_VARG_PROP_GETTER
|| type == OPCODE_META_TYPE_VARG_PROP_SETTER);
@ -1261,10 +1261,10 @@ opfunc_logical_not (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_this (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
opfunc_this_binding (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
{
const idx_t dst_var_idx = opdata.data.this.lhs;
const idx_t dst_var_idx = opdata.data.this_binding.lhs;
const opcode_counter_t lit_oc = int_data->pos;
int_data->pos++;
@ -1276,7 +1276,7 @@ opfunc_this (opcode_t opdata, /**< operation data */
int_data->this_binding);
return ret_value;
} /* opfunc_this */
} /* opfunc_this_binding */
/**
* 'With' opcode handler.
@ -1351,10 +1351,10 @@ opfunc_with (opcode_t opdata, /**< operation data */
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_throw (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
opfunc_throw_value (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
{
const idx_t var_idx = opdata.data.throw.var;
const idx_t var_idx = opdata.data.throw_value.var;
ecma_completion_value_t ret_value;
@ -1371,7 +1371,7 @@ opfunc_throw (opcode_t opdata, /**< operation data */
int_data->pos++;
return ret_value;
} /* opfunc_throw */
} /* opfunc_throw_value */
/**
* Evaluate argument of typeof.
@ -1543,7 +1543,8 @@ opfunc_delete_var (opcode_t opdata, /**< operation data */
ECMA_TRY_CATCH (delete_completion,
ecma_op_delete_binding (bindings_p,
ECMA_GET_NON_NULL_POINTER (ref.referenced_name_cp)),
ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ref.referenced_name_cp)),
ret_value);
ret_value = set_variable_value (int_data, lit_oc, dst_var_idx,
@ -1645,7 +1646,7 @@ ecma_completion_value_t
opfunc_meta (opcode_t opdata, /**< operation data */
int_data_t *int_data __unused) /**< interpreter context */
{
const opcode_meta_type type = opdata.data.meta.type;
const opcode_meta_type type = (opcode_meta_type) opdata.data.meta.type;
switch (type)
{

View File

@ -114,13 +114,13 @@ opcode_counter_t read_meta_opcode_counter (opcode_meta_type expected_type, int_d
p##_3 (a, prop_getter, lhs, obj, prop) \
p##_3 (a, prop_setter, obj, prop, rhs) \
p##_2 (a, obj_decl, lhs, list) \
p##_1 (a, this, lhs) \
p##_1 (a, this_binding, lhs) \
p##_2 (a, delete_var, lhs, name) \
p##_3 (a, delete_prop, lhs, base, name) \
p##_2 (a, typeof, lhs, obj) \
p##_1 (a, with, expr) \
p##_2 (a, try, oc_idx_1, oc_idx_2) \
p##_1 (a, throw, var)
p##_2 (a, try_block, oc_idx_1, oc_idx_2) \
p##_1 (a, throw_value, var)
#define OP_ASSIGNMENTS(p, a) \
p##_3 (a, assignment, var_left, type_value_right, value_right)

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,9 +54,9 @@
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_array_prototype_object_to_string (ecma_value_t this) /**< this argument */
ecma_builtin_array_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_array_prototype_object_to_string */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,12 +54,12 @@
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_boolean_prototype_object_to_string (ecma_value_t this) /**< this argument */
ecma_builtin_boolean_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
ecma_completion_value_t ret_value;
ECMA_TRY_CATCH (completion_value_of,
ecma_builtin_boolean_prototype_object_value_of (this),
ecma_builtin_boolean_prototype_object_value_of (this_arg),
ret_value);
ecma_string_t *ret_str_p;
@ -92,15 +92,15 @@ ecma_builtin_boolean_prototype_object_to_string (ecma_value_t this) /**< this ar
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this) /**< this argument */
ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this_arg) /**< this argument */
{
if (ecma_is_value_boolean (this))
if (ecma_is_value_boolean (this_arg))
{
return ecma_make_normal_completion_value (this);
return ecma_make_normal_completion_value (this_arg);
}
else if (ecma_is_value_object (this))
else if (ecma_is_value_object (this_arg))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this);
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
@ -111,7 +111,7 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this) /**< this arg
JERRY_ASSERT (prim_value_prop_p->u.internal_property.value < ECMA_SIMPLE_VALUE__COUNT);
ecma_simple_value_t prim_simple_value = prim_value_prop_p->u.internal_property.value;
ecma_simple_value_t prim_simple_value = (ecma_simple_value_t) prim_value_prop_p->u.internal_property.value;
ecma_value_t ret_boolean_value = ecma_make_simple_value (prim_simple_value);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,18 +54,18 @@
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_error_prototype_object_to_string (ecma_value_t this) /**< this argument */
ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
ecma_completion_value_t ret_value;
// 2.
if (!ecma_is_value_object (this))
if (!ecma_is_value_object (this_arg))
{
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
ecma_object_t *obj_p = ecma_get_object_from_value (this);
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_string_t *name_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_NAME);
ECMA_TRY_CATCH (name_get_completion,

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -52,9 +52,9 @@
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_function_prototype_object_to_string (ecma_value_t this) /**< this argument */
ecma_builtin_function_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_function_prototype_object_to_string */
/**
@ -67,11 +67,11 @@ ecma_builtin_function_prototype_object_to_string (ecma_value_t this) /**< this a
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_function_prototype_object_apply (ecma_value_t this, /**< this argument */
ecma_builtin_function_prototype_object_apply (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< first argument */
ecma_value_t arg2) /**< second argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg1, arg2);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
} /* ecma_builtin_function_prototype_object_apply */
/**
@ -84,11 +84,11 @@ ecma_builtin_function_prototype_object_apply (ecma_value_t this, /**< this argum
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_function_prototype_object_call (ecma_value_t this, /**< this argument */
ecma_builtin_function_prototype_object_call (ecma_value_t this_arg, /**< this argument */
ecma_value_t *arguments_list_p, /**< list of arguments */
ecma_length_t arguments_number) /**< number of arguments */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arguments_list_p, arguments_number);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arguments_list_p, arguments_number);
} /* ecma_builtin_function_prototype_object_call */
/**
@ -101,11 +101,11 @@ ecma_builtin_function_prototype_object_call (ecma_value_t this, /**< this argume
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_function_prototype_object_bind (ecma_value_t this, /**< this argument */
ecma_builtin_function_prototype_object_bind (ecma_value_t this_arg, /**< this argument */
ecma_value_t *arguments_list_p, /**< list of arguments */
ecma_length_t arguments_number) /**< number of arguments */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arguments_list_p, arguments_number);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arguments_list_p, arguments_number);
} /* ecma_builtin_function_prototype_object_bind */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,7 +33,7 @@
PASTE (PASTE (ecma_builtin_, builtin_underscored_id), _dispatch_routine)
#define ROUTINE_ARG(n) , ecma_value_t arg ## n
#define ROUTINE_ARG_LIST_0 ecma_value_t this
#define ROUTINE_ARG_LIST_0 ecma_value_t this_arg
#define ROUTINE_ARG_LIST_1 ROUTINE_ARG_LIST_0 ROUTINE_ARG(1)
#define ROUTINE_ARG_LIST_2 ROUTINE_ARG_LIST_1 ROUTINE_ARG(2)
#define ROUTINE_ARG_LIST_3 ROUTINE_ARG_LIST_2 ROUTINE_ARG(3)
@ -59,9 +59,6 @@ static ecma_magic_string_id_t ecma_builtin_property_names[] =
#include BUILTIN_INC_HEADER_NAME
};
static const ecma_length_t ecma_builtin_property_number = (sizeof (ecma_builtin_property_names) /
sizeof (ecma_builtin_property_names [0]));
/**
* Sort builtin's property names array
*/
@ -74,7 +71,9 @@ SORT_PROPERTY_NAMES_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (void)
{
swapped = false;
for (ecma_length_t i = 1; i < ecma_builtin_property_number; i++)
for (ecma_length_t i = 1;
i < (sizeof (ecma_builtin_property_names) / sizeof (ecma_builtin_property_names [0]));
i++)
{
if (ecma_builtin_property_names [i] < ecma_builtin_property_names [i - 1])
{
@ -114,10 +113,11 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_object_t
return NULL;
}
const ecma_length_t property_numbers = (ecma_length_t) (sizeof (ecma_builtin_property_names) /
sizeof (ecma_builtin_property_names [0]));
int32_t index;
index = ecma_builtin_bin_search_for_magic_string_id_in_array (ecma_builtin_property_names,
sizeof (ecma_builtin_property_names) /
sizeof (ecma_builtin_property_names [0]),
property_numbers,
id);
if (index == -1)

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,21 +54,21 @@
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_number_prototype_object_to_string (ecma_value_t this, /**< this argument */
ecma_builtin_number_prototype_object_to_string (ecma_value_t this_arg, /**< this argument */
ecma_value_t* arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */
{
ecma_number_t this_arg_number;
if (ecma_is_value_number (this))
if (ecma_is_value_number (this_arg))
{
ecma_number_t *this_arg_number_p = ecma_get_number_from_value (this);
ecma_number_t *this_arg_number_p = ecma_get_number_from_value (this_arg);
this_arg_number = *this_arg_number_p;
}
else if (ecma_is_value_object (this))
else if (ecma_is_value_object (this_arg))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this);
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
@ -77,7 +77,8 @@ ecma_builtin_number_prototype_object_to_string (ecma_value_t this, /**< this arg
ecma_property_t *prim_value_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE);
ecma_number_t *prim_value_num_p = ECMA_GET_NON_NULL_POINTER (prim_value_prop_p->u.internal_property.value);
ecma_number_t *prim_value_num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
prim_value_prop_p->u.internal_property.value);
this_arg_number = *prim_value_num_p;
}
else
@ -111,9 +112,9 @@ ecma_builtin_number_prototype_object_to_string (ecma_value_t this, /**< this arg
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_number_prototype_object_to_locale_string (ecma_value_t this) /**< this argument */
ecma_builtin_number_prototype_object_to_locale_string (ecma_value_t this_arg) /**< this argument */
{
return ecma_builtin_number_prototype_object_to_string (this, NULL, 0);
return ecma_builtin_number_prototype_object_to_string (this_arg, NULL, 0);
} /* ecma_builtin_number_prototype_object_to_locale_string */
/**
@ -126,15 +127,15 @@ ecma_builtin_number_prototype_object_to_locale_string (ecma_value_t this) /**< t
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_number_prototype_object_value_of (ecma_value_t this) /**< this argument */
ecma_builtin_number_prototype_object_value_of (ecma_value_t this_arg) /**< this argument */
{
if (ecma_is_value_number (this))
if (ecma_is_value_number (this_arg))
{
return ecma_make_normal_completion_value (ecma_copy_value (this, true));
return ecma_make_normal_completion_value (ecma_copy_value (this_arg, true));
}
else if (ecma_is_value_object (this))
else if (ecma_is_value_object (this_arg))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this);
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
@ -143,7 +144,8 @@ ecma_builtin_number_prototype_object_value_of (ecma_value_t this) /**< this argu
ecma_property_t *prim_value_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE);
ecma_number_t *prim_value_num_p = ECMA_GET_NON_NULL_POINTER (prim_value_prop_p->u.internal_property.value);
ecma_number_t *prim_value_num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
prim_value_prop_p->u.internal_property.value);
ecma_number_t *ret_num_p = ecma_alloc_number ();
*ret_num_p = *prim_value_num_p;
@ -165,10 +167,10 @@ ecma_builtin_number_prototype_object_value_of (ecma_value_t this) /**< this argu
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_number_prototype_object_to_fixed (ecma_value_t this, /**< this argument */
ecma_builtin_number_prototype_object_to_fixed (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_number_prototype_object_to_fixed */
/**
@ -181,10 +183,10 @@ ecma_builtin_number_prototype_object_to_fixed (ecma_value_t this, /**< this argu
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_number_prototype_object_to_exponential (ecma_value_t this, /**< this argument */
ecma_builtin_number_prototype_object_to_exponential (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_number_prototype_object_to_exponential */
/**
@ -197,10 +199,10 @@ ecma_builtin_number_prototype_object_to_exponential (ecma_value_t this, /**< thi
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_number_prototype_object_to_precision (ecma_value_t this, /**< this argument */
ecma_builtin_number_prototype_object_to_precision (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_number_prototype_object_to_precision */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -52,21 +52,21 @@
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_to_string (ecma_value_t this) /**< this argument */
ecma_builtin_object_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
ecma_magic_string_id_t type_string;
if (ecma_is_value_undefined (this))
if (ecma_is_value_undefined (this_arg))
{
type_string = ECMA_MAGIC_STRING_UNDEFINED_UL;
}
else if (ecma_is_value_null (this))
else if (ecma_is_value_null (this_arg))
{
type_string = ECMA_MAGIC_STRING_NULL_UL;
}
else
{
ecma_completion_value_t obj_this = ecma_op_to_object (this);
ecma_completion_value_t obj_this = ecma_op_to_object (this_arg);
if (!ecma_is_completion_value_normal (obj_this))
{
@ -140,9 +140,9 @@ ecma_builtin_object_prototype_object_to_string (ecma_value_t this) /**< this arg
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_value_of (ecma_value_t this) /**< this argument */
ecma_builtin_object_prototype_object_value_of (ecma_value_t this_arg) /**< this argument */
{
return ecma_op_to_object (this);
return ecma_op_to_object (this_arg);
} /* ecma_builtin_object_prototype_object_value_of */
/**
@ -155,9 +155,9 @@ ecma_builtin_object_prototype_object_value_of (ecma_value_t this) /**< this argu
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this) /**< this argument */
ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_object_prototype_object_to_locale_string */
/**
@ -170,10 +170,10 @@ ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this) /**< t
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_has_own_property (ecma_value_t this, /**< this argument */
ecma_builtin_object_prototype_object_has_own_property (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< first argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_object_prototype_object_has_own_property */
/**
@ -186,10 +186,10 @@ ecma_builtin_object_prototype_object_has_own_property (ecma_value_t this, /**< t
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_is_prototype_of (ecma_value_t this, /**< this argument */
ecma_builtin_object_prototype_object_is_prototype_of (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's first argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_object_prototype_object_is_prototype_of */
/**
@ -202,10 +202,10 @@ ecma_builtin_object_prototype_object_is_prototype_of (ecma_value_t this, /**< th
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_property_is_enumerable (ecma_value_t this, /**< this argument */
ecma_builtin_object_prototype_object_property_is_enumerable (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's first argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_object_prototype_object_property_is_enumerable */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,15 +54,15 @@
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_string (ecma_value_t this) /**< this argument */
ecma_builtin_string_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
if (ecma_is_value_string (this))
if (ecma_is_value_string (this_arg))
{
return ecma_make_normal_completion_value (ecma_copy_value (this, true));
return ecma_make_normal_completion_value (ecma_copy_value (this_arg, true));
}
else if (ecma_is_value_object (this))
else if (ecma_is_value_object (this_arg))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this);
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
@ -71,7 +71,8 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this) /**< this arg
ecma_property_t *prim_value_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_STRING_VALUE);
ecma_string_t *prim_value_str_p = ECMA_GET_NON_NULL_POINTER (prim_value_prop_p->u.internal_property.value);
ecma_string_t *prim_value_str_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
prim_value_prop_p->u.internal_property.value);
prim_value_str_p = ecma_copy_or_ref_ecma_string (prim_value_str_p);
@ -92,9 +93,9 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this) /**< this arg
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_value_of (ecma_value_t this) /**< this argument */
ecma_builtin_string_prototype_object_value_of (ecma_value_t this_arg) /**< this argument */
{
return ecma_builtin_string_prototype_object_to_string (this);
return ecma_builtin_string_prototype_object_to_string (this_arg);
} /* ecma_builtin_string_prototype_object_value_of */
/**
@ -107,10 +108,10 @@ ecma_builtin_string_prototype_object_value_of (ecma_value_t this) /**< this argu
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_char_at (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_char_at (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_string_prototype_object_char_at */
/**
@ -123,10 +124,10 @@ ecma_builtin_string_prototype_object_char_at (ecma_value_t this, /**< this argum
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_char_code_at (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_char_code_at (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_string_prototype_object_char_code_at */
/**
@ -139,11 +140,11 @@ ecma_builtin_string_prototype_object_char_code_at (ecma_value_t this, /**< this
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_concat (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_concat (ecma_value_t this_arg, /**< this argument */
ecma_value_t* argument_list_p, /**< arguments list */
ecma_length_t arguments_number) /**< number of arguments */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, argument_list_p, arguments_number);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, argument_list_p, arguments_number);
} /* ecma_builtin_string_prototype_object_concat */
/**
@ -156,11 +157,11 @@ ecma_builtin_string_prototype_object_concat (ecma_value_t this, /**< this argume
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_index_of (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_index_of (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg1, arg2);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
} /* ecma_builtin_string_prototype_object_index_of */
/**
@ -173,11 +174,11 @@ ecma_builtin_string_prototype_object_index_of (ecma_value_t this, /**< this argu
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_last_index_of (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_last_index_of (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg1, arg2);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
} /* ecma_builtin_string_prototype_object_last_index_of */
/**
@ -190,10 +191,10 @@ ecma_builtin_string_prototype_object_last_index_of (ecma_value_t this, /**< this
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_locale_compare (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_locale_compare (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_string_prototype_object_locale_compare */
/**
@ -206,10 +207,10 @@ ecma_builtin_string_prototype_object_locale_compare (ecma_value_t this, /**< thi
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_match (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_match (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_string_prototype_object_match */
/**
@ -222,11 +223,11 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this, /**< this argumen
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_replace (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_replace (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg1, arg2);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
} /* ecma_builtin_string_prototype_object_replace */
/**
@ -239,10 +240,10 @@ ecma_builtin_string_prototype_object_replace (ecma_value_t this, /**< this argum
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_search (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_search (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
} /* ecma_builtin_string_prototype_object_search */
/**
@ -255,11 +256,11 @@ ecma_builtin_string_prototype_object_search (ecma_value_t this, /**< this argume
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_slice (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_slice (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg1, arg2);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
} /* ecma_builtin_string_prototype_object_slice */
/**
@ -272,11 +273,11 @@ ecma_builtin_string_prototype_object_slice (ecma_value_t this, /**< this argumen
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_split (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg1, arg2);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
} /* ecma_builtin_string_prototype_object_split */
/**
@ -289,11 +290,11 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this, /**< this argumen
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_substring (ecma_value_t this, /**< this argument */
ecma_builtin_string_prototype_object_substring (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this, arg1, arg2);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
} /* ecma_builtin_string_prototype_object_substring */
/**
@ -306,9 +307,9 @@ ecma_builtin_string_prototype_object_substring (ecma_value_t this, /**< this arg
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_lower_case (ecma_value_t this) /**< this argument */
ecma_builtin_string_prototype_object_to_lower_case (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_string_prototype_object_to_lower_case */
/**
@ -321,9 +322,9 @@ ecma_builtin_string_prototype_object_to_lower_case (ecma_value_t this) /**< this
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_locale_lower_case (ecma_value_t this) /**< this argument */
ecma_builtin_string_prototype_object_to_locale_lower_case (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_string_prototype_object_to_locale_lower_case */
/**
@ -336,9 +337,9 @@ ecma_builtin_string_prototype_object_to_locale_lower_case (ecma_value_t this) /*
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_upper_case (ecma_value_t this) /**< this argument */
ecma_builtin_string_prototype_object_to_upper_case (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_string_prototype_object_to_upper_case */
/**
@ -351,9 +352,9 @@ ecma_builtin_string_prototype_object_to_upper_case (ecma_value_t this) /**< this
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_locale_upper_case (ecma_value_t this) /**< this argument */
ecma_builtin_string_prototype_object_to_locale_upper_case (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_string_prototype_object_to_locale_upper_case */
/**
@ -366,9 +367,9 @@ ecma_builtin_string_prototype_object_to_locale_upper_case (ecma_value_t this) /*
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_trim (ecma_value_t this) /**< this argument */
ecma_builtin_string_prototype_object_trim (ecma_value_t this_arg) /**< this argument */
{
ECMA_BUILTIN_CP_UNIMPLEMENTED (this);
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
} /* ecma_builtin_string_prototype_object_trim */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -62,8 +62,8 @@ ecma_builtin_string_object_from_char_code (ecma_value_t this_arg __unused, /**<
size_t zt_str_buffer_size = sizeof (ecma_char_t) * (args_number + 1u);
ecma_char_t *ret_zt_str_p = mem_heap_alloc_block (zt_str_buffer_size,
MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *ret_zt_str_p = (ecma_char_t*) mem_heap_alloc_block (zt_str_buffer_size,
MEM_HEAP_ALLOC_SHORT_TERM);
ret_zt_str_p [args_number] = ECMA_CHAR_NULL;
for (ecma_length_t arg_index = 0;

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -165,9 +165,9 @@ ecma_builtin_init_object (ecma_builtin_id_t obj_builtin_id, /**< built-in ID */
void
ecma_init_builtins (void)
{
for (ecma_builtin_id_t id = 0;
for (ecma_builtin_id_t id = (ecma_builtin_id_t) 0;
id < ECMA_BUILTIN_ID__COUNT;
id++)
id = (ecma_builtin_id_t) (id + 1))
{
ecma_builtin_objects [id] = NULL;
}
@ -233,9 +233,9 @@ ecma_instantiate_builtin (ecma_builtin_id_t id) /**< built-in id */
void
ecma_finalize_builtins (void)
{
for (ecma_builtin_id_t id = 0;
for (ecma_builtin_id_t id = (ecma_builtin_id_t) 0;
id < ECMA_BUILTIN_ID__COUNT;
id++)
id = (ecma_builtin_id_t) (id + 1))
{
if (ecma_builtin_objects [id] != NULL)
{

View File

@ -116,7 +116,8 @@ ecma_gc_get_object_next (ecma_object_t *object_p) /**< object */
ECMA_OBJECT_GC_NEXT_CP_POS,
ECMA_OBJECT_GC_NEXT_CP_WIDTH);
return ECMA_GET_POINTER (next_cp);
return ECMA_GET_POINTER (ecma_object_t,
next_cp);
} /* ecma_gc_get_object_next */
/**
@ -357,7 +358,8 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
property_p != NULL;
property_p = next_property_p)
{
next_property_p = ECMA_GET_POINTER(property_p->next_property_p);
next_property_p = ECMA_GET_POINTER (ecma_property_t,
property_p->next_property_p);
switch ((ecma_property_type_t) property_p->type)
{
@ -388,8 +390,10 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
case ECMA_PROPERTY_NAMEDACCESSOR:
{
ecma_object_t *getter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.get_p);
ecma_object_t *setter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.set_p);
ecma_object_t *getter_obj_p = ECMA_GET_POINTER (ecma_object_t,
property_p->u.named_accessor_property.get_p);
ecma_object_t *setter_obj_p = ECMA_GET_POINTER (ecma_object_t,
property_p->u.named_accessor_property.set_p);
if (getter_obj_p != NULL)
{
@ -428,7 +432,7 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
case ECMA_PROPERTY_INTERNAL:
{
ecma_internal_property_id_t property_id = property_p->u.internal_property.type;
ecma_internal_property_id_t property_id = (ecma_internal_property_id_t) property_p->u.internal_property.type;
uint32_t property_value = property_p->u.internal_property.value;
switch (property_id)
@ -443,6 +447,8 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
(see above in the routine) */
case ECMA_INTERNAL_PROPERTY_EXTENSIBLE: /* the property's value is located in ecma_object_t
(see above in the routine) */
case ECMA_INTERNAL_PROPERTY__COUNT: /* not a real internal property type,
* but number of the real internal property types */
{
JERRY_UNREACHABLE();
}
@ -464,7 +470,7 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
case ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP: /* an object */
{
ecma_object_t *obj_p = ECMA_GET_NON_NULL_POINTER(property_value);
ecma_object_t *obj_p = ECMA_GET_NON_NULL_POINTER(ecma_object_t, property_value);
if (ecma_gc_get_object_generation (obj_p) <= maximum_gen_to_traverse)
{
@ -512,7 +518,8 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
property != NULL;
property = next_property_p)
{
next_property_p = ECMA_GET_POINTER(property->next_property_p);
next_property_p = ECMA_GET_POINTER (ecma_property_t,
property->next_property_p);
ecma_free_property (object_p, property);
}
@ -530,7 +537,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
JERRY_ASSERT(max_gen_to_collect < ECMA_GC_GEN_COUNT);
/* clearing visited flags for all objects of generations to be processed */
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; gen_id <= max_gen_to_collect; gen_id = (ecma_gc_gen_t) (gen_id + 1))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
@ -542,7 +549,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
/* if some object is referenced from stack or globals (i.e. it is root),
* start recursive marking traverse from the object */
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; gen_id <= max_gen_to_collect; gen_id = (ecma_gc_gen_t) (gen_id + 1))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
@ -581,7 +588,9 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
/* if some object from generations that are not processed during current session may reference
* younger generations, start recursive marking traverse from the object, but one the first level
* consider only references to object of at most max_gen_to_collect generation */
for (ecma_gc_gen_t gen_id = max_gen_to_collect + 1; gen_id < ECMA_GC_GEN_COUNT; gen_id++)
for (ecma_gc_gen_t gen_id = (ecma_gc_gen_t) (max_gen_to_collect + 1);
gen_id < ECMA_GC_GEN_COUNT;
gen_id = (ecma_gc_gen_t) (gen_id + 1))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
@ -595,7 +604,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
else if (gen_id > ECMA_GC_GEN_0)
{
ecma_gc_set_object_may_ref_younger_objects (obj_iter_p, true);
ecma_gc_mark (obj_iter_p, gen_id - 1);
ecma_gc_mark (obj_iter_p, (ecma_gc_gen_t) (gen_id - 1));
JERRY_ASSERT (!ecma_gc_is_object_may_ref_younger_objects (obj_iter_p));
}
#endif /* !JERRY_NDEBUG */
@ -608,7 +617,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
__memset (gen_last_obj_p, 0, sizeof (gen_last_obj_p));
#endif /* !JERRY_NDEBUG */
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; gen_id <= max_gen_to_collect; gen_id = (ecma_gc_gen_t) (gen_id + 1))
{
ecma_object_t *obj_prev_p = NULL;
@ -639,7 +648,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
if (ecma_gc_get_object_generation (obj_iter_p) != ECMA_GC_GEN_COUNT - 1)
{
/* the object will be promoted to next generation */
ecma_gc_set_object_generation (obj_iter_p, ecma_gc_get_object_generation (obj_iter_p) + 1);
ecma_gc_set_object_generation (obj_iter_p, (ecma_gc_gen_t) (ecma_gc_get_object_generation (obj_iter_p) + 1));
}
}
}
@ -651,7 +660,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
if (unlikely (gen_to_promote == ECMA_GC_GEN_COUNT - 1))
{
/* not promoting last generation */
gen_to_promote--;
gen_to_promote = (ecma_gc_gen_t) (gen_to_promote - 1);
}
/* promoting to next generation */
@ -673,7 +682,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
#ifndef JERRY_NDEBUG
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0;
gen_id < ECMA_GC_GEN_COUNT;
gen_id++)
gen_id = (ecma_gc_gen_t) (gen_id + 1))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
@ -711,7 +720,7 @@ ecma_try_to_give_back_some_memory (mem_try_give_memory_back_severity_t severity)
/* Freeing as much memory as we currently can */
ecma_lcache_invalidate_all ();
ecma_gc_run (ECMA_GC_GEN_COUNT - 1);
ecma_gc_run ((ecma_gc_gen_t) (ECMA_GC_GEN_COUNT - 1));
}
} /* ecma_try_to_give_back_some_memory */

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -231,7 +231,12 @@ typedef enum
/**
* Bit-mask of non-instantiated built-in's properties (bits 32-63)
*/
ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63
ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63,
/**
* Number of internal properties' types
*/
ECMA_INTERNAL_PROPERTY__COUNT
} ecma_internal_property_id_t;
/**
@ -261,6 +266,11 @@ typedef enum
ECMA_PROPERTY_CONFIGURABLE /**< property's 'Configurable' attribute is true */
} ecma_property_configurable_value_t;
/**
* Width of internal property type field's width
*/
#define ECMA_PROPERTY_INTERNAL_PROPERTY_TYPE_WIDTH (5)
/**
* Description of ecma-property
*/
@ -323,7 +333,7 @@ typedef struct ecma_property_t
struct __packed ecma_internal_property_t
{
/** Internal property's type */
unsigned int type : 5;
unsigned int type : ECMA_PROPERTY_INTERNAL_PROPERTY_TYPE_WIDTH;
/** Value (may be a compressed pointer) */
uint32_t value;
@ -342,6 +352,9 @@ typedef enum
/**
* Internal object types
*
* Warning:
* definition order is significant (see also dispatch tables in libecmaobjects/ecma-objects.c)
*/
typedef enum
{

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -146,8 +146,8 @@ ecma_compare_chars_collection (const ecma_collection_header_t* header1_p, /**< f
{
JERRY_ASSERT (cur_char_buf2_iter_p == cur_char_buf2_end_p);
const ecma_collection_chunk_t *chunk1_p = ECMA_GET_NON_NULL_POINTER (next_chunk1_cp);
const ecma_collection_chunk_t *chunk2_p = ECMA_GET_NON_NULL_POINTER (next_chunk2_cp);
const ecma_collection_chunk_t *chunk1_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t, next_chunk1_cp);
const ecma_collection_chunk_t *chunk2_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t, next_chunk2_cp);
cur_char_buf1_iter_p = (ecma_char_t*) chunk1_p->data;
cur_char_buf1_end_p = cur_char_buf1_iter_p + sizeof (chunk1_p->data) / sizeof (ecma_char_t);
@ -185,7 +185,8 @@ ecma_copy_chars_collection (const ecma_collection_header_t* collection_p) /**< c
uint16_t* next_chunk_cp_p = &new_header_p->next_chunk_cp;
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (collection_p->next_chunk_cp);
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
collection_p->next_chunk_cp);
while (chunk_p != NULL)
{
@ -195,7 +196,8 @@ ecma_copy_chars_collection (const ecma_collection_header_t* collection_p) /**< c
ECMA_SET_NON_NULL_POINTER (*next_chunk_cp_p, new_chunk_p);
next_chunk_cp_p = &new_chunk_p->next_chunk_cp;
chunk_p = ECMA_GET_POINTER (chunk_p->next_chunk_cp);
chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
chunk_p->next_chunk_cp);
}
*next_chunk_cp_p = ECMA_NULL_POINTER;
@ -227,7 +229,7 @@ ecma_copy_chars_collection_to_buffer (const ecma_collection_header_t *collection
{
if (unlikely (cur_char_buf_iter_p == cur_char_buf_end_p))
{
const ecma_collection_chunk_t *chunk_p = ECMA_GET_NON_NULL_POINTER (next_chunk_cp);
const ecma_collection_chunk_t *chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t, next_chunk_cp);
cur_char_buf_iter_p = (ecma_char_t*) chunk_p->data;
cur_char_buf_end_p = cur_char_buf_iter_p + sizeof (chunk_p->data) / sizeof (ecma_char_t);
@ -253,11 +255,13 @@ ecma_free_chars_collection (ecma_collection_header_t* collection_p) /**< collect
{
JERRY_ASSERT (collection_p != NULL);
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (collection_p->next_chunk_cp);
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
collection_p->next_chunk_cp);
while (chunk_p != NULL)
{
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (chunk_p->next_chunk_cp);
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
chunk_p->next_chunk_cp);
ecma_dealloc_collection_chunk (chunk_p);
chunk_p = next_chunk_p;
@ -278,9 +282,9 @@ ecma_strings_init (void)
ecma_magic_string_max_length = 0;
#endif /* !JERRY_NDEBUG */
for (ecma_magic_string_id_t id = 0;
for (ecma_magic_string_id_t id = (ecma_magic_string_id_t) 0;
id < ECMA_MAGIC_STRING__COUNT;
id++)
id = (ecma_magic_string_id_t) (id + 1))
{
ecma_magic_string_lengths [id] = ecma_zt_string_length (ecma_get_magic_string_zt (id));
@ -619,8 +623,8 @@ ecma_copy_ecma_string (ecma_string_t *string_desc_p) /**< string descriptor */
case ECMA_STRING_CONTAINER_CONCATENATION:
{
ecma_string_t *part1_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.concatenation.string1_cp);
ecma_string_t *part2_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.concatenation.string2_cp);
ecma_string_t *part1_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, string_desc_p->u.concatenation.string1_cp);
ecma_string_t *part2_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, string_desc_p->u.concatenation.string2_cp);
new_str_p = ecma_concat_ecma_strings (part1_p, part2_p);
@ -629,7 +633,7 @@ ecma_copy_ecma_string (ecma_string_t *string_desc_p) /**< string descriptor */
case ECMA_STRING_CONTAINER_HEAP_NUMBER:
{
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.number_cp);
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t, string_desc_p->u.number_cp);
new_str_p = ecma_new_ecma_string_from_number (*num_p);
@ -641,7 +645,8 @@ ecma_copy_ecma_string (ecma_string_t *string_desc_p) /**< string descriptor */
new_str_p = ecma_alloc_string ();
*new_str_p = *string_desc_p;
const ecma_collection_header_t *chars_collection_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.collection_cp);
const ecma_collection_header_t *chars_collection_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
string_desc_p->u.collection_cp);
JERRY_ASSERT (chars_collection_p != NULL);
ecma_collection_header_t *new_chars_collection_p = ecma_copy_chars_collection (chars_collection_p);
@ -690,7 +695,7 @@ ecma_copy_or_ref_ecma_string (ecma_string_t *string_desc_p) /**< string descript
/* First trying to free unreachable objects that maybe refer to the string */
ecma_lcache_invalidate_all ();
ecma_gc_run (ECMA_GC_GEN_COUNT - 1);
ecma_gc_run ((ecma_gc_gen_t) (ECMA_GC_GEN_COUNT - 1));
if (current_refs == string_desc_p->refs)
{
@ -734,7 +739,8 @@ ecma_deref_ecma_string (ecma_string_t *string_p) /**< ecma-string */
{
case ECMA_STRING_CONTAINER_HEAP_CHUNKS:
{
ecma_collection_header_t *chars_collection_p = ECMA_GET_NON_NULL_POINTER (string_p->u.collection_cp);
ecma_collection_header_t *chars_collection_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
string_p->u.collection_cp);
ecma_free_chars_collection (chars_collection_p);
@ -742,7 +748,8 @@ ecma_deref_ecma_string (ecma_string_t *string_p) /**< ecma-string */
}
case ECMA_STRING_CONTAINER_HEAP_NUMBER:
{
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (string_p->u.number_cp);
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
string_p->u.number_cp);
ecma_dealloc_number (num_p);
@ -752,8 +759,10 @@ ecma_deref_ecma_string (ecma_string_t *string_p) /**< ecma-string */
{
ecma_string_t *string1_p, *string2_p;
string1_p = ECMA_GET_NON_NULL_POINTER (string_p->u.concatenation.string1_cp);
string2_p = ECMA_GET_NON_NULL_POINTER (string_p->u.concatenation.string2_cp);
string1_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
string_p->u.concatenation.string1_cp);
string2_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
string_p->u.concatenation.string2_cp);
ecma_deref_ecma_string (string1_p);
ecma_deref_ecma_string (string2_p);
@ -793,7 +802,7 @@ ecma_check_that_ecma_string_need_not_be_freed (const ecma_string_t *string_p) /*
*/
JERRY_ASSERT (string_p->refs == 1);
ecma_string_container_t container_type = string_p->container;
ecma_string_container_t container_type = (ecma_string_container_t) string_p->container;
JERRY_ASSERT (container_type == ECMA_STRING_CONTAINER_LIT_TABLE ||
container_type == ECMA_STRING_CONTAINER_MAGIC_STRING ||
@ -820,7 +829,8 @@ ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */
case ECMA_STRING_CONTAINER_HEAP_NUMBER:
{
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (str_p->u.number_cp);
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
str_p->u.number_cp);
return *num_p;
}
@ -833,7 +843,7 @@ ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */
const int32_t string_len = ecma_string_get_length (str_p);
const size_t string_buf_size = (size_t) (string_len + 1) * sizeof (ecma_char_t);
ecma_char_t *str_buffer_p = mem_heap_alloc_block (string_buf_size, MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *str_buffer_p = (ecma_char_t*) mem_heap_alloc_block (string_buf_size, MEM_HEAP_ALLOC_SHORT_TERM);
if (str_buffer_p == NULL)
{
jerry_exit (ERR_OUT_OF_MEMORY);
@ -885,7 +895,8 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d
{
case ECMA_STRING_CONTAINER_HEAP_CHUNKS:
{
const ecma_collection_header_t *chars_collection_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.collection_cp);
const ecma_collection_header_t *chars_collection_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
string_desc_p->u.collection_cp);
ecma_copy_chars_collection_to_buffer (chars_collection_p, buffer_p, (size_t) buffer_size);
@ -913,7 +924,8 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d
}
case ECMA_STRING_CONTAINER_HEAP_NUMBER:
{
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.number_cp);
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
string_desc_p->u.number_cp);
ecma_length_t length = ecma_number_to_zt_string (*num_p, buffer_p, buffer_size);
@ -923,8 +935,10 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d
}
case ECMA_STRING_CONTAINER_CONCATENATION:
{
const ecma_string_t *string1_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.concatenation.string1_cp);
const ecma_string_t *string2_p = ECMA_GET_NON_NULL_POINTER (string_desc_p->u.concatenation.string2_cp);
const ecma_string_t *string1_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
string_desc_p->u.concatenation.string1_cp);
const ecma_string_t *string2_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
string_desc_p->u.concatenation.string2_cp);
ecma_char_t *dest_p = buffer_p;
@ -1021,8 +1035,8 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri
case ECMA_STRING_CONTAINER_HEAP_NUMBER:
{
ecma_number_t *num1_p, *num2_p;
num1_p = ECMA_GET_NON_NULL_POINTER (string1_p->u.number_cp);
num2_p = ECMA_GET_NON_NULL_POINTER (string2_p->u.number_cp);
num1_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t, string1_p->u.number_cp);
num2_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t, string2_p->u.number_cp);
if (ecma_number_is_nan (*num1_p)
&& ecma_number_is_nan (*num2_p))
@ -1034,8 +1048,10 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri
}
case ECMA_STRING_CONTAINER_HEAP_CHUNKS:
{
const ecma_collection_header_t *chars_collection1_p = ECMA_GET_NON_NULL_POINTER (string1_p->u.collection_cp);
const ecma_collection_header_t *chars_collection2_p = ECMA_GET_NON_NULL_POINTER (string2_p->u.collection_cp);
const ecma_collection_header_t *chars_collection1_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
string1_p->u.collection_cp);
const ecma_collection_header_t *chars_collection2_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
string2_p->u.collection_cp);
return ecma_compare_chars_collection (chars_collection1_p, chars_collection2_p);
}
@ -1069,8 +1085,8 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri
const size_t string_buf_size = (size_t) (strings_len + 1) * sizeof (ecma_char_t);
ecma_char_t *string1_buf = mem_heap_alloc_block (string_buf_size, MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *string2_buf = mem_heap_alloc_block (string_buf_size, MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *string1_buf = (ecma_char_t*) mem_heap_alloc_block (string_buf_size, MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *string2_buf = (ecma_char_t*) mem_heap_alloc_block (string_buf_size, MEM_HEAP_ALLOC_SHORT_TERM);
if (string1_buf == NULL
|| string2_buf == NULL)
@ -1186,7 +1202,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
if (req_size < 0)
{
ecma_char_t *heap_buffer_p = mem_heap_alloc_block ((size_t) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *heap_buffer_p = (ecma_char_t*) mem_heap_alloc_block ((size_t) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
if (heap_buffer_p == NULL)
{
jerry_exit (ERR_OUT_OF_MEMORY);
@ -1221,7 +1237,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
if (req_size < 0)
{
ecma_char_t *heap_buffer_p = mem_heap_alloc_block ((size_t) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *heap_buffer_p = (ecma_char_t*) mem_heap_alloc_block ((size_t) -req_size, MEM_HEAP_ALLOC_SHORT_TERM);
if (heap_buffer_p == NULL)
{
jerry_exit (ERR_OUT_OF_MEMORY);
@ -1267,7 +1283,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
int32_t
ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
{
ecma_string_container_t container = string_p->container;
ecma_string_container_t container = (ecma_string_container_t) string_p->container;
if (container == ECMA_STRING_CONTAINER_LIT_TABLE)
{
@ -1309,7 +1325,8 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
}
else if (container == ECMA_STRING_CONTAINER_HEAP_NUMBER)
{
const ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (string_p->u.number_cp);
const ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
string_p->u.number_cp);
ecma_char_t buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER + 1];
@ -1319,7 +1336,8 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
}
else if (container == ECMA_STRING_CONTAINER_HEAP_CHUNKS)
{
const ecma_collection_header_t *collection_header_p = ECMA_GET_NON_NULL_POINTER (string_p->u.collection_cp);
const ecma_collection_header_t *collection_header_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
string_p->u.collection_cp);
return collection_header_p->unit_number;
}
@ -1329,8 +1347,8 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
const ecma_string_t *string1_p, *string2_p;
string1_p = ECMA_GET_NON_NULL_POINTER (string_p->u.concatenation.string1_cp);
string2_p = ECMA_GET_NON_NULL_POINTER (string_p->u.concatenation.string2_cp);
string1_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, string_p->u.concatenation.string1_cp);
string2_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, string_p->u.concatenation.string2_cp);
return ecma_string_get_length (string1_p) + ecma_string_get_length (string2_p);
}
@ -1349,8 +1367,8 @@ ecma_string_get_char_at_pos (const ecma_string_t *string_p, /**< ecma-string */
JERRY_ASSERT (index < (uint32_t) length);
size_t buffer_size = sizeof (ecma_char_t) * (length + 1);
ecma_char_t *zt_str_p = mem_heap_alloc_block (buffer_size,
MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *zt_str_p = (ecma_char_t*) mem_heap_alloc_block (buffer_size,
MEM_HEAP_ALLOC_SHORT_TERM);
if (zt_str_p == NULL)
{
@ -1608,9 +1626,9 @@ ecma_is_zt_string_magic (const ecma_char_t *zt_string_p, /**< zero-terminated st
{
TODO (Improve performance of search);
for (ecma_magic_string_id_t id = 0;
for (ecma_magic_string_id_t id = (ecma_magic_string_id_t) 0;
id < ECMA_MAGIC_STRING__COUNT;
id++)
id = (ecma_magic_string_id_t) (id + 1))
{
if (ecma_compare_zt_strings (zt_string_p, ecma_get_magic_string_zt (id)))
{

View File

@ -37,9 +37,9 @@ JERRY_STATIC_ASSERT (sizeof (ecma_value_t) * JERRY_BITSINBYTE == ECMA_VALUE_SIZE
static ecma_type_t __attribute_const__
ecma_get_value_type_field (ecma_value_t value) /**< ecma-value */
{
return jrt_extract_bit_field (value,
ECMA_VALUE_TYPE_POS,
ECMA_VALUE_TYPE_WIDTH);
return (ecma_type_t) jrt_extract_bit_field (value,
ECMA_VALUE_TYPE_POS,
ECMA_VALUE_TYPE_WIDTH);
} /* ecma_get_value_type_field */
/**
@ -286,7 +286,8 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma-value */
{
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_NUMBER);
return (ecma_number_t*) ECMA_GET_NON_NULL_POINTER (ecma_get_value_value_field (value));
return ECMA_GET_NON_NULL_POINTER (ecma_number_t,
ecma_get_value_value_field (value));
} /* ecma_get_number_from_value */
/**
@ -299,7 +300,8 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma-value */
{
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
return (ecma_string_t*) ECMA_GET_NON_NULL_POINTER (ecma_get_value_value_field (value));
return ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ecma_get_value_value_field (value));
} /* ecma_get_string_from_value */
/**
@ -312,7 +314,8 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma-value */
{
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
return (ecma_object_t*) ECMA_GET_NON_NULL_POINTER (ecma_get_value_value_field (value));
return ECMA_GET_NON_NULL_POINTER (ecma_object_t,
ecma_get_value_value_field (value));
} /* ecma_get_object_from_value */
/**
@ -439,9 +442,9 @@ ecma_free_value (ecma_value_t value, /**< value description */
static ecma_completion_type_t __attribute_const__
ecma_get_completion_value_type_field (ecma_completion_value_t completion_value) /**< completion value */
{
return jrt_extract_bit_field (completion_value,
ECMA_COMPLETION_VALUE_TYPE_POS,
ECMA_COMPLETION_VALUE_TYPE_WIDTH);
return (ecma_completion_type_t) jrt_extract_bit_field (completion_value,
ECMA_COMPLETION_VALUE_TYPE_POS,
ECMA_COMPLETION_VALUE_TYPE_WIDTH);
} /* ecma_get_completion_value_type_field */
/**
@ -465,7 +468,8 @@ ecma_get_completion_value_value_field (ecma_completion_value_t completion_value)
static ecma_label_descriptor_t* __attribute_const__
ecma_get_completion_value_label_descriptor (ecma_completion_value_t completion_value) /**< completion value */
{
return ECMA_GET_NON_NULL_POINTER ((uintptr_t) jrt_extract_bit_field (completion_value,
return ECMA_GET_NON_NULL_POINTER (ecma_label_descriptor_t,
(uintptr_t) jrt_extract_bit_field (completion_value,
ECMA_COMPLETION_VALUE_LABEL_DESC_CP_POS,
ECMA_COMPLETION_VALUE_LABEL_DESC_CP_WIDTH));
} /* ecma_get_completion_value_label_descriptor */
@ -567,11 +571,8 @@ ecma_make_label_completion_value (ecma_completion_type_t type, /**< type */
|| type == ECMA_COMPLETION_TYPE_CONTINUE);
ecma_label_descriptor_t *label_desc_p = ecma_alloc_label_descriptor ();
*label_desc_p = (ecma_label_descriptor_t)
{
.offset = offset,
.depth = depth_level
};
label_desc_p->offset = offset;
label_desc_p->depth = depth_level;
ecma_completion_value_t completion_value = 0;

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -96,7 +96,8 @@ ecma_free_values_collection (ecma_collection_header_t* header_p, /**< collection
string_index++;
}
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (header_p->next_chunk_cp);
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
header_p->next_chunk_cp);
while (chunk_p != NULL)
{
@ -116,7 +117,8 @@ ecma_free_values_collection (ecma_collection_header_t* header_p, /**< collection
string_index++;
}
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (chunk_p->next_chunk_cp);
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
chunk_p->next_chunk_cp);
ecma_dealloc_collection_chunk (chunk_p);
chunk_p = next_chunk_p;
}
@ -205,7 +207,8 @@ ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p) /**< cont
if (iterator_p->current_value_p == iterator_p->current_chunk_end_p)
{
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (iterator_p->next_chunk_cp);
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
iterator_p->next_chunk_cp);
JERRY_ASSERT (next_chunk_p != NULL);
iterator_p->next_chunk_cp = next_chunk_p->next_chunk_cp;

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -226,9 +226,9 @@ ecma_get_object_type (const ecma_object_t *object_p) /**< object */
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
return jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_OBJ_TYPE_POS,
ECMA_OBJECT_OBJ_TYPE_WIDTH);
return (ecma_object_type_t) jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_OBJ_TYPE_POS,
ECMA_OBJECT_OBJ_TYPE_WIDTH);
} /* ecma_get_object_type */
/**
@ -260,7 +260,8 @@ ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */
uintptr_t prototype_object_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS,
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
return ECMA_GET_POINTER (prototype_object_cp);
return ECMA_GET_POINTER (ecma_object_t,
prototype_object_cp);
} /* ecma_get_object_prototype */
/**
@ -314,9 +315,9 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
return jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_LEX_ENV_TYPE_POS,
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
return (ecma_lexical_environment_type_t) jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_LEX_ENV_TYPE_POS,
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
} /* ecma_get_lex_env_type */
/**
@ -332,7 +333,8 @@ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical en
uintptr_t outer_reference_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
return ECMA_GET_POINTER (outer_reference_cp);
return ECMA_GET_POINTER (ecma_object_t,
outer_reference_cp);
} /* ecma_get_lex_env_outer_reference */
/**
@ -349,7 +351,8 @@ ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical en
uintptr_t properties_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
return ECMA_GET_POINTER (properties_cp);
return ECMA_GET_POINTER (ecma_property_t,
properties_cp);
} /* ecma_get_property_list */
/**
@ -404,7 +407,7 @@ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-boun
uintptr_t object_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
return ECMA_GET_NON_NULL_POINTER (object_cp);
return ECMA_GET_NON_NULL_POINTER (ecma_object_t, object_cp);
} /* ecma_get_lex_env_binding_object */
/**
@ -427,7 +430,10 @@ ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
ECMA_SET_POINTER(new_property_p->next_property_p, list_head_p);
ecma_set_property_list (object_p, new_property_p);
new_property_p->u.internal_property.type = property_id;
JERRY_STATIC_ASSERT (ECMA_INTERNAL_PROPERTY__COUNT <= (1ull << ECMA_PROPERTY_INTERNAL_PROPERTY_TYPE_WIDTH));
JERRY_ASSERT (property_id < ECMA_INTERNAL_PROPERTY__COUNT);
new_property_p->u.internal_property.type = property_id & ((1ull << ECMA_PROPERTY_INTERNAL_PROPERTY_TYPE_WIDTH) - 1);
new_property_p->u.internal_property.value = ECMA_NULL_POINTER;
return new_property_p;
@ -450,7 +456,7 @@ ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
for (ecma_property_t *property_p = ecma_get_property_list (object_p);
property_p != NULL;
property_p = ECMA_GET_POINTER(property_p->next_property_p))
property_p = ECMA_GET_POINTER (ecma_property_t, property_p->next_property_p))
{
if (property_p->type == ECMA_PROPERTY_INTERNAL)
{
@ -591,17 +597,19 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
for (property_p = ecma_get_property_list (obj_p);
property_p != NULL;
property_p = ECMA_GET_POINTER(property_p->next_property_p))
property_p = ECMA_GET_POINTER (ecma_property_t, property_p->next_property_p))
{
ecma_string_t *property_name_p;
if (property_p->type == ECMA_PROPERTY_NAMEDDATA)
{
property_name_p = ECMA_GET_NON_NULL_POINTER(property_p->u.named_data_property.name_p);
property_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
property_p->u.named_data_property.name_p);
}
else if (property_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
property_name_p = ECMA_GET_NON_NULL_POINTER(property_p->u.named_accessor_property.name_p);
property_name_p = ECMA_GET_NON_NULL_POINTER(ecma_string_t,
property_p->u.named_accessor_property.name_p);
}
else
{
@ -679,7 +687,8 @@ ecma_free_named_data_property (ecma_object_t *object_p, /**< object the property
ecma_lcache_invalidate (object_p, NULL, property_p);
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (property_p->u.named_data_property.name_p));
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
property_p->u.named_data_property.name_p));
ecma_free_value (property_p->u.named_data_property.value, false);
ecma_dealloc_property (property_p);
@ -697,7 +706,8 @@ ecma_free_named_accessor_property (ecma_object_t *object_p, /**< object the prop
ecma_lcache_invalidate (object_p, NULL, property_p);
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (property_p->u.named_accessor_property.name_p));
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
property_p->u.named_accessor_property.name_p));
ecma_dealloc_property (property_p);
} /* ecma_free_named_accessor_property */
@ -710,7 +720,7 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
{
JERRY_ASSERT (property_p != NULL && property_p->type == ECMA_PROPERTY_INTERNAL);
ecma_internal_property_id_t property_id = property_p->u.internal_property.type;
ecma_internal_property_id_t property_id = (ecma_internal_property_id_t) property_p->u.internal_property.type;
uint32_t property_value = property_p->u.internal_property.value;
switch (property_id)
@ -718,7 +728,9 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* a collection */
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* a collection */
{
ecma_free_values_collection (ECMA_GET_NON_NULL_POINTER(property_value), true);
ecma_free_values_collection (ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
property_value),
true);
break;
}
@ -727,14 +739,17 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
{
if (property_value != ECMA_NULL_POINTER)
{
ecma_free_values_collection (ECMA_GET_NON_NULL_POINTER(property_value), false);
ecma_free_values_collection (ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
property_value),
false);
}
break;
}
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_STRING_VALUE: /* compressed pointer to a ecma_string_t */
{
ecma_string_t *str_p = ECMA_GET_NON_NULL_POINTER (property_value);
ecma_string_t *str_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
property_value);
ecma_deref_ecma_string (str_p);
break;
@ -742,7 +757,8 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE: /* pointer to a ecma_number_t */
{
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (property_value);
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
property_value);
ecma_dealloc_number (num_p);
break;
@ -762,6 +778,12 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
{
break;
}
case ECMA_INTERNAL_PROPERTY__COUNT: /* not a real internal property type,
* but number of the real internal property types */
{
JERRY_UNREACHABLE ();
}
}
ecma_dealloc_property (property_p);
@ -812,7 +834,8 @@ ecma_delete_property (ecma_object_t *obj_p, /**< object */
cur_prop_p != NULL;
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p)
{
next_prop_p = ECMA_GET_POINTER(cur_prop_p->next_property_p);
next_prop_p = ECMA_GET_POINTER (ecma_property_t,
cur_prop_p->next_property_p);
if (cur_prop_p == prop_p)
{
@ -878,7 +901,7 @@ ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
ecma_property_t *prop_iter_p;
for (prop_iter_p = ecma_get_property_list (obj_p);
prop_iter_p != NULL;
prop_iter_p = ECMA_GET_POINTER(prop_iter_p->next_property_p))
prop_iter_p = ECMA_GET_POINTER (ecma_property_t, prop_iter_p->next_property_p))
{
if (prop_iter_p == prop_p)
{
@ -1067,26 +1090,20 @@ ecma_set_property_lcached (ecma_property_t *prop_p, /**< property */
ecma_property_descriptor_t
ecma_make_empty_property_descriptor (void)
{
ecma_property_descriptor_t prop_desc = (ecma_property_descriptor_t)
{
.is_value_defined = false,
.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
ecma_property_descriptor_t prop_desc;
.is_writable_defined = false,
.is_writable = false,
.is_enumerable_defined = false,
.is_enumerable = false,
.is_configurable_defined = false,
.is_configurable = false,
.is_get_defined = false,
.get_p = NULL,
.is_set_defined = false,
.set_p = NULL
};
prop_desc.is_value_defined = false;
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
prop_desc.is_writable_defined = false;
prop_desc.is_writable = false;
prop_desc.is_enumerable_defined = false;
prop_desc.is_enumerable = false;
prop_desc.is_configurable_defined = false;
prop_desc.is_configurable = false;
prop_desc.is_get_defined = false;
prop_desc.get_p = NULL;
prop_desc.is_set_defined = false;
prop_desc.set_p = NULL;
return prop_desc;
} /* ecma_make_empty_property_descriptor */

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,14 +29,14 @@
/**
* Get value of pointer from specified non-null compressed pointer field.
*/
#define ECMA_GET_NON_NULL_POINTER(field) \
(mem_decompress_pointer (field))
#define ECMA_GET_NON_NULL_POINTER(type, field) \
((type *) mem_decompress_pointer (field))
/**
* Get value of pointer from specified compressed pointer field.
*/
#define ECMA_GET_POINTER(field) \
((unlikely (field == ECMA_NULL_POINTER)) ? NULL : ECMA_GET_NON_NULL_POINTER (field))
#define ECMA_GET_POINTER(type, field) \
(((unlikely (field == ECMA_NULL_POINTER)) ? NULL : ECMA_GET_NON_NULL_POINTER (type, field)))
/**
* Set value of non-null compressed pointer field so that it will correspond
@ -52,7 +52,7 @@
#define ECMA_SET_POINTER(field, non_compressed_pointer) \
do \
{ \
void *__temp_pointer = non_compressed_pointer; \
auto __temp_pointer = non_compressed_pointer; \
non_compressed_pointer = __temp_pointer; \
} while (0); \
\

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -84,14 +84,18 @@ ecma_lcache_invalidate_entry (ecma_lcache_hash_entry_t *entry_p) /**< entry to i
JERRY_ASSERT (entry_p != NULL);
JERRY_ASSERT (entry_p->object_cp != ECMA_NULL_POINTER);
ecma_deref_object (ECMA_GET_NON_NULL_POINTER (entry_p->object_cp));
ecma_deref_object (ECMA_GET_NON_NULL_POINTER (ecma_object_t,
entry_p->object_cp));
entry_p->object_cp = ECMA_NULL_POINTER;
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (entry_p->prop_name_cp));
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
entry_p->prop_name_cp));
if (entry_p->prop_cp != ECMA_NULL_POINTER)
{
ecma_set_property_lcached (ECMA_GET_NON_NULL_POINTER (entry_p->prop_cp), false);
ecma_set_property_lcached (ECMA_GET_NON_NULL_POINTER (ecma_property_t,
entry_p->prop_cp),
false);
}
} /* ecma_lcache_invalidate_entry */
@ -166,7 +170,8 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
{
#ifndef JERRY_NDEBUG
ecma_object_t* obj_in_entry_p;
obj_in_entry_p = ECMA_GET_NON_NULL_POINTER (ecma_lcache_hash_table[hash_key][entry_index].object_cp);
obj_in_entry_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
ecma_lcache_hash_table[hash_key][entry_index].object_cp);
JERRY_ASSERT (obj_in_entry_p == object_p);
#endif /* !JERRY_NDEBUG */
break;
@ -232,11 +237,12 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
{
if (ecma_lcache_hash_table[hash_key][i].object_cp == object_cp)
{
ecma_string_t *entry_prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_lcache_hash_table[hash_key][i].prop_name_cp);
ecma_string_t *entry_prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ecma_lcache_hash_table[hash_key][i].prop_name_cp);
if (ecma_compare_ecma_strings_equal_hashes (prop_name_p, entry_prop_name_p))
{
ecma_property_t *prop_p = ECMA_GET_POINTER (ecma_lcache_hash_table[hash_key][i].prop_cp);
ecma_property_t *prop_p = ECMA_GET_POINTER (ecma_property_t, ecma_lcache_hash_table[hash_key][i].prop_cp);
JERRY_ASSERT (prop_p == NULL || ecma_is_property_lcached (prop_p));
*prop_p_p = prop_p;
@ -288,11 +294,13 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
if (prop_p->type == ECMA_PROPERTY_NAMEDDATA)
{
prop_name_p = ECMA_GET_NON_NULL_POINTER (prop_p->u.named_data_property.name_p);
prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
prop_p->u.named_data_property.name_p);
}
else
{
prop_name_p = ECMA_GET_NON_NULL_POINTER (prop_p->u.named_accessor_property.name_p);
prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
prop_p->u.named_accessor_property.name_p);
}
}
else

View File

@ -170,8 +170,9 @@ ecma_stack_push_value_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack fra
if (frame_p->current_slot_index == slots_in_top_chunk)
{
ecma_stack_chunk_header_t *chunk_p = mem_heap_alloc_block (ECMA_STACK_DYNAMIC_CHUNK_SIZE,
MEM_HEAP_ALLOC_SHORT_TERM);
ecma_stack_chunk_header_t *chunk_p;
chunk_p = (ecma_stack_chunk_header_t *) mem_heap_alloc_block (ECMA_STACK_DYNAMIC_CHUNK_SIZE,
MEM_HEAP_ALLOC_SHORT_TERM);
ECMA_SET_POINTER (chunk_p->prev_chunk_p, frame_p->top_chunk_p);
@ -223,7 +224,8 @@ ecma_stack_pop_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
JERRY_ASSERT (frame_p->current_slot_index == 0 && frame_p->top_chunk_p != NULL);
ecma_stack_chunk_header_t *chunk_to_free_p = frame_p->top_chunk_p;
frame_p->top_chunk_p = ECMA_GET_POINTER (frame_p->top_chunk_p->prev_chunk_p);
frame_p->top_chunk_p = ECMA_GET_POINTER (ecma_stack_chunk_header_t,
frame_p->top_chunk_p->prev_chunk_p);
if (frame_p->top_chunk_p != NULL)
{

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -302,7 +302,8 @@ ecma_function_call_setup_args_variables (ecma_object_t *func_obj_p, /**< Functio
ecma_property_t *formal_parameters_prop_p = ecma_get_internal_property (func_obj_p,
ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS);
ecma_collection_header_t *formal_parameters_p;
formal_parameters_p = ECMA_GET_POINTER (formal_parameters_prop_p->u.internal_property.value);
formal_parameters_p = ECMA_GET_POINTER (ecma_collection_header_t,
formal_parameters_prop_p->u.internal_property.value);
if (formal_parameters_p == NULL)
{
@ -479,7 +480,8 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE);
ecma_object_t *scope_p = ECMA_GET_NON_NULL_POINTER(scope_prop_p->u.internal_property.value);
ecma_object_t *scope_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
scope_prop_p->u.internal_property.value);
uint32_t code_prop_value = code_prop_p->u.internal_property.value;
bool is_strict;

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -98,7 +98,8 @@ ecma_op_get_value_object_base (ecma_reference_t ref) /**< ECMA-reference */
JERRY_ASSERT(obj_p != NULL
&& !ecma_is_lexical_environment (obj_p));
return ecma_op_object_get (obj_p, ECMA_GET_NON_NULL_POINTER (ref.referenced_name_cp));
return ecma_op_object_get (obj_p, ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ref.referenced_name_cp));
}
else
{
@ -111,7 +112,8 @@ ecma_op_get_value_object_base (ecma_reference_t ref) /**< ECMA-reference */
JERRY_ASSERT (obj_p != NULL
&& !ecma_is_lexical_environment (obj_p));
ret_value = ecma_op_object_get (obj_p, ECMA_GET_NON_NULL_POINTER (ref.referenced_name_cp));
ret_value = ecma_op_object_get (obj_p, ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ref.referenced_name_cp));
ECMA_FINALIZE (obj_base);
@ -229,7 +231,8 @@ ecma_op_put_value_object_base (ecma_reference_t ref, /**< ECMA-reference */
ECMA_TRY_CATCH (put_completion,
ecma_op_object_put (obj_p,
ECMA_GET_NON_NULL_POINTER (ref.referenced_name_cp),
ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ref.referenced_name_cp),
value,
ref.is_strict),
ret_value);
@ -252,7 +255,8 @@ ecma_op_put_value_object_base (ecma_reference_t ref, /**< ECMA-reference */
JERRY_ASSERT (obj_p != NULL
&& !ecma_is_lexical_environment (obj_p));
ecma_string_t *referenced_name_p = ECMA_GET_NON_NULL_POINTER (ref.referenced_name_cp);
ecma_string_t *referenced_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ref.referenced_name_cp);
// sub_2.
if (!ecma_op_object_can_put (obj_p, referenced_name_p))
@ -280,7 +284,8 @@ ecma_op_put_value_object_base (ecma_reference_t ref, /**< ECMA-reference */
// sub_6.
JERRY_ASSERT (prop_p != NULL && prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
ecma_object_t *setter_p = ECMA_GET_NON_NULL_POINTER(prop_p->u.named_accessor_property.set_p);
ecma_object_t *setter_p = ECMA_GET_NON_NULL_POINTER(ecma_object_t,
prop_p->u.named_accessor_property.set_p);
JERRY_ASSERT (setter_p != NULL);
ECMA_TRY_CATCH (call_completion,

View File

@ -53,7 +53,7 @@ ecma_finalize (void)
ecma_stack_finalize ();
ecma_finalize_builtins ();
ecma_lcache_invalidate_all ();
ecma_gc_run (ECMA_GC_GEN_COUNT - 1);
ecma_gc_run ((ecma_gc_gen_t) (ECMA_GC_GEN_COUNT - 1));
} /* ecma_finalize */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -281,7 +281,8 @@ ecma_arguments_get_mapped_arg_value (ecma_object_t *map_p, /**< [[ParametersMap]
equal to mapped argument's name */
{
ecma_property_t *scope_prop_p = ecma_get_internal_property (map_p, ECMA_INTERNAL_PROPERTY_SCOPE);
ecma_object_t *lex_env_p = ECMA_GET_NON_NULL_POINTER (scope_prop_p->u.internal_property.value);
ecma_object_t *lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
scope_prop_p->u.internal_property.value);
JERRY_ASSERT(lex_env_p != NULL
&& ecma_is_lexical_environment (lex_env_p));
@ -313,7 +314,8 @@ ecma_op_arguments_object_get (ecma_object_t *obj_p, /**< the object */
{
// 1.
ecma_property_t *map_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (map_prop_p->u.internal_property.value);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
map_prop_p->u.internal_property.value);
// 2.
ecma_property_t *mapped_prop_p = ecma_op_object_get_own_property (map_p, property_name_p);
@ -358,7 +360,8 @@ ecma_op_arguments_object_get_own_property (ecma_object_t *obj_p, /**< the object
// 3.
ecma_property_t *map_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (map_prop_p->u.internal_property.value);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
map_prop_p->u.internal_property.value);
// 4.
ecma_property_t *mapped_prop_p = ecma_op_object_get_own_property (map_p, property_name_p);
@ -397,7 +400,8 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *obj_p, /**< the obj
{
// 1.
ecma_property_t *map_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (map_prop_p->u.internal_property.value);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
map_prop_p->u.internal_property.value);
// 2.
ecma_property_t *mapped_prop_p = ecma_op_object_get_own_property (map_p, property_name_p);
@ -490,7 +494,8 @@ ecma_op_arguments_object_delete (ecma_object_t *obj_p, /**< the object */
{
// 1.
ecma_property_t *map_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (map_prop_p->u.internal_property.value);
ecma_object_t *map_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
map_prop_p->u.internal_property.value);
// 2.
ecma_property_t *mapped_prop_p = ecma_op_object_get_own_property (map_p, property_name_p);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -140,7 +140,8 @@ ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */
else
{
// 4.
ecma_object_t *getter_p = ECMA_GET_POINTER(prop_p->u.named_accessor_property.get_p);
ecma_object_t *getter_p = ECMA_GET_POINTER (ecma_object_t,
prop_p->u.named_accessor_property.get_p);
// 5.
if (getter_p == NULL)
@ -285,7 +286,8 @@ ecma_op_general_object_put (ecma_object_t *obj_p, /**< the object */
&& desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
// a.
ecma_object_t *setter_p = ECMA_GET_NON_NULL_POINTER(desc_p->u.named_accessor_property.set_p);
ecma_object_t *setter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
desc_p->u.named_accessor_property.set_p);
JERRY_ASSERT(setter_p != NULL);
ecma_completion_value_t ret_value;
@ -360,7 +362,8 @@ ecma_op_general_object_can_put (ecma_object_t *obj_p, /**< the object */
// a.
if (prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
ecma_object_t *setter_p = ECMA_GET_POINTER(prop_p->u.named_accessor_property.set_p);
ecma_object_t *setter_p = ECMA_GET_POINTER (ecma_object_t,
prop_p->u.named_accessor_property.set_p);
// i.
if (setter_p == NULL)
@ -402,7 +405,8 @@ ecma_op_general_object_can_put (ecma_object_t *obj_p, /**< the object */
// 7.
if (inherited_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
ecma_object_t *setter_p = ECMA_GET_POINTER(inherited_p->u.named_accessor_property.set_p);
ecma_object_t *setter_p = ECMA_GET_POINTER (ecma_object_t,
inherited_p->u.named_accessor_property.set_p);
// a.
if (setter_p == NULL)
@ -684,7 +688,8 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
if (property_desc_p->is_get_defined)
{
if (!is_current_accessor_descriptor
|| property_desc_p->get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
|| property_desc_p->get_p != ECMA_GET_POINTER (ecma_object_t,
current_p->u.named_accessor_property.get_p))
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
@ -693,7 +698,8 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
if (property_desc_p->is_set_defined)
{
if (!is_current_accessor_descriptor
|| property_desc_p->set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p))
|| property_desc_p->set_p != ECMA_GET_POINTER (ecma_object_t,
current_p->u.named_accessor_property.set_p))
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
@ -805,9 +811,11 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
// a.
if ((property_desc_p->is_get_defined
&& property_desc_p->get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
&& property_desc_p->get_p != ECMA_GET_POINTER (ecma_object_t,
current_p->u.named_accessor_property.get_p))
|| (property_desc_p->is_set_defined
&& property_desc_p->set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p)))
&& property_desc_p->set_p != ECMA_GET_POINTER (ecma_object_t,
current_p->u.named_accessor_property.set_p)))
{
// i., ii.
return ecma_reject (is_throw);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -51,19 +51,30 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
const ecma_object_type_t type = ecma_get_object_type (obj_p);
JERRY_ASSERT (type < ECMA_OBJECT_TYPE__COUNT);
typedef ecma_completion_value_t (*get_ptr_t) (ecma_object_t *, ecma_string_t *);
static const get_ptr_t get [ECMA_OBJECT_TYPE__COUNT] =
switch (type)
{
[ECMA_OBJECT_TYPE_GENERAL] = &ecma_op_general_object_get,
[ECMA_OBJECT_TYPE_ARRAY] = &ecma_op_general_object_get,
[ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_get,
[ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_get,
[ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_get,
[ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_get,
[ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_arguments_object_get
};
case ECMA_OBJECT_TYPE_GENERAL:
case ECMA_OBJECT_TYPE_ARRAY:
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
case ECMA_OBJECT_TYPE_STRING:
{
return ecma_op_general_object_get (obj_p, property_name_p);
}
return get[type] (obj_p, property_name_p);
case ECMA_OBJECT_TYPE_ARGUMENTS:
{
return ecma_op_arguments_object_get (obj_p, property_name_p);
}
default:
{
JERRY_ASSERT (false);
return ecma_make_empty_completion_value ();
}
}
} /* ecma_op_object_get */
/**
@ -81,19 +92,42 @@ ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object
const bool is_builtin = ecma_get_object_is_builtin (obj_p);
typedef ecma_property_t* (*get_own_property_ptr_t) (ecma_object_t *, ecma_string_t *);
static const get_own_property_ptr_t get_own_property [ECMA_OBJECT_TYPE__COUNT] =
{
[ECMA_OBJECT_TYPE_GENERAL] = &ecma_op_general_object_get_own_property,
[ECMA_OBJECT_TYPE_ARRAY] = &ecma_op_general_object_get_own_property,
[ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_get_own_property,
[ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_get_own_property,
[ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_get_own_property,
[ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_arguments_object_get_own_property,
[ECMA_OBJECT_TYPE_STRING] = &ecma_op_string_object_get_own_property
};
ecma_property_t *prop_p;
ecma_property_t *prop_p = get_own_property[type] (obj_p, property_name_p);
switch (type)
{
case ECMA_OBJECT_TYPE_GENERAL:
case ECMA_OBJECT_TYPE_ARRAY:
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
{
prop_p = ecma_op_general_object_get_own_property (obj_p, property_name_p);
break;
}
case ECMA_OBJECT_TYPE_STRING:
{
prop_p = ecma_op_string_object_get_own_property (obj_p, property_name_p);
break;
}
case ECMA_OBJECT_TYPE_ARGUMENTS:
{
prop_p = ecma_op_arguments_object_get_own_property (obj_p, property_name_p);
break;
}
default:
{
JERRY_ASSERT (false);
return NULL;
}
}
if (unlikely (prop_p == NULL))
{
@ -276,19 +310,34 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
const ecma_object_type_t type = ecma_get_object_type (obj_p);
JERRY_ASSERT (type < ECMA_OBJECT_TYPE__COUNT);
typedef ecma_completion_value_t (*delete_ptr_t) (ecma_object_t *, ecma_string_t *, bool);
static const delete_ptr_t delete [ECMA_OBJECT_TYPE__COUNT] =
switch (type)
{
[ECMA_OBJECT_TYPE_GENERAL] = &ecma_op_general_object_delete,
[ECMA_OBJECT_TYPE_ARRAY] = &ecma_op_general_object_delete,
[ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_delete,
[ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_delete,
[ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_delete,
[ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_delete,
[ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_arguments_object_delete
};
case ECMA_OBJECT_TYPE_GENERAL:
case ECMA_OBJECT_TYPE_ARRAY:
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
case ECMA_OBJECT_TYPE_STRING:
{
return ecma_op_general_object_delete (obj_p,
property_name_p,
is_throw);
}
return delete[type] (obj_p, property_name_p, is_throw);
case ECMA_OBJECT_TYPE_ARGUMENTS:
{
return ecma_op_arguments_object_delete (obj_p,
property_name_p,
is_throw);
}
default:
{
JERRY_ASSERT (false);
return ecma_make_empty_completion_value ();
}
}
} /* ecma_op_object_delete */
/**
@ -352,25 +401,43 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
const ecma_object_type_t type = ecma_get_object_type (obj_p);
JERRY_ASSERT (type < ECMA_OBJECT_TYPE__COUNT);
typedef ecma_completion_value_t (*define_own_property_ptr_t) (ecma_object_t *,
ecma_string_t *,
const ecma_property_descriptor_t*,
bool);
static const define_own_property_ptr_t define_own_property [ECMA_OBJECT_TYPE__COUNT] =
switch (type)
{
[ECMA_OBJECT_TYPE_GENERAL] = &ecma_op_general_object_define_own_property,
[ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_define_own_property,
[ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_define_own_property,
[ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_define_own_property,
[ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_define_own_property,
[ECMA_OBJECT_TYPE_ARRAY] = &ecma_op_array_object_define_own_property,
[ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_arguments_object_define_own_property
};
case ECMA_OBJECT_TYPE_GENERAL:
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
case ECMA_OBJECT_TYPE_STRING:
{
return ecma_op_general_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
}
return define_own_property[type] (obj_p,
property_name_p,
property_desc_p,
is_throw);
case ECMA_OBJECT_TYPE_ARRAY:
{
return ecma_op_array_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
}
case ECMA_OBJECT_TYPE_ARGUMENTS:
{
return ecma_op_arguments_object_define_own_property (obj_p,
property_name_p,
property_desc_p,
is_throw);
}
default:
{
JERRY_ASSERT (false);
return ecma_make_empty_completion_value ();
}
}
} /* ecma_op_object_define_own_property */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -99,11 +99,9 @@ ecma_make_reference (ecma_value_t base, /**< base value */
{
name_p = ecma_copy_or_ref_ecma_string (name_p);
ecma_reference_t ref = (ecma_reference_t)
{
.base = ecma_copy_value (base, true),
.is_strict = is_strict
};
ecma_reference_t ref;
ref.base = ecma_copy_value (base, true);
ref.is_strict = is_strict;
ECMA_SET_POINTER (ref.referenced_name_cp, name_p);
@ -120,7 +118,8 @@ void
ecma_free_reference (ecma_reference_t ref) /**< reference */
{
ecma_free_value (ref.base, true);
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ref.referenced_name_cp));
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
ref.referenced_name_cp));
} /* ecma_free_reference */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -167,7 +167,8 @@ ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< the array obj
// 4.
ecma_property_t* prim_value_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_STRING_VALUE);
ecma_string_t *prim_value_str_p = ECMA_GET_NON_NULL_POINTER (prim_value_prop_p->u.internal_property.value);
ecma_string_t *prim_value_str_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
prim_value_prop_p->u.internal_property.value);
// 6.
int32_t length = ecma_string_get_length (prim_value_str_p);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ hash_table_insert (hash_table ht, void *key, void *value)
{
list = array_list_init (bucket_size (hti));
}
uint8_t *bucket = mem_heap_alloc_block (bucket_size (hti), hti->alloc_term);
uint8_t *bucket = (uint8_t*) mem_heap_alloc_block (bucket_size (hti), hti->alloc_term);
__memcpy (bucket, key, hti->key_size);
__memcpy (bucket + hti->key_size, value, hti->value_size);
list = array_list_append (list, bucket);
@ -91,7 +91,7 @@ hash_table_lookup (hash_table ht, void *key)
}
for (uint16_t i = 0; i < array_list_len (al); i++)
{
uint8_t *bucket = array_list_element (al, i);
uint8_t *bucket = (uint8_t*) array_list_element (al, i);
JERRY_ASSERT (bucket != NULL);
if (!__memcmp (bucket, key, h->key_size))
{

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -42,7 +42,7 @@ linked_list
linked_list_init (uint16_t element_size)
{
size_t size = mem_heap_recommend_allocation_size (element_size);
linked_list list = mem_heap_alloc_block (size, MEM_HEAP_ALLOC_SHORT_TERM);
linked_list list = (linked_list) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_SHORT_TERM);
if (list == null_list)
{
__printf ("Out of memory");

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,21 +20,23 @@
literal
create_empty_literal (void)
{
return (literal)
{
.type = LIT_UNKNOWN,
.data.none = NULL
};
literal ret;
ret.type = LIT_UNKNOWN;
ret.data.none = NULL;
return ret;
}
literal
create_literal_from_num (ecma_number_t num)
{
return (literal)
{
.type = LIT_NUMBER,
.data.num = num
};
literal ret;
ret.type = LIT_NUMBER;
ret.data.num = num;
return ret;
}
literal
@ -52,7 +54,9 @@ create_literal_from_str_compute_len (const char *s)
literal
create_literal_from_zt (const ecma_char_t *s, ecma_length_t len)
{
for (ecma_magic_string_id_t msi = 0; msi < ECMA_MAGIC_STRING__COUNT; msi++)
for (ecma_magic_string_id_t msi = (ecma_magic_string_id_t) 0;
msi < ECMA_MAGIC_STRING__COUNT;
msi = (ecma_magic_string_id_t) (msi + 1))
{
if (ecma_zt_string_length (ecma_get_magic_string_zt (msi)) != len)
{
@ -60,23 +64,23 @@ create_literal_from_zt (const ecma_char_t *s, ecma_length_t len)
}
if (!__strncmp ((const char *) s, (const char *) ecma_get_magic_string_zt (msi), len))
{
return (literal)
{
.type = LIT_MAGIC_STR,
.data.magic_str_id = msi
};
literal ret;
ret.type = LIT_MAGIC_STR;
ret.data.magic_str_id = msi;
return ret;
}
}
return (literal)
{
.type = LIT_STR,
.data.lp = (lp_string)
{
.length = len,
.str = s,
.hash = ecma_chars_buffer_calc_hash_last_chars (s, len)
}
};
literal ret;
ret.type = LIT_STR;
ret.data.lp.length = len;
ret.data.lp.str = s;
ret.data.lp.hash = ecma_chars_buffer_calc_hash_last_chars (s, len);
return ret;
}
bool

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,13 +23,7 @@
#include "parser.h"
#include "ecma-helpers.h"
static token saved_token, prev_token, sent_token;
static token empty_token =
{
.type = TOK_EMPTY,
.uid = 0,
.loc = 0
};
static token saved_token, prev_token, sent_token, empty_token;
static bool allow_dump_lines = false, strict_mode;
static size_t buffer_size = 0;
@ -101,12 +95,13 @@ dump_current_line (void)
static token
create_token (token_type type, literal_index_t uid)
{
return (token)
{
.type = type,
.loc = current_locus () - (type == TOK_STRING ? 1 : 0),
.uid = uid
};
token ret;
ret.type = type;
ret.loc = current_locus () - (type == TOK_STRING ? 1 : 0);
ret.uid = uid;
return ret;
}
static bool
@ -159,16 +154,15 @@ adjust_string_ptrs (literal lit, size_t diff)
{
return lit;
}
return (literal)
{
.type = LIT_STR,
.data.lp = (lp_string)
{
.length = lit.data.lp.length,
.hash = lit.data.lp.hash,
.str = lit.data.lp.str + diff
}
};
literal ret;
ret.type = LIT_STR;
ret.data.lp.length = lit.data.lp.length;
ret.data.lp.hash = lit.data.lp.hash;
ret.data.lp.str = lit.data.lp.str + diff;
return ret;
}
static literal
@ -844,7 +838,8 @@ parse_number (void)
tok_length = (size_t) (buffer - token_start);;
if (is_fp || is_exp)
{
ecma_char_t *temp = mem_heap_alloc_block ((size_t) (tok_length + 1), MEM_HEAP_ALLOC_SHORT_TERM);
ecma_char_t *temp = (ecma_char_t*) mem_heap_alloc_block ((size_t) (tok_length + 1),
MEM_HEAP_ALLOC_SHORT_TERM);
__strncpy ((char *) temp, token_start, (size_t) (tok_length));
temp[tok_length] = '\0';
ecma_number_t res = ecma_zt_string_to_number (temp);
@ -1087,11 +1082,12 @@ lexer_next_token_private (void)
{
if (replace_comment_by_newline ())
{
return (token)
{
.type = TOK_NEWLINE,
.uid = 0
};
token ret;
ret.type = TOK_NEWLINE;
ret.uid = 0;
return ret;
}
else
{
@ -1431,6 +1427,10 @@ lexer_set_strict_mode (bool is_strict)
void
lexer_init (const char *source, size_t source_size, bool show_opcodes)
{
empty_token.type = TOK_EMPTY;
empty_token.uid = 0;
empty_token.loc = 0;
saved_token = prev_token = sent_token = empty_token;
allow_dump_lines = show_opcodes;
buffer_size = source_size;

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -162,13 +162,14 @@ next_temp_name (void)
static op_meta
create_op_meta (opcode_t op, literal_index_t lit_id1, literal_index_t lit_id2, literal_index_t lit_id3)
{
return (op_meta)
{
.op = op,
.lit_id[0] = lit_id1,
.lit_id[1] = lit_id2,
.lit_id[2] = lit_id3
};
op_meta ret;
ret.op = op;
ret.lit_id[0] = lit_id1;
ret.lit_id[1] = lit_id2;
ret.lit_id[2] = lit_id3;
return ret;
}
static op_meta
@ -222,11 +223,12 @@ create_op_meta_111 (opcode_t op, literal_index_t lit_id1, literal_index_t lit_id
static operand
tmp_operand (void)
{
return (operand)
{
.type = OPERAND_TMP,
.data.uid = next_temp_name ()
};
operand ret;
ret.type = OPERAND_TMP;
ret.data.uid = next_temp_name ();
return ret;
}
static uint8_t
@ -641,20 +643,24 @@ create_operand_from_tmp_and_lit (idx_t tmp, literal_index_t lit_id)
if (tmp != LITERAL_TO_REWRITE)
{
JERRY_ASSERT (lit_id == NOT_A_LITERAL);
return (operand)
{
.type = OPERAND_TMP,
.data.uid = tmp
};
operand ret;
ret.type = OPERAND_TMP;
ret.data.uid = tmp;
return ret;
}
else
{
JERRY_ASSERT (lit_id != NOT_A_LITERAL);
return (operand)
{
.type = OPERAND_LITERAL,
.data.lit_id = lit_id
};
operand ret;
ret.type = OPERAND_LITERAL;
ret.data.lit_id = lit_id;
return ret;
}
}
@ -697,21 +703,23 @@ get_diff_from (opcode_counter_t oc)
operand
empty_operand (void)
{
return (operand)
{
.type = OPERAND_TMP,
.data.uid = INVALID_VALUE
};
operand ret;
ret.type = OPERAND_TMP;
ret.data.uid = INVALID_VALUE;
return ret;
}
operand
literal_operand (literal_index_t lit_id)
{
return (operand)
{
.type = OPERAND_LITERAL,
.data.lit_id = lit_id
};
operand ret;
ret.type = OPERAND_LITERAL;
ret.data.lit_id = lit_id;
return ret;
}
bool
@ -1233,7 +1241,7 @@ rewrite_function_end (varg_list_type vlt)
void
dump_this (operand op)
{
dump_single_address (getop_this, op);
dump_single_address (getop_this_binding, op);
}
operand
@ -2271,7 +2279,7 @@ void
dump_try_for_rewrite (void)
{
STACK_PUSH (tries, serializer_get_current_opcode_counter ());
const opcode_t opcode = getop_try (INVALID_VALUE, INVALID_VALUE);
const opcode_t opcode = getop_try_block (INVALID_VALUE, INVALID_VALUE);
serializer_dump_op_meta (create_op_meta_000 (opcode));
}
@ -2279,11 +2287,11 @@ void
rewrite_try (void)
{
op_meta try_op_meta = deserialize_op_meta (STACK_TOP (tries));
JERRY_ASSERT (try_op_meta.op.op_idx == OPCODE (try));
JERRY_ASSERT (try_op_meta.op.op_idx == OPCODE (try_block));
idx_t id1, id2;
split_opcode_counter (get_diff_from (STACK_TOP (tries)), &id1, &id2);
try_op_meta.op.data.try.oc_idx_1 = id1;
try_op_meta.op.data.try.oc_idx_2 = id2;
try_op_meta.op.data.try_block.oc_idx_1 = id1;
try_op_meta.op.data.try_block.oc_idx_2 = id2;
serializer_rewrite_op_meta (STACK_TOP (tries), try_op_meta);
STACK_DROP (tries, 1);
}
@ -2346,7 +2354,7 @@ dump_end_try_catch_finally (void)
void
dump_throw (operand op)
{
dump_single_address (getop_throw, op);
dump_single_address (getop_throw_value, op);
}
bool

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -91,7 +91,7 @@ must_be_inside_but_not_in (uint8_t not_in, uint8_t insides_count, ...)
}
va_start (insides_list, insides_count);
uint8_t *insides = mem_heap_alloc_block (insides_count, MEM_HEAP_ALLOC_SHORT_TERM);
uint8_t *insides = (uint8_t*) mem_heap_alloc_block (insides_count, MEM_HEAP_ALLOC_SHORT_TERM);
for (uint8_t i = 0; i < insides_count; i++)
{
insides[i] = (uint8_t) va_arg (insides_list, int);
@ -232,7 +232,7 @@ parse_property_name (void)
}
case TOK_KEYWORD:
{
const literal lit = create_literal_from_str_compute_len (lexer_keyword_to_string (token_data ()));
const literal lit = create_literal_from_str_compute_len (lexer_keyword_to_string ((keyword) token_data ()));
lexer_add_literal_if_not_present (lit);
const literal_index_t lit_id = lexer_lookup_literal_uid (lit);
return literal_operand (lit_id);
@ -268,71 +268,73 @@ parse_property_assignment (void)
{
STACK_DECLARE_USAGE (nestings);
if (!token_is (TOK_NAME))
if (token_is (TOK_NAME))
{
bool is_setter;
if (literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "get"))
{
is_setter = false;
}
else if (literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "set"))
{
is_setter = true;
}
else
{
parse_property_name_and_value ();
goto cleanup;
}
const token temp = tok;
skip_newlines ();
if (token_is (TOK_COLON))
{
lexer_save_token (tok);
tok = temp;
parse_property_name_and_value ();
goto cleanup;
}
const operand name = parse_property_name ();
syntax_add_prop_name (name, is_setter ? PROP_SET : PROP_GET);
skip_newlines ();
const operand func = parse_argument_list (VARG_FUNC_EXPR, name, NULL, NULL);
dump_function_end_for_rewrite ();
const bool is_strict = scopes_tree_strict_mode (STACK_TOP (scopes));
scopes_tree_set_strict_mode (STACK_TOP (scopes), false);
token_after_newlines_must_be (TOK_OPEN_BRACE);
skip_newlines ();
push_nesting (NESTING_FUNCTION);
parse_source_element_list (false);
pop_nesting (NESTING_FUNCTION);
token_after_newlines_must_be (TOK_CLOSE_BRACE);
scopes_tree_set_strict_mode (STACK_TOP (scopes), is_strict);
dump_ret ();
rewrite_function_end (VARG_FUNC_EXPR);
if (is_setter)
{
dump_prop_setter_decl (name, func);
}
else
{
dump_prop_getter_decl (name, func);
}
}
else
{
parse_property_name_and_value ();
goto cleanup;
}
bool is_setter;
if (literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "get"))
{
is_setter = false;
}
else if (literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "set"))
{
is_setter = true;
}
else
{
goto simple_prop;
}
const token temp = tok;
skip_newlines ();
if (token_is (TOK_COLON))
{
lexer_save_token (tok);
tok = temp;
goto simple_prop;
}
const operand name = parse_property_name ();
syntax_add_prop_name (name, is_setter ? PROP_SET : PROP_GET);
skip_newlines ();
const operand func = parse_argument_list (VARG_FUNC_EXPR, name, NULL, NULL);
dump_function_end_for_rewrite ();
const bool is_strict = scopes_tree_strict_mode (STACK_TOP (scopes));
scopes_tree_set_strict_mode (STACK_TOP (scopes), false);
token_after_newlines_must_be (TOK_OPEN_BRACE);
skip_newlines ();
push_nesting (NESTING_FUNCTION);
parse_source_element_list (false);
pop_nesting (NESTING_FUNCTION);
token_after_newlines_must_be (TOK_CLOSE_BRACE);
scopes_tree_set_strict_mode (STACK_TOP (scopes), is_strict);
dump_ret ();
rewrite_function_end (VARG_FUNC_EXPR);
if (is_setter)
{
dump_prop_setter_decl (name, func);
}
else
{
dump_prop_getter_decl (name, func);
}
goto cleanup;
simple_prop:
parse_property_name_and_value ();
cleanup:
STACK_CHECK_USAGE (nestings);
}
@ -744,7 +746,7 @@ parse_member_expression (operand *this_arg, operand *prop_gl)
}
else if (token_is (TOK_KEYWORD))
{
const literal lit = create_literal_from_str_compute_len (lexer_keyword_to_string (token_data ()));
const literal lit = create_literal_from_str_compute_len (lexer_keyword_to_string ((keyword) token_data ()));
const literal_index_t lit_id = lexer_lookup_literal_uid (lit);
if (lit_id == INVALID_LITERAL)
{

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -160,12 +160,12 @@ change_uid (op_meta *om, lit_id_hash_table *lit_ids, uint16_t mask)
{
JERRY_ASSERT (om->lit_id[i] != NOT_A_LITERAL);
literal_index_t lit_id = om->lit_id[i];
idx_t *uid = hash_table_lookup (lit_id_to_uid, &lit_id);
idx_t *uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
if (uid == NULL)
{
hash_table_insert (lit_id_to_uid, &lit_id, &next_uid);
lit_id_hash_table_insert (lit_ids, next_uid, global_oc, lit_id);
uid = hash_table_lookup (lit_id_to_uid, &lit_id);
uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
JERRY_ASSERT (uid != NULL);
JERRY_ASSERT (*uid == next_uid);
next_uid++;
@ -195,11 +195,11 @@ insert_uids_to_lit_id_map (op_meta *om, uint16_t mask)
{
JERRY_ASSERT (om->lit_id[i] != NOT_A_LITERAL);
literal_index_t lit_id = om->lit_id[i];
idx_t *uid = hash_table_lookup (lit_id_to_uid, &lit_id);
idx_t *uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
if (uid == NULL)
{
hash_table_insert (lit_id_to_uid, &lit_id, &next_uid);
uid = hash_table_lookup (lit_id_to_uid, &lit_id);
uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id);
JERRY_ASSERT (uid != NULL);
JERRY_ASSERT (*uid == next_uid);
next_uid++;
@ -307,9 +307,9 @@ generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table
case OPCODE (func_decl_n):
case OPCODE (array_decl):
case OPCODE (obj_decl):
case OPCODE (this):
case OPCODE (this_binding):
case OPCODE (with):
case OPCODE (throw):
case OPCODE (throw_value):
case OPCODE (is_true_jmp_up):
case OPCODE (is_true_jmp_down):
case OPCODE (is_false_jmp_up):
@ -322,7 +322,7 @@ generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table
}
case OPCODE (exitval):
case OPCODE (ret):
case OPCODE (try):
case OPCODE (try_block):
case OPCODE (jmp_up):
case OPCODE (jmp_down):
case OPCODE (nop):
@ -446,9 +446,9 @@ count_new_literals_in_opcode (scopes_tree tree, opcode_counter_t opc_index)
case OPCODE (func_decl_n):
case OPCODE (array_decl):
case OPCODE (obj_decl):
case OPCODE (this):
case OPCODE (this_binding):
case OPCODE (with):
case OPCODE (throw):
case OPCODE (throw_value):
case OPCODE (is_true_jmp_up):
case OPCODE (is_true_jmp_down):
case OPCODE (is_false_jmp_up):
@ -461,7 +461,7 @@ count_new_literals_in_opcode (scopes_tree tree, opcode_counter_t opc_index)
}
case OPCODE (exitval):
case OPCODE (ret):
case OPCODE (try):
case OPCODE (try_block):
case OPCODE (jmp_up):
case OPCODE (jmp_down):
case OPCODE (nop):

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -42,11 +42,12 @@ STATIC_STACK (U8, uint8_t)
static prop_literal
create_prop_literal (literal lit, prop_type type)
{
return (prop_literal)
{
.type = type,
.lit = lit
};
prop_literal ret;
ret.type = type;
ret.lit = lit;
return ret;
}
void

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,16 +33,16 @@ typedef struct
}
lit_id_table_key;
struct
typedef struct
{
const literal *literals;
const opcode_t *opcodes;
lit_id_hash_table *lit_id_hash;
literal_index_t literals_count;
opcode_counter_t opcodes_count;
}
bytecode_data;
} bytecode_data_t;
scopes_tree current_scope;
extern bytecode_data_t bytecode_data;
extern scopes_tree current_scope;
#endif // BYTECODE_DATA_H

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@
#define __OPCODE_SIZE(name, arg1, arg2, arg3) \
sizeof (__op_##name) + 1,
static char* opcode_names[] =
static const char* opcode_names[] =
{
OP_LIST (OPCODE_STR)
""
@ -268,7 +268,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
PP_OP (post_decr, "%s = %s--;");
PP_OP (pre_incr, "%s = ++%s;");
PP_OP (pre_decr, "%s = --%s;");
PP_OP (throw, "throw %s;");
PP_OP (throw_value, "throw %s;");
PP_OP (reg_var_decl, "var %s .. %s;");
PP_OP (var_decl, "var %s;");
PP_OP (nop, ";");
@ -277,7 +277,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
PP_OP (ret, "ret;");
PP_OP (prop_getter, "%s = %s[%s];");
PP_OP (prop_setter, "%s[%s] = %s;");
PP_OP (this, "%s = this;");
PP_OP (this_binding, "%s = this;");
PP_OP (delete_var, "%s = delete %s;");
PP_OP (delete_prop, "%s = delete %s.%s;");
PP_OP (typeof, "%s = typeof %s;");
@ -288,7 +288,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
case NAME_TO_ID (is_false_jmp_down): __printf ("if (%s == false) goto %d;", VAR (1), oc + OC (2, 3)); break;
case NAME_TO_ID (jmp_up): __printf ("goto %d;", oc - OC (1, 2)); break;
case NAME_TO_ID (jmp_down): __printf ("goto %d;", oc + OC (1, 2)); break;
case NAME_TO_ID (try): __printf ("try (end: %d);", oc + OC (1, 2)); break;
case NAME_TO_ID (try_block): __printf ("try (end: %d);", oc + OC (1, 2)); break;
case NAME_TO_ID (assignment):
{
__printf ("%s = ", VAR (1));

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,9 @@
#include "deserializer.h"
#include "pretty-printer.h"
bytecode_data_t bytecode_data;
scopes_tree current_scope;
static bool print_opcodes;
void
@ -114,14 +117,14 @@ serializer_print_opcodes (void)
for (loc = 0; loc < bytecode_data.opcodes_count; loc++)
{
const op_meta opm = (op_meta)
op_meta opm;
opm.op = bytecode_data.opcodes[loc];
for (int i = 0; i < 3; i++)
{
.op = bytecode_data.opcodes[loc],
.lit_id =
{
NOT_A_LITERAL
}
};
opm.lit_id [i] = NOT_A_LITERAL;
}
pp_op_meta (loc, opm, false);
}
#endif

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,17 +22,17 @@
/**
* memcpy alias to __memcpy (for compiler usage)
*/
extern void *memcpy (void *s1, const void*s2, size_t n);
extern "C" void *memcpy (void *s1, const void*s2, size_t n);
/**
* memset alias to __memset (for compiler usage)
*/
extern void *memset (void *s, int c, size_t n);
extern "C" void *memset (void *s, int c, size_t n);
/**
* memmove alias to __memmove (for compiler usage)
*/
extern void *memmove (void *s1, const void*s2, size_t n);
extern "C" void *memmove (void *s1, const void*s2, size_t n);
#ifdef __GNUC__
/*
@ -50,9 +50,10 @@ CALL_PRAGMA(GCC optimize ("-fno-tree-loop-distribute-patterns"))
/**
* memcpy alias to __memcpy (for compiler usage)
*/
void* memcpy (void *s1, /**< destination */
const void* s2, /**< source */
size_t n) /**< bytes number */
void* __used
memcpy (void *s1, /**< destination */
const void* s2, /**< source */
size_t n) /**< bytes number */
{
return __memcpy (s1, s2, n);
} /* memcpy */
@ -60,9 +61,10 @@ void* memcpy (void *s1, /**< destination */
/**
* memset alias to __memset (for compiler usage)
*/
void* memset (void *s, /**< area to set values in */
int c, /**< value to set */
size_t n) /**< area size */
void* __used
memset (void *s, /**< area to set values in */
int c, /**< value to set */
size_t n) /**< area size */
{
return __memset (s, c, n);
} /* memset */
@ -70,9 +72,10 @@ void* memset (void *s, /**< area to set values in */
/**
* memmove alias to __memmove (for compiler usage)
*/
void* memmove (void *s1, /**< destination*/
const void*s2, /**< source */
size_t n) /**< area size */
void* __used
memmove (void *s1, /**< destination*/
const void*s2, /**< source */
size_t n) /**< area size */
{
return __memmove (s1, s2, n);
} /* memmove */
@ -87,16 +90,14 @@ CALL_PRAGMA(GCC diagnostic pop)
* but referenced from third-party libraries.
*/
#define JRT_UNREACHABLE_STUB_FOR(...) \
extern __VA_ARGS__; \
extern "C" __VA_ARGS__; \
__used __VA_ARGS__ \
{ \
JERRY_UNREACHABLE (); \
}
JRT_UNREACHABLE_STUB_FOR(void abort (void))
JRT_UNREACHABLE_STUB_FOR(int raise (int sig_no __unused))
#ifdef __TARGET_HOST_ARMv7
JRT_UNREACHABLE_STUB_FOR(void __aeabi_unwind_cpp_pr0 (void))
#endif /* __TARGET_HOST_ARMv7 */
#undef JRT_UNREACHABLE_STUB_FOR
@ -110,10 +111,10 @@ __memset (void *s, /**< area to set values in */
int c, /**< value to set */
size_t n) /**< area size */
{
uint8_t *area_p = s;
uint8_t *area_p = (uint8_t *) s;
for (size_t index = 0; index < n; index++)
{
area_p[ index ] = (uint8_t)c;
area_p[ index ] = (uint8_t) c;
}
return s;
@ -131,7 +132,7 @@ __memcmp (const void *s1, /**< first area */
const void *s2, /**< second area */
size_t n) /**< area size */
{
const uint8_t *area1_p = s1, *area2_p = s2;
const uint8_t *area1_p = (uint8_t *) s1, *area2_p = (uint8_t *) s2;
for (size_t index = 0; index < n; index++)
{
if (area1_p[ index ] < area2_p[ index ])
@ -155,8 +156,8 @@ __memcpy (void *s1, /**< destination */
const void *s2, /**< source */
size_t n) /**< bytes number */
{
uint8_t *area1_p = s1;
const uint8_t *area2_p = s2;
uint8_t *area1_p = (uint8_t *) s1;
const uint8_t *area2_p = (const uint8_t *) s2;
for (size_t index = 0; index < n; index++)
{
@ -176,8 +177,8 @@ __memmove (void *s1, /**< destination */
const void *s2, /**< source */
size_t n) /**< bytes number */
{
uint8_t *dest_p = s1;
const uint8_t *src_p = s2;
uint8_t *dest_p = (uint8_t *) s1;
const uint8_t *src_p = (const uint8_t *) s2;
if (dest_p < src_p)
{ /* from begin to end */

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ extern void* __memcpy (void *s1, const void *s2, size_t n);
extern void* __memmove (void *dest, const void *src, size_t n);
extern int __printf (const char *format, ...);
extern int __putchar (int);
extern void __noreturn __exit (int);
extern "C" void __noreturn __exit (int);
extern int __strcmp (const char *, const char *);
extern int __strncmp (const char *, const char *, size_t);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -60,9 +60,12 @@ static long int syscall_1 (long int syscall_no, long int arg1);
static long int syscall_2 (long int syscall_no, long int arg1, long int arg2);
static long int syscall_3 (long int syscall_no, long int arg1, long int arg2, long int arg3);
extern long int syscall_1_asm (long int syscall_no, long int arg1);
extern long int syscall_2_asm (long int syscall_no, long int arg1, long int arg2);
extern long int syscall_3_asm (long int syscall_no, long int arg1, long int arg2, long int arg3);
extern "C"
{
extern long int syscall_1_asm (long int syscall_no, long int arg1);
extern long int syscall_2_asm (long int syscall_no, long int arg1, long int arg2);
extern long int syscall_3_asm (long int syscall_no, long int arg1, long int arg2, long int arg3);
}
/**
* System call with one argument.

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ jerry_run (const char *script_source, size_t script_source_size,
parser_init (script_source, script_source_size, is_show_opcodes);
parser_parse_program ();
opcodes = deserialize_bytecode ();
opcodes = (const opcode_t*) deserialize_bytecode ();
optimizer_run_passes ((opcode_t *) opcodes);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,11 +16,14 @@
#include "globals.h"
#include "mem-allocator.h"
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
}
// Heap size is 32K
#define test_heap_size (32 * 1024)
@ -101,7 +104,9 @@ main( int __unused argc,
for ( uint32_t j = 0; j < test_sub_iters; j++ )
{
size_t size = (unsigned int) rand() % ( test_threshold_block_size );
ptrs[j] = mem_heap_alloc_block( size, ( rand() % 2 ) ? MEM_HEAP_ALLOC_SHORT_TERM : MEM_HEAP_ALLOC_SHORT_TERM);
ptrs[j] = (uint8_t*) mem_heap_alloc_block (size,
(rand() % 2) ?
MEM_HEAP_ALLOC_SHORT_TERM : MEM_HEAP_ALLOC_SHORT_TERM);
sizes[j] = size;
JERRY_ASSERT(size == 0 || ptrs[j] != NULL);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,11 +20,14 @@
#include "mem-pool.h"
#include "mem-poolman.h"
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
}
// Iterations count
const uint32_t test_iters = 64;
@ -32,6 +35,11 @@ const uint32_t test_iters = 64;
// Subiterations count
const uint32_t test_max_sub_iters = 1024;
#define TEST_POOL_SPACE_SIZE (sizeof (mem_pool_state_t) + (1ull << MEM_POOL_MAX_CHUNKS_NUMBER_LOG) * MEM_POOL_CHUNK_SIZE)
uint8_t test_pool [TEST_POOL_SPACE_SIZE] __attribute__((aligned(MEM_ALIGNMENT)));
uint8_t* ptrs[test_max_sub_iters];
int
main( int __unused argc,
char __unused **argv)
@ -43,13 +51,13 @@ main( int __unused argc,
for ( uint32_t i = 0; i < test_iters; i++ )
{
uint8_t test_pool[MEM_POOL_SIZE] __attribute__((aligned(MEM_ALIGNMENT)));
mem_pool_state_t* pool_p = (mem_pool_state_t*) test_pool;
mem_pool_init( pool_p, MEM_POOL_SIZE);
JERRY_ASSERT (MEM_POOL_SIZE <= TEST_POOL_SPACE_SIZE);
mem_pool_init (pool_p, MEM_POOL_SIZE);
const size_t subiters = ( (size_t) rand() % test_max_sub_iters ) + 1;
uint8_t* ptrs[subiters];
for ( size_t j = 0; j < subiters; j++ )
{

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,9 +25,12 @@
#include "mem-pool.h"
#include "mem-poolman.h"
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
}
// Iterations count
const uint32_t test_iters = 16384;
@ -35,6 +38,8 @@ const uint32_t test_iters = 16384;
// Subiterations count
const uint32_t test_max_sub_iters = 32;
uint8_t *ptrs[test_max_sub_iters];
int
main( int __unused argc,
char __unused **argv)
@ -50,7 +55,6 @@ main( int __unused argc,
{
const size_t subiters = ( (size_t) rand() % test_max_sub_iters ) + 1;
uint8_t *ptrs[subiters];
for ( size_t j = 0; j < subiters; j++ )
{
ptrs[j] = mem_pools_alloc();

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,13 +37,15 @@ main( int __unused argc,
parser_parse_program ();
parser_free ();
if (!opcodes_equal(deserialize_bytecode (), (opcode_t[]) {
[0] = getop_reg_var_decl (128, 129), // var tmp128 .. tmp129;
[1] = getop_var_decl (0), // var a;
[2] = getop_assignment (129, 1, 1), // tmp129 = 1: SMALLINT;
[3] = getop_assignment (0, 6, 129), // a = tmp129 : TYPEOF(tmp129);
[4] = getop_exitval (0) // exit 0;
}, 5))
opcode_t opcodes[] = {
getop_reg_var_decl (128, 129), // var tmp128 .. tmp129;
getop_var_decl (0), // var a;
getop_assignment (129, 1, 1), // tmp129 = 1: SMALLINT;
getop_assignment (0, 6, 129), // a = tmp129 : TYPEOF(tmp129);
getop_exitval (0) // exit 0;
};
if (!opcodes_equal((const opcode_t *) deserialize_bytecode (), opcodes, 5))
{
is_ok = false;
}