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
+8 -32
View File
@@ -1,4 +1,5 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +61,7 @@ test_heap_give_some_memory_back (mem_try_give_memory_back_severity_t severity)
JERRY_ASSERT (ptrs[i][k] == 0);
}
mem_heap_free_block (ptrs[i]);
mem_heap_free_block_size_stored (ptrs[i]);
ptrs[i] = NULL;
}
}
@@ -77,37 +78,18 @@ main (int __attr_unused___ argc,
mem_register_a_try_give_memory_back_callback (test_heap_give_some_memory_back);
mem_heap_print (true, false, true);
mem_heap_print ();
for (uint32_t i = 0; i < test_iters; i++)
{
for (uint32_t j = 0; j < test_sub_iters; j++)
{
if (rand () % 2)
{
size_t size = (size_t) rand () % test_threshold_block_size;
ptrs[j] = (uint8_t*) mem_heap_alloc_block (size,
(rand () % 2) ?
MEM_HEAP_ALLOC_LONG_TERM : MEM_HEAP_ALLOC_SHORT_TERM);
sizes[j] = size;
is_one_chunked[j] = false;
}
else
{
ptrs[j] = (uint8_t*) mem_heap_alloc_chunked_block ((rand () % 2) ?
MEM_HEAP_ALLOC_LONG_TERM : MEM_HEAP_ALLOC_SHORT_TERM);
sizes[j] = mem_heap_get_chunked_block_data_size ();
is_one_chunked[j] = true;
}
size_t size = (size_t) rand () % test_threshold_block_size;
ptrs[j] = (uint8_t*) mem_heap_alloc_block_store_size (size);
sizes[j] = size;
JERRY_ASSERT (sizes[j] == 0 || ptrs[j] != NULL);
memset (ptrs[j], 0, sizes[j]);
if (is_one_chunked[j])
{
JERRY_ASSERT (ptrs[j] != NULL
&& mem_heap_get_chunked_block_start (ptrs[j] + (size_t) rand () % sizes[j]) == ptrs[j]);
}
}
// mem_heap_print (true);
@@ -121,20 +103,14 @@ main (int __attr_unused___ argc,
JERRY_ASSERT (ptrs[j][k] == 0);
}
if (is_one_chunked[j])
{
JERRY_ASSERT (sizes[j] == 0
|| mem_heap_get_chunked_block_start (ptrs[j] + (size_t) rand () % sizes[j]) == ptrs[j]);
}
mem_heap_free_block (ptrs[j]);
mem_heap_free_block_size_stored (ptrs[j]);
ptrs[j] = NULL;
}
}
}
mem_heap_print (true, false, true);
mem_heap_print ();
return 0;
} /* main */
-4
View File
@@ -16,7 +16,6 @@
#include "ecma-helpers.h"
#include "lit-literal.h"
#include "lit-literal-storage.h"
#include "rcs-records.h"
#include "test-common.h"
// Iterations count
@@ -132,9 +131,6 @@ main (int __attr_unused___ argc,
// Check empty string exists
JERRY_ASSERT (lit_find_literal_by_utf8_string (NULL, 0));
rcs_chunked_list_cleanup (&rcs_lit_storage);
JERRY_ASSERT (rcs_record_get_first (&rcs_lit_storage) == NULL);
}
lit_finalize ();
+7 -7
View File
@@ -1,4 +1,5 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,8 +48,7 @@ main (int __attr_unused___ argc,
for (size_t j = 0; j < subiters; j++)
{
ptrs[j] = mem_pools_alloc ();
// JERRY_ASSERT (ptrs[j] != NULL);
ptrs[j] = (uint8_t *) mem_pools_alloc ();
if (ptrs[j] != NULL)
{
@@ -85,11 +85,11 @@ main (int __attr_unused___ argc,
printf ("Pools stats:\n");
printf (" Chunk size: %u\n"
" Pools: %lu\n"
" Allocated chunks: %lu\n"
" Free chunks: %lu\n"
" Peak pools: %lu\n"
" Peak allocated chunks: %lu\n\n",
" Pools: %zu\n"
" Allocated chunks: %zu\n"
" Free chunks: %zu\n"
" Peak pools: %zu\n"
" Peak allocated chunks: %zu\n\n",
MEM_POOL_CHUNK_SIZE,
stats.pools_count,
stats.allocated_chunks,