diff options
author | Sverker Eriksson <[email protected]> | 2014-04-25 23:02:26 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2014-04-29 16:17:56 +0200 |
commit | c4cdb1847e09d1153a6044d7a6aac05db4fad515 (patch) | |
tree | 6bbb66be7b53e2532caee29ee0ff455416e9b2af /erts/emulator/hipe/hipe_x86.c | |
parent | 23246d73bbd3188e2c0a45408b9bd29fd034ccaf (diff) | |
download | otp-c4cdb1847e09d1153a6044d7a6aac05db4fad515.tar.gz otp-c4cdb1847e09d1153a6044d7a6aac05db4fad515.tar.bz2 otp-c4cdb1847e09d1153a6044d7a6aac05db4fad515.zip |
erts: Fix global tracing of beam function when called from hipe code
Make hipe to beam calls use export entry.
Makes it a lot easier to handle global tracing correctly
(breakpoints in export entry). A beam function should now be traced
correctly regardless how it is called.
This will also fix a SEGV crash when a hipe stub is made pointing into
a traced export entry and tracing is then stopped which clears the export
entry causing the hipe stub to execute beam instruction NULL.
This commit assumes that hipe code never calls local beam functions, which
should be the case nowadays as we only hipe compile entire modules.
Diffstat (limited to 'erts/emulator/hipe/hipe_x86.c')
-rw-r--r-- | erts/emulator/hipe/hipe_x86.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/erts/emulator/hipe/hipe_x86.c b/erts/emulator/hipe/hipe_x86.c index 327c74e9aa..314f6b597c 100644 --- a/erts/emulator/hipe/hipe_x86.c +++ b/erts/emulator/hipe/hipe_x86.c @@ -182,18 +182,16 @@ void *hipe_alloc_code(Uint nrbytes, Eterm callees, Eterm *trampolines, Process * return alloc_code(nrbytes); } -/* called from hipe_bif0.c:hipe_bifs_make_native_stub_2() - and hipe_bif0.c:hipe_make_stub() */ -void *hipe_make_native_stub(void *beamAddress, unsigned int beamArity) +void *hipe_make_native_stub(void *callee_exp, unsigned int beamArity) { /* * This creates a native code stub with the following contents: * - * movl $Address, P_BEAM_IP(%ebp) + * movl $Address, P_CALLEE_EXP(%ebp) * movb $Arity, P_ARITY(%ebp) * jmp callemu * - * The stub has variable size, depending on whether the P_BEAM_IP + * The stub has variable size, depending on whether the P_CALLEE_EXP * and P_ARITY offsets fit in 8-bit signed displacements or not. * The rel32 offset in the final jmp depends on its actual location, * which also depends on the size of the previous instructions. @@ -206,28 +204,28 @@ void *hipe_make_native_stub(void *beamAddress, unsigned int beamArity) codeSize = /* 16, 19, or 22 bytes */ 16 + /* 16 when both offsets are 8-bit */ - (P_BEAM_IP >= 128 ? 3 : 0) + + (P_CALLEE_EXP >= 128 ? 3 : 0) + (P_ARITY >= 128 ? 3 : 0); codep = code = alloc_code(codeSize); - /* movl $beamAddress, P_BEAM_IP(%ebp); 3 or 6 bytes, plus 4 */ + /* movl $beamAddress, P_CALLEE_EXP(%ebp); 3 or 6 bytes, plus 4 */ codep[0] = 0xc7; -#if P_BEAM_IP >= 128 +#if P_CALLEE_EXP >= 128 codep[1] = 0x85; /* disp32[EBP] */ - codep[2] = P_BEAM_IP & 0xFF; - codep[3] = (P_BEAM_IP >> 8) & 0xFF; - codep[4] = (P_BEAM_IP >> 16) & 0xFF; - codep[5] = (P_BEAM_IP >> 24) & 0xFF; + codep[2] = P_CALLEE_EXP & 0xFF; + codep[3] = (P_CALLEE_EXP >> 8) & 0xFF; + codep[4] = (P_CALLEE_EXP >> 16) & 0xFF; + codep[5] = (P_CALLEE_EXP >> 24) & 0xFF; codep += 6; #else codep[1] = 0x45; /* disp8[EBP] */ - codep[2] = P_BEAM_IP; + codep[2] = P_CALLEE_EXP; codep += 3; #endif - codep[0] = ((unsigned int)beamAddress) & 0xFF; - codep[1] = ((unsigned int)beamAddress >> 8) & 0xFF; - codep[2] = ((unsigned int)beamAddress >> 16) & 0xFF; - codep[3] = ((unsigned int)beamAddress >> 24) & 0xFF; + codep[0] = ((unsigned int)callee_exp) & 0xFF; + codep[1] = ((unsigned int)callee_exp >> 8) & 0xFF; + codep[2] = ((unsigned int)callee_exp >> 16) & 0xFF; + codep[3] = ((unsigned int)callee_exp >> 24) & 0xFF; codep += 4; /* movb $beamArity, P_ARITY(%ebp); 3 or 6 bytes */ |