aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-01-26 16:25:26 +0100
committerSverker Eriksson <[email protected]>2012-02-21 12:23:04 +0100
commite60c9cd4356a91c10657b5de86af8279ccd6eb79 (patch)
tree0dfe3a276ce4a23571e97cbfbb15a94ced6fd77a /erts/emulator/beam
parent605c7c1bafc72b0cc3a6ee6110abf8676b6b287f (diff)
downloadotp-e60c9cd4356a91c10657b5de86af8279ccd6eb79.tar.gz
otp-e60c9cd4356a91c10657b5de86af8279ccd6eb79.tar.bz2
otp-e60c9cd4356a91c10657b5de86af8279ccd6eb79.zip
erts: Move number-of-breakpoint counter from code to Module struct
The is a refactoring in preparation to add a counter in Module struct for export entry tracing. It is nicer if the two are kept together.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/beam_bif_load.c8
-rw-r--r--erts/emulator/beam/beam_bp.c6
-rw-r--r--erts/emulator/beam/beam_load.c3
-rw-r--r--erts/emulator/beam/beam_load.h17
-rw-r--r--erts/emulator/beam/module.c2
-rw-r--r--erts/emulator/beam/module.h1
6 files changed, 16 insertions, 21 deletions
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c
index c14b86f811..4265f139df 100644
--- a/erts/emulator/beam/beam_bif_load.c
+++ b/erts/emulator/beam/beam_bif_load.c
@@ -826,8 +826,8 @@ static void ensure_no_breakpoints(Process *c_p, ErtsProcLocks c_p_locks,
ErtsCodeIndex code_ix = erts_active_code_ix();
Module* modp = erts_get_module(module, code_ix);
- if (modp && modp->curr.code != NULL
- && modp->curr.code[MI_NUM_BREAKPOINTS] > 0) {
+ if (modp && modp->curr.num_breakpoints > 0) {
+ ASSERT(modp->curr.code != NULL);
#ifdef ERTS_ENABLE_LOCK_CHECK
#ifdef ERTS_SMP
if (c_p && c_p_locks)
@@ -840,7 +840,7 @@ static void ensure_no_breakpoints(Process *c_p, ErtsProcLocks c_p_locks,
erts_smp_proc_unlock(c_p, ERTS_PROC_LOCK_MAIN);
erts_smp_thr_progress_block();
erts_clear_module_break(modp);
- modp->curr.code[MI_NUM_BREAKPOINTS] = 0;
+ modp->curr.num_breakpoints = 0;
erts_smp_thr_progress_unblock();
if (c_p && c_p_locks)
erts_smp_proc_lock(c_p, ERTS_PROC_LOCK_MAIN);
@@ -854,7 +854,7 @@ static void ensure_no_breakpoints(Process *c_p, ErtsProcLocks c_p_locks,
static void
delete_code(Process *c_p, ErtsProcLocks c_p_locks, Module* modp)
{
- ASSERT(!(modp->curr.code && modp->curr.code[MI_NUM_BREAKPOINTS] > 0));
+ ASSERT(modp->curr.num_breakpoints == 0);
modp->old = modp->curr;
modp->curr.code = NULL;
modp->curr.code_length = 0;
diff --git a/erts/emulator/beam/beam_bp.c b/erts/emulator/beam/beam_bp.c
index 30c458244b..ef48d7d05e 100644
--- a/erts/emulator/beam/beam_bp.c
+++ b/erts/emulator/beam/beam_bp.c
@@ -1099,7 +1099,7 @@ static int set_function_break(Module *modp, BeamInstr *pc, int bif,
}
if (bif == BREAK_IS_ERL) {
- ++(*(BeamInstr*)&code_base[MI_NUM_BREAKPOINTS]);
+ ++modp->curr.num_breakpoints;
}
return 1;
}
@@ -1276,8 +1276,8 @@ static int clear_function_break(Module *m, BeamInstr *pc, int bif, BeamInstr bre
}
Free(bd);
if (bif == BREAK_IS_ERL) {
- ASSERT(((BeamInstr) code_base[MI_NUM_BREAKPOINTS]) > 0);
- --(*(BeamInstr*)&code_base[MI_NUM_BREAKPOINTS]);
+ ASSERT(m->curr.num_breakpoints > 0);
+ --m->curr.num_breakpoints;
}
if (*rs) {
for (ix = 1; ix < erts_no_schedulers; ++ix) {
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index 4ac426fc9e..e966f423ec 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -643,8 +643,6 @@ erts_prepare_loading(LoaderState* stp, Process *c_p, Eterm group_leader,
stp->code[MI_COMPILE_PTR] = 0;
stp->code[MI_COMPILE_SIZE] = 0;
stp->code[MI_COMPILE_SIZE_ON_HEAP] = 0;
- stp->code[MI_NUM_BREAKPOINTS] = 0;
-
/*
* Read the atom table.
@@ -5811,7 +5809,6 @@ erts_make_stub_module(Process* p, Eterm Mod, Eterm Beam, Eterm Info)
code[MI_COMPILE_PTR] = 0;
code[MI_COMPILE_SIZE] = 0;
code[MI_COMPILE_SIZE_ON_HEAP] = 0;
- code[MI_NUM_BREAKPOINTS] = 0;
code[MI_LITERALS_START] = 0;
code[MI_LITERALS_END] = 0;
code[MI_LITERALS_OFF_HEAP] = 0;
diff --git a/erts/emulator/beam/beam_load.h b/erts/emulator/beam/beam_load.h
index 9da692625b..0f6ad35cbc 100644
--- a/erts/emulator/beam/beam_load.h
+++ b/erts/emulator/beam/beam_load.h
@@ -89,27 +89,22 @@ extern Uint erts_total_code_size;
#define MI_COMPILE_SIZE_ON_HEAP 6
/*
- * Number of breakpoints in module is stored in this word
- */
-#define MI_NUM_BREAKPOINTS 7
-
-/*
* Literal area (constant pool).
*/
-#define MI_LITERALS_START 8
-#define MI_LITERALS_END 9
-#define MI_LITERALS_OFF_HEAP 10
+#define MI_LITERALS_START 7
+#define MI_LITERALS_END 8
+#define MI_LITERALS_OFF_HEAP 9
/*
* Pointer to the on_load function (or NULL if none).
*/
-#define MI_ON_LOAD_FUNCTION_PTR 11
+#define MI_ON_LOAD_FUNCTION_PTR 10
/*
* Pointer to the line table (or NULL if none).
*/
-#define MI_LINE_TABLE 12
+#define MI_LINE_TABLE 11
/*
* Start of function pointer table. This table contains pointers to
@@ -120,7 +115,7 @@ extern Uint erts_total_code_size;
* this table.
*/
-#define MI_FUNCTIONS 13
+#define MI_FUNCTIONS 12
/*
* Layout of the line table.
diff --git a/erts/emulator/beam/module.c b/erts/emulator/beam/module.c
index b0a3bd1fab..4174f59446 100644
--- a/erts/emulator/beam/module.c
+++ b/erts/emulator/beam/module.c
@@ -74,6 +74,8 @@ static Module* module_alloc(Module* tmpl)
obj->slot.index = -1;
obj->curr.nif = NULL;
obj->old.nif = NULL;
+ obj->curr.num_breakpoints = 0;
+ obj->old.num_breakpoints = 0;
return obj;
}
diff --git a/erts/emulator/beam/module.h b/erts/emulator/beam/module.h
index 209aa3b98a..8c09b3628d 100644
--- a/erts/emulator/beam/module.h
+++ b/erts/emulator/beam/module.h
@@ -29,6 +29,7 @@ struct erl_module_instance {
int code_length; /* Length of loaded code in bytes. */
unsigned catches;
struct erl_module_nif* nif;
+ int num_breakpoints;
};
typedef struct erl_module {