diff options
author | Magnus Lång <[email protected]> | 2016-04-12 13:08:02 +0200 |
---|---|---|
committer | Magnus Lång <[email protected]> | 2016-06-30 12:01:57 +0200 |
commit | 1dd81185dfb2fd6ac30b6eb44c905128c8958cb4 (patch) | |
tree | 4455256dd37472db1188f4c0dce79db658a0e58e /erts/emulator/hipe/hipe_arm_asm.m4 | |
parent | c2157dc06a8c997c207dd82cd6fa11dbcb508f11 (diff) | |
download | otp-1dd81185dfb2fd6ac30b6eb44c905128c8958cb4.tar.gz otp-1dd81185dfb2fd6ac30b6eb44c905128c8958cb4.tar.bz2 otp-1dd81185dfb2fd6ac30b6eb44c905128c8958cb4.zip |
hipe: Add assertion for gc in bif without wrapper
An easy source of tricky bugs is to start calling the garbage collector
from a built-in function without adding that bif to hipe_bif_list.m4.
With this change we, in the debug build, keep track of whether the
canonical stack and heap pointers are stored in the PCB or in
registers/stack, allowing us to catch this class of mistakes with an
assertion.
Diffstat (limited to 'erts/emulator/hipe/hipe_arm_asm.m4')
-rw-r--r-- | erts/emulator/hipe/hipe_arm_asm.m4 | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/erts/emulator/hipe/hipe_arm_asm.m4 b/erts/emulator/hipe/hipe_arm_asm.m4 index ae9ec752bb..68a6faa70b 100644 --- a/erts/emulator/hipe/hipe_arm_asm.m4 +++ b/erts/emulator/hipe/hipe_arm_asm.m4 @@ -48,6 +48,24 @@ define(NR_ARG_REGS,3)dnl admissible values are 0 to 6, inclusive `#define TEMP_LR r8' /* + * Debugging macros + * + * Keeps track of whether context has been saved in the debug build, allowing us + * to detect when the garbage collector is called when it shouldn't. + */ +`#ifdef DEBUG +# define SET_GC_UNSAFE(SCRATCH) \ + mov SCRATCH, #1; \ + str SCRATCH, [P, #P_GCUNSAFE] +# define SET_GC_SAFE(SCRATCH) \ + mov SCRATCH, #0; \ + str SCRATCH, [P, #P_GCUNSAFE] +#else +# define SET_GC_UNSAFE(SCRATCH) +# define SET_GC_SAFE(SCRATCH) +#endif' + +/* * Context switching macros. * * RESTORE_CONTEXT and RESTORE_CONTEXT_QUICK do not affect @@ -59,12 +77,14 @@ define(NR_ARG_REGS,3)dnl admissible values are 0 to 6, inclusive `#define RESTORE_CONTEXT_QUICK \ mov lr, TEMP_LR' -`#define SAVE_CACHED_STATE \ - str HP, [P, #P_HP]; \ - str NSP, [P, #P_NSP]' +`#define SAVE_CACHED_STATE \ + str HP, [P, #P_HP]; \ + str NSP, [P, #P_NSP]; \ + SET_GC_SAFE(HP)' -`#define RESTORE_CACHED_STATE \ - ldr HP, [P, #P_HP]; \ +`#define RESTORE_CACHED_STATE \ + SET_GC_UNSAFE(HP); \ + ldr HP, [P, #P_HP]; \ ldr NSP, [P, #P_NSP]' `#define SAVE_CONTEXT_BIF \ @@ -75,12 +95,14 @@ define(NR_ARG_REGS,3)dnl admissible values are 0 to 6, inclusive ldr HP, [P, #P_HP]' `#define SAVE_CONTEXT_GC \ + SET_GC_SAFE(TEMP_LR); \ mov TEMP_LR, lr; \ str lr, [P, #P_NRA]; \ str NSP, [P, #P_NSP]; \ str HP, [P, #P_HP]' `#define RESTORE_CONTEXT_GC \ + SET_GC_UNSAFE(HP); \ ldr HP, [P, #P_HP]' /* |