aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-02-26 12:23:35 +0100
committerBjörn Gustavsson <[email protected]>2019-03-01 14:06:13 +0100
commita29c834dd3cef789fb6d4a45092c20680eafd29d (patch)
tree3ba554e0e1e68a552193b3ada8e81297a0c361f5 /erts
parent60656d125a0f23c1f45069fdee80a5048439f06e (diff)
downloadotp-a29c834dd3cef789fb6d4a45092c20680eafd29d.tar.gz
otp-a29c834dd3cef789fb6d4a45092c20680eafd29d.tar.bz2
otp-a29c834dd3cef789fb6d4a45092c20680eafd29d.zip
Combine test_arity with get_tuple_element
The test_arity instruction is often followed by get_tuple_element.
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/instrs.tab10
-rw-r--r--erts/emulator/beam/ops.tab4
2 files changed, 14 insertions, 0 deletions
diff --git a/erts/emulator/beam/instrs.tab b/erts/emulator/beam/instrs.tab
index 29e8c29105..5ee98fef02 100644
--- a/erts/emulator/beam/instrs.tab
+++ b/erts/emulator/beam/instrs.tab
@@ -797,6 +797,16 @@ test_arity(Fail, Pointer, Arity) {
}
}
+test_arity_get_tuple_element(Fail, Pointer, Arity, Pos, Dst) {
+ Eterm* ptr = tuple_val($Pointer);
+ Eterm* src;
+ if (*ptr != $Arity) {
+ $FAIL($Fail);
+ }
+ src = ADD_BYTE_OFFSET(ptr, $Pos);
+ $Dst = *src;
+}
+
i_is_eq_exact_immed(Fail, X, Y) {
if ($X != $Y) {
$FAIL($Fail);
diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab
index 96cdabaf5e..e0a947a512 100644
--- a/erts/emulator/beam/ops.tab
+++ b/erts/emulator/beam/ops.tab
@@ -623,9 +623,13 @@ is_tuple f? rxy
test_arity Fail Literal=q Arity => move Literal x | test_arity Fail x Arity
test_arity Fail=f c Arity => jump Fail
+test_arity Fail Tuple=x Arity | get_tuple_element Tuple Pos Dst=x => \
+ test_arity_get_tuple_element Fail Tuple Arity Pos Dst
test_arity f? xy A
+test_arity_get_tuple_element f? x A P x
+
get_tuple_element Reg=x P1 D1=x | get_tuple_element Reg=x P2 D2=x | \
get_tuple_element Reg=x P3 D3=x | \
succ(P1, P2) | succ(P2, P3) | \