cvsuser     04/11/24 09:43:15

  Modified:    build_tools ops2c.pl
               lib/Parrot/OpTrans CSwitch.pm
  Log:
  split switched core in pieces a 300
  
  Revision  Changes    Path
  1.80      +16 -51    parrot/build_tools/ops2c.pl
  
  Index: ops2c.pl
  ===================================================================
  RCS file: /cvs/public/parrot/build_tools/ops2c.pl,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- ops2c.pl  1 Nov 2004 11:52:52 -0000       1.79
  +++ ops2c.pl  24 Nov 2004 17:43:11 -0000      1.80
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: ops2c.pl,v 1.79 2004/11/01 11:52:52 leo Exp $
  +# $Id: ops2c.pl,v 1.80 2004/11/24 17:43:11 leo Exp $
   
   =head1 NAME
   
  @@ -303,13 +303,14 @@
       my $definition;
       my $comment = '';
       $prev_def = '';
  +    my $one_op = "";
       if ($suffix =~ /cg/) {
        $prev_def = $definition = "PC_$index:";
        $comment =  "/* ". $op->func_name($trans) ." */";
        push @cg_jump_table, "        &&PC_$index,\n";
       } elsif ($suffix =~ /switch/) {
        $comment =  "/* ". $op->func_name($trans) ." */";
  -     push @op_funcs, <<END_C;
  +     $one_op = <<END_C;
        case $index:    $comment
   END_C
       }
  @@ -324,57 +325,15 @@
       $source =~ s/\bop_lib\b/${bs}op_lib/;
       $source =~ s/\bops_addr\b/${bs}ops_addr/g;
   
  -#    print HEADER "$prototype;\n";
  -#
  -#   for predereferenced code all variants of one op with or without
  -#   "c" suffix generate the same function body
  -#
  -#   e.g.
  -#
  -#   set i,i,i
  -#   set i,ic,i
  -#   set i,i,ic
  -#   set i,ic,ic
  -#
  -#   have all the same function body, and thus we generate only the
  -#   first one and change the op_func_table accordingly
  -#
  -#   Err, above was true when absolute addresses were used, now
  -#   with frame-pointer relative addressing, this doesn't work
  -#   any more. Anyway, the compare of prev_source and source makes
  -#   sure that correct code is produced.
  -
  -    if ($prev_source && $prev_source eq $source) {
  -     push @op_func_table, sprintf("  %-50s /* %6ld */\n",
  -         "$prev_func_name,", $index);
  -     push @op_funcs, <<"EOF";
  -/*$prev_def   $func_name => $prev_func_name */
  -EOF
  -     # pop off  label and duplicate previous
  -     if ($suffix =~ /cg/) {
  -         pop @cg_jump_table;
  -         push @cg_jump_table, $cg_jump_table[-1];
  -     }
  -     if ($suffix =~ /switch/) {
  -         my $bdy = pop @op_funcs;
  -         my $cas = pop @op_funcs;
  -         $bdy = pop @op_funcs;
  -         push @op_funcs, $cas;
  -         push @op_funcs, $bdy;
  -     }
  +    if ($suffix =~ /switch/) {
  +     $one_op .= "\t{\n$source}\n\n";
       }
       else {
  -     if ($suffix =~ /switch/) {
  -         push @op_funcs,"\t{\n$source}\n\n";
  -     }
  -     else {
  -         push @op_func_table, sprintf("  %-50s /* %6ld */\n",
  -             "$func_name,", $index);
  -         push @op_funcs,      "$definition $comment {\n$source}\n\n";
  -     }
  -     $prev_source = $source;
  -     $prev_func_name = $func_name;
  +     push @op_func_table, sprintf("  %-50s /* %6ld */\n",
  +         "$func_name,", $index);
  +     $one_op .= "$definition $comment {\n$source}\n\n";
       }
  +    push @op_funcs, $one_op;
       $index++;
   }
   
  @@ -424,7 +383,13 @@
   #
   # Finish the SOURCE file's array initializer:
   #
  -print SOURCE @op_funcs;
  +my $CORE_SPLIT = 300;
  +for (my $i = 0; $i < @op_funcs; $i++) {
  +    if ($i && $i % $CORE_SPLIT == 0 && $trans->can("run_core_split")) {
  +     print SOURCE $trans->run_core_split($base);
  +    }
  +    print SOURCE $op_funcs[$i];
  +}
   
   if ($trans->can("run_core_finish")) {
       print SOURCE $trans->run_core_finish($base);
  
  
  
  1.15      +25 -1     parrot/lib/Parrot/OpTrans/CSwitch.pm
  
  Index: CSwitch.pm
  ===================================================================
  RCS file: /cvs/public/parrot/lib/Parrot/OpTrans/CSwitch.pm,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- CSwitch.pm        2 Nov 2004 11:46:24 -0000       1.14
  +++ CSwitch.pm        24 Nov 2004 17:43:15 -0000      1.15
  @@ -1,5 +1,5 @@
   # Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -# $Id: CSwitch.pm,v 1.14 2004/11/02 11:46:24 leo Exp $
  +# $Id: CSwitch.pm,v 1.15 2004/11/24 17:43:15 leo Exp $
   
   =head1 NAME
   
  @@ -195,6 +195,23 @@
   END_C
   }
   
  +=item C<run_core_split($base)>
  +
  +If defined return code to split e.g. a switch.
  +
  +=cut
  +
  +sub run_core_split
  +{
  +    my ($self) = @_;
  +    $self->{split_count}++;
  +
  +    return <<END_C;
  +    default:
  +    switch (*cur_opcode) {
  +END_C
  +}
  +
   =item C<run_core_finish($base)>
   
   Returns the C code following the run core function.
  @@ -214,6 +231,13 @@
            internal_exception(1, "illegal opcode\\n");
            break;
        } /* switch */
  +END_C
  +    for (my $i = 0; $i < $self->{split_count}; $i++) {
  +     $c .= <<END_C;
  +    } /* switch $i */
  +END_C
  +    }
  +     $c .= <<END_C;
       } while (1);
       return NULL;
   }
  
  
  

Reply via email to