aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-06-03 11:58:34 +0200
committerBjörn Gustavsson <[email protected]>2013-06-03 11:58:34 +0200
commitc97ac1a34971ce60bd36519e7ea51db2456217df (patch)
tree7d43360956e4c87f78340287676871ca202dfa9e /lib
parent107625c4fd3e3a50f9c5cc3716899ff595bcda99 (diff)
parent7a1cf0d233d8e3981f1e4a822aa1837591697c3a (diff)
downloadotp-c97ac1a34971ce60bd36519e7ea51db2456217df.tar.gz
otp-c97ac1a34971ce60bd36519e7ea51db2456217df.tar.bz2
otp-c97ac1a34971ce60bd36519e7ea51db2456217df.zip
Merge branch 'maint'
* maint: compiler: Correct liveness optimization for wait/1
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/beam_utils.erl4
-rw-r--r--lib/compiler/test/receive_SUITE.erl21
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl
index 554c14f57a..e623bcc6a5 100644
--- a/lib/compiler/src/beam_utils.erl
+++ b/lib/compiler/src/beam_utils.erl
@@ -734,6 +734,8 @@ live_opt([{loop_rec,_Fail,_Dst}=I|Is], _, D, Acc) ->
live_opt(Is, 0, D, [I|Acc]);
live_opt([timeout=I|Is], _, D, Acc) ->
live_opt(Is, 0, D, [I|Acc]);
+live_opt([{wait,_}=I|Is], _, D, Acc) ->
+ live_opt(Is, 0, D, [I|Acc]);
%% Transparent instructions - they neither use nor modify x registers.
live_opt([{deallocate,_}=I|Is], Regs, D, Acc) ->
@@ -744,8 +746,6 @@ live_opt([{try_end,_}=I|Is], Regs, D, Acc) ->
live_opt(Is, Regs, D, [I|Acc]);
live_opt([{loop_rec_end,_}=I|Is], Regs, D, Acc) ->
live_opt(Is, Regs, D, [I|Acc]);
-live_opt([{wait,_}=I|Is], Regs, D, Acc) ->
- live_opt(Is, Regs, D, [I|Acc]);
live_opt([{wait_timeout,_,{Tag,_}}=I|Is], Regs, D, Acc) when Tag =/= x ->
live_opt(Is, Regs, D, [I|Acc]);
live_opt([{line,_}=I|Is], Regs, D, Acc) ->
diff --git a/lib/compiler/test/receive_SUITE.erl b/lib/compiler/test/receive_SUITE.erl
index e60584d4ab..ec49267ded 100644
--- a/lib/compiler/test/receive_SUITE.erl
+++ b/lib/compiler/test/receive_SUITE.erl
@@ -23,7 +23,8 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2,
init_per_testcase/2,end_per_testcase/2,
- export/1,recv/1,coverage/1,otp_7980/1,ref_opt/1]).
+ export/1,recv/1,coverage/1,otp_7980/1,ref_opt/1,
+ wait/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -44,7 +45,7 @@ all() ->
groups() ->
[{p,test_lib:parallel(),
- [recv,coverage,otp_7980,ref_opt,export]}].
+ [recv,coverage,otp_7980,ref_opt,export,wait]}].
init_per_suite(Config) ->
@@ -252,4 +253,20 @@ export_1(Reference) ->
id({build,self()}),
Result.
+wait(Config) when is_list(Config) ->
+ self() ! <<42>>,
+ <<42>> = wait_1(r, 1, 2),
+ {1,2,3} = wait_1(1, 2, 3),
+ ok.
+
+wait_1(r, _, _) ->
+ receive
+ B when byte_size(B) > 0 ->
+ B
+ end;
+%% beam_utils would wrongly assume that wait/1 could fall through
+%% to the next clause.
+wait_1(A, B, C) ->
+ {A,B,C}.
+
id(I) -> I.