aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_validator.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-01-15 12:26:17 +0100
committerBjörn Gustavsson <[email protected]>2010-01-15 13:40:14 +0100
commit31e231d813d8a15a937ebd5fbb71299ce1faf9c1 (patch)
treefc90dee8d743c38b3072350c16d23ec3f4899044 /lib/compiler/src/beam_validator.erl
parentb327123e4da61ee2794aa473d357c37e7168d189 (diff)
downloadotp-31e231d813d8a15a937ebd5fbb71299ce1faf9c1.tar.gz
otp-31e231d813d8a15a937ebd5fbb71299ce1faf9c1.tar.bz2
otp-31e231d813d8a15a937ebd5fbb71299ce1faf9c1.zip
beam_validator: fix incorrect assumptions about GC guard BIFs
The beam_validator pass incorrectly assumes that a GC guard BIF (such as length/1) may first do a garbage collection and then fail. That assumption is not correct (guards BIF only do garbage collection when it is known that the BIF call will succeed), and will cause the compiler to reject valid programs. Modify the beam_validator to assume that if the branch is taken for a gc_bif instruction, all registers are unchanged and no garbage collection has occurred. Also add a comment in the emulator about that assumption.
Diffstat (limited to 'lib/compiler/src/beam_validator.erl')
-rw-r--r--lib/compiler/src/beam_validator.erl6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index 08ba9c3ee4..5ddc534abc 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -604,9 +604,9 @@ valfun_4({gc_bif,Op,{f,Fail},Live,Src,Dst}, #vst{current=St0}=Vst0) ->
St = kill_heap_allocation(St0),
Vst1 = Vst0#vst{current=St},
verify_live(Live, Vst1),
- Vst2 = prune_x_regs(Live, Vst1),
- validate_src(Src, Vst2),
- Vst = branch_state(Fail, Vst2),
+ Vst2 = branch_state(Fail, Vst1),
+ Vst = prune_x_regs(Live, Vst2),
+ validate_src(Src, Vst),
Type = bif_type(Op, Src, Vst),
set_type_reg(Type, Dst, Vst);
valfun_4(return, #vst{current=#st{numy=none}}=Vst) ->