aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_emu.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-09-20 12:50:10 +0200
committerBjörn Gustavsson <[email protected]>2017-10-01 07:08:19 +0200
commit27c7c501b52f27eb252dc6b7633223bad7a732c4 (patch)
tree79109cc4b00fa2594294fc7140805ba9cf228e61 /erts/emulator/beam/beam_emu.c
parent53e6fb04c52703a222884b709e86d1fd8bcf98d9 (diff)
downloadotp-27c7c501b52f27eb252dc6b7633223bad7a732c4.tar.gz
otp-27c7c501b52f27eb252dc6b7633223bad7a732c4.tar.bz2
otp-27c7c501b52f27eb252dc6b7633223bad7a732c4.zip
Break out most of the initialization from process_main()
process_main() is already too big.
Diffstat (limited to 'erts/emulator/beam/beam_emu.c')
-rw-r--r--erts/emulator/beam/beam_emu.c60
1 files changed, 35 insertions, 25 deletions
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);
- }
}
/*