aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-04-17 11:09:54 +0200
committerBjörn-Egil Dahlberg <[email protected]>2015-04-17 11:09:54 +0200
commitaa8efa1cc3f776d5b3b5af24afd4369ca1f7da00 (patch)
tree617463937424429da0ced4e1249037df055b90db /erts/emulator
parent8a16e96c66728a1fd8f3b00e00c8fb999d9ad30f (diff)
parent88b79b875731199a789bbda43d104ea9c8a1f235 (diff)
downloadotp-aa8efa1cc3f776d5b3b5af24afd4369ca1f7da00.tar.gz
otp-aa8efa1cc3f776d5b3b5af24afd4369ca1f7da00.tar.bz2
otp-aa8efa1cc3f776d5b3b5af24afd4369ca1f7da00.zip
Merge branch 'egil/cmp-immediate-optimization/OTP-12663'
* egil/cmp-immediate-optimization/OTP-12663: erts: Optimize comparison operator for frequent immediates
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/utils.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index f253aa5cd0..ae62a7a708 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -2918,15 +2918,44 @@ Sint cmp(Eterm a, Eterm b)
}
#endif
+#if HALFWORD_HEAP
+static Sint erts_cmp_compound_rel_opt(Eterm a, Eterm* a_base,
+ Eterm b, Eterm* b_base,
+ int exact, int eq_only);
+#else
+static Sint erts_cmp_compound(Eterm a, Eterm b, int exact, int eq_only);
+#endif
+
+#if HALFWORD_HEAP
+Sint erts_cmp(Eterm a, Eterm* a_base,
+ Eterm b, Eterm* b_base,
+ int exact, int eq_only)
+#else
+Sint erts_cmp(Eterm a, Eterm b, int exact, int eq_only)
+#endif
+{
+ if (is_atom(a) && is_atom(b)) {
+ return cmp_atoms(a, b);
+ } else if (is_both_small(a, b)) {
+ return (signed_val(a) - signed_val(b));
+ }
+#if HALFWORD_HEAP
+ return erts_cmp_compound(a,a_base,b,b_base,exact,eq_only);
+#else
+ return erts_cmp_compound(a,b,exact,eq_only);
+#endif
+}
+
+
/* erts_cmp(Eterm a, Eterm b, int exact)
* exact = 1 -> term-based compare
* exact = 0 -> arith-based compare
*/
#if HALFWORD_HEAP
-Sint erts_cmp_rel_opt(Eterm a, Eterm* a_base, Eterm b, Eterm* b_base,
+static Sint erts_cmp_compound_rel_opt(Eterm a, Eterm* a_base, Eterm b, Eterm* b_base,
int exact, int eq_only)
#else
-Sint erts_cmp(Eterm a, Eterm b, int exact, int eq_only)
+static Sint erts_cmp_compound(Eterm a, Eterm b, int exact, int eq_only)
#endif
{
#define PSTACK_TYPE struct erts_cmp_hashmap_state