summaryrefslogtreecommitdiff
path: root/bytecode.pl
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-09-06 14:04:33 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-09-06 14:04:33 +0000
commitde1254415ffeb03ba71a0802be6f212b10153304 (patch)
tree8ebd5287b407a8f18ca3ed35c80b8e55b8127493 /bytecode.pl
parentb6717e144d05264a3d0614dbad53f919e8a59efc (diff)
downloadperl-de1254415ffeb03ba71a0802be6f212b10153304.tar.gz
Remove perlcc and the byteloader
p4raw-id: //depot/perl@28790
Diffstat (limited to 'bytecode.pl')
-rw-r--r--bytecode.pl169
1 files changed, 2 insertions, 167 deletions
diff --git a/bytecode.pl b/bytecode.pl
index cbbdefae69..95b5b12322 100644
--- a/bytecode.pl
+++ b/bytecode.pl
@@ -39,7 +39,7 @@ EOT
my $perl_header;
($perl_header = $c_header) =~ s{[/ ]?\*/?}{#}g;
-safer_unlink "ext/ByteLoader/byterun.c", "ext/ByteLoader/byterun.h", "ext/B/B/Asmdata.pm";
+safer_unlink "ext/B/B/Asmdata.pm";
#
# Start with boilerplate for Asmdata.pm
@@ -66,79 +66,12 @@ print ASMDATA_PM <<"EOT";
# I get a hard-to-track-down stack underflow and segfault.
EOT
-#
-# Boilerplate for byterun.c
-#
-open(BYTERUN_C, ">ext/ByteLoader/byterun.c") or die "ext/ByteLoader/byterun.c: $!";
-binmode BYTERUN_C;
-print BYTERUN_C $c_header, <<'EOT';
-
-#define PERL_NO_GET_CONTEXT
-#include "EXTERN.h"
-#include "perl.h"
-#define NO_XSLOCKS
-#include "XSUB.h"
-
-#include "byterun.h"
-#include "bytecode.h"
-
-
-static const int optype_size[] = {
-EOT
-my $i = 0;
-for ($i = 0; $i < @optype - 1; $i++) {
- printf BYTERUN_C " sizeof(%s),\n", $optype[$i], $i;
-}
-printf BYTERUN_C " sizeof(%s)\n", $optype[$i], $i;
-
my $size = @specialsv;
-print BYTERUN_C <<"EOT";
-};
-
-void *
-bset_obj_store(pTHX_ struct byteloader_state *bstate, void *obj, I32 ix)
-{
- if (ix > bstate->bs_obj_list_fill) {
- Renew(bstate->bs_obj_list, ix + 32, void*);
- bstate->bs_obj_list_fill = ix + 31;
- }
- bstate->bs_obj_list[ix] = obj;
- return obj;
-}
-
-int
-byterun(pTHX_ register struct byteloader_state *bstate)
-{
- dVAR;
- register int insn;
- U32 ix;
- SV *specialsv_list[$size];
-
- BYTECODE_HEADER_CHECK; /* croak if incorrect platform */
- Newx(bstate->bs_obj_list, 32, void*); /* set op objlist */
- bstate->bs_obj_list_fill = 31;
- bstate->bs_obj_list[0] = NULL; /* first is always Null */
- bstate->bs_ix = 1;
-
-EOT
-
-for my $i ( 0 .. $#specialsv ) {
- print BYTERUN_C " specialsv_list[$i] = $specialsv[$i];\n";
-}
-
-print BYTERUN_C <<'EOT';
-
- while ((insn = BGET_FGETC()) != EOF) {
- switch (insn) {
-EOT
-
-
my (@insn_name, $insn_num, $insn, $lvalue, $argtype, $flags, $fundtype);
while (<DATA>) {
if (/^\s*#/) {
- print BYTERUN_C if /^\s*#\s*(?:if|endif|el)/;
next;
}
chop;
@@ -159,26 +92,6 @@ while (<DATA>) {
$fundtype = $alias_from{$argtype} || $argtype;
#
- # Add the case statement and code for the bytecode interpreter in byterun.c
- #
- printf BYTERUN_C "\t case INSN_%s:\t\t/* %d */\n\t {\n",
- uc($insn), $insn_num;
- my $optarg = $argtype eq "none" ? "" : ", arg";
- if ($optarg) {
- printf BYTERUN_C "\t\t$argtype arg;\n\t\tBGET_%s(arg);\n", $fundtype;
- }
- if ($flags =~ /x/) {
- print BYTERUN_C "\t\tBSET_$insn($lvalue$optarg);\n";
- } elsif ($flags =~ /s/) {
- # Store instructions store to bytecode_obj_list[arg]. "lvalue" field is rvalue.
- print BYTERUN_C "\t\tBSET_OBJ_STORE($lvalue$optarg);\n";
- }
- elsif ($optarg && $lvalue ne "none") {
- print BYTERUN_C "\t\t$lvalue = ${rvalcast}arg;\n";
- }
- print BYTERUN_C "\t\tbreak;\n\t }\n";
-
- #
# Add the initialiser line for %insn_data in Asmdata.pm
#
print ASMDATA_PM <<"EOT";
@@ -190,82 +103,6 @@ EOT
}
#
-# Finish off byterun.c
-#
-print BYTERUN_C <<'EOT';
- default:
- Perl_croak(aTHX_ "Illegal bytecode instruction %d\n", insn);
- /* NOTREACHED */
- }
- }
- return 0;
-}
-
-/* ex: set ro: */
-EOT
-
-#
-# Write the instruction and optype enum constants into byterun.h
-#
-open(BYTERUN_H, ">ext/ByteLoader/byterun.h") or die "ext/ByteLoader/byterun.h: $!";
-binmode BYTERUN_H;
-print BYTERUN_H $c_header, <<'EOT';
-struct byteloader_fdata {
- SV *datasv;
- int next_out;
- int idx;
-};
-
-struct byteloader_pv_state {
- char *pvx;
- XPV xpv;
-};
-
-struct byteloader_state {
- struct byteloader_fdata *bs_fdata;
- SV *bs_sv;
- void **bs_obj_list;
- int bs_obj_list_fill;
- int bs_ix;
- struct byteloader_pv_state bs_pv;
- int bs_iv_overflows;
-};
-
-int bl_getc(struct byteloader_fdata *);
-int bl_read(struct byteloader_fdata *, char *, size_t, size_t);
-extern int byterun(pTHX_ struct byteloader_state *);
-
-enum {
-EOT
-
-my $add_enum_value = 0;
-my $max_insn;
-for $i ( 0 .. $#insn_name ) {
- $insn = uc($insn_name[$i]);
- if (defined($insn)) {
- $max_insn = $i;
- if ($add_enum_value) {
- print BYTERUN_H " INSN_$insn = $i,\t\t\t/* $i */\n";
- $add_enum_value = 0;
- } else {
- print BYTERUN_H " INSN_$insn,\t\t\t/* $i */\n";
- }
- } else {
- $add_enum_value = 1;
- }
-}
-
-print BYTERUN_H " MAX_INSN = $max_insn\n};\n";
-
-print BYTERUN_H "\nenum {\n";
-for ($i = 0; $i < @optype - 1; $i++) {
- printf BYTERUN_H " OPt_%s,\t\t/* %d */\n", $optype[$i], $i;
-}
-printf BYTERUN_H " OPt_%s\t\t/* %d */\n};\n\n", $optype[$i], $i;
-
-print BYTERUN_H "/* ex: set ro: */\n";
-
-#
# Finish off insn_data and create array initialisers in Asmdata.pm
#
print ASMDATA_PM <<'EOT';
@@ -283,7 +120,7 @@ __END__
=head1 NAME
-B::Asmdata - Autogenerated data about Perl ops, used to generate bytecode
+B::Asmdata - Autogenerated data about Perl ops
=head1 SYNOPSIS
@@ -346,8 +183,6 @@ EOT
close ASMDATA_PM or die "Error closing ASMDATA_PM: $!";
-close BYTERUN_H or die "Error closing BYTERUN_H: $!";
-close BYTERUN_C or die "Error closing BYTERUN_C: $!";
__END__
# First set instruction ord("#") to read comment to end-of-line (sneaky)