Re: A task independent of the freeze
Dan -- > Here's something for someone looking to do something interesting while the > code freeze is on. > > Write yourself a program that takes a .pasm file and, rather than spitting > out bytecode, spits out the bodies of the opcode functions with the > appropriate replacements done on the parameters. The output should be > suitable for stuffing into the guts of test_main.c in the place of the call > to the runops loop. My first cut is pretty sloppy, but it does generate this C file, which compiles, but I don't have the time to figure out how to get it all the stuff it needs to link to. If someones gets it running, I'd like to see how many Mops they get vs. regular. This is generated from t/test.pbc (not t/test.pasm). The code is a total hack job, but you are welcome to look at it (compile.pl and Parrot/OpFunc.pm). Enjoy, -- Gregor _ / perl -e 'srand(-2091643526); print chr rand 90 for (0..4)' \ Gregor N. Purdy [EMAIL PROTECTED] Focus Research, Inc.http://www.focusresearch.com/ 8080 Beckett Center Drive #203 513-860-3570 vox West Chester, OH 45069 513-860-3579 fax \_/ #include "parrot/parrot.h" #include int main(int argc, char **argv) { int i; struct Parrot_Interp *interpreter; init_world(); interpreter = make_interpreter(); /* time_i I1 */ PC_1: { /* time_i */ INT_REG(1) = time(NULL); goto PC_3; } /* set_i_ic I2, 0 */ PC_3: { /* set_i_ic */ INT_REG(2) = 0; goto PC_6; } /* set_i_ic I3, 1 */ PC_6: { /* set_i_ic */ INT_REG(3) = 1; goto PC_9; } /* set_i_ic I4, 1 */ PC_9: { /* set_i_ic */ INT_REG(4) = 1; goto PC_12; } /* set_s_sc S0, [String 1] */ PC_12: { /* set_s_sc */ STR_REG(0) = Parrot_string_constants[1]; goto PC_15; } /* print_s S0 */ PC_15: { /* print_s */ STRING *s = STR_REG(0); printf("%.*s",(int)string_length(s),(char *) s->bufstart); goto PC_17; } /* print_i I4 */ PC_17: { /* print_i */ printf("%li", INT_REG(4)); goto PC_19; } /* eq_i_ic I2, I4, 10 */ PC_19: { /* eq_i_ic */ if (INT_REG(2) == INT_REG(4)) { goto PC_29; } goto PC_23; } /* add_i I2, I2, I3 */ PC_23: { /* add_i */ INT_REG(2) = INT_REG(2) + INT_REG(3); goto PC_27; } /* branch_ic -8 */ PC_27: { /* branch_ic */ goto PC_19; goto PC_29; } /* time_i I5 */ PC_29: { /* time_i */ INT_REG(5) = time(NULL); goto PC_31; } /* set_s_sc S0, [String 2] */ PC_31: { /* set_s_sc */ STR_REG(0) = Parrot_string_constants[2]; goto PC_34; } /* print_s S0 */ PC_34: { /* print_s */ STRING *s = STR_REG(0); printf("%.*s",(int)string_length(s),(char *) s->bufstart); goto PC_36; } /* print_i I1 */ PC_36: { /* print_i */ printf("%li", INT_REG(1)); goto PC_38; } /* set_s_sc S0, [String 3] */ PC_38: { /* set_s_sc */ STR_REG(0) = Parrot_string_constants[3]; goto PC_41; } /* print_s S0 */ PC_41: { /* print_s */ STRING *s = STR_REG(0); printf("%.*s",(int)string_length(s),(char *) s->bufstart); goto PC_43; } /* print_i I5 */ PC_43: { /* print_i */ printf("%li", INT_REG(5)); goto PC_45; } /* set_s_sc S0, [String 4] */ PC_45: { /* set_s_sc */ STR_REG(0) = Parrot_string_constants[4]; goto PC_48; } /* print_s S0 */ PC_48: { /* print_s */ STRING *s = STR_REG(0); printf("%.*s",(int)string_length(s),(char *) s->bufstart); goto PC_50; } /* print_i I2 */ PC_50: { /* print_i */ printf("%li", INT_REG(2)); goto PC_52; } /* set_s_sc S0, [String 5] */ PC_52: { /* set_s_sc */ STR_REG(0) = Parrot_string_constants[5]; goto PC_55; } /* print_s S0 */ PC_55: { /* print_s */ STRING *s = STR_REG(0); printf("%.*s",(int)string_length(s),(char *) s->bufstart); goto PC_57; } /* sub_i I2, I5, I1 */ PC_57: { /* sub_i */ INT_REG(2) = INT_REG(5) - INT_REG(1); goto PC_61; } /* print_i I2 */ PC_61: { /* print_i */ printf("%li", INT_REG(2)); goto PC_63; } /* set_i_ic I1, 3 */ PC_63: { /* set_i_ic */ INT_REG(1) = 3; goto PC_66; } /* mul_i I4, I4, I1 */ PC_66: { /* mul_i */ INT_REG(4) = INT_REG(4) * INT_REG(1); goto PC_70; } /* iton_n_i N1, I4 */ PC_70: { /* iton_n_i */ NUM_REG(1) = INT_REG(4); goto PC_73; } /* iton_n_i N2, I2 */ PC_73: { /* iton_n_i */ NUM_REG(2) = INT_REG(2); goto PC_76; } /* set_s_sc S0, [String 6] */ PC_76: { /* set_s_sc */ STR_REG(0) = Parrot_string_constants[6]; goto PC_79; } /* print_s S0 */ PC_79: { /* print_s */ STRING *s = STR_REG(0); printf("%.*s",(int)string_length(s),(char *) s->bufstart); goto PC_81; } /* print_i I4 */ PC_81: { /* print_i */ printf("%li", INT_REG(4)); goto PC_83; } /* set_s_sc S0, [String 7] */ PC_83: { /* set_s_sc */ STR_REG(0) = Parrot_string_constants[7]; goto PC_86; } /* print_s S0 */ PC_86: { /* pri
Should try work on use?
In Configure.pl, one of the things I do is include Data::Dumper if it's there, and skip the part that needs it otherwise. Unfortunately, because of the compile-time nature of use, I can't do it. Thus, I have to use the following hack: my($DDOK)=eval { require Data::Dumper; import Data::Dumper; 1; } Ugly, no? What I propose to fix it is that, if I do something like this: $DDOK=1; try { use Data::Dumper; } catch { $DDOK=0; } and Data::Dumper doesn't load, the use statement be transmogrified: $DDOK=1; try { throw "Can't find Data/Dumper.pm in \@INC (\@INC contains: @INC)"; } catch { $DDOK=0; } However, the transmogrification only occurs if a use is in a try block; otherwise we get the same die-at-compile-time behavior. In other words, I want exceptions thrown at compile-time to be catchable at run-time by surrounding try blocks. Are there any barriers to this working? If so, what are they? --Brent Dax [EMAIL PROTECTED] They *will* pay for what they've done.
RE: A task independent of the freeze
Gregor N. Purdy: # Dan -- # # > Here's something for someone looking to do something # interesting while the # > code freeze is on. # > # > Write yourself a program that takes a .pasm file and, # rather than spitting # > out bytecode, spits out the bodies of the opcode functions with the # > appropriate replacements done on the parameters. The output # should be # > suitable for stuffing into the guts of test_main.c in the # place of the call # > to the runops loop. # # My first cut is pretty sloppy, but it does generate this C file, which # compiles, but I don't have the time to figure out how to get # it all the # stuff it needs to link to. If someones gets it running, I'd Parrot::Config may come in handy, especially @PConfig{qw(cc ccflags libs)}. # like to see # how many Mops they get vs. regular. # # This is generated from t/test.pbc (not t/test.pasm). # # The code is a total hack job, but you are welcome to look at it # (compile.pl and Parrot/OpFunc.pm). I modified my Makefile: --- ..\..\parrot-cvs\parrot\MakefileFri Sep 21 16:41:52 2001 +++ MakefileFri Sep 21 16:39:18 2001 @@ -15,7 +15,7 @@ CC = cl LD = link PERL = C:\Perl\bin\perl.exe -TEST_PROG = test_prog.exe +TEST_PROG = test.exe PDUMP = pdump.exe .c.o: @@ -29,12 +29,12 @@ $(CC) -shared $(C_LIBS) -o $@ $(O_FILES) $(TEST_PROG): test_main$(O) $(O_FILES) - $(CC) $(CFLAGS) -o $(TEST_PROG) $(O_FILES) test_main$(O) $(C_LIBS) + $(CC) $(CFLAGS) -o $(TEST_PROG) $(O_FILES) test$(O) $(C_LIBS) $(PDUMP): pdump$(O) $(O_FILES) $(CC) $(CFLAGS) -o $(PDUMP) $(O_FILES) pdump$(O) $(C_LIBS) -test_main$(O): $(H_FILES) +test$(O): $(H_FILES) test.c global_setup$(O): $(H_FILES) and it built, but gave me a GPF (from trying to read memory at 0x4) when I ran the resulting program. Make sure that you delete test$(O) before trying this--it's a remnant from the Configure process I never thought of. I'll patch Configure to delete it soon. --Brent Dax [EMAIL PROTECTED] They *will* pay for what they've done.
Re: A task independent of the freeze
All -- > My first cut is pretty sloppy, but it does generate this C file, which > compiles, but I don't have the time to figure out how to get it all the > stuff it needs to link to. If someones gets it running, I'd like to see > how many Mops they get vs. regular. BTW, I realized as I left the office that I hadn't dealt with inserting code at the beginning to copy the const_table from the pack file into the interpreter's string table. So, someone could either hard-code that into the C file, or muck with compiler.pl's const table printing code ("inherited" from disassembler.pl) to make it print out C code that will insert the strings. Let me know if you get it running... Regards, -- Gregor
RE: A task independent of the freeze
Brent -- > # My first cut is pretty sloppy, but it does generate this C file, which > # compiles, but I don't have the time to figure out how to get > # it all the > # stuff it needs to link to. If someones gets it running, I'd > > Parrot::Config may come in handy, especially @PConfig{qw(cc ccflags > libs)}. I've had to comment out PConfig-related code from assembler.pl and disassembler.pl lately, so I dont' think I want to muck with it until all that stuff is working. There are lots of things about this code that need improvement, since I created it by forking disassembler.pl (Simon has already pointed out some infelicities there, such as hard-coded pack templates) and process_opfunc.pl (Major hackage here; I figured out only enough about it to mutate it into something that seemed to do a decent job of grabbing sections of code into an op-mnemonic-keyed hash). > I modified my Makefile: > [munch] BTW, beware of targets that would be named 'test' on *nix, since *nix has a 'test' program that is likely to be in the path. > and it built, but gave me a GPF (from trying to read memory at 0x4) when > I ran the resulting program. Make sure that you delete test$(O) before > trying this--it's a remnant from the Configure process I never thought > of. I'll patch Configure to delete it soon. Chances are good that you were at least having trouble do to the string constants not being loaded into the interpreter (I pointed this problem out a few minutes ago in a related message). Perhaps getting those string-constant-loading statements in there as directed earlier would solve this problem (but no guarantees -- I wrote this code under a major time crunch, more to prove it was possible than anything else). Thanks for taking a look at it, and good luck if you work with it more... Regards, -- Gregor