Allocate stack memory by chunks

This commit is contained in:
Ilmir Usmanov
2014-09-30 18:40:24 +04:00
parent 1c3bf4951d
commit 9d129e15dc
10 changed files with 569 additions and 372 deletions
+24 -1
View File
@@ -16,6 +16,8 @@
#include "deserializer.h"
#include "bytecode-data.h"
static opcode_t *raw_bytecode;
const ecma_char_t *
deserialize_string_by_id (uint8_t id)
{
@@ -41,7 +43,9 @@ const void *
deserialize_bytecode (void)
{
JERRY_ASSERT (STACK_SIZE (bytecode_opcodes) > 0);
return STACK_RAW_DATA (bytecode_opcodes);
JERRY_ASSERT (raw_bytecode == NULL);
STACK_CONVERT_TO_RAW_DATA (bytecode_opcodes, raw_bytecode);
return raw_bytecode;
}
opcode_t
@@ -57,3 +61,22 @@ deserialize_min_temp (void)
{
return (uint8_t) (bytecode_data.strs_count + bytecode_data.nums_count);
}
void
deserializer_init (void)
{
raw_bytecode = NULL;
STACK_INIT (opcode_t, bytecode_opcodes);
}
void
deserializer_free (void)
{
STACK_FREE (bytecode_opcodes);
if (raw_bytecode)
{
mem_heap_free_block ((uint8_t *) raw_bytecode);
}
mem_heap_free_block ((uint8_t *) bytecode_data.strings);
mem_heap_free_block ((uint8_t *) bytecode_data.nums);
}
+2
View File
@@ -20,10 +20,12 @@
#include "ecma-globals.h"
#include "opcodes.h"
void deserializer_init (void);
const ecma_char_t *deserialize_string_by_id (uint8_t);
ecma_number_t deserialize_num_by_id (uint8_t);
const void *deserialize_bytecode (void);
opcode_t deserialize_opcode (opcode_counter_t);
uint8_t deserialize_min_temp (void);
void deserializer_free (void);
#endif //DESERIALIZER_H
+1 -3
View File
@@ -61,7 +61,7 @@ void
serializer_rewrite_opcode (const opcode_counter_t loc, opcode_t opcode)
{
JERRY_ASSERT (loc < STACK_SIZE (bytecode_opcodes));
STACK_ELEMENT (bytecode_opcodes, loc) = opcode;
STACK_SET_ELEMENT (bytecode_opcodes, loc, opcode);
if (print_opcodes)
{
@@ -102,11 +102,9 @@ void
serializer_init (bool show_opcodes)
{
print_opcodes = show_opcodes;
STACK_INIT (opcode_t, bytecode_opcodes);
}
void
serializer_free (void)
{
STACK_FREE (bytecode_opcodes);
}