aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/beam_emu.c90
-rw-r--r--erts/emulator/beam/copy.c10
-rw-r--r--erts/emulator/beam/erl_bif_guard.c6
-rw-r--r--erts/emulator/beam/erl_bif_op.c2
-rw-r--r--erts/emulator/beam/erl_db_util.c50
-rw-r--r--erts/emulator/beam/erl_gc.h2
-rw-r--r--erts/emulator/beam/erl_map.c196
-rw-r--r--erts/emulator/beam/erl_map.h34
-rw-r--r--erts/emulator/beam/erl_nif.c58
-rw-r--r--erts/emulator/beam/erl_printf_term.c8
-rw-r--r--erts/emulator/beam/external.c24
-rw-r--r--erts/emulator/beam/io.c8
-rw-r--r--erts/emulator/beam/utils.c36
13 files changed, 262 insertions, 262 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index d45aa93f73..10ae3ed77c 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -699,7 +699,7 @@ void** beam_ops;
Fail; \
}
-#define IsMap(Src, Fail) if (is_not_map(Src) && is_not_hashmap(Src)) { Fail; }
+#define IsMap(Src, Fail) if (is_not_flatmap(Src) && is_not_hashmap(Src)) { Fail; }
#define HasMapField(Src, Key, Fail) if (has_not_map_field(Src, Key)) { Fail; }
@@ -2392,7 +2392,7 @@ void process_main(void)
}
OpCase(i_has_map_fields_fsI): {
- map_t* mp;
+ flatmap_t* mp;
Eterm map;
Eterm field;
Eterm *ks;
@@ -2417,17 +2417,17 @@ void process_main(void)
goto has_map_fields_ok;
}
- ASSERT(is_map(map));
+ ASSERT(is_flatmap(map));
- mp = (map_t *)map_val(map);
- sz = map_get_size(mp);
+ mp = (flatmap_t *)flatmap_val(map);
+ sz = flatmap_get_size(mp);
if (sz == 0) {
SET_I((BeamInstr *) Arg(0));
goto has_map_fields_fail;
}
- ks = map_get_keys(mp);
+ ks = flatmap_get_keys(mp);
ASSERT(n>0);
@@ -2484,21 +2484,21 @@ do { \
n = (Uint)Arg(2) / 2;
fs = &Arg(3); /* pattern fields and target registers */
- if (is_map(map)) {
- map_t *mp;
+ if (is_flatmap(map)) {
+ flatmap_t *mp;
Eterm *ks;
Eterm *vs;
- mp = (map_t *)map_val(map);
- sz = map_get_size(mp);
+ mp = (flatmap_t *)flatmap_val(map);
+ sz = flatmap_get_size(mp);
if (sz == 0) {
SET_I((BeamInstr *) Arg(0));
goto get_map_elements_fail;
}
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
while(sz) {
if (EQ((Eterm)*fs,*ks)) {
@@ -6473,15 +6473,15 @@ new_fun(Process* p, Eterm* reg, ErlFunEntry* fe, int num_free)
static int has_not_map_field(Eterm map, Eterm key)
{
Uint32 hx;
- if (is_map(map)) {
- map_t* mp;
+ if (is_flatmap(map)) {
+ flatmap_t* mp;
Eterm* keys;
Uint i;
Uint n;
- mp = (map_t *)map_val(map);
- keys = map_get_keys(mp);
- n = map_get_size(mp);
+ mp = (flatmap_t *)flatmap_val(map);
+ keys = flatmap_get_keys(mp);
+ n = flatmap_get_size(mp);
if (is_immed(key)) {
for (i = 0; i < n; i++) {
if (keys[i] == key) {
@@ -6506,16 +6506,16 @@ static Eterm get_map_element(Eterm map, Eterm key)
{
Uint32 hx;
const Eterm *vs;
- if (is_map(map)) {
- map_t *mp;
+ if (is_flatmap(map)) {
+ flatmap_t *mp;
Eterm *ks;
Uint i;
Uint n;
- mp = (map_t *)map_val(map);
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
- n = map_get_size(mp);
+ mp = (flatmap_t *)flatmap_val(map);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
+ n = flatmap_get_size(mp);
if (is_immed(key)) {
for (i = 0; i < n; i++) {
if (ks[i] == key) {
@@ -6567,7 +6567,7 @@ new_map(Process* p, Eterm* reg, BeamInstr* I)
Eterm *mhp,*thp;
Eterm *E;
BeamInstr *ptr;
- map_t *mp;
+ flatmap_t *mp;
ErtsHeapFactory factory;
ptr = &Arg(4);
@@ -6602,7 +6602,7 @@ new_map(Process* p, Eterm* reg, BeamInstr* I)
keys = make_tuple(thp);
*thp++ = make_arityval(n/2);
- mp = (map_t *)mhp; mhp += MAP_HEADER_SIZE;
+ mp = (flatmap_t *)mhp; mhp += MAP_HEADER_SIZE;
mp->thing_word = MAP_HEADER;
mp->size = n/2;
mp->keys = keys;
@@ -6612,7 +6612,7 @@ new_map(Process* p, Eterm* reg, BeamInstr* I)
GET_TERM(*ptr++, *mhp++);
}
p->htop = mhp;
- return make_map(mp);
+ return make_flatmap(mp);
}
static Eterm
@@ -6622,7 +6622,7 @@ update_map_assoc(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
Uint num_old;
Uint num_updates;
Uint need;
- map_t *old_mp, *mp;
+ flatmap_t *old_mp, *mp;
Eterm res;
Eterm* hp;
Eterm* E;
@@ -6635,7 +6635,7 @@ update_map_assoc(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
new_p = &Arg(5);
num_updates = Arg(4) / 2;
- if (is_not_map(map)) {
+ if (is_not_flatmap(map)) {
Uint32 hx;
Eterm val;
@@ -6668,8 +6668,8 @@ update_map_assoc(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
return res;
}
- old_mp = (map_t *) map_val(map);
- num_old = map_get_size(old_mp);
+ old_mp = (flatmap_t *) flatmap_val(map);
+ num_old = flatmap_get_size(old_mp);
/*
* If the old map is empty, create a new map.
@@ -6690,7 +6690,7 @@ update_map_assoc(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
reg[live] = map;
erts_garbage_collect(p, need, reg, live+1);
map = reg[live];
- old_mp = (map_t *)map_val(map);
+ old_mp = (flatmap_t *)flatmap_val(map);
}
/*
@@ -6721,14 +6721,14 @@ update_map_assoc(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
kp = p->htop + 1; /* Point to first key */
hp = kp + num_old + num_updates;
- res = make_map(hp);
- mp = (map_t *)hp;
+ res = make_flatmap(hp);
+ mp = (flatmap_t *)hp;
hp += MAP_HEADER_SIZE;
mp->thing_word = MAP_HEADER;
mp->keys = make_tuple(kp-1);
- old_vals = map_get_values(old_mp);
- old_keys = map_get_keys(old_mp);
+ old_vals = flatmap_get_values(old_mp);
+ old_keys = flatmap_get_keys(old_mp);
GET_TERM(*new_p, new_key);
n = num_updates;
@@ -6820,7 +6820,7 @@ update_map_assoc(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
/* The expensive case, need to build a hashmap */
if (n > MAP_SMALL_MAP_LIMIT) {
- res = erts_hashmap_from_ks_and_vs(p,map_get_keys(mp),map_get_values(mp),n);
+ res = erts_hashmap_from_ks_and_vs(p,flatmap_get_keys(mp),flatmap_get_values(mp),n);
if (p->mbuf) {
Uint live = Arg(3);
reg[live] = res;
@@ -6842,7 +6842,7 @@ update_map_exact(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
Uint i;
Uint num_old;
Uint need;
- map_t *old_mp, *mp;
+ flatmap_t *old_mp, *mp;
Eterm res;
Eterm* hp;
Eterm* E;
@@ -6855,7 +6855,7 @@ update_map_exact(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
n = Arg(4) / 2; /* Number of values to be updated */
ASSERT(n > 0);
- if (is_not_map(map)) {
+ if (is_not_flatmap(map)) {
Uint32 hx;
Eterm val;
@@ -6891,8 +6891,8 @@ update_map_exact(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
return res;
}
- old_mp = (map_t *) map_val(map);
- num_old = map_get_size(old_mp);
+ old_mp = (flatmap_t *) flatmap_val(map);
+ num_old = flatmap_get_size(old_mp);
/*
* If the old map is empty, create a new map.
@@ -6912,7 +6912,7 @@ update_map_exact(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
reg[live] = map;
erts_garbage_collect(p, need, reg, live+1);
map = reg[live];
- old_mp = (map_t *)map_val(map);
+ old_mp = (flatmap_t *)flatmap_val(map);
}
/*
@@ -6922,11 +6922,11 @@ update_map_exact(Process* p, Eterm* reg, Eterm map, BeamInstr* I)
hp = p->htop;
E = p->stop;
- old_vals = map_get_values(old_mp);
- old_keys = map_get_keys(old_mp);
+ old_vals = flatmap_get_values(old_mp);
+ old_keys = flatmap_get_keys(old_mp);
- res = make_map(hp);
- mp = (map_t *)hp;
+ res = make_flatmap(hp);
+ mp = (flatmap_t *)hp;
hp += MAP_HEADER_SIZE;
mp->thing_word = MAP_HEADER;
mp->size = num_old;
diff --git a/erts/emulator/beam/copy.c b/erts/emulator/beam/copy.c
index 5901c00d0a..83214aca19 100644
--- a/erts/emulator/beam/copy.c
+++ b/erts/emulator/beam/copy.c
@@ -186,10 +186,10 @@ Uint size_object(Eterm obj)
case MAP_SUBTAG:
{
Uint n;
- map_t *mp;
- mp = (map_t*)map_val_rel(obj,base);
+ flatmap_t *mp;
+ mp = (flatmap_t*)flatmap_val_rel(obj,base);
ptr = (Eterm *)mp;
- n = map_get_size(mp) + 1;
+ n = flatmap_get_size(mp) + 1;
sum += n + 2;
ptr += 2; /* hdr + size words */
while (n--) {
@@ -371,8 +371,8 @@ Eterm copy_struct(Eterm obj, Uint sz, Eterm** hpp, ErlOffHeap* off_heap)
break;
case MAP_SUBTAG:
{
- i = map_get_size(objp) + 3;
- *argp = make_map_rel(htop, dst_base);
+ i = flatmap_get_size(objp) + 3;
+ *argp = make_flatmap_rel(htop, dst_base);
while (i--) {
*htop++ = *objp++;
}
diff --git a/erts/emulator/beam/erl_bif_guard.c b/erts/emulator/beam/erl_bif_guard.c
index bc0891422b..e7d84ebda1 100644
--- a/erts/emulator/beam/erl_bif_guard.c
+++ b/erts/emulator/beam/erl_bif_guard.c
@@ -461,9 +461,9 @@ Eterm erts_gc_map_size_1(Process* p, Eterm* reg, Uint live)
Eterm arg = reg[live];
Eterm* hp;
Uint size;
- if (is_map(arg)) {
- map_t *mp = (map_t*)map_val(arg);
- size = map_get_size(mp);
+ if (is_flatmap(arg)) {
+ flatmap_t *mp = (flatmap_t*)flatmap_val(arg);
+ size = flatmap_get_size(mp);
} else if (is_hashmap(arg)) {
size = hashmap_size(arg);
} else {
diff --git a/erts/emulator/beam/erl_bif_op.c b/erts/emulator/beam/erl_bif_op.c
index 11c6c9e556..af9b7bd908 100644
--- a/erts/emulator/beam/erl_bif_op.c
+++ b/erts/emulator/beam/erl_bif_op.c
@@ -324,7 +324,7 @@ BIF_RETTYPE is_record_3(BIF_ALIST_3)
BIF_RETTYPE is_map_1(BIF_ALIST_1)
{
- if (is_map(BIF_ARG_1) || is_hashmap(BIF_ARG_1)) {
+ if (is_flatmap(BIF_ARG_1) || is_hashmap(BIF_ARG_1)) {
BIF_RET(am_true);
}
BIF_RET(am_false);
diff --git a/erts/emulator/beam/erl_db_util.c b/erts/emulator/beam/erl_db_util.c
index 8b5ab16642..cca3f381a1 100644
--- a/erts/emulator/beam/erl_db_util.c
+++ b/erts/emulator/beam/erl_db_util.c
@@ -1377,15 +1377,15 @@ restart:
for (;;) {
switch (t & _TAG_PRIMARY_MASK) {
case TAG_PRIMARY_BOXED:
- if (is_map(t)) {
- num_iters = map_get_size(map_val(t));
+ if (is_flatmap(t)) {
+ num_iters = flatmap_get_size(flatmap_val(t));
if (!structure_checked) {
DMC_PUSH(text, matchMap);
DMC_PUSH(text, num_iters);
}
structure_checked = 0;
for (i = 0; i < num_iters; ++i) {
- Eterm key = map_get_keys(map_val(t))[i];
+ Eterm key = flatmap_get_keys(flatmap_val(t))[i];
if (db_is_variable(key) >= 0) {
if (context.err_info) {
add_dmc_err(context.err_info,
@@ -1405,7 +1405,7 @@ restart:
DMC_PUSH(text, dmc_private_copy(&context, key));
{
int old_stack = ++(context.stack_used);
- Eterm value = map_get_values(map_val(t))[i];
+ Eterm value = flatmap_get_values(flatmap_val(t))[i];
res = dmc_one_term(&context, &heap, &stack, &text,
value);
ASSERT(res != retFail);
@@ -2004,12 +2004,12 @@ restart:
++ep;
break;
case matchMap:
- if (!is_map_rel(*ep, base) && !is_hashmap_rel(*ep,base)) {
+ if (!is_flatmap_rel(*ep, base) && !is_hashmap_rel(*ep,base)) {
FAIL();
}
n = *pc++;
- if (is_map_rel(*ep,base)) {
- if (map_get_size(map_val_rel(*ep, base)) < n) {
+ if (is_flatmap_rel(*ep,base)) {
+ if (flatmap_get_size(flatmap_val_rel(*ep, base)) < n) {
FAIL();
}
} else {
@@ -2018,15 +2018,15 @@ restart:
FAIL();
}
}
- ep = map_val_rel(*ep, base);
+ ep = flatmap_val_rel(*ep, base);
break;
case matchPushM:
- if (!is_map_rel(*ep, base) && !is_hashmap_rel(*ep, base)) {
+ if (!is_flatmap_rel(*ep, base) && !is_hashmap_rel(*ep, base)) {
FAIL();
}
n = *pc++;
- if (is_map_rel(*ep,base)) {
- if (map_get_size(map_val_rel(*ep, base)) < n) {
+ if (is_flatmap_rel(*ep,base)) {
+ if (flatmap_get_size(flatmap_val_rel(*ep, base)) < n) {
FAIL();
}
} else {
@@ -2035,11 +2035,11 @@ restart:
FAIL();
}
}
- *sp++ = map_val_rel(*ep++, base);
+ *sp++ = flatmap_val_rel(*ep++, base);
break;
case matchKey:
t = (Eterm) *pc++;
- tp = erts_maps_get_rel(t, make_map_rel(ep, base), base);
+ tp = erts_maps_get_rel(t, make_flatmap_rel(ep, base), base);
if (!tp) {
FAIL();
}
@@ -2156,12 +2156,12 @@ restart:
ehp = HAllocX(build_proc, 1 + MAP_HEADER_SIZE + n, HEAP_XTRA);
t = *ehp++ = *--esp;
{
- map_t *m = (map_t *)ehp;
+ flatmap_t *m = (flatmap_t *)ehp;
m->thing_word = MAP_HEADER;
m->size = n;
m->keys = t;
}
- t = make_map(ehp);
+ t = make_flatmap(ehp);
ehp += MAP_HEADER_SIZE;
while (n--) {
*ehp++ = *--esp;
@@ -3373,10 +3373,10 @@ int db_has_variable(Eterm node) {
while(arity--) {
ESTACK_PUSH(s,*(++tuple));
}
- } else if (is_map(node)) {
- Eterm *values = map_get_values(map_val(node));
- int size = map_get_size(map_val(node));
- ESTACK_PUSH(s, ((map_t *) map_val(node))->keys);
+ } else if (is_flatmap(node)) {
+ Eterm *values = flatmap_get_values(flatmap_val(node));
+ Uint size = flatmap_get_size(flatmap_val(node));
+ ESTACK_PUSH(s, ((flatmap_t *) flatmap_val(node))->keys);
while (size--) {
ESTACK_PUSH(s, *(values++));
}
@@ -3540,7 +3540,7 @@ static DMCRet dmc_one_term(DMCContext *context,
DMC_PUSH(*stack, c);
break;
case (_TAG_HEADER_MAP >> _TAG_PRIMARY_SIZE):
- n = map_get_size(map_val(c));
+ n = flatmap_get_size(flatmap_val(c));
DMC_PUSH(*text, matchPushM);
++(context->stack_used);
DMC_PUSH(*text, n);
@@ -3841,11 +3841,11 @@ dmc_map(DMCContext *context, DMCHeap *heap, DMC_STACK_TYPE(UWord) *text,
int nelems;
int constant_values;
DMCRet ret;
- if (is_map(t)) {
- map_t *m = (map_t *)map_val(t);
- Eterm *values = map_get_values(m);
+ if (is_flatmap(t)) {
+ flatmap_t *m = (flatmap_t *)flatmap_val(t);
+ Eterm *values = flatmap_get_values(m);
- nelems = map_get_size(m);
+ nelems = flatmap_get_size(m);
ret = dmc_array(context, heap, text, values, nelems, &constant_values);
if (ret != retOk) {
@@ -4915,7 +4915,7 @@ static DMCRet dmc_expr(DMCContext *context,
return ret;
break;
case TAG_PRIMARY_BOXED:
- if (is_map(t) || is_hashmap(t)) {
+ if (is_flatmap(t) || is_hashmap(t)) {
return dmc_map(context, heap, text, t, constant);
}
if (!is_tuple(t)) {
diff --git a/erts/emulator/beam/erl_gc.h b/erts/emulator/beam/erl_gc.h
index 3fec553684..8afcb060a1 100644
--- a/erts/emulator/beam/erl_gc.h
+++ b/erts/emulator/beam/erl_gc.h
@@ -55,7 +55,7 @@ do { \
nelts = header_arity(HDR); \
switch ((HDR) & _HEADER_SUBTAG_MASK) { \
case SUB_BINARY_SUBTAG: nelts++; break; \
- case MAP_SUBTAG: nelts+=map_get_size(PTR) + 1; break; \
+ case MAP_SUBTAG: nelts+=flatmap_get_size(PTR) + 1; break; \
case HASHMAP_SUBTAG: nelts=hashmap_bitcount(MAP_HEADER_VAL(HDR)); \
nelts += is_hashmap_header_head(HDR) ? 1 : 0; break; \
case FUN_SUBTAG: nelts+=((ErlFunThing*)(PTR))->num_free+1; break; \
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c
index 65a31d3680..ca43baf1a6 100644
--- a/erts/emulator/beam/erl_map.c
+++ b/erts/emulator/beam/erl_map.c
@@ -78,7 +78,7 @@ typedef struct {
} hxnode_t;
-static Eterm map_merge(Process *p, Eterm nodeA, Eterm nodeB);
+static Eterm flatmap_merge(Process *p, Eterm nodeA, Eterm nodeB);
static Eterm map_merge_mixed(Process *p, Eterm flat, Eterm tree, int swap_args);
static Eterm hashmap_merge(Process *p, Eterm nodeA, Eterm nodeB);
static Eterm hashmap_to_list(Process *p, Eterm map);
@@ -101,11 +101,11 @@ static int hxnodecmpkey(hxnode_t* a, hxnode_t* b);
*/
BIF_RETTYPE map_size_1(BIF_ALIST_1) {
- if (is_map(BIF_ARG_1)) {
+ if (is_flatmap(BIF_ARG_1)) {
Eterm *hp;
Uint hsz = 0;
- map_t *mp = (map_t*)map_val(BIF_ARG_1);
- Uint n = map_get_size(mp);
+ flatmap_t *mp = (flatmap_t*)flatmap_val(BIF_ARG_1);
+ Uint n = flatmap_get_size(mp);
erts_bld_uint(NULL, &hsz, n);
hp = HAlloc(BIF_P, hsz);
@@ -128,15 +128,15 @@ BIF_RETTYPE map_size_1(BIF_ALIST_1) {
/* maps:to_list/1 */
BIF_RETTYPE maps_to_list_1(BIF_ALIST_1) {
- if (is_map(BIF_ARG_1)) {
+ if (is_flatmap(BIF_ARG_1)) {
Uint n;
Eterm* hp;
Eterm *ks,*vs, res, tup;
- map_t *mp = (map_t*)map_val(BIF_ARG_1);
+ flatmap_t *mp = (flatmap_t*)flatmap_val(BIF_ARG_1);
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
- n = map_get_size(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
+ n = flatmap_get_size(mp);
hp = HAlloc(BIF_P, (2 + 3) * n);
res = NIL;
@@ -165,20 +165,20 @@ erts_maps_get(Eterm key, Eterm map)
#endif
{
Uint32 hx;
- if (is_map(map)) {
+ if (is_flatmap(map)) {
Eterm *ks, *vs;
- map_t *mp;
+ flatmap_t *mp;
Uint n, i;
- mp = (map_t *)map_val_rel(map, map_base);
- n = map_get_size(mp);
+ mp = (flatmap_t *)flatmap_val_rel(map, map_base);
+ n = flatmap_get_size(mp);
if (n == 0) {
return NULL;
}
ks = (Eterm *)tuple_val_rel(mp->keys, map_base) + 1;
- vs = map_get_values(mp);
+ vs = flatmap_get_values(mp);
if (is_immed(key)) {
for (i = 0; i < n; i++) {
@@ -202,7 +202,7 @@ erts_maps_get(Eterm key, Eterm map)
}
BIF_RETTYPE maps_find_2(BIF_ALIST_2) {
- if (is_map(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
Eterm *hp, res;
const Eterm *value;
@@ -226,7 +226,7 @@ BIF_RETTYPE maps_find_2(BIF_ALIST_2) {
*/
BIF_RETTYPE maps_get_2(BIF_ALIST_2) {
- if (is_map(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
Eterm *hp;
Eterm error;
const Eterm *value;
@@ -289,7 +289,7 @@ error:
static Eterm map_from_validated_list(Process *p, Eterm list, Uint size) {
Eterm *kv, item = list;
Eterm *hp, *thp,*vs, *ks, keys, res;
- map_t *mp;
+ flatmap_t *mp;
Uint unused_size = 0;
Sint c = 0;
Sint idx = 0;
@@ -301,8 +301,8 @@ static Eterm map_from_validated_list(Process *p, Eterm list, Uint size) {
*hp++ = make_arityval(size);
ks = hp;
hp += size;
- mp = (map_t*)hp;
- res = make_map(mp);
+ mp = (flatmap_t*)hp;
+ res = make_flatmap(mp);
hp += MAP_HEADER_SIZE;
vs = hp;
@@ -427,7 +427,7 @@ static Eterm hashmap_from_validated_list(Process *p, Eterm list, Uint size) {
if (hashmap_size(res) <= MAP_SMALL_MAP_LIMIT) {
DECLARE_WSTACK(wstack);
Eterm *kv, *ks, *vs;
- map_t *mp;
+ flatmap_t *mp;
Eterm keys;
Uint n = hashmap_size(res);
@@ -437,7 +437,7 @@ static Eterm hashmap_from_validated_list(Process *p, Eterm list, Uint size) {
*hp++ = make_arityval(n);
ks = hp;
hp += n;
- mp = (map_t*)hp;
+ mp = (flatmap_t*)hp;
hp += MAP_HEADER_SIZE;
vs = hp;
@@ -453,10 +453,10 @@ static Eterm hashmap_from_validated_list(Process *p, Eterm list, Uint size) {
}
/* it cannot have multiple keys */
- erts_validate_and_sort_map(mp);
+ erts_validate_and_sort_flatmap(mp);
DESTROY_WSTACK(wstack);
- return make_map(mp);
+ return make_flatmap(mp);
}
return res;
@@ -877,7 +877,7 @@ static int hxnodecmp(hxnode_t *a, hxnode_t *b) {
/* maps:is_key/2 */
BIF_RETTYPE maps_is_key_2(BIF_ALIST_2) {
- if (is_map(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
BIF_RET(erts_maps_get(BIF_ARG_1, BIF_ARG_2) ? am_true : am_false);
}
BIF_ERROR(BIF_P, BADARG);
@@ -886,19 +886,19 @@ BIF_RETTYPE maps_is_key_2(BIF_ALIST_2) {
/* maps:keys/1 */
BIF_RETTYPE maps_keys_1(BIF_ALIST_1) {
- if (is_map(BIF_ARG_1)) {
+ if (is_flatmap(BIF_ARG_1)) {
Eterm *hp, *ks, res = NIL;
- map_t *mp;
+ flatmap_t *mp;
Uint n;
- mp = (map_t*)map_val(BIF_ARG_1);
- n = map_get_size(mp);
+ mp = (flatmap_t*)flatmap_val(BIF_ARG_1);
+ n = flatmap_get_size(mp);
if (n == 0)
BIF_RET(res);
hp = HAlloc(BIF_P, (2 * n));
- ks = map_get_keys(mp);
+ ks = flatmap_get_keys(mp);
while(n--) {
res = CONS(hp, ks[n], res); hp += 2;
@@ -913,9 +913,9 @@ BIF_RETTYPE maps_keys_1(BIF_ALIST_1) {
/* maps:merge/2 */
BIF_RETTYPE maps_merge_2(BIF_ALIST_2) {
- if (is_map(BIF_ARG_1)) {
- if (is_map(BIF_ARG_2)) {
- BIF_RET(map_merge(BIF_P, BIF_ARG_1, BIF_ARG_2));
+ if (is_flatmap(BIF_ARG_1)) {
+ if (is_flatmap(BIF_ARG_2)) {
+ BIF_RET(flatmap_merge(BIF_P, BIF_ARG_1, BIF_ARG_2));
} else if (is_hashmap(BIF_ARG_2)) {
/* Will always become a tree */
BIF_RET(map_merge_mixed(BIF_P, BIF_ARG_1, BIF_ARG_2, 0));
@@ -923,7 +923,7 @@ BIF_RETTYPE maps_merge_2(BIF_ALIST_2) {
} else if (is_hashmap(BIF_ARG_1)) {
if (is_hashmap(BIF_ARG_2)) {
BIF_RET(hashmap_merge(BIF_P, BIF_ARG_1, BIF_ARG_2));
- } else if (is_map(BIF_ARG_2)) {
+ } else if (is_flatmap(BIF_ARG_2)) {
/* Will always become a tree */
BIF_RET(map_merge_mixed(BIF_P, BIF_ARG_2, BIF_ARG_1, 1));
}
@@ -931,18 +931,18 @@ BIF_RETTYPE maps_merge_2(BIF_ALIST_2) {
BIF_ERROR(BIF_P, BADARG);
}
-static Eterm map_merge(Process *p, Eterm nodeA, Eterm nodeB) {
+static Eterm flatmap_merge(Process *p, Eterm nodeA, Eterm nodeB) {
Eterm *hp,*thp;
Eterm tup;
Eterm *ks,*vs,*ks1,*vs1,*ks2,*vs2;
- map_t *mp1,*mp2,*mp_new;
+ flatmap_t *mp1,*mp2,*mp_new;
Uint n,n1,n2,i1,i2,need,unused_size=0;
int c = 0;
- mp1 = (map_t*)map_val(nodeA);
- mp2 = (map_t*)map_val(nodeB);
- n1 = map_get_size(mp1);
- n2 = map_get_size(mp2);
+ mp1 = (flatmap_t*)flatmap_val(nodeA);
+ mp2 = (flatmap_t*)flatmap_val(nodeB);
+ n1 = flatmap_get_size(mp1);
+ n2 = flatmap_get_size(mp2);
need = MAP_HEADER_SIZE + 1 + 2*(n1 + n2);
@@ -950,7 +950,7 @@ static Eterm map_merge(Process *p, Eterm nodeA, Eterm nodeB) {
thp = hp;
tup = make_tuple(thp);
ks = hp + 1; hp += 1 + n1 + n2;
- mp_new = (map_t*)hp; hp += MAP_HEADER_SIZE;
+ mp_new = (flatmap_t*)hp; hp += MAP_HEADER_SIZE;
vs = hp; hp += n1 + n2;
mp_new->thing_word = MAP_HEADER;
@@ -958,10 +958,10 @@ static Eterm map_merge(Process *p, Eterm nodeA, Eterm nodeB) {
mp_new->keys = tup;
i1 = 0; i2 = 0;
- ks1 = map_get_keys(mp1);
- vs1 = map_get_values(mp1);
- ks2 = map_get_keys(mp2);
- vs2 = map_get_values(mp2);
+ ks1 = flatmap_get_keys(mp1);
+ vs1 = flatmap_get_values(mp1);
+ ks2 = flatmap_get_keys(mp2);
+ vs2 = flatmap_get_values(mp2);
while(i1 < n1 && i2 < n2) {
c = CMP_TERM(ks1[i1],ks2[i2]);
@@ -1018,8 +1018,8 @@ static Eterm map_merge(Process *p, Eterm nodeA, Eterm nodeB) {
hxnode_t *hxns;
ErtsHeapFactory factory;
- ks = map_get_keys(mp_new);
- vs = map_get_values(mp_new);
+ ks = flatmap_get_keys(mp_new);
+ vs = flatmap_get_values(mp_new);
hp = HAlloc(p, 2 * n);
@@ -1045,12 +1045,12 @@ static Eterm map_merge(Process *p, Eterm nodeA, Eterm nodeB) {
mp_new->size = n;
- return make_map(mp_new);
+ return make_flatmap(mp_new);
}
static Eterm map_merge_mixed(Process *p, Eterm flat, Eterm tree, int swap_args) {
Eterm *ks, *vs, *hp, res;
- map_t *mp;
+ flatmap_t *mp;
Uint n, i;
hxnode_t *hxns;
Uint32 sw, hx;
@@ -1058,14 +1058,14 @@ static Eterm map_merge_mixed(Process *p, Eterm flat, Eterm tree, int swap_args)
/* convert flat to tree */
- ASSERT(is_map(flat));
+ ASSERT(is_flatmap(flat));
ASSERT(is_hashmap(tree));
- mp = (map_t*)map_val(flat);
- n = map_get_size(mp);
+ mp = (flatmap_t*)flatmap_val(flat);
+ n = flatmap_get_size(mp);
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
hp = HAlloc(p, 2 * n);
@@ -1343,24 +1343,24 @@ int hashmap_key_hash_cmp(Eterm* ap, Eterm* bp)
BIF_RETTYPE maps_new_0(BIF_ALIST_0) {
Eterm* hp;
Eterm tup;
- map_t *mp;
+ flatmap_t *mp;
hp = HAlloc(BIF_P, (MAP_HEADER_SIZE + 1));
tup = make_tuple(hp);
*hp++ = make_arityval(0);
- mp = (map_t*)hp;
+ mp = (flatmap_t*)hp;
mp->thing_word = MAP_HEADER;
mp->size = 0;
mp->keys = tup;
- BIF_RET(make_map(mp));
+ BIF_RET(make_flatmap(mp));
}
/* maps:put/3 */
BIF_RETTYPE maps_put_3(BIF_ALIST_3) {
- if (is_map(BIF_ARG_3) || is_hashmap(BIF_ARG_3)) {
+ if (is_flatmap(BIF_ARG_3) || is_hashmap(BIF_ARG_3)) {
BIF_RET(erts_maps_put(BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3));
}
BIF_ERROR(BIF_P, BADARG);
@@ -1370,23 +1370,23 @@ BIF_RETTYPE maps_put_3(BIF_ALIST_3) {
int erts_maps_remove(Process *p, Eterm key, Eterm map, Eterm *res) {
Uint32 hx;
- if (is_map(map)) {
+ if (is_flatmap(map)) {
Sint n;
Uint need;
Eterm *hp_start;
Eterm *thp, *mhp;
Eterm *ks, *vs, tup;
- map_t *mp = (map_t*)map_val(map);
+ flatmap_t *mp = (flatmap_t*)flatmap_val(map);
- n = map_get_size(mp);
+ n = flatmap_get_size(mp);
if (n == 0) {
*res = map;
return 1;
}
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
/* Assume key exists.
* Release allocated if it didn't.
@@ -1401,7 +1401,7 @@ int erts_maps_remove(Process *p, Eterm key, Eterm map, Eterm *res) {
tup = make_tuple(thp);
*thp++ = make_arityval(n - 1);
- *res = make_map(mhp);
+ *res = make_flatmap(mhp);
*mhp++ = MAP_HEADER;
*mhp++ = n - 1;
*mhp++ = tup;
@@ -1451,7 +1451,7 @@ found_key:
}
BIF_RETTYPE maps_remove_2(BIF_ALIST_2) {
- if (is_map(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
+ if (is_flatmap(BIF_ARG_2) || is_hashmap(BIF_ARG_2)) {
Eterm res;
if (erts_maps_remove(BIF_P, BIF_ARG_1, BIF_ARG_2, &res)) {
BIF_RET(res);
@@ -1462,18 +1462,18 @@ BIF_RETTYPE maps_remove_2(BIF_ALIST_2) {
int erts_maps_update(Process *p, Eterm key, Eterm value, Eterm map, Eterm *res) {
Uint32 hx;
- if (is_map(map)) {
+ if (is_flatmap(map)) {
Sint n,i;
Eterm* hp,*shp;
Eterm *ks,*vs;
- map_t *mp = (map_t*)map_val(map);
+ flatmap_t *mp = (flatmap_t*)flatmap_val(map);
- if ((n = map_get_size(mp)) == 0) {
+ if ((n = flatmap_get_size(mp)) == 0) {
return 0;
}
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
/* only allocate for values,
* assume key-tuple will be intact
@@ -1511,7 +1511,7 @@ found_key:
vs++;
if (++i < n)
sys_memcpy(hp, vs, (n - i)*sizeof(Eterm));
- *res = make_map(shp);
+ *res = make_flatmap(shp);
return 1;
}
@@ -1527,21 +1527,21 @@ found_key:
Eterm erts_maps_put(Process *p, Eterm key, Eterm value, Eterm map) {
Uint32 hx;
Eterm res;
- if (is_map(map)) {
+ if (is_flatmap(map)) {
Sint n,i;
Sint c = 0;
Eterm* hp, *shp;
Eterm *ks, *vs, tup;
- map_t *mp = (map_t*)map_val(map);
+ flatmap_t *mp = (flatmap_t*)flatmap_val(map);
- n = map_get_size(mp);
+ n = flatmap_get_size(mp);
if (n == 0) {
hp = HAlloc(p, MAP_HEADER_SIZE + 1 + 2);
tup = make_tuple(hp);
*hp++ = make_arityval(1);
*hp++ = key;
- res = make_map(hp);
+ res = make_flatmap(hp);
*hp++ = MAP_HEADER;
*hp++ = 1;
*hp++ = tup;
@@ -1550,8 +1550,8 @@ Eterm erts_maps_put(Process *p, Eterm key, Eterm value, Eterm map) {
return res;
}
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
/* only allocate for values,
* assume key-tuple will be intact
@@ -1559,7 +1559,7 @@ Eterm erts_maps_put(Process *p, Eterm key, Eterm value, Eterm map) {
hp = HAlloc(p, MAP_HEADER_SIZE + n);
shp = hp; /* save hp, used if optimistic update fails */
- res = make_map(hp);
+ res = make_flatmap(hp);
*hp++ = MAP_HEADER;
*hp++ = n;
*hp++ = mp->keys;
@@ -1593,8 +1593,8 @@ Eterm erts_maps_put(Process *p, Eterm key, Eterm value, Eterm map) {
if (n >= MAP_SMALL_MAP_LIMIT) {
HRelease(p, shp + MAP_HEADER_SIZE + n, shp);
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
res = erts_hashmap_from_ks_and_vs_extra(p,ks,vs,n,key,value);
@@ -1608,13 +1608,13 @@ Eterm erts_maps_put(Process *p, Eterm key, Eterm value, Eterm map) {
*shp++ = make_arityval(n+1);
hp = HAlloc(p, 3 + n + 1);
- res = make_map(hp);
+ res = make_flatmap(hp);
*hp++ = MAP_HEADER;
*hp++ = n + 1;
*hp++ = tup;
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
ASSERT(n >= 0);
@@ -1653,7 +1653,7 @@ Eterm erts_maps_put(Process *p, Eterm key, Eterm value, Eterm map) {
/* maps:update/3 */
BIF_RETTYPE maps_update_3(BIF_ALIST_3) {
- if (is_map(BIF_ARG_3) || is_hashmap(BIF_ARG_3)) {
+ if (is_flatmap(BIF_ARG_3) || is_hashmap(BIF_ARG_3)) {
Eterm res;
if (erts_maps_update(BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3, &res)) {
BIF_RET(res);
@@ -1666,19 +1666,19 @@ BIF_RETTYPE maps_update_3(BIF_ALIST_3) {
/* maps:values/1 */
BIF_RETTYPE maps_values_1(BIF_ALIST_1) {
- if (is_map(BIF_ARG_1)) {
+ if (is_flatmap(BIF_ARG_1)) {
Eterm *hp, *vs, res = NIL;
- map_t *mp;
+ flatmap_t *mp;
Uint n;
- mp = (map_t*)map_val(BIF_ARG_1);
- n = map_get_size(mp);
+ mp = (flatmap_t*)flatmap_val(BIF_ARG_1);
+ n = flatmap_get_size(mp);
if (n == 0)
BIF_RET(res);
hp = HAlloc(BIF_P, (2 * n));
- vs = map_get_values(mp);
+ vs = flatmap_get_values(mp);
while(n--) {
res = CONS(hp, vs[n], res); hp += 2;
@@ -2257,7 +2257,7 @@ unroll:
if (n <= MAP_SMALL_MAP_LIMIT) {
DECLARE_WSTACK(wstack);
Eterm *kv, *ks, *vs;
- map_t *mp;
+ flatmap_t *mp;
Eterm keys;
DESTROY_ESTACK(stack);
@@ -2268,7 +2268,7 @@ unroll:
*hp++ = make_arityval(n);
ks = hp;
hp += n;
- mp = (map_t*)hp;
+ mp = (flatmap_t*)hp;
hp += MAP_HEADER_SIZE;
vs = hp;
@@ -2286,10 +2286,10 @@ unroll:
}
/* it cannot have multiple keys */
- erts_validate_and_sort_map(mp);
+ erts_validate_and_sort_flatmap(mp);
DESTROY_WSTACK(wstack);
- return make_map(mp);
+ return make_flatmap(mp);
}
hp = HAlloc(p, size);
@@ -2451,11 +2451,11 @@ not_found:
}
-int erts_validate_and_sort_map(map_t* mp)
+int erts_validate_and_sort_flatmap(flatmap_t* mp)
{
- Eterm *ks = map_get_keys(mp);
- Eterm *vs = map_get_values(mp);
- Uint sz = map_get_size(mp);
+ Eterm *ks = flatmap_get_keys(mp);
+ Eterm *vs = flatmap_get_values(mp);
+ Uint sz = flatmap_get_size(mp);
Uint ix,jx;
Eterm tmp;
int c;
@@ -2533,8 +2533,8 @@ BIF_RETTYPE erts_debug_map_info_1(BIF_ALIST_1) {
*/
BIF_RETTYPE erts_internal_map_to_tuple_keys_1(BIF_ALIST_1) {
- if (is_map(BIF_ARG_1)) {
- map_t *mp = (map_t*)map_val(BIF_ARG_1);
+ if (is_flatmap(BIF_ARG_1)) {
+ flatmap_t *mp = (flatmap_t*)flatmap_val(BIF_ARG_1);
BIF_RET(mp->keys);
}
BIF_ERROR(BIF_P, BADARG);
diff --git a/erts/emulator/beam/erl_map.h b/erts/emulator/beam/erl_map.h
index db22d461ce..884bf69a34 100644
--- a/erts/emulator/beam/erl_map.h
+++ b/erts/emulator/beam/erl_map.h
@@ -34,11 +34,11 @@ Uint32 hashmap_bitcount(Uint32 x);
/* MAP */
-typedef struct map_s {
+typedef struct flatmap_s {
Eterm thing_word;
Uint size;
Eterm keys; /* tuple */
-} map_t;
+} flatmap_t;
/* map node
*
* -----------
@@ -66,23 +66,23 @@ typedef struct map_s {
/* erl_term.h stuff */
-#define make_map(x) make_boxed((Eterm*)(x))
-#define make_map_rel(x, BASE) make_boxed_rel((Eterm*)(x),(BASE))
-#define is_map(x) (is_boxed((x)) && is_map_header(*boxed_val((x))))
-#define is_map_rel(RTERM,BASE) is_map(rterm2wterm(RTERM,BASE))
-#define is_not_map(x) (!is_map((x)))
-#define is_map_header(x) (((x) & (_TAG_HEADER_MASK)) == _TAG_HEADER_MAP)
-#define header_is_map(x) ((((x) & (_HEADER_SUBTAG_MASK)) == MAP_SUBTAG))
-#define map_val(x) (_unchecked_boxed_val((x)))
-#define map_val_rel(RTERM, BASE) map_val(rterm2wterm(RTERM, BASE))
-
-#define map_get_values(x) (((Eterm *)(x)) + 3)
-#define map_get_keys(x) (((Eterm *)tuple_val(((map_t *)(x))->keys)) + 1)
-#define map_get_size(x) (((map_t*)(x))->size)
+#define make_flatmap(x) make_boxed((Eterm*)(x))
+#define make_flatmap_rel(x, BASE) make_boxed_rel((Eterm*)(x),(BASE))
+#define is_flatmap(x) (is_boxed((x)) && is_flatmap_header(*boxed_val((x))))
+#define is_flatmap_rel(RTERM,BASE) is_flatmap(rterm2wterm(RTERM,BASE))
+#define is_not_flatmap(x) (!is_flatmap((x)))
+#define is_flatmap_header(x) (((x) & (_TAG_HEADER_MASK)) == _TAG_HEADER_MAP)
+#define header_is_flatmap(x) ((((x) & (_HEADER_SUBTAG_MASK)) == MAP_SUBTAG))
+#define flatmap_val(x) (_unchecked_boxed_val((x)))
+#define flatmap_val_rel(RTERM, BASE) flatmap_val(rterm2wterm(RTERM, BASE))
+
+#define flatmap_get_values(x) (((Eterm *)(x)) + 3)
+#define flatmap_get_keys(x) (((Eterm *)tuple_val(((flatmap_t *)(x))->keys)) + 1)
+#define flatmap_get_size(x) (((flatmap_t*)(x))->size)
#define MAP_SMALL_MAP_LIMIT (2) /*SVERK (32) */
#define MAP_HEADER _make_header(1,_TAG_HEADER_MAP)
-#define MAP_HEADER_SIZE (sizeof(map_t) / sizeof(Eterm))
+#define MAP_HEADER_SIZE (sizeof(flatmap_t) / sizeof(Eterm))
struct ErtsWStack_;
struct ErtsEStack_;
@@ -98,7 +98,7 @@ int erts_hashmap_insert_down(Uint32 hx, Eterm key, Eterm node, Uint *sz,
Eterm erts_hashmap_insert_up(Eterm *hp, Eterm key, Eterm value,
Uint *upsz, struct ErtsEStack_ *sp);
-int erts_validate_and_sort_map(map_t* map);
+int erts_validate_and_sort_flatmap(flatmap_t* map);
Uint hashmap_over_estimated_heap_size(Uint n);
void hashmap_iterator_init(struct ErtsWStack_* s, Eterm node);
Eterm* hashmap_iterator_next(struct ErtsWStack_* s);
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 198acfd128..fd793fd7e4 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1905,15 +1905,15 @@ enif_is_on_dirty_scheduler(ErlNifEnv* env)
int enif_is_map(ErlNifEnv* env, ERL_NIF_TERM term)
{
- return is_map(term);
+ return is_flatmap(term);
}
int enif_get_map_size(ErlNifEnv* env, ERL_NIF_TERM term, size_t *size)
{
- if (is_map(term)) {
- map_t *mp;
- mp = (map_t*)map_val(term);
- *size = map_get_size(mp);
+ if (is_flatmap(term)) {
+ flatmap_t *mp;
+ mp = (flatmap_t*)flatmap_val(term);
+ *size = flatmap_get_size(mp);
return 1;
}
return 0;
@@ -1923,16 +1923,16 @@ ERL_NIF_TERM enif_make_new_map(ErlNifEnv* env)
{
Eterm* hp = alloc_heap(env,MAP_HEADER_SIZE+1);
Eterm tup;
- map_t *mp;
+ flatmap_t *mp;
tup = make_tuple(hp);
*hp++ = make_arityval(0);
- mp = (map_t*)hp;
+ mp = (flatmap_t*)hp;
mp->thing_word = MAP_HEADER;
mp->size = 0;
mp->keys = tup;
- return make_map(mp);
+ return make_flatmap(mp);
}
int enif_make_map_put(ErlNifEnv* env,
@@ -1941,7 +1941,7 @@ int enif_make_map_put(ErlNifEnv* env,
Eterm value,
Eterm *map_out)
{
- if (is_not_map(map_in)) {
+ if (is_not_flatmap(map_in)) {
return 0;
}
flush_env(env);
@@ -1956,7 +1956,7 @@ int enif_get_map_value(ErlNifEnv* env,
Eterm *value)
{
const Eterm *ret;
- if (is_not_map(map)) {
+ if (is_not_flatmap(map)) {
return 0;
}
ret = erts_maps_get(key, map);
@@ -1974,7 +1974,7 @@ int enif_make_map_update(ErlNifEnv* env,
Eterm *map_out)
{
int res;
- if (is_not_map(map_in)) {
+ if (is_not_flatmap(map_in)) {
return 0;
}
@@ -1990,7 +1990,7 @@ int enif_make_map_remove(ErlNifEnv* env,
Eterm *map_out)
{
int res;
- if (is_not_map(map_in)) {
+ if (is_not_flatmap(map_in)) {
return 0;
}
flush_env(env);
@@ -2004,13 +2004,13 @@ int enif_map_iterator_create(ErlNifEnv *env,
ErlNifMapIterator *iter,
ErlNifMapIteratorEntry entry)
{
- if (is_map(map)) {
- map_t *mp = (map_t*)map_val(map);
+ if (is_flatmap(map)) {
+ flatmap_t *mp = (flatmap_t*)flatmap_val(map);
size_t offset;
switch (entry) {
case ERL_NIF_MAP_ITERATOR_HEAD: offset = 0; break;
- case ERL_NIF_MAP_ITERATOR_TAIL: offset = map_get_size(mp) - 1; break;
+ case ERL_NIF_MAP_ITERATOR_TAIL: offset = flatmap_get_size(mp) - 1; break;
default: goto error;
}
@@ -2019,9 +2019,9 @@ int enif_map_iterator_create(ErlNifEnv *env,
*/
iter->map = map;
- iter->ks = ((Eterm *)map_get_keys(mp)) + offset;
- iter->vs = ((Eterm *)map_get_values(mp)) + offset;
- iter->t_limit = map_get_size(mp) + 1;
+ iter->ks = ((Eterm *)flatmap_get_keys(mp)) + offset;
+ iter->vs = ((Eterm *)flatmap_get_values(mp)) + offset;
+ iter->t_limit = flatmap_get_size(mp) + 1;
iter->idx = offset + 1;
return 1;
@@ -2045,22 +2045,22 @@ void enif_map_iterator_destroy(ErlNifEnv *env, ErlNifMapIterator *iter)
int enif_map_iterator_is_tail(ErlNifEnv *env, ErlNifMapIterator *iter)
{
- ASSERT(iter && is_map(iter->map));
- ASSERT(iter->idx >= 0 && (iter->idx <= map_get_size(map_val(iter->map)) + 1));
+ ASSERT(iter && is_flatmap(iter->map));
+ ASSERT(iter->idx >= 0 && (iter->idx <= flatmap_get_size(flatmap_val(iter->map)) + 1));
return (iter->t_limit == 1 || iter->idx == iter->t_limit);
}
int enif_map_iterator_is_head(ErlNifEnv *env, ErlNifMapIterator *iter)
{
- ASSERT(iter && is_map(iter->map));
- ASSERT(iter->idx >= 0 && (iter->idx <= map_get_size(map_val(iter->map)) + 1));
+ ASSERT(iter && is_flatmap(iter->map));
+ ASSERT(iter->idx >= 0 && (iter->idx <= flatmap_get_size(flatmap_val(iter->map)) + 1));
return (iter->t_limit == 1 || iter->idx == 0);
}
int enif_map_iterator_next(ErlNifEnv *env, ErlNifMapIterator *iter)
{
- ASSERT(iter && is_map(iter->map));
+ ASSERT(iter && is_flatmap(iter->map));
if (iter->idx < iter->t_limit) {
iter->idx++;
iter->ks++;
@@ -2071,7 +2071,7 @@ int enif_map_iterator_next(ErlNifEnv *env, ErlNifMapIterator *iter)
int enif_map_iterator_prev(ErlNifEnv *env, ErlNifMapIterator *iter)
{
- ASSERT(iter && is_map(iter->map));
+ ASSERT(iter && is_flatmap(iter->map));
if (iter->idx > 0) {
iter->idx--;
iter->ks--;
@@ -2085,12 +2085,12 @@ int enif_map_iterator_get_pair(ErlNifEnv *env,
Eterm *key,
Eterm *value)
{
- ASSERT(iter && is_map(iter->map));
+ ASSERT(iter && is_flatmap(iter->map));
if (iter->idx > 0 && iter->idx < iter->t_limit) {
- ASSERT(iter->ks >= map_get_keys(map_val(iter->map)) &&
- iter->ks < (map_get_keys(map_val(iter->map)) + map_get_size(map_val(iter->map))));
- ASSERT(iter->vs >= map_get_values(map_val(iter->map)) &&
- iter->vs < (map_get_values(map_val(iter->map)) + map_get_size(map_val(iter->map))));
+ ASSERT(iter->ks >= flatmap_get_keys(flatmap_val(iter->map)) &&
+ iter->ks < (flatmap_get_keys(flatmap_val(iter->map)) + flatmap_get_size(flatmap_val(iter->map))));
+ ASSERT(iter->vs >= flatmap_get_values(flatmap_val(iter->map)) &&
+ iter->vs < (flatmap_get_values(flatmap_val(iter->map)) + flatmap_get_size(flatmap_val(iter->map))));
*key = *(iter->ks);
*value = *(iter->vs);
return 1;
diff --git a/erts/emulator/beam/erl_printf_term.c b/erts/emulator/beam/erl_printf_term.c
index 81fd19693a..8046f54a0c 100644
--- a/erts/emulator/beam/erl_printf_term.c
+++ b/erts/emulator/beam/erl_printf_term.c
@@ -568,10 +568,10 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
{
Uint n;
Eterm *ks, *vs;
- map_t *mp = (map_t *)map_val(wobj);
- n = map_get_size(mp);
- ks = map_get_keys(mp);
- vs = map_get_values(mp);
+ flatmap_t *mp = (flatmap_t *)flatmap_val(wobj);
+ n = flatmap_get_size(mp);
+ ks = flatmap_get_keys(mp);
+ vs = flatmap_get_values(mp);
PRINT_CHAR(res, fn, arg, '#');
PRINT_CHAR(res, fn, arg, '{');
diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
index bd9ad65086..65b4ae5412 100644
--- a/erts/emulator/beam/external.c
+++ b/erts/emulator/beam/external.c
@@ -2605,15 +2605,15 @@ enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep,
case MAP_DEF:
{
- map_t *mp = (map_t*)map_val(obj);
- Uint size = map_get_size(mp);
+ flatmap_t *mp = (flatmap_t*)flatmap_val(obj);
+ Uint size = flatmap_get_size(mp);
*ep++ = MAP_EXT;
put_int32(size, ep); ep += 4;
if (size > 0) {
- Eterm *kptr = map_get_keys(mp);
- Eterm *vptr = map_get_values(mp);
+ Eterm *kptr = flatmap_get_keys(mp);
+ Eterm *vptr = flatmap_get_values(mp);
WSTACK_PUSH4(s, (UWord)kptr, (UWord)vptr,
ENC_MAP_PAIR, size);
@@ -3599,14 +3599,14 @@ dec_term_atom_common:
size = get_int32(ep); ep += 4;
if (size <= MAP_SMALL_MAP_LIMIT) {
- map_t *mp;
+ flatmap_t *mp;
keys = make_tuple(hp);
*hp++ = make_arityval(size);
hp += size;
kptr = hp - 1;
- mp = (map_t*)hp;
+ mp = (flatmap_t*)hp;
hp += MAP_HEADER_SIZE;
hp += size;
vptr = hp - 1;
@@ -3625,7 +3625,7 @@ dec_term_atom_common:
mp->size = size;
mp->keys = keys;
- *objp = make_map(mp);
+ *objp = make_flatmap(mp);
for (n = size; n; n--) {
*vptr = (Eterm) COMPRESS_POINTER(next);
@@ -3891,7 +3891,7 @@ dec_term_atom_common:
while (maps_list) {
next = (Eterm *)(EXPAND_POINTER(*maps_list));
*maps_list = MAP_HEADER;
- if (!erts_validate_and_sort_map((map_t*)maps_list))
+ if (!erts_validate_and_sort_flatmap((flatmap_t*)maps_list))
goto error;
maps_list = next;
}
@@ -4120,15 +4120,15 @@ encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj,
break;
case MAP_DEF:
{
- map_t *mp = (map_t*)map_val(obj);
- Uint size = map_get_size(mp);
+ flatmap_t *mp = (flatmap_t*)flatmap_val(obj);
+ Uint size = flatmap_get_size(mp);
Uint i;
Eterm *ptr;
result += 1 + 4; /* tag + 4 bytes size */
/* push values first */
- ptr = map_get_values(mp);
+ ptr = flatmap_get_values(mp);
i = size;
while(i--) {
if (is_list(*ptr)) {
@@ -4142,7 +4142,7 @@ encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj,
++ptr;
}
- ptr = map_get_keys(mp);
+ ptr = flatmap_get_keys(mp);
i = size;
while(i--) {
if (is_list(*ptr)) {
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index dc4c6fc350..804d3ddf50 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -5595,16 +5595,16 @@ driver_deliver_term(Eterm to, ErlDrvTermData* data, int len)
int size = (int)ptr[0];
Eterm* tp = hp;
Eterm* vp;
- map_t *mp;
+ flatmap_t *mp;
*tp = make_arityval(size);
hp += 1 + size;
- mp = (map_t*)hp;
+ mp = (flatmap_t*)hp;
mp->thing_word = MAP_HEADER;
mp->size = size;
mp->keys = make_tuple(tp);
- mess = make_map(mp);
+ mess = make_flatmap(mp);
hp += MAP_HEADER_SIZE + size; /* advance "heap" pointer */
@@ -5615,7 +5615,7 @@ driver_deliver_term(Eterm to, ErlDrvTermData* data, int len)
*vp-- = ESTACK_POP(stack);
*tp-- = ESTACK_POP(stack);
}
- if (!erts_validate_and_sort_map(mp))
+ if (!erts_validate_and_sort_flatmap(mp))
ERTS_DDT_FAIL;
ptr++;
break;
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index 66f13461a1..cc97e2f3d1 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -1274,11 +1274,11 @@ make_hash2(Eterm term)
break;
case MAP_SUBTAG:
{
- map_t *mp = (map_t *)map_val(term);
+ flatmap_t *mp = (flatmap_t *)flatmap_val(term);
int i;
- int size = map_get_size(mp);
- Eterm *ks = map_get_keys(mp);
- Eterm *vs = map_get_values(mp);
+ int size = flatmap_get_size(mp);
+ Eterm *ks = flatmap_get_keys(mp);
+ Eterm *vs = flatmap_get_values(mp);
UINT32_HASH(size, HCONST_16);
if (size == 0) {
goto hash2_common;
@@ -1669,11 +1669,11 @@ make_internal_hash(Eterm term)
break;
case MAP_SUBTAG:
{
- map_t *mp = (map_t *)map_val(term);
+ flatmap_t *mp = (flatmap_t *)flatmap_val(term);
int i;
- int size = map_get_size(mp);
- Eterm *ks = map_get_keys(mp);
- Eterm *vs = map_get_values(mp);
+ int size = flatmap_get_size(mp);
+ Eterm *ks = flatmap_get_keys(mp);
+ Eterm *vs = flatmap_get_values(mp);
UINT32_HASH(size, HCONST_16);
if (size == 0) {
goto pop_next;
@@ -2574,13 +2574,13 @@ tailrecur_ne:
}
case MAP_SUBTAG:
{
- aa = map_val_rel(a, a_base);
+ aa = flatmap_val_rel(a, a_base);
if (!is_boxed(b) || *boxed_val_rel(b,b_base) != *aa)
goto not_equal;
- bb = map_val_rel(b,b_base);
- sz = map_get_size((map_t*)aa);
+ bb = flatmap_val_rel(b,b_base);
+ sz = flatmap_get_size((flatmap_t*)aa);
- if (sz != map_get_size((map_t*)bb)) goto not_equal;
+ if (sz != flatmap_get_size((flatmap_t*)bb)) goto not_equal;
if (sz == 0) goto pop_next;
aa += 2;
@@ -3119,16 +3119,16 @@ tailrecur_ne:
++bb;
goto term_array;
case (_TAG_HEADER_MAP >> _TAG_PRIMARY_SIZE) :
- if (!is_map_rel(b,b_base)) {
+ if (!is_flatmap_rel(b,b_base)) {
a_tag = MAP_DEF;
goto mixed_types;
}
- aa = (Eterm *)map_val_rel(a,a_base);
- bb = (Eterm *)map_val_rel(b,b_base);
+ aa = (Eterm *)flatmap_val_rel(a,a_base);
+ bb = (Eterm *)flatmap_val_rel(b,b_base);
- i = map_get_size((map_t*)aa);
- if (i != map_get_size((map_t*)bb)) {
- RETURN_NEQ((int)(i - map_get_size((map_t*)bb)));
+ i = flatmap_get_size((flatmap_t*)aa);
+ if (i != flatmap_get_size((flatmap_t*)bb)) {
+ RETURN_NEQ((int)(i - flatmap_get_size((flatmap_t*)bb)));
}
if (i == 0) {
goto pop_next;