Simplify serializer/deserializer. Reduce memory usage in lexer. Create HashTable data structure. Finish preparations for introducing new strings addressation.

This commit is contained in:
Ilmir Usmanov
2014-09-23 16:39:30 +04:00
parent f237a8d5e1
commit 8a5b956e38
27 changed files with 1152 additions and 1159 deletions
+6
View File
@@ -16,16 +16,22 @@
#ifndef COMMON_H
#define COMMON_H
#include "jerry-libc.h"
#define NAME_TO_ID(op) (__op__idx_##op)
#define __OPCODE_SIZE(name, arg1, arg2, arg3) \
sizeof (__op_##name) + 1,
#define LP(s) (lp_string) { .length = (uint8_t) __strlen(s), .str = (ecma_char_t *) s }
static uint8_t opcode_sizes[] = {
OP_LIST (OPCODE_SIZE)
0
};
static bool opcodes_equal (const opcode_t *, opcode_t *, uint16_t) __unused;
static bool
opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size)
{
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -39,11 +40,10 @@ main( int __unused argc,
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
const lp_string strings[] = { LP("a"),
LP("b") };
ecma_number_t nums [] = { 2.0 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
serializer_dump_strings_and_nums (strings, 2, nums, 1);
init_int( test_program, false);
+6 -6
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -171,15 +172,14 @@ main( int __unused argc,
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b",
"length",
"1" };
const lp_string strings[] = { LP("a"),
LP("b"),
LP("length"),
LP("1") };
ecma_number_t nums [] = { 2.0,
12.0,
2.5 };
uint16_t offset = serializer_dump_strings( strings, 4);
serializer_dump_nums( nums, 3, offset, 4);
serializer_dump_strings_and_nums (strings, 4, nums, 3);
init_int( test_program, false);
+5 -4
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -42,12 +43,12 @@ main( int __unused argc,
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
const lp_string strings[] = { LP("a"),
LP("b") };
ecma_number_t nums [] = { 2.0 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
serializer_dump_strings_and_nums (strings, 2, nums, 1);
init_int( test_program, false);
+6 -5
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -37,12 +38,12 @@ main( int __unused argc,
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
ecma_number_t nums [] = { 2 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
const lp_string strings[] = { LP("a"),
LP("b") };
ecma_number_t nums [] = { 2.0 };
serializer_dump_strings_and_nums (strings, 2, nums, 1);
init_int( test_program, false);
+6 -5
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -37,12 +38,12 @@ main( int __unused argc,
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
ecma_number_t nums [] = { 2 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
const lp_string strings[] = { LP("a"),
LP("b") };
ecma_number_t nums [] = { 2.0 };
serializer_dump_strings_and_nums (strings, 2, nums, 1);
init_int( test_program, false);
+9 -9
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -136,16 +137,15 @@ main( int __unused argc,
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b",
"property1",
"property2",
"property3",
"value1",
"value2" };
const lp_string strings[] = { LP("a"),
LP("b"),
LP("property1"),
LP("property2"),
LP("property3"),
LP("value1"),
LP("value2") };
ecma_number_t nums [] = { 2.5 };
uint16_t offset = serializer_dump_strings( strings, 7);
serializer_dump_nums( nums, 1, offset, 7);
serializer_dump_strings_and_nums (strings, 7, nums, 1);
init_int( test_program, false);
+6 -5
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -37,12 +38,12 @@ main( int __unused argc,
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
ecma_number_t nums [] = { 2 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
const lp_string strings[] = { LP("a"),
LP("b") };
ecma_number_t nums [] = { 2.0 };
serializer_dump_strings_and_nums (strings, 2, nums, 1);
init_int( test_program, false);
+6 -5
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -37,12 +38,12 @@ main( int __unused argc,
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
ecma_number_t nums [] = { 2 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
const lp_string strings[] = { LP("a"),
LP("b") };
ecma_number_t nums [] = { 2.0 };
serializer_dump_strings_and_nums (strings, 2, nums, 1);
init_int( test_program, false);
+6 -5
View File
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -50,13 +51,13 @@ main( int __unused argc,
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b",
"c" };
const lp_string strings[] = { LP("a"),
LP("b"),
LP("c") };
ecma_number_t nums [] = { 2.0 };
uint16_t offset = serializer_dump_strings( strings, 3);
serializer_dump_nums( nums, 1, offset, 3);
serializer_dump_strings_and_nums (strings, 3, nums, 1);
init_int( test_program, false);
@@ -18,6 +18,7 @@
#include "mem-allocator.h"
#include "opcodes.h"
#include "serializer.h"
#include "common.h"
/**
* Unit test's main function.
@@ -35,12 +36,12 @@ main( int __unused argc,
};
mem_init();
serializer_init (false);
const char *strings[] = { "a",
"b" };
ecma_number_t nums [] = { 2 };
uint16_t offset = serializer_dump_strings( strings, 2);
serializer_dump_nums( nums, 1, offset, 2);
const lp_string strings[] = { LP("a"),
LP("b") };
ecma_number_t nums [] = { 2.0 };
serializer_dump_strings_and_nums (strings, 2, nums, 1);
init_int( test_program, false);