aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_printf_term.c
diff options
context:
space:
mode:
authorMichał Muskała <[email protected]>2018-02-25 14:19:48 +0100
committerMichał Muskała <[email protected]>2018-03-26 12:07:10 +0200
commit63e1c58d27ab695a19897423fc75e607f69ff51b (patch)
tree5965bba7175e8cb29596d3cdabb2db8cd86d6cd3 /erts/emulator/beam/erl_printf_term.c
parent0217dbfee505ed8c88164c7a4ea5e1834e6ce8cd (diff)
downloadotp-63e1c58d27ab695a19897423fc75e607f69ff51b.tar.gz
otp-63e1c58d27ab695a19897423fc75e607f69ff51b.tar.bz2
otp-63e1c58d27ab695a19897423fc75e607f69ff51b.zip
Compile external fun expressions to literals
The expressions fun M:F/A, when all elements are literals are also treated as a literal. Since they have consistent representation and don't depend on the code currently loaded in the VM, this is safe. This can provide significant performance improvements in code using such functions extensively - a full function call to erlang:make_fun/3 is replaced by a single move instruction and no register shuffling or saving registers to stack is necessary. Additionally, compound data types that contain such external functions as elements can be treated as literals too. The commit also changes the representation of external funs to be a valid Erlang syntax and adds support for literal external funs to core Erlang.
Diffstat (limited to 'erts/emulator/beam/erl_printf_term.c')
-rw-r--r--erts/emulator/beam/erl_printf_term.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/erts/emulator/beam/erl_printf_term.c b/erts/emulator/beam/erl_printf_term.c
index e6f8460164..910f241a3a 100644
--- a/erts/emulator/beam/erl_printf_term.c
+++ b/erts/emulator/beam/erl_printf_term.c
@@ -532,14 +532,13 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount) {
Atom* module = atom_tab(atom_val(ep->info.mfa.module));
Atom* name = atom_tab(atom_val(ep->info.mfa.function));
- PRINT_STRING(res, fn, arg, "#Fun<");
+ PRINT_STRING(res, fn, arg, "fun ");
PRINT_BUF(res, fn, arg, module->name, module->len);
- PRINT_CHAR(res, fn, arg, '.');
+ PRINT_CHAR(res, fn, arg, ':');
PRINT_BUF(res, fn, arg, name->name, name->len);
- PRINT_CHAR(res, fn, arg, '.');
+ PRINT_CHAR(res, fn, arg, '/');
PRINT_SWORD(res, fn, arg, 'd', 0, 1,
(ErlPfSWord) ep->info.mfa.arity);
- PRINT_CHAR(res, fn, arg, '>');
}
break;
case FUN_DEF: