diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-08-29 18:27:45 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2017-03-24 10:53:14 +0100 |
commit | 14d709b0e07e899161a40bb43fc43fd6916f59ab (patch) | |
tree | 841aac1ed1a67417d4274215aeadbec3b1b2ead3 /erts/emulator/beam/ops.tab | |
parent | f7d248a6794655809e2fdc7d0d1932bbb3dc8cc0 (diff) | |
download | otp-14d709b0e07e899161a40bb43fc43fd6916f59ab.tar.gz otp-14d709b0e07e899161a40bb43fc43fd6916f59ab.tar.bz2 otp-14d709b0e07e899161a40bb43fc43fd6916f59ab.zip |
compiler: Add is_tagged_tuple instruction
Rewrite the instruction stream on tagged tuple tests.
Tagged tuples means a tuple of any arity with an atom as its first element.
Typically records, ok-tuples and error-tuples.
from:
...
{test,is_tuple,Fail,[Src]}.
{test,test_arity,Fail,[Src,Sz]}.
...
{get_tuple_element,Src,0,Dst}.
...
{test,is_eq_exact,Fail,[Dst,Atom]}.
...
to:
...
{test,is_tagged_tuple,Fail,[Src,Sz,Atom]}.
...
Diffstat (limited to 'erts/emulator/beam/ops.tab')
-rw-r--r-- | erts/emulator/beam/ops.tab | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab index ec36b23059..9b5bd7a749 100644 --- a/erts/emulator/beam/ops.tab +++ b/erts/emulator/beam/ops.tab @@ -620,6 +620,20 @@ test_heap Need u==1 | put_list Y=y x==0 x==0 => test_heap_1_put_list Need Y %macro: test_heap_1_put_list TestHeapPutList -pack test_heap_1_put_list I y +# +# is_tagged_tuple Fail=f Src=rxy Arity Atom=a +# + +is_tagged_tuple Fail Literal=q Arity Atom => \ + move Literal x | is_tagged_tuple Fail x Arity Atom +is_tagged_tuple Fail=f c Arity Atom => jump Fail + +%macro:is_tagged_tuple IsTaggedTuple -fail_action + +is_tagged_tuple f r A a +is_tagged_tuple f x A a +is_tagged_tuple f y A a + # Test tuple & arity (head) is_tuple Fail Literal=q => move Literal x | is_tuple Fail x |