New Allocator and improved String handling.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2016-02-11 14:46:08 +01:00
parent 3d6339bbf4
commit d47c36f1b4
45 changed files with 1383 additions and 4288 deletions
+4 -4
View File
@@ -52,11 +52,11 @@
/* Malloc functions. */
#define PARSER_MALLOC(size) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_LONG_TERM)
#define PARSER_FREE(ptr) mem_heap_free_block ((void *) ptr)
#define PARSER_MALLOC(size) mem_heap_alloc_block_store_size (size)
#define PARSER_FREE(ptr) mem_heap_free_block_size_stored ((void *) ptr)
#define PARSER_MALLOC_LOCAL(size) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_SHORT_TERM)
#define PARSER_FREE_LOCAL(ptr) mem_heap_free_block (ptr)
#define PARSER_MALLOC_LOCAL(size) mem_heap_alloc_block_store_size (size)
#define PARSER_FREE_LOCAL(ptr) mem_heap_free_block_size_stored (ptr)
/* UTF character management. Only ASCII characters are
* supported for simplicity. */
+2 -2
View File
@@ -1566,13 +1566,13 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
num = -num;
}
lit_cp = rcs_cpointer_compress (lit_find_or_create_literal_from_num (num));
lit_cp = lit_cpointer_compress (lit_find_or_create_literal_from_num (num));
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
while ((literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
{
if (literal_p->type == LEXER_NUMBER_LITERAL
&& literal_p->u.value.u.value.base_cp == lit_cp.u.value.base_cp)
&& literal_p->u.value == lit_cp)
{
context_p->lit_object.literal_p = literal_p;
context_p->lit_object.index = (uint16_t) literal_index;
+8 -7
View File
@@ -18,6 +18,7 @@
#include "jerry-snapshot.h"
#include "js-parser-internal.h"
#include "lit-literal.h"
#include "lit-cpointer.h"
#ifdef PARSER_DUMP_BYTE_CODE
static int parser_show_instrs = PARSER_FALSE;
@@ -100,7 +101,7 @@ parser_compute_indicies (parser_context_t *context_p, /**< context */
{
lit_literal_t lit = lit_find_or_create_literal_from_utf8_string (char_p,
literal_p->prop.length);
literal_p->u.value = rcs_cpointer_compress (lit);
literal_p->u.value = lit_cpointer_compress (lit);
if (!(literal_p->status_flags & LEXER_FLAG_SOURCE_PTR))
{
@@ -521,7 +522,7 @@ parser_generate_initializers (parser_context_t *context_p, /**< context */
#ifdef PARSER_DUMP_BYTE_CODE
lit_literal_t lit = lit_find_or_create_literal_from_utf8_string (literal_p->u.char_p,
literal_p->prop.length);
literal_pool_p[literal_p->prop.index] = rcs_cpointer_compress (lit);
literal_pool_p[literal_p->prop.index] = lit_cpointer_compress (lit);
if (!context_p->is_show_opcodes
&& !(literal_p->status_flags & LEXER_FLAG_SOURCE_PTR))
@@ -535,7 +536,7 @@ parser_generate_initializers (parser_context_t *context_p, /**< context */
else if ((literal_p->type == LEXER_FUNCTION_LITERAL)
|| (literal_p->type == LEXER_REGEXP_LITERAL))
{
ECMA_SET_NON_NULL_POINTER (literal_pool_p[literal_p->prop.index].u.value.base_cp,
ECMA_SET_NON_NULL_POINTER (literal_pool_p[literal_p->prop.index],
literal_p->u.bytecode_p);
}
else
@@ -579,7 +580,7 @@ parser_generate_initializers (parser_context_t *context_p, /**< context */
JERRY_ASSERT (literal_p != NULL
&& literal_p->type == LEXER_FUNCTION_LITERAL);
init_index = literal_p->prop.index;
ECMA_SET_NON_NULL_POINTER (literal_pool_p[literal_p->prop.index].u.value.base_cp,
ECMA_SET_NON_NULL_POINTER (literal_pool_p[literal_p->prop.index],
literal_p->u.bytecode_p);
}
@@ -1723,7 +1724,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
const uint8_t *char_p = context_p->source_end_p - (source_data & 0xfffff);
lit_literal_t lit = lit_find_or_create_literal_from_utf8_string (char_p,
source_data >> 20);
literal_pool_p[literal_p->prop.index] = rcs_cpointer_compress (lit);
literal_pool_p[literal_p->prop.index] = lit_cpointer_compress (lit);
}
}
}
@@ -1753,7 +1754,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
{
if (literal_p->u.char_p == NULL)
{
literal_pool_p[argument_count] = rcs_cpointer_null_cp ();
literal_pool_p[argument_count] = lit_cpointer_null_cp ();
argument_count++;
continue;
}
@@ -1775,7 +1776,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
if (context_p->status_flags & PARSER_NAMED_FUNCTION_EXP)
{
ECMA_SET_NON_NULL_POINTER (literal_pool_p[const_literal_end].u.value.base_cp,
ECMA_SET_NON_NULL_POINTER (literal_pool_p[const_literal_end],
compiled_code_p);
}
+7 -7
View File
@@ -72,12 +72,12 @@ re_realloc_regexp_bytecode_block (re_bytecode_ctx_t *bc_ctx_p) /**< RegExp bytec
JERRY_ASSERT (bc_ctx_p->current_p >= bc_ctx_p->block_start_p);
size_t current_ptr_offset = (size_t) (bc_ctx_p->current_p - bc_ctx_p->block_start_p);
uint8_t *new_block_start_p = (uint8_t *) mem_heap_alloc_block (new_block_size,
MEM_HEAP_ALLOC_SHORT_TERM);
uint8_t *new_block_start_p = (uint8_t *) mem_heap_alloc_block_store_size (new_block_size);
if (bc_ctx_p->current_p)
{
memcpy (new_block_start_p, bc_ctx_p->block_start_p, (size_t) (current_ptr_offset));
mem_heap_free_block (bc_ctx_p->block_start_p);
mem_heap_free_block_size_stored (bc_ctx_p->block_start_p);
}
bc_ctx_p->block_start_p = new_block_start_p;
bc_ctx_p->block_end_p = new_block_start_p + new_block_size;
@@ -128,11 +128,11 @@ re_bytecode_list_insert (re_bytecode_ctx_t *bc_ctx_p, /**< RegExp bytecode conte
{
uint8_t *dest_p = src_p + length;
uint8_t *tmp_block_start_p;
tmp_block_start_p = (uint8_t *) mem_heap_alloc_block ((re_get_bytecode_length (bc_ctx_p) - offset),
MEM_HEAP_ALLOC_SHORT_TERM);
tmp_block_start_p = (uint8_t *) mem_heap_alloc_block_store_size (re_get_bytecode_length (bc_ctx_p) - offset);
memcpy (tmp_block_start_p, src_p, (size_t) (re_get_bytecode_length (bc_ctx_p) - offset));
memcpy (dest_p, tmp_block_start_p, (size_t) (re_get_bytecode_length (bc_ctx_p) - offset));
mem_heap_free_block (tmp_block_start_p);
mem_heap_free_block_size_stored (tmp_block_start_p);
}
memcpy (src_p, bytecode_p, length);
@@ -698,7 +698,7 @@ re_compile_bytecode (re_compiled_code_t **out_bytecode_p, /**< out:pointer to by
if (!ecma_is_value_empty (ret_value))
{
/* Compilation failed, free bytecode. */
mem_heap_free_block (bc_ctx.block_start_p);
mem_heap_free_block_size_stored (bc_ctx.block_start_p);
*out_bytecode_p = NULL;
}
else