diff options
author | John Högberg <john@erlang.org> | 2020-11-13 15:01:59 +0100 |
---|---|---|
committer | John Högberg <john@erlang.org> | 2020-11-13 15:11:41 +0100 |
commit | e574a1e36a9fe809be86273e71ee8ba99dbe71e7 (patch) | |
tree | 5acb05d5f30a4e0bc0d05048f5611e49df0982ac | |
parent | c707c4b047aca1dace06f879237e048dfb92a46a (diff) | |
download | erlang-e574a1e36a9fe809be86273e71ee8ba99dbe71e7.tar.gz |
erts: Statically allocate trap export entries again
Now that we no longer execute code inside them, they no longer
need to be allocated at runtime.
-rw-r--r-- | erts/emulator/beam/bif.c | 32 | ||||
-rw-r--r-- | erts/emulator/beam/bif.h | 6 | ||||
-rw-r--r-- | erts/emulator/beam/binary.c | 8 | ||||
-rw-r--r-- | erts/emulator/beam/dist.c | 6 | ||||
-rw-r--r-- | erts/emulator/beam/emu/beam_emu.c | 2 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_binary.c | 26 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_chksum.c | 6 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_guard.c | 4 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_persistent.c | 12 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_re.c | 6 | ||||
-rw-r--r-- | erts/emulator/beam/erl_db.c | 23 | ||||
-rw-r--r-- | erts/emulator/beam/erl_db.h | 8 | ||||
-rw-r--r-- | erts/emulator/beam/erl_db_hash.c | 8 | ||||
-rw-r--r-- | erts/emulator/beam/erl_db_tree.c | 26 | ||||
-rw-r--r-- | erts/emulator/beam/erl_map.c | 4 | ||||
-rw-r--r-- | erts/emulator/beam/erl_ptab.c | 6 | ||||
-rw-r--r-- | erts/emulator/beam/erl_unicode.c | 20 | ||||
-rw-r--r-- | erts/emulator/beam/external.c | 18 | ||||
-rw-r--r-- | erts/emulator/beam/global.h | 2 | ||||
-rw-r--r-- | erts/emulator/beam/jit/beam_asm.cpp | 2 | ||||
-rwxr-xr-x | erts/emulator/utils/make_tables | 6 |
21 files changed, 113 insertions, 118 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index 22e1e79ddc..bfcbcb2edd 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -48,12 +48,12 @@ #include "jit/beam_asm.h" Export *erts_await_result; -static Export *await_exit_trap; +static Export await_exit_trap; static Export* flush_monitor_messages_trap = NULL; static Export* set_cpu_topology_trap = NULL; static Export* await_port_send_result_trap = NULL; Export* erts_format_cpu_topology_trap = NULL; -static Export *dsend_continue_trap_export; +static Export dsend_continue_trap_export; Export *erts_convert_time_unit_trap = NULL; static Export *await_msacc_mod_trap = NULL; @@ -1361,7 +1361,7 @@ erts_internal_await_exit_trap(BIF_ALIST_0) if (state & ERTS_PSFLG_EXITING) ERTS_BIF_EXITED(BIF_P); - ERTS_BIF_YIELD0(await_exit_trap, BIF_P); + ERTS_BIF_YIELD0(&await_exit_trap, BIF_P); } /**********************************************************************/ @@ -1396,7 +1396,7 @@ static BIF_RETTYPE send_exit_signal_bif(Process *c_p, Eterm id, Eterm reason, in erts_proc_lock(c_p, ERTS_PROC_LOCK_MSGQ); erts_proc_sig_fetch(c_p); erts_proc_unlock(c_p, ERTS_PROC_LOCK_MSGQ); - ERTS_BIF_PREP_TRAP0(ret_val, await_exit_trap, c_p); + ERTS_BIF_PREP_TRAP0(ret_val, &await_exit_trap, c_p); } } else if (is_internal_port(id)) { @@ -1455,7 +1455,7 @@ static BIF_RETTYPE send_exit_signal_bif(Process *c_p, Eterm id, Eterm reason, in case ERTS_DSIG_SEND_CONTINUE: BUMP_ALL_REDS(c_p); erts_set_gc_state(c_p, 0); - ERTS_BIF_PREP_TRAP1(ret_val, dsend_continue_trap_export, c_p, + ERTS_BIF_PREP_TRAP1(ret_val, &dsend_continue_trap_export, c_p, erts_dsend_export_trap_context(c_p, &ctx)); break; case ERTS_DSIG_SEND_OK: @@ -2338,7 +2338,7 @@ BIF_RETTYPE send_3(BIF_ALIST_3) break; case SEND_YIELD_CONTINUE: BUMP_ALL_REDS(p); - ERTS_BIF_PREP_TRAP1(retval, dsend_continue_trap_export, p, ctx); + ERTS_BIF_PREP_TRAP1(retval, &dsend_continue_trap_export, p, ctx); break; default: erts_exit(ERTS_ABORT_EXIT, "send_3 invalid result %d\n", (int)result); @@ -2379,7 +2379,7 @@ static BIF_RETTYPE dsend_continue_trap_1(BIF_ALIST_1) case ERTS_DSIG_SEND_CONTINUE: { /*SEND_YIELD_CONTINUE*/ BUMP_ALL_REDS(BIF_P); - BIF_TRAP1(dsend_continue_trap_export, BIF_P, BIF_ARG_1); + BIF_TRAP1(&dsend_continue_trap_export, BIF_P, BIF_ARG_1); } case ERTS_DSIG_SEND_TOO_LRG: { /*SEND_SYSTEM_LIMIT*/ erts_set_gc_state(BIF_P, 1); @@ -2447,7 +2447,7 @@ Eterm erl_send(Process *p, Eterm to, Eterm msg) break; case SEND_YIELD_CONTINUE: BUMP_ALL_REDS(p); - ERTS_BIF_PREP_TRAP1(retval, dsend_continue_trap_export, p, ctx); + ERTS_BIF_PREP_TRAP1(retval, &dsend_continue_trap_export, p, ctx); break; default: erts_exit(ERTS_ABORT_EXIT, "invalid send result %d\n", (int)result); @@ -5116,35 +5116,31 @@ static BIF_RETTYPE bif_return_trap(BIF_ALIST_2) BIF_RET(res); } -Export *bif_return_trap_export; +Export bif_return_trap_export; -void erts_init_trap_export(Export** epp, Eterm m, Eterm f, Uint a, +void erts_init_trap_export(Export *ep, Eterm m, Eterm f, Uint a, Eterm (*bif)(BIF_ALIST)) { - Export* ep; int i; - ep = erts_alloc(ERTS_ALC_T_EXPORT, sizeof(Export)); sys_memset((void *) ep, 0, sizeof(Export)); for (i = 0; i < ERTS_NUM_CODE_IX; i++) { erts_activate_export_trampoline(ep, i); } +#ifdef BEAMASM + ep->addresses[ERTS_SAVE_CALLS_CODE_IX] = beam_save_calls; +#endif + ep->bif_number = -1; ep->info.op = op_i_func_info_IaaI; ep->info.mfa.module = m; ep->info.mfa.function = f; ep->info.mfa.arity = a; -#ifdef BEAMASM - ep->addresses[ERTS_SAVE_CALLS_CODE_IX] = beam_save_calls; -#endif - ep->trampoline.common.op = BeamOpCodeAddr(op_call_bif_W); ep->trampoline.bif.address = (BeamInstr)bif; - - *epp = ep; } void erts_init_bif(void) diff --git a/erts/emulator/beam/bif.h b/erts/emulator/beam/bif.h index f0991fa6a8..bfd7582061 100644 --- a/erts/emulator/beam/bif.h +++ b/erts/emulator/beam/bif.h @@ -439,11 +439,11 @@ extern ErtsCodePtr beam_bif_export_trap; return THE_NON_VALUE; \ } while(0) -extern Export *bif_return_trap_export; +extern Export bif_return_trap_export; #define ERTS_BIF_PREP_YIELD_RETURN_X(RET, P, VAL, OP) \ do { \ ERTS_VBUMP_ALL_REDS(P); \ - ERTS_BIF_PREP_TRAP2(RET, bif_return_trap_export, (P), (VAL), (OP));\ + ERTS_BIF_PREP_TRAP2(RET, &bif_return_trap_export, (P), (VAL), (OP));\ } while (0) #define ERTS_BIF_PREP_YIELD_RETURN(RET, P, VAL) \ @@ -452,7 +452,7 @@ do { \ #define ERTS_BIF_YIELD_RETURN_X(P, VAL, OP) \ do { \ ERTS_VBUMP_ALL_REDS(P); \ - BIF_TRAP2(bif_return_trap_export, (P), (VAL), (OP)); \ + BIF_TRAP2(&bif_return_trap_export, (P), (VAL), (OP)); \ } while (0) #define ERTS_BIF_RETURN_YIELD(P) ERTS_VBUMP_ALL_REDS((P)) diff --git a/erts/emulator/beam/binary.c b/erts/emulator/beam/binary.c index 5a3b52ff1f..39ca0827ca 100644 --- a/erts/emulator/beam/binary.c +++ b/erts/emulator/beam/binary.c @@ -35,8 +35,8 @@ #define L2B_B2L_MIN_EXEC_REDS (CONTEXT_REDS/4) #define L2B_B2L_RESCHED_REDS (CONTEXT_REDS/40) -static Export *binary_to_list_continue_export; -static Export *list_to_binary_continue_export; +static Export binary_to_list_continue_export; +static Export list_to_binary_continue_export; static BIF_RETTYPE binary_to_list_continue(BIF_ALIST_1); static BIF_RETTYPE list_to_binary_continue(BIF_ALIST_1); @@ -479,7 +479,7 @@ binary_to_list_chunk(Process *c_p, ASSERT(c_p->flags & F_DISABLE_GC); ASSERT(is_value(mb_eterm)); ERTS_BIF_PREP_TRAP1(ret, - binary_to_list_continue_export, + &binary_to_list_continue_export, c_p, mb_eterm); } @@ -878,7 +878,7 @@ list_to_binary_chunk(Eterm mb_eterm, ASSERT(c_p->flags & F_DISABLE_GC); ERTS_BIF_PREP_TRAP1(ret, - list_to_binary_continue_export, + &list_to_binary_continue_export, c_p, mb_eterm); break; diff --git a/erts/emulator/beam/dist.c b/erts/emulator/beam/dist.c index 7630138796..c828b56fd1 100644 --- a/erts/emulator/beam/dist.c +++ b/erts/emulator/beam/dist.c @@ -175,7 +175,7 @@ int erts_dist_buf_busy_limit; int erts_dflags_test_remove_hopefull_flags; -Export *spawn_request_yield_export; +Export spawn_request_yield_export; /* distribution trap functions */ Export* dmonitor_node_trap = NULL; @@ -5277,7 +5277,7 @@ static BIF_RETTYPE spawn_request_yield_3(BIF_ALIST_3) case ERTS_DSIG_SEND_CONTINUE: { BUMP_ALL_REDS(BIF_P); - BIF_TRAP3(spawn_request_yield_export, BIF_P, + BIF_TRAP3(&spawn_request_yield_export, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); } @@ -5612,7 +5612,7 @@ BIF_RETTYPE erts_internal_dist_spawn_request_4(BIF_ALIST_4) erts_set_gc_state(BIF_P, 0); ctx_term = erts_dsend_export_trap_context(BIF_P, &ctx); BUMP_ALL_REDS(BIF_P); - ERTS_BIF_PREP_TRAP3(ret_val, spawn_request_yield_export, + ERTS_BIF_PREP_TRAP3(ret_val, &spawn_request_yield_export, BIF_P, ctx_term, ok_result, tag); break; } diff --git a/erts/emulator/beam/emu/beam_emu.c b/erts/emulator/beam/emu/beam_emu.c index 938f6d5fbc..932e8a2108 100644 --- a/erts/emulator/beam/emu/beam_emu.c +++ b/erts/emulator/beam/emu/beam_emu.c @@ -642,7 +642,7 @@ static void install_bifs(void) { /* Set up a hidden export entry so we can trap to this BIF without * it being seen when tracing. */ - erts_init_trap_export(&BIF_TRAP_EXPORT(i), + erts_init_trap_export(BIF_TRAP_EXPORT(i), entry->module, entry->name, entry->arity, entry->f); } diff --git a/erts/emulator/beam/erl_bif_binary.c b/erts/emulator/beam/erl_bif_binary.c index f6f785890b..dbc606505e 100644 --- a/erts/emulator/beam/erl_bif_binary.c +++ b/erts/emulator/beam/erl_bif_binary.c @@ -53,13 +53,13 @@ /* Init and local variables */ -static Export *binary_find_trap_export; +static Export binary_find_trap_export; static BIF_RETTYPE binary_find_trap(BIF_ALIST_3); -static Export *binary_longest_prefix_trap_export; +static Export binary_longest_prefix_trap_export; static BIF_RETTYPE binary_longest_prefix_trap(BIF_ALIST_3); -static Export *binary_longest_suffix_trap_export; +static Export binary_longest_suffix_trap_export; static BIF_RETTYPE binary_longest_suffix_trap(BIF_ALIST_3); -static Export *binary_copy_trap_export; +static Export binary_copy_trap_export; static BIF_RETTYPE binary_copy_trap(BIF_ALIST_2); static Uint max_loop_limit; @@ -1553,7 +1553,7 @@ binary_match(Process *p, Eterm arg1, Eterm arg2, Eterm arg3, Uint flags) BIF_RET(result); case BF_RESTART: ASSERT(result == THE_NON_VALUE && ctx->trap_term != result && ctx->pat_term != result); - BIF_TRAP3(binary_find_trap_export, p, arg1, ctx->trap_term, ctx->pat_term); + BIF_TRAP3(&binary_find_trap_export, p, arg1, ctx->trap_term, ctx->pat_term); default: goto badarg; } @@ -1614,7 +1614,7 @@ binary_split(Process *p, Eterm arg1, Eterm arg2, Eterm arg3) BIF_RET(result); case BF_RESTART: ASSERT(result == THE_NON_VALUE && ctx->trap_term != result && ctx->pat_term != result); - BIF_TRAP3(binary_find_trap_export, p, arg1, ctx->trap_term, ctx->pat_term); + BIF_TRAP3(&binary_find_trap_export, p, arg1, ctx->trap_term, ctx->pat_term); default: goto badarg; } @@ -1925,7 +1925,7 @@ static BIF_RETTYPE binary_find_trap(BIF_ALIST_3) BIF_RET(result); } else { ASSERT(result == THE_NON_VALUE && ctx->trap_term != result && ctx->pat_term != result); - BIF_TRAP3(binary_find_trap_export, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); + BIF_TRAP3(&binary_find_trap_export, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); } } @@ -2218,11 +2218,11 @@ static BIF_RETTYPE do_longest_common(Process *p, Eterm list, int direction) pos = 0; if (direction == DIRECTION_PREFIX) { - trapper = binary_longest_prefix_trap_export; + trapper = &binary_longest_prefix_trap_export; res = do_search_forward(cd,&pos,&reds); } else { ASSERT(direction == DIRECTION_SUFFIX); - trapper = binary_longest_suffix_trap_export; + trapper = &binary_longest_suffix_trap_export; res = do_search_backward(cd,&pos,&reds); } epos = erts_make_integer(pos,p); @@ -2272,11 +2272,11 @@ static BIF_RETTYPE do_longest_common_trap(Process *p, Eterm bin_term, Eterm curr bin = erts_magic_ref2bin(bin_term); cd = (CommonData *) ERTS_MAGIC_BIN_DATA(bin); if (direction == DIRECTION_PREFIX) { - trapper = binary_longest_prefix_trap_export; + trapper = &binary_longest_prefix_trap_export; res = do_search_forward(cd,&pos,&reds); } else { ASSERT(direction == DIRECTION_SUFFIX); - trapper = binary_longest_suffix_trap_export; + trapper = &binary_longest_suffix_trap_export; res = do_search_backward(cd,&pos,&reds); } epos = erts_make_integer(pos,p); @@ -2550,7 +2550,7 @@ static BIF_RETTYPE do_binary_copy(Process *p, Eterm bin, Eterm en) hp = HAlloc(p, ERTS_MAGIC_REF_THING_SIZE); trap_term = erts_mk_magic_ref(&hp, &MSO(p), mb); BUMP_ALL_REDS(p); - BIF_TRAP2(binary_copy_trap_export, p, bin, trap_term); + BIF_TRAP2(&binary_copy_trap_export, p, bin, trap_term); } else { Eterm res_term; byte *temp_alloc = NULL; @@ -2602,7 +2602,7 @@ BIF_RETTYPE binary_copy_trap(BIF_ALIST_2) cbs->result_pos = pos; cbs->times_left -= i; BUMP_ALL_REDS(BIF_P); - BIF_TRAP2(binary_copy_trap_export, BIF_P, BIF_ARG_1, BIF_ARG_2); + BIF_TRAP2(&binary_copy_trap_export, BIF_P, BIF_ARG_1, BIF_ARG_2); } else { Binary *save; Eterm resbin; diff --git a/erts/emulator/beam/erl_bif_chksum.c b/erts/emulator/beam/erl_bif_chksum.c index d19b7d0590..f01bc0d0c3 100644 --- a/erts/emulator/beam/erl_bif_chksum.c +++ b/erts/emulator/beam/erl_bif_chksum.c @@ -38,7 +38,7 @@ typedef void (*ChksumFun)(void *sum_in_out, unsigned char *buf, /* Hidden trap target */ static BIF_RETTYPE md5_2(BIF_ALIST_2); -static Export *chksum_md5_2_exp; +static Export chksum_md5_2_exp; void erts_init_bif_chksum(void) { @@ -494,7 +494,7 @@ md5_1(BIF_ALIST_1) if (rest != NIL) { BUMP_ALL_REDS(BIF_P); bin = new_binary(BIF_P, (byte *) &context, sizeof(MD5_CTX)); - BIF_TRAP2(chksum_md5_2_exp, BIF_P, bin, rest); + BIF_TRAP2(&chksum_md5_2_exp, BIF_P, bin, rest); } BUMP_REDS(BIF_P,res); bin = new_binary(BIF_P, (byte *)NULL, 16); @@ -526,7 +526,7 @@ md5_2(BIF_ALIST_2) if (rest != NIL) { BUMP_ALL_REDS(BIF_P); bin = new_binary(BIF_P, (byte *) &context, sizeof(MD5_CTX)); - BIF_TRAP2(chksum_md5_2_exp, BIF_P, bin, rest); + BIF_TRAP2(&chksum_md5_2_exp, BIF_P, bin, rest); } BUMP_REDS(BIF_P,res); bin = new_binary(BIF_P, (byte *)NULL, 16); diff --git a/erts/emulator/beam/erl_bif_guard.c b/erts/emulator/beam/erl_bif_guard.c index 8b463a1189..4d3fbfcfb7 100644 --- a/erts/emulator/beam/erl_bif_guard.c +++ b/erts/emulator/beam/erl_bif_guard.c @@ -43,7 +43,7 @@ static Eterm double_to_integer(Process* p, double x); static BIF_RETTYPE erlang_length_trap(BIF_ALIST_3); -static Export *erlang_length_export; +static Export erlang_length_export; void erts_init_bif_guard(void) { @@ -233,7 +233,7 @@ static BIF_RETTYPE erlang_length_trap(BIF_ALIST_3) /* * The available reductions were exceeded. Trap. */ - BIF_TRAP3(erlang_length_export, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); + BIF_TRAP3(&erlang_length_export, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); } else { /* * Signal an error. The original argument was tucked away in BIF_ARG_3. diff --git a/erts/emulator/beam/erl_bif_persistent.c b/erts/emulator/beam/erl_bif_persistent.c index 4f720cacb0..b925c1e339 100644 --- a/erts/emulator/beam/erl_bif_persistent.c +++ b/erts/emulator/beam/erl_bif_persistent.c @@ -170,9 +170,9 @@ static int cleanup_trap_data(Binary *bp); * Traps */ -static Export *persistent_term_get_all_export; +static Export persistent_term_get_all_export; static BIF_RETTYPE persistent_term_get_all_trap(BIF_ALIST_2); -static Export *persistent_term_info_export; +static Export persistent_term_info_export; static BIF_RETTYPE persistent_term_info_trap(BIF_ALIST_1); /* @@ -465,7 +465,7 @@ BIF_RETTYPE persistent_term_get_0(BIF_ALIST_0) BIF_RET(res); } else { BUMP_ALL_REDS(BIF_P); - BIF_TRAP2(persistent_term_get_all_export, BIF_P, magic_ref, res); + BIF_TRAP2(&persistent_term_get_all_export, BIF_P, magic_ref, res); } } @@ -700,7 +700,7 @@ BIF_RETTYPE persistent_term_info_0(BIF_ALIST_0) BIF_RET(res); } else { BUMP_ALL_REDS(BIF_P); - BIF_TRAP2(persistent_term_info_export, BIF_P, magic_ref, res); + BIF_TRAP2(&persistent_term_info_export, BIF_P, magic_ref, res); } } @@ -767,7 +767,7 @@ persistent_term_get_all_trap(BIF_ALIST_2) ASSERT(is_list(res)); if (trap_data->remaining > 0) { BUMP_ALL_REDS(BIF_P); - BIF_TRAP2(persistent_term_get_all_export, BIF_P, BIF_ARG_1, res); + BIF_TRAP2(&persistent_term_get_all_export, BIF_P, BIF_ARG_1, res); } else { release_update_permission(0); trap_data->got_update_permission = 0; @@ -863,7 +863,7 @@ persistent_term_info_trap(BIF_ALIST_1) if (trap_data->remaining > 0) { ASSERT(res == am_ok); BUMP_ALL_REDS(BIF_P); - BIF_TRAP1(persistent_term_info_export, BIF_P, BIF_ARG_1); + BIF_TRAP1(&persistent_term_info_export, BIF_P, BIF_ARG_1); } else { release_update_permission(0); trap_data->got_update_permission = 0; diff --git a/erts/emulator/beam/erl_bif_re.c b/erts/emulator/beam/erl_bif_re.c index 8bc5350dcf..d5bf196ef0 100644 --- a/erts/emulator/beam/erl_bif_re.c +++ b/erts/emulator/beam/erl_bif_re.c @@ -40,7 +40,7 @@ static const unsigned char *default_table; static Uint max_loop_limit; -static Export *re_exec_trap_export; +static Export re_exec_trap_export; static Export *grun_trap_exportp = NULL; static Export *urun_trap_exportp = NULL; static Export *ucompile_trap_exportp = NULL; @@ -1356,7 +1356,7 @@ handle_iolist: ERTS_VBUMP_ALL_REDS(p); hp = HAlloc(p, ERTS_MAGIC_REF_THING_SIZE); magic_ref = erts_mk_magic_ref(&hp, &MSO(p), mbp); - BIF_TRAP3(re_exec_trap_export, + BIF_TRAP3(&re_exec_trap_export, p, arg1, arg2 /* To avoid GC of precompiled code, XXX: not utilized yet */, @@ -1472,7 +1472,7 @@ static BIF_RETTYPE re_exec_trap(BIF_ALIST_3) if (rc == PCRE_ERROR_LOOP_LIMIT) { /* Trap */ BUMP_ALL_REDS(BIF_P); - BIF_TRAP3(re_exec_trap_export, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); + BIF_TRAP3(&re_exec_trap_export, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); } res = build_exec_return(BIF_P, rc, restartp, BIF_ARG_1); diff --git a/erts/emulator/beam/erl_db.c b/erts/emulator/beam/erl_db.c index af53e7301a..31fcd5c420 100644 --- a/erts/emulator/beam/erl_db.c +++ b/erts/emulator/beam/erl_db.c @@ -406,15 +406,14 @@ static BIF_RETTYPE ets_select3(Process* p, DbTable*, Eterm tid, Eterm ms, Sint c /* * Exported global */ -Export *ets_select_delete_continue_exp; -Export *ets_select_count_continue_exp; -Export *ets_select_replace_continue_exp; -Export *ets_select_continue_exp; - +Export ets_select_delete_continue_exp; +Export ets_select_count_continue_exp; +Export ets_select_replace_continue_exp; +Export ets_select_continue_exp; /* * Static traps */ -static Export *ets_delete_continue_exp; +static Export ets_delete_continue_exp; static Export *ets_info_binary_trap = NULL; @@ -2550,7 +2549,7 @@ BIF_RETTYPE ets_delete_1(BIF_ALIST_1) hp[0] = make_pos_bignum_header(1); hp[1] = (Eterm) tb; BUMP_ALL_REDS(BIF_P); - BIF_TRAP1(ets_delete_continue_exp, BIF_P, make_big(hp)); + BIF_TRAP1(&ets_delete_continue_exp, BIF_P, make_big(hp)); } else { BUMP_REDS(BIF_P, (initial_reds - reds)); @@ -2852,7 +2851,7 @@ static BIF_RETTYPE ets_select_delete_trap_1(BIF_ALIST_1) ASSERT(arityval(*tptr) >= 1); DB_TRAP_GET_TABLE(tb, tptr[1], DB_WRITE, kind, - ets_select_delete_continue_exp); + &ets_select_delete_continue_exp); cret = tb->common.meth->db_select_delete_continue(p,tb,a1,&ret,&safety); @@ -3336,7 +3335,7 @@ static BIF_RETTYPE ets_select_trap_1(BIF_ALIST_1) ASSERT(arityval(*tptr) >= 1); DB_TRAP_GET_TABLE(tb, tptr[1], DB_READ, kind, - ets_select_continue_exp); + &ets_select_continue_exp); cret = tb->common.meth->db_select_continue(p, tb, a1, &ret, &safety); @@ -3504,7 +3503,7 @@ static BIF_RETTYPE ets_select_count_1(BIF_ALIST_1) ASSERT(arityval(*tptr) >= 1); DB_TRAP_GET_TABLE(tb, tptr[1], DB_READ, kind, - ets_select_count_continue_exp); + &ets_select_count_continue_exp); cret = tb->common.meth->db_select_count_continue(p, tb, a1, &ret, &safety); @@ -3595,7 +3594,7 @@ static BIF_RETTYPE ets_select_replace_1(BIF_ALIST_1) ASSERT(arityval(*tptr) >= 1); DB_TRAP_GET_TABLE(tb, tptr[1], DB_WRITE, kind, - ets_select_replace_continue_exp); + &ets_select_replace_continue_exp); cret = tb->common.meth->db_select_replace_continue(p,tb,a1,&ret,&safety); @@ -4802,7 +4801,7 @@ static BIF_RETTYPE ets_delete_trap(BIF_ALIST_1) reds = free_table_continue(BIF_P, tb, reds); if (reds < 0) { BUMP_ALL_REDS(BIF_P); - BIF_TRAP1(ets_delete_continue_exp, BIF_P, cont); + BIF_TRAP1(&ets_delete_continue_exp, BIF_P, cont); } else { BUMP_REDS(BIF_P, (initial_reds - reds)); diff --git a/erts/emulator/beam/erl_db.h b/erts/emulator/beam/erl_db.h index 373e84dc06..139e3311b7 100644 --- a/erts/emulator/beam/erl_db.h +++ b/erts/emulator/beam/erl_db.h @@ -125,10 +125,10 @@ extern int erts_ets_rwmtx_spin_count; extern int user_requested_db_max_tabs; /* set in erl_init */ extern int erts_ets_realloc_always_moves; /* set in erl_init */ extern int erts_ets_always_compress; /* set in erl_init */ -extern Export *ets_select_delete_continue_exp; -extern Export *ets_select_count_continue_exp; -extern Export *ets_select_replace_continue_exp; -extern Export *ets_select_continue_exp; +extern Export ets_select_delete_continue_exp; +extern Export ets_select_count_continue_exp; +extern Export ets_select_replace_continue_exp; +extern Export ets_select_continue_exp; extern erts_atomic_t erts_ets_misc_mem_size; Eterm erts_ets_colliding_names(Process*, Eterm name, Uint cnt); diff --git a/erts/emulator/beam/erl_db_hash.c b/erts/emulator/beam/erl_db_hash.c index acfc5a3af3..6eb7bde1b4 100644 --- a/erts/emulator/beam/erl_db_hash.c +++ b/erts/emulator/beam/erl_db_hash.c @@ -1996,7 +1996,7 @@ static int select_chunk_on_trap(traverse_context_t* ctx_base, make_small(got), make_small(ctx->base.safety)); } - ERTS_BIF_PREP_TRAP1(*ret, ets_select_continue_exp, ctx->base.p, + ERTS_BIF_PREP_TRAP1(*ret, &ets_select_continue_exp, ctx->base.p, continuation); return DB_ERROR_NONE; } @@ -2213,7 +2213,7 @@ static int select_count_on_trap(traverse_context_t* ctx, Binary** mpp, Eterm* ret) { return on_simple_trap( - ets_select_count_continue_exp, ctx, + &ets_select_count_continue_exp, ctx, slot_ix, got, mpp, ret); } @@ -2406,7 +2406,7 @@ static int select_delete_on_trap(traverse_context_t* ctx_base, free_term_list(ctx->base.tb, ctx->free_us); ctx->free_us = NULL; return on_simple_trap( - ets_select_delete_continue_exp, &ctx->base, + &ets_select_delete_continue_exp, &ctx->base, slot_ix, got, mpp, ret); } @@ -2553,7 +2553,7 @@ static int select_replace_on_trap(traverse_context_t* ctx, Binary** mpp, Eterm* ret) { return on_simple_trap( - ets_select_replace_continue_exp, ctx, + &ets_select_replace_continue_exp, ctx, slot_ix, got, mpp, ret); } diff --git a/erts/emulator/beam/erl_db_tree.c b/erts/emulator/beam/erl_db_tree.c index f7246ab416..68afae1a7d 100644 --- a/erts/emulator/beam/erl_db_tree.c +++ b/erts/emulator/beam/erl_db_tree.c @@ -481,7 +481,7 @@ static int db_put_dbterm_tree(DbTable* tbl, /* [in out] */ ** Static variables */ -Export *ets_select_reverse_exp; +Export ets_select_reverse_exp; /* ** External interface @@ -1142,7 +1142,7 @@ static BIF_RETTYPE ets_select_reverse(BIF_ALIST_3) if (--max_iter == 0) { BUMP_ALL_REDS(p); HRelease(p, hend, hp); - BIF_TRAP3(ets_select_reverse_exp, p, list, result, a3); + BIF_TRAP3(&ets_select_reverse_exp, p, list, result, a3); } if (hp == hend) { hp = HAlloc(p, 64); @@ -1267,7 +1267,7 @@ int db_select_continue_tree_common(Process *p, if (!sc.got) { RET_TO_BIF(am_EOT, DB_ERROR_NONE); } else { - RET_TO_BIF(bif_trap3(ets_select_reverse_exp, p, + RET_TO_BIF(bif_trap3(&ets_select_reverse_exp, p, sc.accum, NIL, am_EOT), DB_ERROR_NONE); } @@ -1287,7 +1287,7 @@ int db_select_continue_tree_common(Process *p, NIL, tptr[7], make_small(0)); - RET_TO_BIF(bif_trap3(ets_select_reverse_exp, p, + RET_TO_BIF(bif_trap3(&ets_select_reverse_exp, p, sc.accum, NIL, continuation), DB_ERROR_NONE); } else { @@ -1303,7 +1303,7 @@ int db_select_continue_tree_common(Process *p, if (!sc.got) { RET_TO_BIF(am_EOT, DB_ERROR_NONE); } else { - RET_TO_BIF(bif_trap3(ets_select_reverse_exp, p, + RET_TO_BIF(bif_trap3(&ets_select_reverse_exp, p, sc.accum, NIL, am_EOT), DB_ERROR_NONE); } @@ -1583,7 +1583,7 @@ int db_select_count_continue_tree_common(Process *p, tptr[3], tptr[4], egot); - RET_TO_BIF(bif_trap1(ets_select_count_continue_exp, p, continuation), + RET_TO_BIF(bif_trap1(&ets_select_count_continue_exp, p, continuation), DB_ERROR_NONE); #undef RET_TO_BIF @@ -1707,7 +1707,7 @@ int db_select_count_tree_common(Process *p, DbTable *tb, egot); /* Don't free mpi.mp, so don't use macro */ - *ret = bif_trap1(ets_select_count_continue_exp, p, continuation); + *ret = bif_trap1(&ets_select_count_continue_exp, p, continuation); return DB_ERROR_NONE; #undef RET_TO_BIF @@ -1837,7 +1837,7 @@ int db_select_chunk_tree_common(Process *p, DbTable *tb, if (!sc.got) { RET_TO_BIF(am_EOT, DB_ERROR_NONE); } else { - RET_TO_BIF(bif_trap3(ets_select_reverse_exp, p, + RET_TO_BIF(bif_trap3(&ets_select_reverse_exp, p, sc.accum, NIL, am_EOT), DB_ERROR_NONE); } @@ -1861,7 +1861,7 @@ int db_select_chunk_tree_common(Process *p, DbTable *tb, make_small(reverse), make_small(0)); /* Don't let RET_TO_BIF macro free mpi.mp*/ - *ret = bif_trap3(ets_select_reverse_exp, p, + *ret = bif_trap3(&ets_select_reverse_exp, p, sc.accum, NIL, continuation); return DB_ERROR_NONE; } @@ -1993,7 +1993,7 @@ int db_select_delete_continue_tree_common(Process *p, tptr[3], tptr[4], eaccsum); - RET_TO_BIF(bif_trap1(ets_select_delete_continue_exp, p, continuation), + RET_TO_BIF(bif_trap1(&ets_select_delete_continue_exp, p, continuation), DB_ERROR_NONE); #undef RET_TO_BIF @@ -2124,7 +2124,7 @@ int db_select_delete_tree_common(Process *p, DbTable *tbl, if (sc.erase_lastterm) { free_term(tbl, sc.lastterm); } - *ret = bif_trap1(ets_select_delete_continue_exp, p, continuation); + *ret = bif_trap1(&ets_select_delete_continue_exp, p, continuation); return DB_ERROR_NONE; #undef RET_TO_BIF @@ -2234,7 +2234,7 @@ int db_select_replace_continue_tree_common(Process *p, tptr[3], tptr[4], ereplaced); - RET_TO_BIF(bif_trap1(ets_select_replace_continue_exp, p, continuation), + RET_TO_BIF(bif_trap1(&ets_select_replace_continue_exp, p, continuation), DB_ERROR_NONE); #undef RET_TO_BIF @@ -2361,7 +2361,7 @@ int db_select_replace_tree_common(Process *p, DbTable *tbl, ereplaced); /* Don't free mpi.mp, so don't use macro */ - *ret = bif_trap1(ets_select_replace_continue_exp, p, continuation); + *ret = bif_trap1(&ets_select_replace_continue_exp, p, continuation); return DB_ERROR_NONE; #undef RET_TO_BIF diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c index bdd75f7d4b..b8c7337bf4 100644 --- a/erts/emulator/beam/erl_map.c +++ b/erts/emulator/beam/erl_map.c @@ -88,7 +88,7 @@ static BIF_RETTYPE map_merge_mixed(Process *p, Eterm flat, Eterm tree, int swap_ struct HashmapMergeContext_; static BIF_RETTYPE hashmap_merge(Process *p, Eterm nodeA, Eterm nodeB, int swap_args, struct HashmapMergeContext_*); -static Export *hashmap_merge_trap_export; +static Export hashmap_merge_trap_export; static BIF_RETTYPE maps_merge_trap_1(BIF_ALIST_1); static Uint hashmap_subtree_size(Eterm node); static Eterm hashmap_keys(Process *p, Eterm map); @@ -1461,7 +1461,7 @@ trap: /* Yield */ PSTACK_SAVE(s, &ctx->pstack); BUMP_ALL_REDS(p); - ERTS_BIF_PREP_TRAP1(trap_ret, hashmap_merge_trap_export, + ERTS_BIF_PREP_TRAP1(trap_ret, &hashmap_merge_trap_export, p, ctx->trap_bin); UnUseTmpHeap(2,p); return trap_ret; diff --git a/erts/emulator/beam/erl_ptab.c b/erts/emulator/beam/erl_ptab.c index c1295755a2..38c095fb4a 100644 --- a/erts/emulator/beam/erl_ptab.c +++ b/erts/emulator/beam/erl_ptab.c @@ -237,7 +237,7 @@ struct ErtsPTabDeletedElement_ { } u; }; -static Export *ptab_list_continue_export; +static Export ptab_list_continue_export; typedef struct { Uint64 interval; @@ -780,7 +780,7 @@ erts_ptab_list(Process *c_p, ErtsPTab *ptab) ERTS_PTAB_LIST_DBG_VERIFY_HEAP_ALLOC_USED(ptlbdp, hp); ERTS_PTAB_LIST_DBG_TRACE(c_p->common.id, trap); ERTS_BIF_PREP_YIELD2(ret_val, - ptab_list_continue_export, + &ptab_list_continue_export, c_p, res_acc, magic_ref); @@ -1304,7 +1304,7 @@ static BIF_RETTYPE ptab_list_continue(BIF_ALIST_2) } else { ERTS_PTAB_LIST_DBG_TRACE(BIF_P->common.id, trap); - ERTS_BIF_YIELD2(ptab_list_continue_export, BIF_P, res_acc, BIF_ARG_2); + ERTS_BIF_YIELD2(&ptab_list_continue_export, BIF_P, res_acc, BIF_ARG_2); } } diff --git a/erts/emulator/beam/erl_unicode.c b/erts/emulator/beam/erl_unicode.c index 43163cebf6..992ef9e3e4 100644 --- a/erts/emulator/beam/erl_unicode.c +++ b/erts/emulator/beam/erl_unicode.c @@ -64,12 +64,12 @@ static BIF_RETTYPE characters_to_list_trap_2(BIF_ALIST_3); static BIF_RETTYPE characters_to_list_trap_3(BIF_ALIST_3); static BIF_RETTYPE characters_to_list_trap_4(BIF_ALIST_1); -static Export *characters_to_utf8_trap_exp; -static Export *characters_to_list_trap_1_exp; -static Export *characters_to_list_trap_2_exp; +static Export characters_to_utf8_trap_exp; +static Export characters_to_list_trap_1_exp; +static Export characters_to_list_trap_2_exp; -static Export *characters_to_list_trap_3_exp; -static Export *characters_to_list_trap_4_exp; +static Export characters_to_list_trap_3_exp; +static Export characters_to_list_trap_4_exp; static Export *c_to_b_int_trap_exportp = NULL; static Export *c_to_l_int_trap_exportp = NULL; @@ -873,7 +873,7 @@ static BIF_RETTYPE build_utf8_return(Process *p,Eterm bin,Uint pos, rest_term = CONS(hp,rest_bin,rest_term); } BUMP_ALL_REDS(p); - BIF_TRAP3(characters_to_utf8_trap_exp, p, bin, rest_term, latin1); + BIF_TRAP3(&characters_to_utf8_trap_exp, p, bin, rest_term, latin1); } else { /* Success */ /*hp = HAlloc(p,5); ret = TUPLE4(hp,mk_utf8_result_bin(p,bin),rest_term,make_small(pos),make_small(err));*/ @@ -1090,7 +1090,7 @@ static BIF_RETTYPE build_list_return(Process *p, byte *bytes, Uint pos, Uint cha rc.num_bytes_to_process = pos; rc.num_resulting_chars = characters; rc.state = ERTS_UTF8_OK; /* not used */ - BIF_TRAP3(characters_to_list_trap_1_exp, p, make_magic_bin_for_restart(p,&rc), + BIF_TRAP3(&characters_to_list_trap_1_exp, p, make_magic_bin_for_restart(p,&rc), rest_term, latin1); } else { /* Success */ BIF_RET(finalize_list_to_list(p, bytes, NIL, 0U, pos, characters, ERTS_UTF8_OK, left, NIL)); @@ -1680,7 +1680,7 @@ static BIF_RETTYPE finalize_list_to_list(Process *p, rc.state = state; rc.bytes = bytes; BUMP_ALL_REDS(p); - BIF_TRAP3(characters_to_list_trap_2_exp, p, + BIF_TRAP3(&characters_to_list_trap_2_exp, p, make_magic_bin_for_restart(p, &rc), rest, converted); } } @@ -1789,7 +1789,7 @@ static BIF_RETTYPE do_bif_utf8_to_list(Process *p, Eterm enumchar = erts_make_integer(num_resulting_chars,p); erts_free_aligned_binary_bytes(temp_alloc); BUMP_ALL_REDS(p); - BIF_TRAP3(characters_to_list_trap_3_exp, p, orig_bin, epos, + BIF_TRAP3(&characters_to_list_trap_3_exp, p, orig_bin, epos, enumchar); } } @@ -1825,7 +1825,7 @@ static BIF_RETTYPE do_bif_utf8_to_list(Process *p, converted); BUMP_ALL_REDS(p); erts_free_aligned_binary_bytes(temp_alloc); - BIF_TRAP1(characters_to_list_trap_4_exp,p,traptuple); + BIF_TRAP1(&characters_to_list_trap_4_exp,p,traptuple); } } diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index 6c7be1c2cb..428ec4a445 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -96,7 +96,7 @@ */ #define IS_SSMALL32(x) (((Uint) (((x) >> (32-1)) + 1)) < 2) -static Export *term_to_binary_trap_export; +static Export term_to_binary_trap_export; static byte* enc_term(ErtsAtomCacheMap *, Eterm, byte*, Uint64, struct erl_off_heap_header** off_heap); struct TTBEncodeContext_; @@ -120,7 +120,7 @@ static Uint encode_size_struct2(ErtsAtomCacheMap *, Eterm, Uint64); static ErtsExtSzRes encode_size_struct_int(TTBSizeContext*, ErtsAtomCacheMap *acmp, Eterm obj, Uint64 dflags, Sint *reds, Uint *res); -static Export *binary_to_term_trap_export; +static Export binary_to_term_trap_export; static BIF_RETTYPE binary_to_term_trap_1(BIF_ALIST_1); static Sint transcode_dist_obuf(ErtsDistOutputBuf*, DistEntry*, Uint64 dflags, Sint reds); static byte *hopefull_bit_binary(TTBEncodeContext* ctx, byte **epp, Binary *pb_val, Eterm pb_term, @@ -1367,7 +1367,7 @@ static BIF_RETTYPE term_to_binary_trap_1(BIF_ALIST_1) } if (is_tuple(res)) { ASSERT(BIF_P->flags & F_DISABLE_GC); - BIF_TRAP1(term_to_binary_trap_export,BIF_P,res); + BIF_TRAP1(&term_to_binary_trap_export,BIF_P,res); } else { if (erts_set_gc_state(BIF_P, 1) || MSO(BIF_P).overhead > BIN_VHEAP_SZ(BIF_P)) @@ -1389,7 +1389,7 @@ BIF_RETTYPE term_to_binary_1(BIF_ALIST_1) } if (is_tuple(res)) { erts_set_gc_state(BIF_P, 0); - BIF_TRAP1(term_to_binary_trap_export,BIF_P,res); + BIF_TRAP1(&term_to_binary_trap_export,BIF_P,res); } else { ASSERT(!(BIF_P->flags & F_DISABLE_GC)); BIF_RET(res); @@ -1408,7 +1408,7 @@ BIF_RETTYPE term_to_iovec_1(BIF_ALIST_1) } if (is_tuple(res)) { erts_set_gc_state(BIF_P, 0); - BIF_TRAP1(term_to_binary_trap_export,BIF_P,res); + BIF_TRAP1(&term_to_binary_trap_export,BIF_P,res); } else { ASSERT(!(BIF_P->flags & F_DISABLE_GC)); BIF_RET(res); @@ -1502,7 +1502,7 @@ BIF_RETTYPE term_to_binary_2(BIF_ALIST_2) } if (is_tuple(res)) { erts_set_gc_state(BIF_P, 0); - BIF_TRAP1(term_to_binary_trap_export,BIF_P,res); + BIF_TRAP1(&term_to_binary_trap_export,BIF_P,res); } else { ASSERT(!(BIF_P->flags & F_DISABLE_GC)); BIF_RET(res); @@ -1529,7 +1529,7 @@ BIF_RETTYPE term_to_iovec_2(BIF_ALIST_2) } if (is_tuple(res)) { erts_set_gc_state(BIF_P, 0); - BIF_TRAP1(term_to_binary_trap_export,BIF_P,res); + BIF_TRAP1(&term_to_binary_trap_export,BIF_P,res); } else { ASSERT(!(BIF_P->flags & F_DISABLE_GC)); BIF_RET(res); @@ -1558,7 +1558,7 @@ erts_debug_term_to_binary(Process *p, Eterm term, Eterm opts) } else if (is_tuple(res)) { erts_set_gc_state(p, 0); - ERTS_BIF_PREP_TRAP1(ret, term_to_binary_trap_export,p,res); + ERTS_BIF_PREP_TRAP1(ret, &term_to_binary_trap_export,p,res); } else { ASSERT(!(p->flags & F_DISABLE_GC)); @@ -2044,7 +2044,7 @@ static BIF_RETTYPE binary_to_term_int(Process* p, Eterm bin, B2TContext *ctx) } BUMP_ALL_REDS(p); - ERTS_BIF_PREP_TRAP1(ret_val, binary_to_term_trap_export, + ERTS_BIF_PREP_TRAP1(ret_val, &binary_to_term_trap_export, p, ctx->trap_bin); return ret_val; diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h index 4b2fe5ab0f..c8421849d4 100644 --- a/erts/emulator/beam/global.h +++ b/erts/emulator/beam/global.h @@ -894,7 +894,7 @@ void erts_queue_monitor_message(Process *, Eterm, Eterm, Eterm); -void erts_init_trap_export(Export** epp, Eterm m, Eterm f, Uint a, +void erts_init_trap_export(Export* ep, Eterm m, Eterm f, Uint a, Eterm (*bif)(Process*, Eterm*, ErtsCodePtr)); void erts_init_bif(void); Eterm erl_send(Process *p, Eterm to, Eterm msg); diff --git a/erts/emulator/beam/jit/beam_asm.cpp b/erts/emulator/beam/jit/beam_asm.cpp index 06c27b5690..6147c45848 100644 --- a/erts/emulator/beam/jit/beam_asm.cpp +++ b/erts/emulator/beam/jit/beam_asm.cpp @@ -99,7 +99,7 @@ static void install_bifs(void) { /* Set up a hidden export entry so we can trap to this BIF without * it being seen when tracing. */ - erts_init_trap_export(&BIF_TRAP_EXPORT(i), + erts_init_trap_export(BIF_TRAP_EXPORT(i), entry->module, entry->name, entry->arity, diff --git a/erts/emulator/utils/make_tables b/erts/emulator/utils/make_tables index b7ea014407..a7b3a1c535 100755 --- a/erts/emulator/utils/make_tables +++ b/erts/emulator/utils/make_tables @@ -251,8 +251,8 @@ extern const ErtsUBif erts_u_bifs[]; EOF -print "#define BIF_TRAP_EXPORT(BIF_NAME) (bif_trap_exports[BIF_NAME])\n"; -print "extern Export *bif_trap_exports[];\n"; +print "#define BIF_TRAP_EXPORT(BIF_NAME) (&bif_trap_exports__[BIF_NAME])\n"; +print "extern Export bif_trap_exports__[];\n"; print "\n"; my $i; @@ -284,7 +284,7 @@ my $i; includes("export.h", "sys.h", "erl_vm.h", "erl_process.h", "bif.h", "erl_bif_table.h", "erl_atom_table.h"); -print "\nExport *bif_trap_exports[BIF_SIZE];\n"; +print "\nExport bif_trap_exports__[BIF_SIZE];\n"; print "BifEntry bif_table[] = {\n"; for ($i = 0; $i < @bif; $i++) { |