Prop hashmap allocation strategy based on gc pattern is implemented. (#1429)

The algorithm is the following:
* introduced a counter variable, which value can be [0-4]
* if its value is 0, property hashmap allocation is enabled
* JMEM_FREE_UNUSED_MEMORY_SEVERITY_LOW -> decrease the counter
* JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH -> increase the number
* if JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH happens twice in a row increase the counter to 4

According to the measurements this algorithm provides better runtime results in low memory conditions.

JerryScript-DCO-1.0-Signed-off-by: István Kádár ikadar@inf.u-szeged.hu
This commit is contained in:
Istvan Kadar
2016-11-16 08:32:45 +01:00
committed by Zoltan Herczeg
parent e443d95566
commit 405092e700
5 changed files with 57 additions and 0 deletions
+21
View File
@@ -664,6 +664,15 @@ ecma_free_unused_memory (jmem_free_unused_memory_severity_t severity) /**< sever
{
if (severity == JMEM_FREE_UNUSED_MEMORY_SEVERITY_LOW)
{
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
if (JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) > ECMA_PROP_HASHMAP_ALLOC_ON)
{
--JERRY_CONTEXT (ecma_prop_hashmap_alloc_state);
}
JERRY_CONTEXT (ecma_prop_hashmap_alloc_last_is_hs_gc) = false;
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
/*
* If there is enough newly allocated objects since last GC, probably it is worthwhile to start GC now.
* Otherwise, probability to free sufficient space is considered to be low.
@@ -679,6 +688,18 @@ ecma_free_unused_memory (jmem_free_unused_memory_severity_t severity) /**< sever
{
JERRY_ASSERT (severity == JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH);
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
if (JERRY_CONTEXT (ecma_prop_hashmap_alloc_last_is_hs_gc))
{
JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) = ECMA_PROP_HASHMAP_ALLOC_MAX;
}
else if (JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) < ECMA_PROP_HASHMAP_ALLOC_MAX)
{
++JERRY_CONTEXT (ecma_prop_hashmap_alloc_state);
JERRY_CONTEXT (ecma_prop_hashmap_alloc_last_is_hs_gc) = true;
}
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
/* Freeing as much memory as we currently can */
ecma_gc_run (severity);
}