aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2011-02-01 20:01:52 +0100
committerSverker Eriksson <[email protected]>2011-02-03 19:31:14 +0100
commit2e0181837dbe96a4ce738a339a9a02a6e26746f8 (patch)
tree41add3cbfdbb5fdfd9798dad9f33ad4a2592df8e /erts/emulator/beam/erl_nif.c
parent677d59fc6d76360dc5ad996bdf91a4c05293b52d (diff)
downloadotp-2e0181837dbe96a4ce738a339a9a02a6e26746f8.tar.gz
otp-2e0181837dbe96a4ce738a339a9a02a6e26746f8.tar.bz2
otp-2e0181837dbe96a4ce738a339a9a02a6e26746f8.zip
HALFWORD ETS match spec heap fragment optimization
Introduce HAllocX to allocate heap fragments with a larger capacity than requested and by that reduce the number of fragments allocated.
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 529b602575..2f9295e624 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -81,7 +81,6 @@ static ERTS_INLINE Eterm* alloc_heap(ErlNifEnv* env, unsigned need)
static Eterm* alloc_heap_heavy(ErlNifEnv* env, unsigned need, Eterm* hp)
{
- unsigned frag_sz;
env->hp = hp;
if (env->heap_frag == NULL) {
ASSERT(HEAP_LIMIT(env->proc) == env->hp_end);
@@ -91,11 +90,11 @@ static Eterm* alloc_heap_heavy(ErlNifEnv* env, unsigned need, Eterm* hp)
env->heap_frag->used_size = hp - env->heap_frag->mem;
ASSERT(env->heap_frag->used_size <= env->heap_frag->alloc_size);
}
- frag_sz = need + MIN_HEAP_FRAG_SZ;
- hp = erts_heap_alloc(env->proc, frag_sz);
- env->hp = hp + need;
- env->hp_end = hp + frag_sz;
+ hp = erts_heap_alloc(env->proc, need, MIN_HEAP_FRAG_SZ);
env->heap_frag = MBUF(env->proc);
+ env->hp = hp + need;
+ env->hp_end = env->heap_frag->mem + env->heap_frag->alloc_size;
+
return hp;
}