diff options
author | Björn Gustavsson <[email protected]> | 2017-09-19 06:33:06 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-10-05 12:37:56 +0200 |
commit | 22d2a00aebf0eef878af95d8b7598adbfca06e7e (patch) | |
tree | f5598c7bd2d965fa9416d4e0e1ec11925e71a173 /erts/emulator/beam/erl_vm.h | |
parent | e1c9772ffdacae4007209ac5a82758b8e0d3cec4 (diff) | |
download | otp-22d2a00aebf0eef878af95d8b7598adbfca06e7e.tar.gz otp-22d2a00aebf0eef878af95d8b7598adbfca06e7e.tar.bz2 otp-22d2a00aebf0eef878af95d8b7598adbfca06e7e.zip |
Use 32-bits pointers to C code
On a 64-bit machine, we only need 32 bits to store a pointer to
the C code that implements a BEAM instruction. Refactor the code
to only use the lower 32 bits of each instruction word, and take
care to preserve the high 32 bits.
Diffstat (limited to 'erts/emulator/beam/erl_vm.h')
-rw-r--r-- | erts/emulator/beam/erl_vm.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_vm.h b/erts/emulator/beam/erl_vm.h index 661538eadd..76980b5871 100644 --- a/erts/emulator/beam/erl_vm.h +++ b/erts/emulator/beam/erl_vm.h @@ -209,6 +209,15 @@ extern void** beam_ops; # define BeamOpCodeAddr(OpCode) ((BeamInstr)beam_ops[(OpCode)]) #endif -#define BeamIsOpCode(InstrWord, OpCode) ((InstrWord) == BeamOpCodeAddr(OpCode)) +#if defined(ARCH_64) && defined(CODE_MODEL_SMALL) +# define BeamCodeAddr(InstrWord) ((BeamInstr)(Uint32)(InstrWord)) +# define BeamSetCodeAddr(InstrWord, Addr) (((InstrWord) & ~((1ull << 32)-1)) | (Addr)) +# define BeamExtraData(InstrWord) ((InstrWord) >> 32) +#else +# define BeamCodeAddr(InstrWord) ((BeamInstr)(InstrWord)) +# define BeamSetCodeAddr(InstrWord, Addr) (Addr) +#endif + +#define BeamIsOpCode(InstrWord, OpCode) (BeamCodeAddr(InstrWord) == BeamOpCodeAddr(OpCode)) #endif /* __ERL_VM_H__ */ |