aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-08-11 10:39:01 +0200
committerBjörn Gustavsson <[email protected]>2011-10-11 11:46:35 +0200
commit39c0668121ff347877090e3ed237214f873c3e55 (patch)
tree95362d93a7d16e937c7b1fd7a826849e1029cfbc /erts
parentc75c84657c1b65c5df24e3c9316a25cb67803873 (diff)
downloadotp-39c0668121ff347877090e3ed237214f873c3e55.tar.gz
otp-39c0668121ff347877090e3ed237214f873c3e55.tar.bz2
otp-39c0668121ff347877090e3ed237214f873c3e55.zip
Share code for call of predicate and transformation functions
Diffstat (limited to 'erts')
-rwxr-xr-xerts/emulator/utils/beam_makeops32
1 files changed, 22 insertions, 10 deletions
diff --git a/erts/emulator/utils/beam_makeops b/erts/emulator/utils/beam_makeops
index 367f089401..fa3f3ed5e3 100755
--- a/erts/emulator/utils/beam_makeops
+++ b/erts/emulator/utils/beam_makeops
@@ -105,7 +105,9 @@ my %match_engine_ops; # All opcodes for the match engine.
my %gen_transform_offset;
my @transformations;
my @call_table;
+my %call_table;
my @pred_table;
+my %pred_table;
# Operand types for generic instructions.
@@ -1562,9 +1564,8 @@ sub tr_gen_from {
push(@args, "var+$var{$var}");
}
}
- splice(@code, $index, 1, &make_op("$name()",
- 'pred', scalar(@pred_table)));
- push(@pred_table, [$name, @args]);
+ my $pi = tr_next_index(\@pred_table, \%pred_table, $name, @args);
+ splice(@code, $index, 1, make_op("$name()", 'pred', $pi));
}
$te_max_vars = $var_num
@@ -1607,8 +1608,9 @@ sub tr_gen_to {
}
}
pop(@code); # Get rid of 'commit' instruction
- push(@code, make_op("$name()", 'call_end', scalar(@call_table)));
- push(@call_table, [$name, @args]);
+ my $index = tr_next_index(\@call_table, \%call_table,
+ $name, @args);
+ push(@code, make_op("$name()", 'call_end', $index));
last;
}
@@ -1700,16 +1702,26 @@ sub get_comment {
$ref->[2];
}
+sub tr_next_index {
+ my($lref,$href,$name,@args) = @_;
+ my $code = "RVAL = $name(" . join(', ', 'st', @args) . "); break;\n";
+ my $index;
+
+ if (defined $$href{$code}) {
+ $index = $$href{$code};
+ } else {
+ $index = scalar(@$lref);
+ push(@$lref, $code);
+ $$href{$code} = $index;
+ }
+ $index;
+}
sub tr_gen_call {
my(@call_table) = @_;
my($i);
- print "\n";
for ($i = 0; $i < @call_table; $i++) {
- my $ref = $call_table[$i];
- my($name, @args) = @$ref;
- print "case $i: RVAL = $name(", join(', ', 'st', @args), "); break;\n";
+ print "case $i: $call_table[$i]";
}
- print "\n";
}