1 #!/usr/local/bin/perl -w
3 # Create link and execute definitions for jumps2 dispatch method.
4 # Copyright (c) 1998 New Generation Software (NGS) Oy
6 # Author: Markku Rossi <mtr@ngs.fi>
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Library General Public
12 # License as published by the Free Software Foundation; either
13 # version 2 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Library General Public License for more details.
20 # You should have received a copy of the GNU Library General Public
21 # License along with this library; if not, write to the Free
22 # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
33 $target = "c1jumps.h";
34 open(CFP
, ">$target") || die "couldn't create `$target': $!\n";
36 $target = "c2jumps.h";
37 open(CFP2
, ">$target") || die "couldn't create `$target': $!\n";
39 $target = "./ejumps.h";
40 open(EFP
, ">$target") || die "couldn't create `$target': $!\n";
43 if (/operand\s+([a-zA-Z_][a-zA-Z0-9_]*)\s+([\S]+)\s+\{(.*)/) {
49 if ($flags =~ /symbol/) {
53 if ($flags =~ /jump/) {
58 printf CFP
("#line %d \"%s\"\n", $. - 1, $ARGV);
61 # Compilation phase 1.
63 print CFP
"/* operand $operand ($opcount) */\n";
64 print CFP
"case $opcount:\n";
65 print CFP
" SAVE_OP (&&op_$operand);\n";
67 if ($operand eq "const") {
68 # Patch const offsets.
69 printf CFP
" JS_BC_READ_INT32 (cp, i);\n";
70 printf CFP
" i += consts_offset;\n";
71 printf CFP
" SAVE_INT32 (i);\n";
74 printf CFP
" JS_BC_READ_INT32 (cp, i);\n";
75 printf CFP
" i += consts_offset;\n";
76 printf CFP
" i = vm->consts[i].u.vsymbol;\n";
77 printf CFP
" SAVE_INT32 (i);\n";
79 # Handle standard arguments.
81 } elsif ($args =~ /1/) {
82 print CFP
" JS_BC_READ_INT8 (cp, i);\n";
83 print CFP
" SAVE_INT8 (i);\n";
84 } elsif ($args =~ /2/) {
85 print CFP
" JS_BC_READ_INT16 (cp, i);\n";
86 print CFP
" SAVE_INT16 (i);\n";
87 } elsif ($args =~ /4/) {
88 print CFP
" JS_BC_READ_INT32 (cp, i);\n";
89 print CFP
" SAVE_INT32 (i);\n";
91 die("$ARGV:$.: illegal argument: $args\n");
95 print CFP
" cp += $args;\n";
96 print CFP
" break;\n\n";
102 # Compilation phase 2.
105 printf CFP2
"#line %d \"%s\"\n", $. - 1, $ARGV;
107 print CFP2
"/* operand $operand ($opcount) */\n";
108 print CFP2
"case $opcount:\n";
109 print CFP2
" cpos++;\n";
111 print CFP2
" i = ARG_INT32 ();\n";
113 print CFP2
" printf(\"%s: delta=%d, cp=%d\\n\", \"$operand\", i, cp - code_start - 1);\n";
115 print CFP2
" i = reloc[cp - code_start + 4 + i] - &f->code[cpos + 1];\n";
117 print CFP2
" printf (\"%s: newdelta=%d\\n\", \"$operand\", i);\n";
119 print CFP2
" ARG_INT32 () = i;\n";
122 print CFP2
" cp += $args;\n";
123 print CFP2
" cpos++;\n";
125 print CFP2
" break;\n\n";
132 printf EFP
"#line %d \"%s\"\n", $. - 1, $ARGV;
134 print EFP
"/* operand $operand ($opcount) */\n";
135 print EFP
"op_$operand:\n";
136 print EFP
" OPERAND ($opcount);\n";
139 print EFP
"printf (\"$operand\\n\");\n";
144 print EFP
" NEXT ();\n";