Parser refactoring. Remove deserializer notion.

This commit is contained in:
Andrey Shitov
2015-04-07 13:05:09 +03:00
parent 469ef4e622
commit 7c67606b00
21 changed files with 176 additions and 317 deletions
+6 -6
View File
@@ -20,7 +20,6 @@
* @{ * @{
*/ */
#include "deserializer.h"
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
@@ -28,6 +27,7 @@
#include "ecma-lcache.h" #include "ecma-lcache.h"
#include "jrt.h" #include "jrt.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "serializer.h"
#include "vm.h" #include "vm.h"
/** /**
@@ -309,7 +309,7 @@ ecma_init_ecma_string_from_lit_index (ecma_string_t *string_p, /**< descriptor t
JERRY_ASSERT (is_stack_var == (!mem_is_heap_pointer (string_p))); JERRY_ASSERT (is_stack_var == (!mem_is_heap_pointer (string_p)));
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
const literal lit = deserialize_literal_by_id (lit_index); const literal lit = serializer_get_literal_by_id (lit_index);
if (lit.type == LIT_MAGIC_STR) if (lit.type == LIT_MAGIC_STR)
{ {
ecma_init_ecma_string_from_magic_string_id (string_p, ecma_init_ecma_string_from_magic_string_id (string_p,
@@ -903,7 +903,7 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d
} }
case ECMA_STRING_CONTAINER_LIT_TABLE: case ECMA_STRING_CONTAINER_LIT_TABLE:
{ {
const literal lit = deserialize_literal_by_id (string_desc_p->u.lit_index); const literal lit = serializer_get_literal_by_id (string_desc_p->u.lit_index);
JERRY_ASSERT (lit.type == LIT_STR); JERRY_ASSERT (lit.type == LIT_STR);
const ecma_char_t *str_p = literal_to_zt (lit); const ecma_char_t *str_p = literal_to_zt (lit);
JERRY_ASSERT (str_p != NULL); JERRY_ASSERT (str_p != NULL);
@@ -1189,7 +1189,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
if (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE) if (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
{ {
const literal lit = deserialize_literal_by_id (string1_p->u.lit_index); const literal lit = serializer_get_literal_by_id (string1_p->u.lit_index);
JERRY_ASSERT (lit.type == LIT_STR); JERRY_ASSERT (lit.type == LIT_STR);
zt_string1_p = literal_to_zt (lit); zt_string1_p = literal_to_zt (lit);
} }
@@ -1224,7 +1224,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
if (string2_p->container == ECMA_STRING_CONTAINER_LIT_TABLE) if (string2_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
{ {
const literal lit = deserialize_literal_by_id (string2_p->u.lit_index); const literal lit = serializer_get_literal_by_id (string2_p->u.lit_index);
JERRY_ASSERT (lit.type == LIT_STR); JERRY_ASSERT (lit.type == LIT_STR);
zt_string2_p = literal_to_zt (lit); zt_string2_p = literal_to_zt (lit);
} }
@@ -1286,7 +1286,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
if (container == ECMA_STRING_CONTAINER_LIT_TABLE) if (container == ECMA_STRING_CONTAINER_LIT_TABLE)
{ {
const literal lit = deserialize_literal_by_id (string_p->u.lit_index); const literal lit = serializer_get_literal_by_id (string_p->u.lit_index);
return lit.data.lp.length; return lit.data.lp.length;
} }
+3 -4
View File
@@ -15,7 +15,6 @@
#include <stdio.h> #include <stdio.h>
#include "deserializer.h"
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-extension.h" #include "ecma-extension.h"
@@ -762,7 +761,7 @@ jerry_init (jerry_flag_t flags) /**< combination of Jerry flags */
#endif /* !MEM_STATS */ #endif /* !MEM_STATS */
mem_init (); mem_init ();
deserializer_init (); serializer_init ();
ecma_init (); ecma_init ();
} /* jerry_init */ } /* jerry_init */
@@ -779,7 +778,7 @@ jerry_cleanup (void)
bool is_show_mem_stats = ((jerry_flags & JERRY_FLAG_MEM_STATS) != 0); bool is_show_mem_stats = ((jerry_flags & JERRY_FLAG_MEM_STATS) != 0);
ecma_finalize (); ecma_finalize ();
deserializer_free (); serializer_free ();
mem_finalize (is_show_mem_stats); mem_finalize (is_show_mem_stats);
} /* jerry_cleanup */ } /* jerry_cleanup */
@@ -838,7 +837,7 @@ jerry_parse (jerry_ctx_t* ctx_p, /**< run context */
parser_init (source_p, source_size, is_show_opcodes); parser_init (source_p, source_size, is_show_opcodes);
parser_parse_program (); parser_parse_program ();
const opcode_t* opcodes = (const opcode_t*) deserialize_bytecode (); const opcode_t* opcodes = (const opcode_t*) serializer_get_bytecode ();
serializer_print_opcodes (); serializer_print_opcodes ();
parser_free (); parser_free ();
@@ -14,9 +14,9 @@
*/ */
#include "lit-id-hash-table.h" #include "lit-id-hash-table.h"
#include "bytecode-data.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "bytecode-data.h"
lit_id_hash_table * lit_id_hash_table *
lit_id_hash_table_init (size_t buckets_count, size_t blocks_count) lit_id_hash_table_init (size_t buckets_count, size_t blocks_count)
-62
View File
@@ -1,62 +0,0 @@
/* Copyright 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef LITERAL_H
#define LITERAL_H
#include "ecma-globals.h"
#include "lp-string.h"
typedef enum __attr_packed___
{
LIT_UNKNOWN,
LIT_STR,
LIT_MAGIC_STR,
LIT_NUMBER
}
literal_type;
typedef struct
{
union
{
ecma_magic_string_id_t magic_str_id;
ecma_number_t num;
lp_string lp;
void *none;
}
data;
literal_type type;
}
literal;
#define LITERAL_TO_REWRITE (INVALID_VALUE - 1)
literal create_empty_literal (void);
literal create_literal_from_num (ecma_number_t);
literal create_literal_from_str (const char *, ecma_length_t);
literal create_literal_from_str_compute_len (const char *);
literal create_literal_from_zt (const ecma_char_t *, ecma_length_t);
bool literal_equal (literal, literal);
bool literal_equal_s (literal, const char *);
bool literal_equal_zt (literal, const ecma_char_t *);
bool literal_equal_num (literal, ecma_number_t);
bool literal_equal_type (literal, literal);
bool literal_equal_type_s (literal, const char *);
bool literal_equal_type_zt (literal, const ecma_char_t *);
bool literal_equal_type_num (literal, ecma_number_t);
const ecma_char_t *literal_to_zt (literal);
#endif /* LITERAL_H */
-29
View File
@@ -1,29 +0,0 @@
/* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TREE_H
#define TREE_H
#include "linked-list.h"
typedef struct tree_header
{
struct tree_header *parent;
linked_list children;
uint8_t children_num;
}
tree_header;
#endif /* TREE_H */
+14 -14
View File
@@ -17,24 +17,27 @@
#define BYTECODE_DATA_H #define BYTECODE_DATA_H
#include "opcodes.h" #include "opcodes.h"
#include "stack.h"
#include "jrt-libc-includes.h"
#include "literal.h" #include "literal.h"
#include "scopes-tree.h"
#include "lit-id-hash-table.h" #include "lit-id-hash-table.h"
/*
* All literals are kept in the 'literals' array.
* Literal structure doesn't hold real string. All program-specific strings
* are kept in the 'strings_buffer' and literal has pointer to this buffer.
*
* Literal id is its index in 'literals' array of bytecode_data_t structure.
*
* Bytecode, which is kept in the 'opcodes' field, is divided into blocks
* of 'BLOCK_SIZE' operands. Every block has its own numbering of literals.
* Literal uid could be in range [0, 127] in every block.
*
* To map uid to literal id 'lit_id_hash' table is used.
*/
#define BLOCK_SIZE 64 #define BLOCK_SIZE 64
typedef struct typedef struct
{ {
opcode_counter_t oc; const ecma_char_t *strings_buffer;
idx_t uid;
uint8_t reserved;
}
lit_id_table_key;
typedef struct
{
const literal *literals; const literal *literals;
const opcode_t *opcodes; const opcode_t *opcodes;
lit_id_hash_table *lit_id_hash; lit_id_hash_table *lit_id_hash;
@@ -42,7 +45,4 @@ typedef struct
opcode_counter_t opcodes_count; opcode_counter_t opcodes_count;
} bytecode_data_t; } bytecode_data_t;
extern bytecode_data_t bytecode_data;
extern scopes_tree current_scope;
#endif // BYTECODE_DATA_H #endif // BYTECODE_DATA_H
-101
View File
@@ -1,101 +0,0 @@
/* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "deserializer.h"
#include "bytecode-data.h"
#include "ecma-helpers.h"
const ecma_char_t *strings_buffer;
void
deserializer_set_strings_buffer (const ecma_char_t *s)
{
strings_buffer = s;
}
literal
deserialize_literal_by_id (literal_index_t id)
{
JERRY_ASSERT (id != INVALID_LITERAL);
JERRY_ASSERT (id < bytecode_data.literals_count);
return bytecode_data.literals[id];
}
literal_index_t
deserialize_lit_id_by_uid (uint8_t id, opcode_counter_t oc)
{
if (bytecode_data.lit_id_hash == null_hash)
{
return INVALID_LITERAL;
}
return lit_id_hash_table_lookup (bytecode_data.lit_id_hash, id, oc);
}
const void *
deserialize_bytecode (void)
{
JERRY_ASSERT (bytecode_data.opcodes != NULL);
return bytecode_data.opcodes;
}
opcode_t
deserialize_opcode (opcode_counter_t oc)
{
if (bytecode_data.opcodes == NULL)
{
return deserialize_op_meta (oc).op;
}
JERRY_ASSERT (oc < bytecode_data.opcodes_count);
return bytecode_data.opcodes[oc];
}
op_meta
deserialize_op_meta (opcode_counter_t oc)
{
JERRY_ASSERT (current_scope);
return scopes_tree_op_meta (current_scope, oc);
}
uint8_t
deserialize_min_temp (void)
{
return 128;
}
void
deserializer_init (void)
{
bytecode_data.literals = NULL;
strings_buffer = NULL;
bytecode_data.opcodes = NULL;
}
void
deserializer_free (void)
{
if (strings_buffer)
{
mem_heap_free_block ((uint8_t *) strings_buffer);
}
if (bytecode_data.lit_id_hash != NULL)
{
lit_id_hash_table_free (bytecode_data.lit_id_hash);
}
if (bytecode_data.literals != NULL)
{
mem_heap_free_block ((uint8_t *) bytecode_data.literals);
}
mem_heap_free_block ((uint8_t *) bytecode_data.opcodes);
}
-35
View File
@@ -1,35 +0,0 @@
/* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DESERIALIZER_H
#define DESERIALIZER_H
#include "jrt.h"
#include "ecma-globals.h"
#include "opcodes.h"
#include "scopes-tree.h"
#include "literal.h"
void deserializer_init (void);
void deserializer_set_strings_buffer (const ecma_char_t *);
literal deserialize_literal_by_id (literal_index_t);
literal_index_t deserialize_lit_id_by_uid (uint8_t, opcode_counter_t);
const void *deserialize_bytecode (void);
opcode_t deserialize_opcode (opcode_counter_t);
op_meta deserialize_op_meta (opcode_counter_t);
uint8_t deserialize_min_temp (void);
void deserializer_free (void);
#endif //DESERIALIZER_H
+16 -16
View File
@@ -15,13 +15,13 @@
#include "opcodes-dumper.h" #include "opcodes-dumper.h"
#include "serializer.h" #include "serializer.h"
#include "deserializer.h"
#include "jrt.h" #include "jrt.h"
#include "lexer.h" #include "lexer.h"
#include "stack.h" #include "stack.h"
#include "syntax-errors.h" #include "syntax-errors.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "opcodes-native-call.h" #include "opcodes-native-call.h"
#include "serializer.h"
#define MIN_TEMP_NAME 128 #define MIN_TEMP_NAME 128
static idx_t temp_name, max_temp_name; static idx_t temp_name, max_temp_name;
@@ -445,7 +445,7 @@ split_opcode_counter (opcode_counter_t oc, idx_t *id1, idx_t *id2)
static op_meta static op_meta
last_dumped_op_meta (void) last_dumped_op_meta (void)
{ {
return deserialize_op_meta ((opcode_counter_t) (serializer_get_current_opcode_counter () - 1)); return serializer_get_op_meta ((opcode_counter_t) (serializer_get_current_opcode_counter () - 1));
} }
static void static void
@@ -1049,7 +1049,7 @@ dump_varg_header_for_rewrite (varg_list_type vlt, operand obj)
operand operand
rewrite_varg_header_set_args_count (uint8_t args_count) rewrite_varg_header_set_args_count (uint8_t args_count)
{ {
op_meta om = deserialize_op_meta (STACK_TOP (varg_headers)); op_meta om = serializer_get_op_meta (STACK_TOP (varg_headers));
switch (om.op.op_idx) switch (om.op.op_idx)
{ {
case OPCODE (func_expr_n): case OPCODE (func_expr_n):
@@ -1875,7 +1875,7 @@ rewrite_logical_and_checks (void)
{ {
for (uint8_t i = STACK_TOP (U8); i < STACK_SIZE (logical_and_checks); i++) for (uint8_t i = STACK_TOP (U8); i < STACK_SIZE (logical_and_checks); i++)
{ {
op_meta jmp_op_meta = deserialize_op_meta (STACK_ELEMENT (logical_and_checks, i)); op_meta jmp_op_meta = serializer_get_op_meta (STACK_ELEMENT (logical_and_checks, i));
JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_false_jmp_down)); JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_false_jmp_down));
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter (get_diff_from (STACK_ELEMENT (logical_and_checks, i)), &id1, &id2); split_opcode_counter (get_diff_from (STACK_ELEMENT (logical_and_checks, i)), &id1, &id2);
@@ -1919,7 +1919,7 @@ rewrite_logical_or_checks (void)
{ {
for (uint8_t i = STACK_TOP (U8); i < STACK_SIZE (logical_or_checks); i++) for (uint8_t i = STACK_TOP (U8); i < STACK_SIZE (logical_or_checks); i++)
{ {
op_meta jmp_op_meta = deserialize_op_meta (STACK_ELEMENT (logical_or_checks, i)); op_meta jmp_op_meta = serializer_get_op_meta (STACK_ELEMENT (logical_or_checks, i));
JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_true_jmp_down)); JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_true_jmp_down));
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter (get_diff_from (STACK_ELEMENT (logical_or_checks, i)), &id1, &id2); split_opcode_counter (get_diff_from (STACK_ELEMENT (logical_or_checks, i)), &id1, &id2);
@@ -1955,7 +1955,7 @@ dump_conditional_check_for_rewrite (operand op)
void void
rewrite_conditional_check (void) rewrite_conditional_check (void)
{ {
op_meta jmp_op_meta = deserialize_op_meta (STACK_TOP (conditional_checks)); op_meta jmp_op_meta = serializer_get_op_meta (STACK_TOP (conditional_checks));
JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_false_jmp_down)); JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_false_jmp_down));
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter (get_diff_from (STACK_TOP (conditional_checks)), &id1, &id2); split_opcode_counter (get_diff_from (STACK_TOP (conditional_checks)), &id1, &id2);
@@ -1976,7 +1976,7 @@ dump_jump_to_end_for_rewrite (void)
void void
rewrite_jump_to_end (void) rewrite_jump_to_end (void)
{ {
op_meta jmp_op_meta = deserialize_op_meta (STACK_TOP (jumps_to_end)); op_meta jmp_op_meta = serializer_get_op_meta (STACK_TOP (jumps_to_end));
JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (jmp_down)); JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (jmp_down));
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter (get_diff_from (STACK_TOP (jumps_to_end)), &id1, &id2); split_opcode_counter (get_diff_from (STACK_TOP (jumps_to_end)), &id1, &id2);
@@ -2167,7 +2167,7 @@ rewrite_breaks (void)
{ {
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter ((opcode_counter_t) (break_target - break_oc), &id1, &id2); split_opcode_counter ((opcode_counter_t) (break_target - break_oc), &id1, &id2);
op_meta break_op_meta = deserialize_op_meta (break_oc); op_meta break_op_meta = serializer_get_op_meta (break_oc);
JERRY_ASSERT (break_op_meta.op.op_idx == OPCODE (jmp_down)); JERRY_ASSERT (break_op_meta.op.op_idx == OPCODE (jmp_down));
break_op_meta.op.data.jmp_down.opcode_1 = id1; break_op_meta.op.data.jmp_down.opcode_1 = id1;
break_op_meta.op.data.jmp_down.opcode_2 = id2; break_op_meta.op.data.jmp_down.opcode_2 = id2;
@@ -2189,7 +2189,7 @@ rewrite_continues (void)
{ {
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter ((opcode_counter_t) (continue_target - continue_oc), &id1, &id2); split_opcode_counter ((opcode_counter_t) (continue_target - continue_oc), &id1, &id2);
op_meta continue_op_meta = deserialize_op_meta (continue_oc); op_meta continue_op_meta = serializer_get_op_meta (continue_oc);
JERRY_ASSERT (continue_op_meta.op.op_idx == OPCODE (jmp_down)); JERRY_ASSERT (continue_op_meta.op.op_idx == OPCODE (jmp_down));
continue_op_meta.op.data.jmp_down.opcode_1 = id1; continue_op_meta.op.data.jmp_down.opcode_1 = id1;
continue_op_meta.op.data.jmp_down.opcode_2 = id2; continue_op_meta.op.data.jmp_down.opcode_2 = id2;
@@ -2233,7 +2233,7 @@ rewrite_case_clause (void)
const opcode_counter_t jmp_oc = STACK_ELEMENT (case_clauses, STACK_HEAD (U8, 2)); const opcode_counter_t jmp_oc = STACK_ELEMENT (case_clauses, STACK_HEAD (U8, 2));
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter (get_diff_from (jmp_oc), &id1, &id2); split_opcode_counter (get_diff_from (jmp_oc), &id1, &id2);
op_meta jmp_op_meta = deserialize_op_meta (jmp_oc); op_meta jmp_op_meta = serializer_get_op_meta (jmp_oc);
JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_true_jmp_down)); JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (is_true_jmp_down));
jmp_op_meta.op.data.is_true_jmp_down.opcode_1 = id1; jmp_op_meta.op.data.is_true_jmp_down.opcode_1 = id1;
jmp_op_meta.op.data.is_true_jmp_down.opcode_2 = id2; jmp_op_meta.op.data.is_true_jmp_down.opcode_2 = id2;
@@ -2247,7 +2247,7 @@ rewrite_default_clause (void)
const opcode_counter_t jmp_oc = STACK_TOP (case_clauses); const opcode_counter_t jmp_oc = STACK_TOP (case_clauses);
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter (get_diff_from (jmp_oc), &id1, &id2); split_opcode_counter (get_diff_from (jmp_oc), &id1, &id2);
op_meta jmp_op_meta = deserialize_op_meta (jmp_oc); op_meta jmp_op_meta = serializer_get_op_meta (jmp_oc);
JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (jmp_down)); JERRY_ASSERT (jmp_op_meta.op.op_idx == OPCODE (jmp_down));
jmp_op_meta.op.data.jmp_down.opcode_1 = id1; jmp_op_meta.op.data.jmp_down.opcode_1 = id1;
jmp_op_meta.op.data.jmp_down.opcode_2 = id2; jmp_op_meta.op.data.jmp_down.opcode_2 = id2;
@@ -2286,7 +2286,7 @@ dump_try_for_rewrite (void)
void void
rewrite_try (void) rewrite_try (void)
{ {
op_meta try_op_meta = deserialize_op_meta (STACK_TOP (tries)); op_meta try_op_meta = serializer_get_op_meta (STACK_TOP (tries));
JERRY_ASSERT (try_op_meta.op.op_idx == OPCODE (try_block)); JERRY_ASSERT (try_op_meta.op.op_idx == OPCODE (try_block));
idx_t id1, id2; idx_t id1, id2;
split_opcode_counter (get_diff_from (STACK_TOP (tries)), &id1, &id2); split_opcode_counter (get_diff_from (STACK_TOP (tries)), &id1, &id2);
@@ -2310,7 +2310,7 @@ dump_catch_for_rewrite (operand op)
void void
rewrite_catch (void) rewrite_catch (void)
{ {
op_meta catch_op_meta = deserialize_op_meta (STACK_TOP (catches)); op_meta catch_op_meta = serializer_get_op_meta (STACK_TOP (catches));
JERRY_ASSERT (catch_op_meta.op.op_idx == OPCODE (meta) JERRY_ASSERT (catch_op_meta.op.op_idx == OPCODE (meta)
&& catch_op_meta.op.data.meta.type == OPCODE_META_TYPE_CATCH); && catch_op_meta.op.data.meta.type == OPCODE_META_TYPE_CATCH);
idx_t id1, id2; idx_t id1, id2;
@@ -2332,7 +2332,7 @@ dump_finally_for_rewrite (void)
void void
rewrite_finally (void) rewrite_finally (void)
{ {
op_meta finally_op_meta = deserialize_op_meta (STACK_TOP (finallies)); op_meta finally_op_meta = serializer_get_op_meta (STACK_TOP (finallies));
JERRY_ASSERT (finally_op_meta.op.op_idx == OPCODE (meta) JERRY_ASSERT (finally_op_meta.op.op_idx == OPCODE (meta)
&& finally_op_meta.op.data.meta.type == OPCODE_META_TYPE_FINALLY); && finally_op_meta.op.data.meta.type == OPCODE_META_TYPE_FINALLY);
idx_t id1, id2; idx_t id1, id2;
@@ -2363,7 +2363,7 @@ dumper_variable_declaration_exists (literal_index_t lit_id)
for (opcode_counter_t oc = (opcode_counter_t) (serializer_get_current_opcode_counter () - 1); for (opcode_counter_t oc = (opcode_counter_t) (serializer_get_current_opcode_counter () - 1);
oc > 0; oc--) oc > 0; oc--)
{ {
const op_meta var_decl_op_meta = deserialize_op_meta (oc); const op_meta var_decl_op_meta = serializer_get_op_meta (oc);
if (var_decl_op_meta.op.op_idx != OPCODE (var_decl)) if (var_decl_op_meta.op.op_idx != OPCODE (var_decl))
{ {
break; break;
@@ -2407,7 +2407,7 @@ void
rewrite_reg_var_decl (void) rewrite_reg_var_decl (void)
{ {
opcode_counter_t reg_var_decl_oc = STACK_TOP (reg_var_decls); opcode_counter_t reg_var_decl_oc = STACK_TOP (reg_var_decls);
op_meta opm = deserialize_op_meta (reg_var_decl_oc); op_meta opm = serializer_get_op_meta (reg_var_decl_oc);
JERRY_ASSERT (opm.op.op_idx == OPCODE (reg_var_decl)); JERRY_ASSERT (opm.op.op_idx == OPCODE (reg_var_decl));
opm.op.data.reg_var_decl.max = max_temp_name; opm.op.data.reg_var_decl.max = max_temp_name;
serializer_rewrite_op_meta (reg_var_decl_oc, opm); serializer_rewrite_op_meta (reg_var_decl_oc, opm);
+5 -5
View File
@@ -13,6 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include <stdarg.h>
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "parser.h" #include "parser.h"
#include "opcodes.h" #include "opcodes.h"
@@ -20,13 +22,12 @@
#include "vm.h" #include "vm.h"
#include "stack.h" #include "stack.h"
#include "hash-table.h" #include "hash-table.h"
#include "deserializer.h"
#include "opcodes-native-call.h" #include "opcodes-native-call.h"
#include "scopes-tree.h" #include "scopes-tree.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "syntax-errors.h" #include "syntax-errors.h"
#include "opcodes-dumper.h" #include "opcodes-dumper.h"
#include "stdarg.h" #include "serializer.h"
#define NESTING_ITERATIONAL 1 #define NESTING_ITERATIONAL 1
#define NESTING_SWITCH 2 #define NESTING_SWITCH 2
@@ -2713,7 +2714,7 @@ parser_parse_program (void)
serializer_dump_literals (lexer_get_literals (), lexer_get_literals_count ()); serializer_dump_literals (lexer_get_literals (), lexer_get_literals_count ());
serializer_merge_scopes_into_bytecode (); serializer_merge_scopes_into_bytecode ();
serializer_set_scope (NULL); serializer_set_scope (NULL);
deserializer_set_strings_buffer (lexer_get_strings_cache ()); serializer_set_strings_buffer (lexer_get_strings_cache ());
scopes_tree_free (STACK_TOP (scopes)); scopes_tree_free (STACK_TOP (scopes));
STACK_DROP (scopes, 1); STACK_DROP (scopes, 1);
@@ -2723,7 +2724,7 @@ void
parser_init (const char *source, size_t source_size, bool show_opcodes) parser_init (const char *source, size_t source_size, bool show_opcodes)
{ {
lexer_init (source, source_size, show_opcodes); lexer_init (source, source_size, show_opcodes);
serializer_init (show_opcodes); serializer_set_show_opcodes (show_opcodes);
dumper_init (); dumper_init ();
syntax_init (); syntax_init ();
@@ -2739,6 +2740,5 @@ parser_free (void)
syntax_free (); syntax_free ();
dumper_free (); dumper_free ();
serializer_free ();
lexer_free (); lexer_free ();
} }
+1 -1
View File
@@ -14,10 +14,10 @@
*/ */
#include "scopes-tree.h" #include "scopes-tree.h"
#include "bytecode-data.h"
#include "mem-heap.h" #include "mem-heap.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "lexer.h" #include "lexer.h"
#include "bytecode-data.h"
#define OPCODE(op) (__op__idx_##op) #define OPCODE(op) (__op__idx_##op)
#define HASH_SIZE 128 #define HASH_SIZE 128
+9 -2
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
#ifndef SCOPES_TREE_H #ifndef SCOPES_TREE_H
#define SCOPES_TREE_H #define SCOPES_TREE_H
#include "tree.h"
#include "linked-list.h" #include "linked-list.h"
#include "lexer.h" #include "lexer.h"
#include "ecma-globals.h" #include "ecma-globals.h"
@@ -33,6 +32,14 @@ typedef struct
} }
op_meta; op_meta;
typedef struct tree_header
{
struct tree_header *parent;
linked_list children;
uint8_t children_num;
}
tree_header;
typedef struct typedef struct
{ {
tree_header t; tree_header t;
+78 -7
View File
@@ -13,19 +13,67 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jrt.h"
#include "serializer.h" #include "serializer.h"
#include "bytecode-data.h"
#include "jrt.h"
#include "parser.h" #include "parser.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "bytecode-data.h"
#include "deserializer.h"
#include "pretty-printer.h" #include "pretty-printer.h"
bytecode_data_t bytecode_data; static bytecode_data_t bytecode_data;
scopes_tree current_scope; static scopes_tree current_scope;
static bool print_opcodes; static bool print_opcodes;
op_meta
serializer_get_op_meta (opcode_counter_t oc)
{
JERRY_ASSERT (current_scope);
return scopes_tree_op_meta (current_scope, oc);
}
opcode_t
serializer_get_opcode (opcode_counter_t oc)
{
if (bytecode_data.opcodes == NULL)
{
return serializer_get_op_meta (oc).op;
}
JERRY_ASSERT (oc < bytecode_data.opcodes_count);
return bytecode_data.opcodes[oc];
}
literal
serializer_get_literal_by_id (literal_index_t id)
{
JERRY_ASSERT (id != INVALID_LITERAL);
JERRY_ASSERT (id < bytecode_data.literals_count);
return bytecode_data.literals[id];
}
literal_index_t
serializer_get_literal_id_by_uid (uint8_t id, opcode_counter_t oc)
{
if (bytecode_data.lit_id_hash == null_hash)
{
return INVALID_LITERAL;
}
return lit_id_hash_table_lookup (bytecode_data.lit_id_hash, id, oc);
}
const void *
serializer_get_bytecode (void)
{
JERRY_ASSERT (bytecode_data.opcodes != NULL);
return bytecode_data.opcodes;
}
void
serializer_set_strings_buffer (const ecma_char_t *s)
{
bytecode_data.strings_buffer = s;
}
void void
serializer_set_scope (scopes_tree new_scope) serializer_set_scope (scopes_tree new_scope)
{ {
@@ -43,7 +91,7 @@ serializer_merge_scopes_into_bytecode (void)
} }
void void
serializer_dump_literals (const literal literals[], literal_index_t literals_count) serializer_dump_literals (const literal *literals, literal_index_t literals_count)
{ {
#ifdef JERRY_ENABLE_PRETTY_PRINTER #ifdef JERRY_ENABLE_PRETTY_PRINTER
if (print_opcodes) if (print_opcodes)
@@ -131,13 +179,36 @@ serializer_print_opcodes (void)
} }
void void
serializer_init (bool show_opcodes) serializer_init ()
{ {
current_scope = NULL; current_scope = NULL;
print_opcodes = false;
bytecode_data.strings_buffer = NULL;
bytecode_data.literals = NULL;
bytecode_data.opcodes = NULL;
bytecode_data.lit_id_hash = null_hash;
}
void serializer_set_show_opcodes (bool show_opcodes)
{
print_opcodes = show_opcodes; print_opcodes = show_opcodes;
} }
void void
serializer_free (void) serializer_free (void)
{ {
if (bytecode_data.strings_buffer)
{
mem_heap_free_block ((uint8_t *) bytecode_data.strings_buffer);
}
if (bytecode_data.lit_id_hash != null_hash)
{
lit_id_hash_table_free (bytecode_data.lit_id_hash);
}
if (bytecode_data.literals != NULL)
{
mem_heap_free_block ((uint8_t *) bytecode_data.literals);
}
mem_heap_free_block ((uint8_t *) bytecode_data.opcodes);
} }
+8 -1
View File
@@ -23,7 +23,14 @@
#include "literal.h" #include "literal.h"
#include "scopes-tree.h" #include "scopes-tree.h"
void serializer_init (bool show_opcodes); void serializer_init ();
void serializer_set_show_opcodes (bool show_opcodes);
op_meta serializer_get_op_meta (opcode_counter_t);
opcode_t serializer_get_opcode (opcode_counter_t);
literal serializer_get_literal_by_id (literal_index_t);
literal_index_t serializer_get_literal_id_by_uid (uint8_t, opcode_counter_t);
const void *serializer_get_bytecode (void);
void serializer_set_strings_buffer (const ecma_char_t *);
void serializer_dump_literals (const literal *, literal_index_t); void serializer_dump_literals (const literal *, literal_index_t);
void serializer_set_scope (scopes_tree); void serializer_set_scope (scopes_tree);
void serializer_merge_scopes_into_bytecode (void); void serializer_merge_scopes_into_bytecode (void);
+1 -1
View File
@@ -30,7 +30,7 @@
#include "ecma-objects-general.h" #include "ecma-objects-general.h"
#include "ecma-reference.h" #include "ecma-reference.h"
#include "ecma-try-catch-macro.h" #include "ecma-try-catch-macro.h"
#include "deserializer.h" #include "serializer.h"
bool is_reg_variable (int_data_t *int_data, idx_t var_idx); bool is_reg_variable (int_data_t *int_data, idx_t var_idx);
ecma_completion_value_t get_variable_value (int_data_t *, idx_t, bool); ecma_completion_value_t get_variable_value (int_data_t *, idx_t, bool);
@@ -62,8 +62,9 @@ opfunc_try_block (opcode_t opdata, /**< operation data */
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta); JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER); JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER);
const literal_index_t catch_exc_val_var_name_lit_idx = deserialize_lit_id_by_uid (next_opcode.data.meta.data_1, const literal_index_t catch_exc_val_var_name_lit_idx = serializer_get_literal_id_by_uid (
int_data->pos); next_opcode.data.meta.data_1,
int_data->pos);
int_data->pos++; int_data->pos++;
ecma_string_t *catch_exc_var_name_str_p = ecma_new_ecma_string_from_lit_index (catch_exc_val_var_name_lit_idx); ecma_string_t *catch_exc_var_name_str_p = ecma_new_ecma_string_from_lit_index (catch_exc_val_var_name_lit_idx);
+2 -2
View File
@@ -91,7 +91,7 @@ get_variable_value (int_data_t *int_data, /**< interpreter context */
else else
{ {
ecma_string_t var_name_string; ecma_string_t var_name_string;
const literal_index_t lit_id = deserialize_lit_id_by_uid (var_idx, int_data->pos); const literal_index_t lit_id = serializer_get_literal_id_by_uid (var_idx, int_data->pos);
JERRY_ASSERT (lit_id != INVALID_LITERAL); JERRY_ASSERT (lit_id != INVALID_LITERAL);
ecma_new_ecma_string_on_stack_from_lit_index (&var_name_string, lit_id); ecma_new_ecma_string_on_stack_from_lit_index (&var_name_string, lit_id);
@@ -158,7 +158,7 @@ set_variable_value (int_data_t *int_data, /**< interpreter context */
else else
{ {
ecma_string_t var_name_string; ecma_string_t var_name_string;
const literal_index_t lit_id = deserialize_lit_id_by_uid (var_idx, lit_oc); const literal_index_t lit_id = serializer_get_literal_id_by_uid (var_idx, lit_oc);
JERRY_ASSERT (lit_id != INVALID_LITERAL); JERRY_ASSERT (lit_id != INVALID_LITERAL);
ecma_new_ecma_string_on_stack_from_lit_index (&var_name_string, lit_id); ecma_new_ecma_string_on_stack_from_lit_index (&var_name_string, lit_id);
+2 -1
View File
@@ -96,7 +96,8 @@ fill_params_list (int_data_t *int_data, /**< interpreter context */
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta); JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG); JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG);
const literal_index_t param_name_lit_idx = deserialize_lit_id_by_uid (next_opcode.data.meta.data_1, int_data->pos); const literal_index_t param_name_lit_idx = serializer_get_literal_id_by_uid (next_opcode.data.meta.data_1,
int_data->pos);
params_names [param_index] = ecma_new_ecma_string_from_lit_index (param_name_lit_idx); params_names [param_index] = ecma_new_ecma_string_from_lit_index (param_name_lit_idx);
+14 -14
View File
@@ -13,11 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include "deserializer.h"
#include "jrt.h" #include "jrt.h"
#include "vm.h"
#include "opcodes.h" #include "opcodes.h"
#include "opcodes-ecma-support.h" #include "opcodes-ecma-support.h"
#include "serializer.h"
#include "vm.h"
/** /**
* Note: * Note:
@@ -98,7 +98,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
} }
else if (type_value_right == OPCODE_ARG_TYPE_STRING) else if (type_value_right == OPCODE_ARG_TYPE_STRING)
{ {
const literal_index_t lit_id = deserialize_lit_id_by_uid (src_val_descr, int_data->pos); const literal_index_t lit_id = serializer_get_literal_id_by_uid (src_val_descr, int_data->pos);
ecma_string_t *string_p = ecma_new_ecma_string_from_lit_index (lit_id); ecma_string_t *string_p = ecma_new_ecma_string_from_lit_index (lit_id);
ret_value = set_variable_value (int_data, ret_value = set_variable_value (int_data,
@@ -127,8 +127,8 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
{ {
ecma_number_t *num_p = int_data->tmp_num_p; ecma_number_t *num_p = int_data->tmp_num_p;
const literal_index_t lit_id = deserialize_lit_id_by_uid (src_val_descr, int_data->pos); const literal_index_t lit_id = serializer_get_literal_id_by_uid (src_val_descr, int_data->pos);
const literal lit = deserialize_literal_by_id (lit_id); const literal lit = serializer_get_literal_by_id (lit_id);
JERRY_ASSERT (lit.type == LIT_NUMBER); JERRY_ASSERT (lit.type == LIT_NUMBER);
*num_p = lit.data.num; *num_p = lit.data.num;
@@ -142,8 +142,8 @@ opfunc_assignment (opcode_t opdata, /**< operation data */
{ {
ecma_number_t *num_p = int_data->tmp_num_p; ecma_number_t *num_p = int_data->tmp_num_p;
const literal_index_t lit_id = deserialize_lit_id_by_uid (src_val_descr, int_data->pos); const literal_index_t lit_id = serializer_get_literal_id_by_uid (src_val_descr, int_data->pos);
const literal lit = deserialize_literal_by_id (lit_id); const literal lit = serializer_get_literal_by_id (lit_id);
JERRY_ASSERT (lit.type == LIT_NUMBER); JERRY_ASSERT (lit.type == LIT_NUMBER);
*num_p = ecma_number_negate (lit.data.num); *num_p = ecma_number_negate (lit.data.num);
@@ -397,8 +397,8 @@ ecma_completion_value_t
opfunc_var_decl (opcode_t opdata, /**< operation data */ opfunc_var_decl (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */ int_data_t *int_data) /**< interpreter context */
{ {
const literal_index_t lit_id = deserialize_lit_id_by_uid (opdata.data.var_decl.variable_name, const literal_index_t lit_id = serializer_get_literal_id_by_uid (opdata.data.var_decl.variable_name,
int_data->pos); int_data->pos);
JERRY_ASSERT (lit_id != INVALID_LITERAL); JERRY_ASSERT (lit_id != INVALID_LITERAL);
ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_index (lit_id); ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_index (lit_id);
@@ -487,8 +487,8 @@ opfunc_func_decl_n (opcode_t opdata, /**< operation data */
const idx_t function_name_idx = opdata.data.func_decl_n.name_lit_idx; const idx_t function_name_idx = opdata.data.func_decl_n.name_lit_idx;
const ecma_length_t params_number = opdata.data.func_decl_n.arg_list; const ecma_length_t params_number = opdata.data.func_decl_n.arg_list;
literal_index_t function_name_lit_id = deserialize_lit_id_by_uid (function_name_idx, literal_index_t function_name_lit_id = serializer_get_literal_id_by_uid (function_name_idx,
int_data->pos); int_data->pos);
int_data->pos++; int_data->pos++;
@@ -563,7 +563,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
{ {
scope_p = ecma_create_decl_lex_env (int_data->lex_env_p); scope_p = ecma_create_decl_lex_env (int_data->lex_env_p);
const literal_index_t lit_id = deserialize_lit_id_by_uid (function_name_lit_idx, lit_oc); const literal_index_t lit_id = serializer_get_literal_id_by_uid (function_name_lit_idx, lit_oc);
JERRY_ASSERT (lit_id != INVALID_LITERAL); JERRY_ASSERT (lit_id != INVALID_LITERAL);
function_name_string_p = ecma_new_ecma_string_from_lit_index (lit_id); function_name_string_p = ecma_new_ecma_string_from_lit_index (lit_id);
@@ -1389,7 +1389,7 @@ evaluate_arg_for_typeof (int_data_t *int_data, /**< interpreter context */
} }
else else
{ {
const literal_index_t lit_id = deserialize_lit_id_by_uid (var_idx, int_data->pos); const literal_index_t lit_id = serializer_get_literal_id_by_uid (var_idx, int_data->pos);
JERRY_ASSERT (lit_id != INVALID_LITERAL); JERRY_ASSERT (lit_id != INVALID_LITERAL);
ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_index (lit_id); ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_index (lit_id);
@@ -1505,7 +1505,7 @@ opfunc_delete_var (opcode_t opdata, /**< operation data */
ecma_completion_value_t ret_value; ecma_completion_value_t ret_value;
const literal_index_t lit_id = deserialize_lit_id_by_uid (name_lit_idx, lit_oc); const literal_index_t lit_id = serializer_get_literal_id_by_uid (name_lit_idx, lit_oc);
JERRY_ASSERT (lit_id != INVALID_LITERAL); JERRY_ASSERT (lit_id != INVALID_LITERAL);
ecma_string_t *name_string_p = ecma_new_ecma_string_from_lit_index (lit_id); ecma_string_t *name_string_p = ecma_new_ecma_string_from_lit_index (lit_id);
+9 -9
View File
@@ -13,16 +13,16 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jrt.h"
#ifdef JERRY_ENABLE_PRETTY_PRINTER #ifdef JERRY_ENABLE_PRETTY_PRINTER
#include <stdarg.h>
#include "pretty-printer.h" #include "pretty-printer.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "lexer.h" #include "lexer.h"
#include "deserializer.h"
#include "opcodes-native-call.h" #include "opcodes-native-call.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include <stdarg.h> #include "serializer.h"
#define NAME_TO_ID(op) (__op__idx_##op) #define NAME_TO_ID(op) (__op__idx_##op)
@@ -79,7 +79,7 @@ dump_literal (literal lit)
} }
void void
pp_literals (const literal lits[], literal_index_t size) pp_literals (const literal *lits, literal_index_t size)
{ {
printf ("LITERALS %lu:\n", (unsigned long) size); printf ("LITERALS %lu:\n", (unsigned long) size);
for (literal_index_t i = 0; i < size; i++) for (literal_index_t i = 0; i < size; i++)
@@ -160,7 +160,7 @@ var_to_str (opcode_t opcode, literal_index_t lit_ids[], opcode_counter_t oc, uin
} }
else else
{ {
return lit_id_to_str (deserialize_lit_id_by_uid (raw.uids[current_arg], oc)); return lit_id_to_str (serializer_get_literal_id_by_uid (raw.uids[current_arg], oc));
} }
} }
@@ -241,7 +241,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{ {
PP_OP (addition, "%s = %s + %s;"); PP_OP (addition, "%s = %s + %s;");
PP_OP (substraction, "%s = %s - %s;"); PP_OP (substraction, "%s = %s - %s;");
PP_OP (division, "%s = %s - %s;"); PP_OP (division, "%s = %s / %s;");
PP_OP (multiplication, "%s = %s * %s;"); PP_OP (multiplication, "%s = %s * %s;");
PP_OP (remainder, "%s = %s %% %s;"); PP_OP (remainder, "%s = %s %% %s;");
PP_OP (unary_minus, "%s = -%s;"); PP_OP (unary_minus, "%s = -%s;");
@@ -447,7 +447,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
while ((int16_t) start >= 0 && !found) while ((int16_t) start >= 0 && !found)
{ {
start--; start--;
switch (deserialize_opcode (start).op_idx) switch (serializer_get_opcode (start).op_idx)
{ {
case NAME_TO_ID (call_n): case NAME_TO_ID (call_n):
case NAME_TO_ID (native_call): case NAME_TO_ID (native_call):
@@ -462,7 +462,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
} }
} }
} }
opcode_t start_op = deserialize_opcode (start); opcode_t start_op = serializer_get_opcode (start);
switch (start_op.op_idx) switch (start_op.op_idx)
{ {
case NAME_TO_ID (call_n): case NAME_TO_ID (call_n):
@@ -527,7 +527,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
} }
for (opcode_counter_t counter = start; counter <= oc; counter++) for (opcode_counter_t counter = start; counter <= oc; counter++)
{ {
opcode_t meta_op = deserialize_opcode (counter); opcode_t meta_op = serializer_get_opcode (counter);
switch (meta_op.op_idx) switch (meta_op.op_idx)
{ {
case NAME_TO_ID (meta): case NAME_TO_ID (meta):
+4 -4
View File
@@ -18,9 +18,9 @@
#include "jrt.h" #include "jrt.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#include "opcodes.h" #include "opcodes.h"
#include "deserializer.h"
#include "common.h" #include "common.h"
#include "parser.h" #include "parser.h"
#include "serializer.h"
/** /**
* Unit test's main function. * Unit test's main function.
@@ -33,7 +33,7 @@ main (int __attr_unused___ argc,
bool is_ok; bool is_ok;
mem_init (); mem_init ();
deserializer_init (); serializer_init ();
parser_init (program, strlen (program), true); parser_init (program, strlen (program), true);
parser_parse_program (); parser_parse_program ();
parser_free (); parser_free ();
@@ -47,7 +47,7 @@ main (int __attr_unused___ argc,
getop_exitval (0) // exit 0; getop_exitval (0) // exit 0;
}; };
if (!opcodes_equal ((const opcode_t *) deserialize_bytecode (), opcodes, 5)) if (!opcodes_equal ((const opcode_t *) serializer_get_bytecode (), opcodes, 5))
{ {
is_ok = false; is_ok = false;
} }
@@ -56,7 +56,7 @@ main (int __attr_unused___ argc,
is_ok = true; is_ok = true;
} }
deserializer_free (); serializer_free ();
mem_finalize (false); mem_finalize (false);
return (is_ok ? 0 : 1); return (is_ok ? 0 : 1);