diff options
author | Björn Gustavsson <[email protected]> | 2017-09-08 09:55:53 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-09-08 09:55:53 +0200 |
commit | aebaa8a4e0670217a2f91d3456119824ee2c8500 (patch) | |
tree | e648c1881ffe80693effa03ca1561fd9ee157084 /erts/emulator/utils/beam_makeops | |
parent | c91cdb3d5805f067b7ef306620f30ed9e1a6dc50 (diff) | |
parent | b30e726197fd3a94079c955879e5db745eda5ecd (diff) | |
download | otp-aebaa8a4e0670217a2f91d3456119824ee2c8500.tar.gz otp-aebaa8a4e0670217a2f91d3456119824ee2c8500.tar.bz2 otp-aebaa8a4e0670217a2f91d3456119824ee2c8500.zip |
Merge branch 'bjorn/erts/improve-beam-ops'
* bjorn/erts/improve-beam-ops:
Don't allow macros to assign to hard-coded variables
Annotate try_case_end as cold
beam_emu.c: Mark initialization code as unlikely
Try to avoid generating unecessary do/while wrappers
Eliminate unecessary instruction macro i_move_call_only()
Diffstat (limited to 'erts/emulator/utils/beam_makeops')
-rwxr-xr-x | erts/emulator/utils/beam_makeops | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/erts/emulator/utils/beam_makeops b/erts/emulator/utils/beam_makeops index bcc92472d4..38754e67a1 100755 --- a/erts/emulator/utils/beam_makeops +++ b/erts/emulator/utils/beam_makeops @@ -1451,7 +1451,32 @@ sub expand_macro { warn $@; die "... from the body of $name at $where\n"; } - ("do {\n$body\n} while (0)",$rest); + $body = "do {\n$body\n} while (0)" + if needs_do_wrapper($body); + ($body,$rest); +} + +# Conservative heuristic to determine whether a do { ... } while(0) +# wrapper is needed. +sub needs_do_wrapper { + local $_ = shift; + + s@^//[|][^\n]*\n@@; + s@^\s*@@s; + s@^/[*].*[*]/\s*@@s; + return 1 if /^(Eterm|Uint|Sint|int|unsigned)/; # Definitely needed. + return 0 if /^do/; + return 0 if /^SET_I/; + return 0 if /^SET_CP/; + return 0 if /^ERTS_NO_FPE_CHECK_INIT/; + return 0 if /^ASSERT/; + return 0 if /^DTRACE/; + return 0 if /^[A-Za-z_]*\s*=/; + return 0 if /^c_p->/; + return 0 if /^[A-Z_]*SWAPOUT/; + return 0 if /^if\s*[(]/; + return 0 if /^goto\b/; + return 1; # Not sure, say that it is needed. } sub do_pack { |