aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorGuilherme Andrade <[email protected]>2017-02-14 22:31:31 +0000
committerGuilherme Andrade <[email protected]>2017-03-22 23:57:54 +0000
commit36d93952f6ca64192f05e0482fa55270103c8d97 (patch)
treec0f1a3714ed799079032b89d6c999ad5dcfb52a2 /erts/emulator/beam
parent3323f01156a698e2d21c2bb1c51b58cf47444aa0 (diff)
downloadotp-36d93952f6ca64192f05e0482fa55270103c8d97.tar.gz
otp-36d93952f6ca64192f05e0482fa55270103c8d97.tar.bz2
otp-36d93952f6ca64192f05e0482fa55270103c8d97.zip
Use magic refs on revamped ETS code
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/erl_db_hash.c27
-rw-r--r--erts/emulator/beam/erl_db_tree.c12
2 files changed, 15 insertions, 24 deletions
diff --git a/erts/emulator/beam/erl_db_hash.c b/erts/emulator/beam/erl_db_hash.c
index 1b5c8fe422..44d11dd5e7 100644
--- a/erts/emulator/beam/erl_db_hash.c
+++ b/erts/emulator/beam/erl_db_hash.c
@@ -1495,7 +1495,7 @@ static ERTS_INLINE int on_mtraversal_simple_trap(Export* trap_function,
Eterm mpb = NIL;
Eterm continuation = NIL;
int is_first_trap = (prev_continuation_tptr == NULL);
- size_t base_halloc_sz = (is_first_trap ? PROC_BIN_SIZE : 0);
+ size_t base_halloc_sz = (is_first_trap ? ERTS_MAGIC_REF_THING_SIZE : 0);
BUMP_ALL_REDS(p);
if (IS_USMALL(0, got)) {
@@ -1509,7 +1509,7 @@ static ERTS_INLINE int on_mtraversal_simple_trap(Export* trap_function,
}
if (is_first_trap) {
- mpb = db_make_mp_binary(p, *mpp, &hp);
+ mpb = erts_db_make_match_prog_ref(p, *mpp, &hp);
*mpp = NULL; /* otherwise the caller will destroy it */
}
else {
@@ -1539,17 +1539,14 @@ static ERTS_INLINE int unpack_simple_mtraversal_continuation(Eterm continuation,
if (arityval(*tptr) != 4)
return 1;
- if (! is_small(tptr[2])
- || !(is_binary(tptr[3]) && thing_subtag(*binary_val(tptr[3])) == REFC_BINARY_SUBTAG)
- || !(is_big(tptr[4]) || is_small(tptr[4])))
- {
+ if (! is_small(tptr[2]) || !(is_big(tptr[4]) || is_small(tptr[4]))) {
return 1;
}
*tptr_ptr = tptr;
*tid_ptr = tptr[1];
*slot_ix_p = unsigned_val(tptr[2]);
- *mpp = ((ProcBin *) binary_val(tptr[3]))->val;
+ *mpp = erts_db_get_match_prog_binary_unchecked(tptr[3]);
if (is_big(tptr[4])) {
*got_p = big_to_uint32(tptr[4]);
}
@@ -1629,8 +1626,8 @@ static int mtraversal_select_chunk_on_loop_ended(void* context_ptr, Sint slot_ix
been in 'user space' */
}
if (rest != NIL || slot_ix >= 0) { /* Need more calls */
- sc_context_ptr->hp = HAlloc(sc_context_ptr->p, 3 + 7 + PROC_BIN_SIZE);
- mpb = db_make_mp_binary(sc_context_ptr->p, *mpp, &sc_context_ptr->hp);
+ sc_context_ptr->hp = HAlloc(sc_context_ptr->p, 3 + 7 + ERTS_MAGIC_REF_THING_SIZE);
+ mpb = erts_db_make_match_prog_ref(sc_context_ptr->p, *mpp, &sc_context_ptr->hp);
continuation = TUPLE6(
sc_context_ptr->hp,
sc_context_ptr->tid,
@@ -1671,8 +1668,8 @@ static int mtraversal_select_chunk_on_trap(void* context_ptr, Sint slot_ix, Sint
if (sc_context_ptr->prev_continuation_tptr == NULL) {
/* First time we're trapping */
- hp = HAlloc(sc_context_ptr->p, 7 + PROC_BIN_SIZE);
- mpb = db_make_mp_binary(sc_context_ptr->p, *mpp, &hp);
+ hp = HAlloc(sc_context_ptr->p, 7 + ERTS_MAGIC_REF_THING_SIZE);
+ mpb = erts_db_make_match_prog_ref(sc_context_ptr->p, *mpp, &hp);
continuation = TUPLE6(
hp,
sc_context_ptr->tid,
@@ -1807,16 +1804,14 @@ static int db_select_continue_hash(Process* p, DbTable* tbl, Eterm continuation,
if (arityval(*tptr) != 6)
return DB_ERROR_BADPARAM;
- if (!is_small(tptr[2]) || !is_small(tptr[3]) || !is_binary(tptr[4]) ||
+ if (!is_small(tptr[2]) || !is_small(tptr[3]) ||
!(is_list(tptr[5]) || tptr[5] == NIL) || !is_small(tptr[6]))
return DB_ERROR_BADPARAM;
if ((chunk_size = signed_val(tptr[3])) < 0)
return DB_ERROR_BADPARAM;
- if (!(thing_subtag(*binary_val(tptr[4])) == REFC_BINARY_SUBTAG))
- return DB_ERROR_BADPARAM;
- mp = ((ProcBin *) binary_val(tptr[4]))->val;
- if (!IsMatchProgBinary(mp))
+ mp = erts_db_get_match_prog_binary(tptr[4]);
+ if (mp == NULL)
return DB_ERROR_BADPARAM;
if ((got = signed_val(tptr[6])) < 0)
diff --git a/erts/emulator/beam/erl_db_tree.c b/erts/emulator/beam/erl_db_tree.c
index 83cbf059c5..fea888b12d 100644
--- a/erts/emulator/beam/erl_db_tree.c
+++ b/erts/emulator/beam/erl_db_tree.c
@@ -1779,11 +1779,7 @@ static int db_select_replace_continue_tree(Process *p,
lastkey = tptr[2];
end_condition = tptr[3];
- if (!(thing_subtag(*binary_val(tptr[4])) == REFC_BINARY_SUBTAG))
- RET_TO_BIF(NIL,DB_ERROR_BADPARAM);
- mp = ((ProcBin *) binary_val(tptr[4]))->val;
- if (!IsMatchProgBinary(mp))
- RET_TO_BIF(NIL,DB_ERROR_BADPARAM);
+ mp = erts_db_get_match_prog_binary_unchecked(tptr[4]);
sc.p = p;
sc.mp = mp;
@@ -1923,18 +1919,18 @@ static int db_select_replace_tree(Process *p, DbTable *tbl,
key = GETKEY(tb, sc.lastobj);
sz = size_object(key);
if (IS_USMALL(0, sc.replaced)) {
- hp = HAlloc(p, sz + PROC_BIN_SIZE + 6);
+ hp = HAlloc(p, sz + ERTS_MAGIC_REF_THING_SIZE + 6);
ereplaced = make_small(sc.replaced);
}
else {
- hp = HAlloc(p, BIG_UINT_HEAP_SIZE + sz + PROC_BIN_SIZE + 6);
+ hp = HAlloc(p, BIG_UINT_HEAP_SIZE + sz + ERTS_MAGIC_REF_THING_SIZE + 6);
ereplaced = uint_to_big(sc.replaced, hp);
hp += BIG_UINT_HEAP_SIZE;
}
key = copy_struct(key, sz, &hp, &MSO(p));
if (mpi.all_objects)
(mpi.mp)->flags |= BIN_FLAG_ALL_OBJECTS;
- mpb = db_make_mp_binary(p,mpi.mp,&hp);
+ mpb = erts_db_make_match_prog_ref(p,mpi.mp,&hp);
continuation = TUPLE5
(hp,