aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_except.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-02-21 06:10:38 +0100
committerBjörn Gustavsson <[email protected]>2019-02-21 14:04:29 +0100
commit5239eb0c62a96fb6b02c182a6786049e9782b123 (patch)
treef79d552850686625dfb43b03783df1154c838374 /lib/compiler/src/beam_except.erl
parent03d097203b23cca5da801f25abf40218ad5ada83 (diff)
downloadotp-5239eb0c62a96fb6b02c182a6786049e9782b123.tar.gz
otp-5239eb0c62a96fb6b02c182a6786049e9782b123.tar.bz2
otp-5239eb0c62a96fb6b02c182a6786049e9782b123.zip
sys_core_fold: Remove an unsafe optimization
`sys_core_fold` has an optimization of repeated pattern matching. For example, when a record is matched the first time, the pattern is remembered. When the same record is matched again, the matching does not need to be repeated, but the variables bound in the first matching can be re-used. It turns out that that there is a name capture problem when the old inliner is used. The old inliner is used when explicitly inling certain functions, and by the compiler test suites for testing the compiler. The name capture problem could be eliminated by more aggressive variable renaming when inlining. But, fortunately, given the new SSA passes, this optimization is no longer as essential as it used to be. Removing the optimization turns out to be mostly benefical, leading to a smaller stack frame in many cases. Also remove the optimizations of `element/2`, `is_record/3`, and `setelement/3` from `sys_core_fold`. Because matched patterns are no longer remembered, those optimizations can very rarely be applied any more. (Those same optimizations are already done in `beam_ssa_type`.)
Diffstat (limited to 'lib/compiler/src/beam_except.erl')
-rw-r--r--lib/compiler/src/beam_except.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_except.erl b/lib/compiler/src/beam_except.erl
index 09925b2872..28c89782c9 100644
--- a/lib/compiler/src/beam_except.erl
+++ b/lib/compiler/src/beam_except.erl
@@ -225,7 +225,11 @@ moves_from_stack(nil, I, Acc) ->
{reverse(Acc),I};
moves_from_stack({literal,[H|T]}, I, Acc) ->
Cons = {cons,tag_literal(H),tag_literal(T)},
- moves_from_stack(Cons, I, Acc).
+ moves_from_stack(Cons, I, Acc);
+moves_from_stack(_, _, _) ->
+ %% Not understood. Give up.
+ {[],-1}.
+
get_reg(R, Regs) ->
case Regs of