From 27c7c501b52f27eb252dc6b7633223bad7a732c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 20 Sep 2017 12:50:10 +0200 Subject: Break out most of the initialization from process_main() process_main() is already too big. --- erts/emulator/beam/beam_emu.c | 60 +++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'erts') diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 009be37d40..b412cf8b79 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -376,6 +376,7 @@ do { \ * The following functions are called directly by process_main(). * Don't inline them. */ +static void init_emulator_finish(void) NOINLINE; static ErtsCodeMFA *ubif2mfa(void* uf) NOINLINE; static ErtsCodeMFA *gcbif2mfa(void* gcf) NOINLINE; static BeamInstr* handle_error(Process* c_p, BeamInstr* pc, @@ -957,9 +958,6 @@ void process_main(Eterm * x_reg_array, FloatDef* f_reg_array) init_emulator: { - int i; - Export* ep; - #ifndef NO_JUMP_TABLE #ifdef ERTS_OPCODE_COUNTER_SUPPORT #ifdef DEBUG @@ -972,6 +970,40 @@ void process_main(Eterm * x_reg_array, FloatDef* f_reg_array) #endif /* ERTS_OPCODE_COUNTER_SUPPORT */ #endif /* NO_JUMP_TABLE */ + init_emulator_finish(); + return; + } +#ifdef NO_JUMP_TABLE + default: + erts_exit(ERTS_ERROR_EXIT, "unexpected op code %d\n",Go); + } +#endif + return; /* Never executed */ + + save_calls1: + { + BeamInstr dis_next; + + save_calls(c_p, (Export *) Arg(0)); + + SET_I(((Export *) Arg(0))->addressv[erts_active_code_ix()]); + + dis_next = *I; + FCALLS--; + Goto(dis_next); + } +} + +/* + * One-time initialization of emulator. Does not need to be + * in process_main(). + */ +static void +init_emulator_finish(void) +{ + int i; + Export* ep; + beam_apply[0] = BeamOpCodeAddr(op_i_apply); beam_apply[1] = BeamOpCodeAddr(op_normal_exit); beam_exit[0] = BeamOpCodeAddr(op_error_action_code); @@ -994,28 +1026,6 @@ void process_main(Eterm * x_reg_array, FloatDef* f_reg_array) /* XXX: set func info for bifs */ ep->info.op = BeamOpCodeAddr(op_i_func_info_IaaI); } - - return; - } -#ifdef NO_JUMP_TABLE - default: - erts_exit(ERTS_ERROR_EXIT, "unexpected op code %d\n",Go); - } -#endif - return; /* Never executed */ - - save_calls1: - { - BeamInstr dis_next; - - save_calls(c_p, (Export *) Arg(0)); - - SET_I(((Export *) Arg(0))->addressv[erts_active_code_ix()]); - - dis_next = *I; - FCALLS--; - Goto(dis_next); - } } /* -- cgit v1.2.3