Skip to content

Commit

Permalink
Merge pull request #783 from pguyot/w34/optimize-by-offsetting-labels
Browse files Browse the repository at this point in the history
Optimize by registering labels to the instruction that follows the label

It brings a significant speed improvement by avoiding processing label opcodes
during execution.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
  • Loading branch information
bettio committed Oct 25, 2023
2 parents e30c243 + a5a2195 commit 9aab333
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/libAtomVM/opcodesswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -1590,18 +1590,15 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)

switch (*pc++) {
case OP_LABEL: {
#ifdef IMPL_CODE_LOADER
const uint8_t* saved_pc = pc - 1;
#endif
uint32_t label;
DECODE_LITERAL(label, pc)

TRACE("label/1 label=%i\n", label);
USED_BY_TRACE(label);

#ifdef IMPL_CODE_LOADER
TRACE("Mark label %i here at %" PRIuPTR "\n", label, saved_pc - code);
module_add_label(mod, label, saved_pc);
TRACE("Mark label %i here at %" PRIuPTR "\n", label, pc - code);
module_add_label(mod, label, pc);
#endif
break;
}
Expand Down

0 comments on commit 9aab333

Please sign in to comment.