mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-31 19:57:06 +01:00
emit param-passing code as functions rather than byte-by-byte
assignment for a 15-20% reduction in code size (and likely some slight slowdown.)
This commit is contained in:
parent
fe10d97986
commit
03377593fa
1 changed files with 15 additions and 9 deletions
|
@ -299,7 +299,7 @@ sub push_param($$$) {
|
||||||
|
|
||||||
my $size = $$info{'size'};
|
my $size = $$info{'size'};
|
||||||
|
|
||||||
$result .= " ADD_TO_STACK$size($name, $$offset),\n";
|
$result .= " ADD_TO_STACK$size(stack, $name, $$offset);\n";
|
||||||
if ( $size == 1 ) {
|
if ( $size == 1 ) {
|
||||||
$$offset += 2;
|
$$offset += 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -328,6 +328,11 @@ sub swap_param($$$) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub nameToBytes($) {
|
||||||
|
my ( $nam ) = @_;
|
||||||
|
return "\"'" . join( "','", split( //, $nam ) ) . "'\"";
|
||||||
|
}
|
||||||
|
|
||||||
sub print_body($$$$$) {
|
sub print_body($$$$$) {
|
||||||
my ( $name, $returnType, $params, $trapSel, $trapType ) = @_;
|
my ( $name, $returnType, $params, $trapSel, $trapType ) = @_;
|
||||||
my $result;
|
my $result;
|
||||||
|
@ -345,14 +350,17 @@ sub print_body($$$$$) {
|
||||||
}
|
}
|
||||||
$result .= " {\n";
|
$result .= " {\n";
|
||||||
$result .= " PNOState* sp = GET_CALLBACK_STATE();\n";
|
$result .= " PNOState* sp = GET_CALLBACK_STATE();\n";
|
||||||
$result .= " unsigned char stack[] = {\n";
|
|
||||||
|
|
||||||
|
my $parmsResult;
|
||||||
foreach my $param ( @$params ) {
|
foreach my $param ( @$params ) {
|
||||||
$result .= push_param( $$param{"type"},
|
$parmsResult .= push_param( $$param{"type"},
|
||||||
$$param{"name"},
|
$$param{"name"},
|
||||||
\$offset );
|
\$offset );
|
||||||
}
|
}
|
||||||
$result .= " 0 };\n";
|
$result .= " STACK_START(unsigned char, stack, $offset);\n"
|
||||||
|
. $parmsResult
|
||||||
|
#$result .= " unsigned char stack[] = {\n";
|
||||||
|
. " STACK_END(stack);\n";
|
||||||
|
|
||||||
my $info = $typeInfo{$returnType};
|
my $info = $typeInfo{$returnType};
|
||||||
if ( $info->{'a0'} ) {
|
if ( $info->{'a0'} ) {
|
||||||
|
@ -382,6 +390,7 @@ sub print_body($$$$$) {
|
||||||
if ( $notVoid ) {
|
if ( $notVoid ) {
|
||||||
$result .= " return result;\n";
|
$result .= " return result;\n";
|
||||||
}
|
}
|
||||||
|
$result .= " EMIT_NAME(" . nameToBytes($name) . ");\n";
|
||||||
$result .= "} /* $name */\n";
|
$result .= "} /* $name */\n";
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -475,9 +484,6 @@ foreach my $key (keys %funcInfo) {
|
||||||
print DOT $funcstr;
|
print DOT $funcstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
print DOT "#include \"pace_man.c\"\n";
|
|
||||||
|
|
||||||
|
|
||||||
close DOT;
|
close DOT;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue