diff options
author | Björn Gustavsson <[email protected]> | 2015-03-23 10:24:56 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-04-13 12:37:54 +0200 |
commit | 85afb5e3441e78cd0d572dc809d94cfc810d71ff (patch) | |
tree | 943c8473599ff816e100008e73afed7ab5478a79 | |
parent | cd4c3e3bc699e73a7bada55a74333e5a09c7f9e4 (diff) | |
download | otp-85afb5e3441e78cd0d572dc809d94cfc810d71ff.tar.gz otp-85afb5e3441e78cd0d572dc809d94cfc810d71ff.tar.bz2 otp-85afb5e3441e78cd0d572dc809d94cfc810d71ff.zip |
Fully evaluate is_map/1 for literals at load-time
The compiler will only emit is_map/1 instructions with literal
argument if optimization is turned off. Therefore, the only
reason for this commit is cleanliness.
-rw-r--r-- | erts/emulator/beam/beam_load.c | 14 | ||||
-rw-r--r-- | erts/emulator/beam/ops.tab | 4 |
2 files changed, 16 insertions, 2 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index f140bb54cc..60f4ab5280 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -4052,6 +4052,20 @@ tuple_append_put(LoaderState* stp, GenOpArg Arity, GenOpArg Dst, } /* + * Predicate to test whether the given literal is a map. + */ + +static int +literal_is_map(LoaderState* stp, GenOpArg Lit) +{ + Eterm term; + + ASSERT(Lit.type == TAG_q); + term = stp->literals[Lit.val].term; + return is_map(term); +} + +/* * Predicate to test whether the given literal is an empty map. */ diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab index 7993dd9e25..a5a89b3990 100644 --- a/erts/emulator/beam/ops.tab +++ b/erts/emulator/beam/ops.tab @@ -1489,8 +1489,8 @@ new_map d I I update_map_assoc j s d I I update_map_exact j s d I I -is_map Fail Literal=q => move Literal x | is_map Fail x -is_map Fail c => jump Fail +is_map Fail Lit=q | literal_is_map(Lit) => +is_map Fail cq => jump Fail %macro: is_map IsMap -fail_action is_map f r |