JavaScriptCore/create_jit_stubs
changeset 0 4f2f89ce4247
child 2 303757a437d3
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 #! /usr/bin/perl -w
       
     2 #
       
     3 # Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
       
     4 # Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
       
     5 #
       
     6 # This library is free software; you can redistribute it and/or
       
     7 # modify it under the terms of the GNU Library General Public
       
     8 # License as published by the Free Software Foundation; either
       
     9 # version 2 of the License, or (at your option) any later version.
       
    10 #
       
    11 # This library is distributed in the hope that it will be useful,
       
    12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    14 # Library General Public License for more details.
       
    15 #
       
    16 # You should have received a copy of the GNU Library General Public License
       
    17 # along with this library; see the file COPYING.LIB.  If not, write to
       
    18 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    19 # Boston, MA 02110-1301, USA.
       
    20 
       
    21 use strict;
       
    22 use File::Basename;
       
    23 use Getopt::Long;
       
    24 
       
    25 my $usage = basename($0) . " --prefix prefix [--offset offset] file";
       
    26 
       
    27 my $rtype_template = quotemeta("#rtype#");
       
    28 my $offset_template = quotemeta("#offset#");
       
    29 my $op_template = quotemeta("#op#");
       
    30 
       
    31 my $prefix;
       
    32 my $offset = 32;
       
    33 my $file;
       
    34 
       
    35 my $getOptionsResult = GetOptions(
       
    36     'prefix=s' => \$prefix,
       
    37     'offset=i' => \$offset
       
    38 );
       
    39 
       
    40 $file = $ENV{"WEBKITDIR"} . $ARGV[0];
       
    41 
       
    42 die "$usage\n" unless ($prefix and $file);
       
    43 
       
    44 my $stub_template = "";
       
    45 my $output_end = "";
       
    46 my $stub = "";
       
    47 
       
    48 my $rtype = "";
       
    49 my $op = "";
       
    50 
       
    51 print STDERR "Creating JIT stubs for $file \n";
       
    52 open(IN, $file) or die "No such file $file";
       
    53 
       
    54 while ( $_ = <IN> ) {
       
    55     if ( /^$prefix\_BEGIN\((.*)\)/ ) {
       
    56         $stub = $1;
       
    57         $stub =~ s/$offset_template/$offset/g;
       
    58         print $stub . "\n";
       
    59     }
       
    60     if ( /^$prefix\((.*)\)/ ) {
       
    61         $stub_template .= $1 . "\n";
       
    62     }
       
    63     if ( /^$prefix\_END\((.*)\)/ ) {
       
    64         $output_end .= $1 . "\n";
       
    65     }
       
    66     if ( /^DEFINE_STUB_FUNCTION\((.*), (.*)\)/ ) {
       
    67         $stub = $stub_template;
       
    68         $rtype = quotemeta($1);
       
    69         $op = quotemeta($2);
       
    70         $stub =~ s/$offset_template/$offset/g;
       
    71         $stub =~ s/$rtype_template/$rtype/g;
       
    72         $stub =~ s/$op_template/$op/g;
       
    73         $stub =~ s/\\\*/\*/g;
       
    74         print $stub;
       
    75     }
       
    76 }
       
    77 
       
    78 print $output_end;
       
    79 
       
    80 close(IN);