diff options
author | Michał Muskała <[email protected]> | 2018-02-25 14:19:48 +0100 |
---|---|---|
committer | Michał Muskała <[email protected]> | 2018-03-26 12:07:10 +0200 |
commit | 63e1c58d27ab695a19897423fc75e607f69ff51b (patch) | |
tree | 5965bba7175e8cb29596d3cdabb2db8cd86d6cd3 /erts/emulator/beam/beam_load.c | |
parent | 0217dbfee505ed8c88164c7a4ea5e1834e6ce8cd (diff) | |
download | otp-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/beam_load.c')
-rw-r--r-- | erts/emulator/beam/beam_load.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index e242fe9140..3ac98cec8d 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -4521,6 +4521,19 @@ is_empty_map(LoaderState* stp, GenOpArg Lit) } /* + * Predicate to test whether the given literal is an export. + */ +static int +literal_is_export(LoaderState* stp, GenOpArg Lit) +{ + Eterm term; + + ASSERT(Lit.type == TAG_q); + term = stp->literals[Lit.val].term; + return is_export(term); +} + +/* * Pseudo predicate map_key_sort that will sort the Rest operand for * map instructions as a side effect. */ |