diff options
author | Björn Gustavsson <[email protected]> | 2017-09-02 14:35:39 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-09-13 12:20:56 +0200 |
commit | 8650d6d811bb99490e1a75cbbab684a673a950ba (patch) | |
tree | 39924f5d0b31516b7e1d54e0755a6e7cc47c2b78 /erts/emulator/beam/beam_load.c | |
parent | bffbd4fb504e9551fc7feb9177ef0a2394c00cae (diff) | |
download | otp-8650d6d811bb99490e1a75cbbab684a673a950ba.tar.gz otp-8650d6d811bb99490e1a75cbbab684a673a950ba.tar.bz2 otp-8650d6d811bb99490e1a75cbbab684a673a950ba.zip |
Refactor instructions to support relative jumps
Introduce new macros that can be used for relative jumps and
use them consistently.
Test that everything works by using a non-zero constant JUMP_OFFSET.
The loader subtracts JUMP_OFFSET from loaded labels, and all
instructions that use 'f' operands add it back.
Diffstat (limited to 'erts/emulator/beam/beam_load.c')
-rw-r--r-- | erts/emulator/beam/beam_load.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index 7d3a19ff86..9b8f33f576 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -4840,7 +4840,11 @@ freeze_code(LoaderState* stp) ASSERT(this_patch < stp->ci); next_patch = codev[this_patch]; ASSERT(next_patch < stp->ci); - codev[this_patch] = (BeamInstr) (codev + value); + if (this_patch < stp->num_functions) { + codev[this_patch] = (BeamInstr) (codev + value); + } else { + codev[this_patch] = (BeamInstr) (codev + value - JUMP_OFFSET); + } this_patch = next_patch; } } @@ -4885,7 +4889,7 @@ final_touch(LoaderState* stp, struct erl_module_instance* inst_p) while (index != 0) { BeamInstr next = codev[index]; codev[index] = BeamOpCode(op_catch_yf); - catches = beam_catches_cons((BeamInstr *)codev[index+2], catches); + catches = beam_catches_cons((BeamInstr *)codev[index+2]+JUMP_OFFSET, catches); codev[index+2] = make_catch(catches); index = next; } |