aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_trace.h
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-06-26 15:49:48 +0200
committerBjörn Gustavsson <[email protected]>2019-08-22 13:37:41 +0200
commit25fe3fb23c594d735cb6ebae120910e44f0cdae4 (patch)
tree746907d20fb667858ec419cf49138f851317e055 /erts/emulator/beam/erl_trace.h
parente51727f129d6b5667f81e86865d17cf564712054 (diff)
downloadotp-25fe3fb23c594d735cb6ebae120910e44f0cdae4.tar.gz
otp-25fe3fb23c594d735cb6ebae120910e44f0cdae4.tar.bz2
otp-25fe3fb23c594d735cb6ebae120910e44f0cdae4.zip
Optimize continuation pointer management
The BEAM instructions for calling a function don't save the continuation pointer (return address) on the stack, but to a special BEAM register called CP. It is the responsibility of the called function to save CP to the stack frame before calling other functions. In the earlier implementations of BEAM on Sparc, CP was located in a CPU register. That meant that the continuation pointer was never written to memory when calling simple functions that didn't call other functions at all or ended in a tail-call to another function. The modern BEAM no longer keeps CP in CPU register. Instead, it is kept in the `process` struct (in `p->cp`). That means the continuation pointer must be written to the memory on every call, and if the called function will call other functions, it will must read the continuation pointer from `p->cp` and store it on the stack. This commit eliminates the concept of the CP register and modifies the call instructions to directly store the continuation pointer on the stack. That makes allocation and trimming of stack frames slightly faster. A more important benefit is simplification of code that handles continuation pointers. Because all continuation pointers are now stored on the stack, the special case of handling `p->cp` disappears. Co-authored-by: John Högberg <[email protected]>
Diffstat (limited to 'erts/emulator/beam/erl_trace.h')
-rw-r--r--erts/emulator/beam/erl_trace.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_trace.h b/erts/emulator/beam/erl_trace.h
index d25f97c656..f564549ab9 100644
--- a/erts/emulator/beam/erl_trace.h
+++ b/erts/emulator/beam/erl_trace.h
@@ -145,7 +145,7 @@ int erts_trace_flags(Eterm List,
Eterm erts_bif_trace(int bif_index, Process* p, Eterm* args, BeamInstr *I);
Eterm
erts_bif_trace_epilogue(Process *p, Eterm result, int applying,
- Export* ep, BeamInstr *cp, Uint32 flags,
+ Export* ep, Uint32 flags,
Uint32 flags_meta, BeamInstr* I,
ErtsTracer meta_tracer);