Old Warnock's Dilemma for 'make quicktest'

2002-03-21 Thread Michel J Lambert

Heya,

I submitted a bunch of patches awhile back, all of which were committed
except for one, which dealt with adding a 'make quicktest'. Information on
it can be found here:

http:[EMAIL PROTECTED]/msg07834.html

It did provide for a significant speedup, from 170 seconds using 'make
test' to 24 seconds using 'make quicktest' on this old version of parrot.
Is there any interest in me bringing this patch up to date?

Thanks,
Mike Lambert





licensing fun

2002-03-21 Thread Josh Wilmes


Thought this was interesting reading.. this is what's going on over in
mozilla-land with regard to licensing.

  http://www.mozilla.org/MPL/relicensing-faq.html

--Josh

-- 
Josh Wilmes  ([EMAIL PROTECTED]) | http://www.hitchhiker.org




Re: licensing fun

2002-03-21 Thread Simon Cozens

Josh Wilmes:
> Thought this was interesting reading.. 

This too: http://tmn.dyndns.org/~dcormier/tilly.html
If you're contributing code, please make sure it's yours to contribute.

-- 
I wish my keyboard had a SMITE key
-- J-P Stacey



Cola update

2002-03-21 Thread Melvin Smith

Well you can now write neato string code with Parrot with standard
array notation. I mapped it onto the substr w/replace op.

// copy a string
int i = 0;
while(str[i] != "")
newstr[i] = str[i++];

-Melvin




Re: Cola update

2002-03-21 Thread Dan Sugalski

At 5:15 AM -0500 3/21/02, Melvin Smith wrote:
>Well you can now write neato string code with Parrot with standard
>array notation. I mapped it onto the substr w/replace op.
>
>// copy a string
>int i = 0;
>while(str[i] != "")
>newstr[i] = str[i++];

Shares of Atari Basic... Cool. ;)
-- 
 Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
   teddy bears get drunk



Re: Old Warnock's Dilemma for 'make quicktest'

2002-03-21 Thread Dan Sugalski

At 10:37 PM -0500 3/20/02, Michel J Lambert wrote:
>Heya,
>
>I submitted a bunch of patches awhile back, all of which were committed
>except for one, which dealt with adding a 'make quicktest'. Information on
>it can be found here:
>
>http:[EMAIL PROTECTED]/msg07834.html
>
>It did provide for a significant speedup, from 170 seconds using 'make
>test' to 24 seconds using 'make quicktest' on this old version of parrot.
>Is there any interest in me bringing this patch up to date?

Yes, please.

-- 
 Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
   teddy bears get drunk



Some updates

2002-03-21 Thread Dan Sugalski

Folks,

I've added or enabled the following ops:

clone Sx, sy
savec Sx
set Ix, sy
set Nx, sy

which clone the string in Y and put it in X, push a clone of string 
register X, turn the string in Y into an integer in X, and turn the 
string in Y into a float in X, respectively.

We don't yet have:

set Sx, iy
set Sx, ny

to to integer or number to string conversions yet. Anyone fancy a shot at it?
-- 
 Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
   teddy bears get drunk



MSVC Warnings

2002-03-21 Thread Michel J Lambert


We take in const params, and set them into non-const members of STRING:
string.c(51) : warning C4090: '=' : different 'const' qualifiers
string.c(55) : warning C4090: '=' : different 'const' qualifiers

Due to MAKE_KEY in set_keyed setting keys[0] on an uninitialized pointer.
But I hear this isn't supposed to work anyway. The patch below comments
the code out.
c:\p\parrot\core.ops(574) : warning C4700: local variable 'src_key' used
without having been initialized
c:\p\parrot\core.ops(575) : warning C4700: local variable 'dest_key' used
without having been initialized

IntQueue can miscalculate the length:
c:\p\parrot\classes\intqueue.c(84) : warning C4700: local variable
'length' used without having been initialized

Patch to remove MAKE_KEY and IntQueue warnings is below.

Mike Lambert



Index: core.ops
===
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.111
diff -u -r1.111 core.ops
--- core.ops21 Mar 2002 22:01:50 -  1.111
+++ core.ops21 Mar 2002 22:30:03 -
@@ -567,14 +567,14 @@
 =cut

 inline op set_keyed (out PMC, in PMC, in PMC, in PMC)  {
-KEY_PAIR src_key_p, dest_key_p;
-KEY src_key, dest_key;
+//KEY_PAIR src_key_p, dest_key_p;
+//KEY src_key, dest_key;

-MAKE_KEY(src_key, src_key_p, $2, enum_key_pmc, pmc_val);
-MAKE_KEY(dest_key, dest_key_p, $4, enum_key_pmc, pmc_val);
+//MAKE_KEY(src_key, src_key_p, $2, enum_key_pmc, pmc_val);
+//MAKE_KEY(dest_key, dest_key_p, $4, enum_key_pmc, pmc_val);

-$1->vtable->set_pmc_keyed(interpreter,
-$1, $2 ? &src_key : NULL, $3, $4 ? &dest_key : NULL);
+//$1->vtable->set_pmc_keyed(interpreter,
+//$1, $2 ? &src_key : NULL, $3, $4 ? &dest_key :
NULL);
 goto NEXT();
 }

Index: classes/intqueue.pmc
===
RCS file: /cvs/public/parrot/classes/intqueue.pmc,v
retrieving revision 1.6
diff -u -r1.6 intqueue.pmc
--- classes/intqueue.pmc10 Mar 2002 21:18:13 -  1.6
+++ classes/intqueue.pmc21 Mar 2002 22:30:04 -
@@ -68,7 +68,7 @@
 }

 static INTVAL queue_length ( CONTAINER* container ) {
-  INTVAL length;
+  INTVAL length = 0;
   if(container->head != NULL) {
 BUCKET* head = container->head;
 while(head != NULL) {





Re: MSVC Warnings

2002-03-21 Thread Simon Glover



On Thu, 21 Mar 2002, Michel J Lambert wrote:

> +//KEY_PAIR src_key_p, dest_key_p;
> +//KEY src_key, dest_key;

 [etc.]

 These need to be C-style comments; not every compiler will accept the
 C++ style ones.

 Simon





Re: Cola update

2002-03-21 Thread Melvin Smith

   
 
  Dan Sugalski 
 
  <[EMAIL PROTECTED]>  To:   Melvin Smith 
<[EMAIL PROTECTED]>,  
[EMAIL PROTECTED]   
 
  03/21/2002 11:51 cc: 
 
  AM   Subject:  Re: Cola update   
 
   
 
   
 
   
 




>At 5:15 AM -0500 3/21/02, Melvin Smith wrote:
>>Well you can now write neato string code with Parrot with standard
>>array notation. I mapped it onto the substr w/replace op.
>>
>>// copy a string
>>int i = 0;
>>while(str[i] != "")
>>newstr[i] = str[i++];
>
>Shares of Atari Basic... Cool. ;)
>--
> Dan

Ahhh, those simpler days

Hmm you have just given me an evil idea...

-Melvin Smith

IBM :: Atlanta Innovation Center
[EMAIL PROTECTED] :: 770-835-6984




RE: Some updates

2002-03-21 Thread Brent Dax

Dan Sugalski:
# I've added or enabled the following ops:
#
# clone Sx, sy
# savec Sx
# set Ix, sy
# set Nx, sy
#
# which clone the string in Y and put it in X, push a clone of string
# register X, turn the string in Y into an integer in X, and turn the
# string in Y into a float in X, respectively.
#
# We don't yet have:
#
# set Sx, iy
# set Sx, ny
#
# to to integer or number to string conversions yet. Anyone
# fancy a shot at it?

This should be pretty easy--Parrot_sprintf_c should handle it nicely.
Unfortunately, I'm too busy to do it myself.  :^(

--Brent Dax <[EMAIL PROTECTED]>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

#define private public
--Spotted in a C++ program just before a #include




Re: MSVC Warnings

2002-03-21 Thread Michel J Lambert

Ooops. I originally did the /**/, but thought that was way too easy to be
C code, and so changed them to //. :)

Below is a proper patch.

Mike Lambert

Index: core.ops
===
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.111
diff -u -r1.111 core.ops
--- core.ops21 Mar 2002 22:01:50 -  1.111
+++ core.ops21 Mar 2002 22:48:58 -
@@ -567,6 +567,7 @@
 =cut

 inline op set_keyed (out PMC, in PMC, in PMC, in PMC)  {
+/*
 KEY_PAIR src_key_p, dest_key_p;
 KEY src_key, dest_key;

@@ -575,6 +576,7 @@

 $1->vtable->set_pmc_keyed(interpreter,
 $1, $2 ? &src_key : NULL, $3, $4 ? &dest_key : NULL);
+*/
 goto NEXT();
 }

Index: classes/intqueue.pmc
===
RCS file: /cvs/public/parrot/classes/intqueue.pmc,v
retrieving revision 1.6
diff -u -r1.6 intqueue.pmc
--- classes/intqueue.pmc10 Mar 2002 21:18:13 -  1.6
+++ classes/intqueue.pmc21 Mar 2002 22:48:59 -
@@ -68,7 +68,7 @@
 }

 static INTVAL queue_length ( CONTAINER* container ) {
-  INTVAL length;
+  INTVAL length = 0;
   if(container->head != NULL) {
 BUCKET* head = container->head;
 while(head != NULL) {





Re: Old Warnock's Dilemma for 'make quicktest'

2002-03-21 Thread Michel J Lambert

Times are:
make quicktest, after caching output: 23 seconds
make test: 175 seconds

make quicktest could screw up if:
- you ctrl-c it, or make test (although I haven't had problems with that
yet) during the compilation process at just the right time
- you do anything to invalidate existing .pbc files, such as rearranging
ops. not sure what else could trigger this.

I still find it extremely useful, in spite of these limitations on its
usage. The patch is included below.

Mike Lambert



Index: Makefile.in
===
RCS file: /cvs/public/parrot/Makefile.in,v
retrieving revision 1.140
diff -u -r1.140 Makefile.in
--- Makefile.in 16 Mar 2002 14:38:25 -  1.140
+++ Makefile.in 21 Mar 2002 22:48:56 -
@@ -403,6 +403,11 @@
 .test_dummy_j:
$(PERL) t/harness -j

+quicktest: $(TEST_PROG) assemble.pl .quicktest_dummy
+
+.quicktest_dummy:
+   $(PERL) t/harness quick
+
 mopstest: $(TEST_PROG) examples/assembly/mops.pbc
$(TEST_PROG) examples/assembly/mops.pbc

Index: lib/Parrot/Test.pm
===
RCS file: /cvs/public/parrot/lib/Parrot/Test.pm,v
retrieving revision 1.18
diff -u -r1.18 Test.pm
--- lib/Parrot/Test.pm  4 Mar 2002 02:32:54 -   1.18
+++ lib/Parrot/Test.pm  21 Mar 2002 22:49:01 -
@@ -64,12 +64,27 @@
   my $t = $0; $t =~ s/\.t$/$count\.$_/; $t
 } ( qw(pasm pbc out) );

-open ASSEMBLY, "> $as_f" or die "Unable to open '$as_f'";
-binmode ASSEMBLY;
-print ASSEMBLY $assembly;
-close ASSEMBLY;
+my $can_skip_compile = $ENV{PARROT_QUICKTEST};
+if ($can_skip_compile)
+{
+  open INASSEMBLY, "$as_f" or $can_skip_compile = 0;
+  if ($can_skip_compile) {
+local $/ = undef;
+my $inassembly = ;
+close INASSEMBLY;
+$can_skip_compile = 0 if ($assembly ne $inassembly);
+$can_skip_compile = 0 if (not -e $by_f);
+  }
+}

-_run_command( "$PConfig{perl} assemble.pl $as_f --output $by_f" );
+if (!$can_skip_compile) {
+  open ASSEMBLY, "> $as_f" or die "Unable to open '$as_f'";
+  binmode ASSEMBLY;
+  print ASSEMBLY $assembly;
+  close ASSEMBLY;
+
+  _run_command( "$PConfig{perl} assemble.pl $as_f --output $by_f" );
+}
 $TEST_PROG_ARGS = "" unless defined $TEST_PROG_ARGS;
 _run_command( "./$PConfig{test_prog} ${TEST_PROG_ARGS} $by_f", 'STDOUT' => 
$out_f, 'STDERR' => $out_f);

@@ -86,9 +101,7 @@
 my $pass = $Builder->$meth( $prog_output, $output, $desc );

 unless($ENV{POSTMORTEM}) {
-  foreach my $i ( $as_f, $by_f, $out_f ) {
-unlink $i;
-  }
+  unlink $out_f;
 }

 return $pass;
Index: t/harness
===
RCS file: /cvs/public/parrot/t/harness,v
retrieving revision 1.9
diff -u -r1.9 harness
--- t/harness   31 Jan 2002 19:03:34 -  1.9
+++ t/harness   21 Mar 2002 22:49:01 -
@@ -14,6 +14,9 @@
 getopts('jP', \%opts);
 $ENV{TEST_PROG_ARGS} = join(' ', map { "-$_" } keys %opts );

+$ENV{PARROT_QUICKTEST} = grep $_ eq 'quick', @ARGV;
+@ARGV = grep $_ ne 'quick', @ARGV;
+
 # Pass in a list of tests to run on the command line, else run all the tests.
 my @tests = @ARGV ? @ARGV : map { glob( "t/$_/*.t" ) } ( qw(op pmc) );
 runtests(@tests);






Re: MSVC Warnings

2002-03-21 Thread Josh Wilmes


I've applied the classes/intqueue.pmc patch.  The other needs adjustment.  
FWIW, your change doesn't cure the errors on TCC:

"string.c", line 51: Error:
  [ISO 6.3.16.1]: Conversion casts away 'const'-ness.
  [ISO 6.3.16]: Can't perform this conversion by assignment.

"string.c", line 55: Error:
  [ISO 6.3.16.1]: Conversion casts away 'const'-ness.
  [ISO 6.3.16]: Can't perform this conversion by assignment.

--Josh

At 17:32 on 03/21/2002 EST, Michel J Lambert <[EMAIL PROTECTED]> wrote:

> 
> We take in const params, and set them into non-const members of STRING:
> string.c(51) : warning C4090: '=' : different 'const' qualifiers
> string.c(55) : warning C4090: '=' : different 'const' qualifiers
> 
> Due to MAKE_KEY in set_keyed setting keys[0] on an uninitialized pointer.
> But I hear this isn't supposed to work anyway. The patch below comments
> the code out.
> c:\p\parrot\core.ops(574) : warning C4700: local variable 'src_key' used
> without having been initialized
> c:\p\parrot\core.ops(575) : warning C4700: local variable 'dest_key' used
> without having been initialized
> 
> IntQueue can miscalculate the length:
> c:\p\parrot\classes\intqueue.c(84) : warning C4700: local variable
> 'length' used without having been initialized
> 
> Patch to remove MAKE_KEY and IntQueue warnings is below.
> 
> Mike Lambert
> 
> 
> 
> Index: core.ops
> ===
> RCS file: /cvs/public/parrot/core.ops,v
> retrieving revision 1.111
> diff -u -r1.111 core.ops
> --- core.ops  21 Mar 2002 22:01:50 -  1.111
> +++ core.ops  21 Mar 2002 22:30:03 -
> @@ -567,14 +567,14 @@
>  =cut
> 
>  inline op set_keyed (out PMC, in PMC, in PMC, in PMC)  {
> -KEY_PAIR src_key_p, dest_key_p;
> -KEY src_key, dest_key;
> +//KEY_PAIR src_key_p, dest_key_p;
> +//KEY src_key, dest_key;
> 
> -MAKE_KEY(src_key, src_key_p, $2, enum_key_pmc, pmc_val);
> -MAKE_KEY(dest_key, dest_key_p, $4, enum_key_pmc, pmc_val);
> +//MAKE_KEY(src_key, src_key_p, $2, enum_key_pmc, pmc_val);
> +//MAKE_KEY(dest_key, dest_key_p, $4, enum_key_pmc, pmc_val);
> 
> -$1->vtable->set_pmc_keyed(interpreter,
> -$1, $2 ? &src_key : NULL, $3, $4 ? &dest_key : NULL);
> +//$1->vtable->set_pmc_keyed(interpreter,
> +//$1, $2 ? &src_key : NULL, $3, $4 ? &dest_key :
> NULL);
>  goto NEXT();
>  }
> 
> Index: classes/intqueue.pmc
> ===
> RCS file: /cvs/public/parrot/classes/intqueue.pmc,v
> retrieving revision 1.6
> diff -u -r1.6 intqueue.pmc
> --- classes/intqueue.pmc  10 Mar 2002 21:18:13 -  1.6
> +++ classes/intqueue.pmc  21 Mar 2002 22:30:04 -
> @@ -68,7 +68,7 @@
>  }
> 
>  static INTVAL queue_length ( CONTAINER* container ) {
> -  INTVAL length;
> +  INTVAL length = 0;
>if(container->head != NULL) {
>  BUCKET* head = container->head;
>  while(head != NULL) {
> 
> 





Re: Cola update

2002-03-21 Thread David M. Lloyd

On Thu, 21 Mar 2002, Melvin Smith wrote:

> Ahhh, those simpler days
>
> Hmm you have just given me an evil idea...

I must have had the same idea in the same instant. :-)

- D

<[EMAIL PROTECTED]>




Re: Some updates

2002-03-21 Thread Melvin Smith

At 05:13 PM 3/21/2002 -0500, Dan Sugalski wrote:
>Folks,
>
>I've added or enabled the following ops:
>
>clone Sx, sy

I'm not seeing the difference between clone Sx, sy and set Sx, sy

When I do:

set S30, "PARROT"
set S31, S30
chopn S30, 2
print S30
print "\n"
print S31
print "\n"
end

I still get:

PARR
PARROT

What am I missing?

-Melvin




Re: Some updates

2002-03-21 Thread Dan Sugalski

On Thu, 21 Mar 2002, Melvin Smith wrote:

> At 05:13 PM 3/21/2002 -0500, Dan Sugalski wrote:
> >Folks,
> >
> >I've added or enabled the following ops:
> >
> >clone Sx, sy
> 
> I'm not seeing the difference between clone Sx, sy and set Sx, sy
> 
> When I do:
> 
> set S30, "PARROT"
> set S31, S30

Change this to

  clone S31, S30

and see what happens.

Dan




Problems with strings on the stack (small, concise example)

2002-03-21 Thread Clinton A. Pierce

(p6i cc'd)

Okay, I've got this down to a dozen lines.  I'm using a build pulled from 
CVS two hours ago.  In case what's going on here isn't obvious, I'm 
shifting the first character off of S2 and putting it on the stack until S2 
is finally exhausted.  It's a boiled down version of my tokenizer.

 set S2, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 set I5, 0# Stack depth
TOKLOOP:
 length I0, S2
 eq I0, 0, DUMP
 substr S1, S2, 0, 1
 dec I0
 substr S2, S2, 1, I0

 inc I5
 savec S1
 branch TOKLOOP

DUMP:  eq I5, 0, BAIL
 restore S0
 print S0
 dec I5
 branch DUMP
BAIL:
 end

With the current build, even using your new savec opcode (or clone), the 
stack gets seriously messed up.   [In this example, the save opcode doesn't 
have the problem!  But in others it does.  I can't get anything to behave 
consistently.  Strings on the stack are just *broke*.]

So for the code given, the output instead of appearing as:

ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba

You get the unlikely:

ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjZYXWVUTSR

(I think it only *appears* like the stack wrapped on itself, BTW.  In 
larger examples, garbage from elsewhere seems to pollute the stack instead 
of earlier entries like this.)  Dumping larger things on the stack makes 
the problem occur at shallower depths -- sometimes.  It really seems like 
things that have been hanging around on the stack for a while get mashed.

Sorry it took me so long to get this down to something concise.  I wish it 
were smaller, not so critical to me, and a little more consistent.




Re: Problems with strings on the stack (small, concise example)

2002-03-21 Thread Dan Sugalski

At 8:52 PM -0500 3/21/02, Clinton A. Pierce wrote:
>Sorry it took me so long to get this down to something concise.  I 
>wish it were smaller, not so critical to me, and a little more 
>consistent.

Don't sweat it--I think that the issue is stack corruption, so I'll 
go poke around in the stack code some.

-- 
 Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
   teddy bears get drunk



Re: Some updates

2002-03-21 Thread Melvin Smith

At 07:41 PM 3/21/2002 -0500, Dan Sugalski wrote:
>On Thu, 21 Mar 2002, Melvin Smith wrote:
>
> > >clone Sx, sy
> >
> > I'm not seeing the difference between clone Sx, sy and set Sx, sy
> >
> > When I do:
> >
> > set S30, "PARROT"
> > set S31, S30
>
>Change this to
>
>   clone S31, S30
>
>and see what happens.

I did and I got the same results, hence my confusion.

[msmith@linux parrot]$ ./parrot a.pbc
PARR
PARROT
[msmith@linux parrot]$ ./parrot b.pbc
PARR
PARROT
[msmith@linux parrot]$ diff -u a.pasm b.pasm
--- a.pasm  Thu Mar 21 21:01:08 2002
+++ b.pasm  Thu Mar 21 20:58:43 2002
@@ -1,5 +1,5 @@
  set S30, "PARROT"
-set S31, S30
+clone S31, S30
  chopn S30, 2
  print S30
  print "\n"



-Melvin




Re: Old Warnock's Dilemma for 'make quicktest'

2002-03-21 Thread Robert Spier

> make quicktest could screw up if:
> - you ctrl-c it, or make test (although I haven't had problems with that
> yet) during the compilation process at just the right time
> - you do anything to invalidate existing .pbc files, such as rearranging
> ops. not sure what else could trigger this.
> 
> I still find it extremely useful, in spite of these limitations on its
> usage. The patch is included below.


Could you also provide a patch (or at least comments in the code) that
describe the limiations?




set Sx, iy

2002-03-21 Thread Melvin Smith

Just committed the set Sx, iy op.

Patch at end.

Cheers,

-Melvin




Tested with following:

# Cola (0.0.1) generated
#
_START:
bsr __Main
__END:
end

__Main:
set I31, -123456789
LBL1:
ge I31, 123456789, LBL2
 set S0, I31
 print I31
 print "\n "
 print S0
 print "\n"
add I31, I31, 1
branch LBL1
LBL2:
LBL0:
ret






Index: core.ops
===
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.111
diff -u -r1.111 core.ops
--- core.ops21 Mar 2002 22:01:50 -  1.111
+++ core.ops22 Mar 2002 04:09:33 -
@@ -540,6 +540,11 @@
goto NEXT();
  }

+inline op set(out STR, in INT) {
+  $1 = string_from_int(interpreter, $2);
+  goto NEXT();
+}
+
  inline op set(out PMC, in INT) {
$1->vtable->set_integer_native(interpreter, $1, $2);
goto NEXT();
Index: string.c
===
RCS file: /cvs/public/parrot/string.c,v
retrieving revision 1.60
diff -u -r1.60 string.c
--- string.c21 Mar 2002 09:56:41 -  1.60
+++ string.c22 Mar 2002 04:09:34 -
@@ -774,6 +774,35 @@
  return f;
  }

+STRING *
+string_from_int(struct Parrot_Interp * interpreter, INTVAL i) {
+const char * digits = "0123456789";
+char buf[128];
+char *ptr = &buf[127];
+int neg = 0;
+
+if(i < 0) {
+neg = 1;
+i = abs(i);
+}
+
+/* Dangerous looking but no 32/64/128/ bit int
+ * would approach 128 characters in the buffer.
+ */
+do {
+*--ptr = digits[i % 10];
+i /= 10;
+}
+while(i);
+
+if(neg)
+*--ptr = '-';
+
+return string_make(interpreter, ptr, (UINTVAL)(127 - (ptr - buf)),
+NULL, 0, NULL);
+}
+
+
  /*
   * Local variables:
   * c-indentation-style: bsd
Index: include/parrot/string_funcs.h
===
RCS file: /cvs/public/parrot/include/parrot/string_funcs.h,v
retrieving revision 1.5
diff -u -r1.5 string_funcs.h
--- include/parrot/string_funcs.h   20 Mar 2002 02:08:16 -  1.5
+++ include/parrot/string_funcs.h   22 Mar 2002 04:09:35 -
@@ -33,7 +33,8 @@
  INTVAL Parrot_string_ord(const STRING *, INTVAL idx);
  FLOATVAL Parrot_string_to_num(const STRING *);
  INTVAL Parrot_string_to_int(const STRING *);
-STRING * Parrot_string_grow(struct Parrot_Interp * interpreter, STRING * 
s, INTVAL addlen);
+STRING * Parrot_string_from_int(struct Parrot_Interp *, INTVAL i);
+STRING * Parrot_string_grow(struct Parrot_Interp *, STRING * s, INTVAL 
addlen);
  void Parrot_string_destroy(STRING *);
  STRING *Parrot_string_make(struct Parrot_Interp *, const void *buffer,
 UINTVAL buflen, const ENCODING *, UINTVAL flags,
@@ -60,6 +61,7 @@
  #define string_ord  Parrot_string_ord
  #define string_to_num   Parrot_string_to_num
  #define string_to_int   Parrot_string_to_int
+#define string_from_int Parrot_string_from_int
  #define string_grow Parrot_string_grow
  #define string_destroy  Parrot_string_destroy
  #define string_make Parrot_string_make





RE: set Sx, iy

2002-03-21 Thread Brent Dax

Melvin Smith:
# Just committed the set Sx, iy op.
#
# Patch at end.

# diff -u -r1.60 string.c
# --- string.c  21 Mar 2002 09:56:41 -  1.60
# +++ string.c  22 Mar 2002 04:09:34 -
# @@ -774,6 +774,35 @@
#   return f;
#   }
#
# +STRING *
# +string_from_int(struct Parrot_Interp * interpreter, INTVAL i) {
# +const char * digits = "0123456789";
# +char buf[128];
# +char *ptr = &buf[127];
# +int neg = 0;
# +
# +if(i < 0) {
# +neg = 1;
# +i = abs(i);
# +}
# +
# +/* Dangerous looking but no 32/64/128/ bit int
# + * would approach 128 characters in the buffer.
# + */
# +do {
# +*--ptr = digits[i % 10];
# +i /= 10;
# +}
# +while(i);
# +
# +if(neg)
# +*--ptr = '-';
# +
# +return string_make(interpreter, ptr, (UINTVAL)(127 -
# (ptr - buf)),
# +NULL, 0, NULL);
# +}
# +
# +

Just do "$1=Parrot_sprintf_c(interpreter, "%Vd", $2);".  I've already
implemented this logic there; there's no sense having it in the core
twice.

--Brent Dax <[EMAIL PROTECTED]>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

#define private public
--Spotted in a C++ program just before a #include




Re: Some updates

2002-03-21 Thread Dan Sugalski

At 6:53 PM -0500 3/21/02, Melvin Smith wrote:
>At 05:13 PM 3/21/2002 -0500, Dan Sugalski wrote:
>>Folks,
>>
>>I've added or enabled the following ops:
>>
>>clone Sx, sy
>
>I'm not seeing the difference between clone Sx, sy and set Sx, sy
>
>When I do:
>
>set S30, "PARROT"
>set S31, S30
>chopn S30, 2
>print S30
>print "\n"
>print S31
>print "\n"
>end
>
>I still get:
>
>PARR
>PARROT
>
>What am I missing?

Okay, I see what's happening. We changed set Sx, Sy to do a copy. I'm 
not sure who or when--I'll go look, not that it makes much difference.

I'll go change things back in the morning. It's a little late for me 
to be comfortable changing the source right now.

-- 
 Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
   teddy bears get drunk



Re: Some updates

2002-03-21 Thread Bryan C. Warnock

On Thursday 21 March 2002 23:51, Dan Sugalski wrote:
> 
> Okay, I see what's happening. We changed set Sx, Sy to do a copy. I'm 
> not sure who or when--I'll go look, not that it makes much difference.

Pre-GC, if that helps narrow it down.  It was the constant flag on the clone 
that was a cause of the GC going exponential.


-- 
Bryan C. Warnock
[EMAIL PROTECTED]



[PATCH] resources.c

2002-03-21 Thread Bryan C. Warnock

Fixes some UMRs, and makes GC a smidgen zippier.

Index: resources.c
===
RCS file: /home/perlcvs/parrot/resources.c,v
retrieving revision 1.31
diff -u -r1.31 resources.c
--- resources.c 18 Mar 2002 20:15:02 -  1.31
+++ resources.c 22 Mar 2002 05:07:20 -
@@ -394,7 +394,7 @@
 chunks_traced = 0;
 /* The general stack's circular, so we need to be careful */
 while(cur_stack && ((start_stack != cur_stack) || (chunks_traced == 0))) {
-for (i = 0; i < STACK_CHUNK_DEPTH; i++) {
+for (i = 0; i < cur_stack->used; i++) {
 if (STACK_ENTRY_PMC == cur_stack->entry[i].flags) {
 last = mark_used(cur_stack->entry[i].entry.pmc_val, last);
 }
@@ -471,7 +471,7 @@
   chunks_traced = 0;
   /* The general stack's circular, so we need to be careful */
   while(cur_stack && ((start_stack != cur_stack) || (chunks_traced == 0))) {
-for (i = 0; i < STACK_CHUNK_DEPTH; i++) {
+for (i = 0; i < cur_stack->used; i++) {
   if (STACK_ENTRY_STRING == cur_stack->entry[i].flags) {
buffer_lives((Buffer *)cur_stack->entry[i].entry.string_val);
   }


-- 
Bryan C. Warnock
[EMAIL PROTECTED]



RE: set Sx, iy

2002-03-21 Thread Melvin Smith

At 08:53 PM 3/21/2002 -0800, Brent Dax wrote:
>Just do "$1=Parrot_sprintf_c(interpreter, "%Vd", $2);".  I've already
>implemented this logic there; there's no sense having it in the core
>twice.

Calling the sprintf routine is kind of expensive if the op is only to 
convert an
int to a base10 string rep. We are talking dozen lines of C code for the op.

-Melvin




RE: set Sx, iy

2002-03-21 Thread Melvin Smith

At 12:25 AM 3/22/2002 -0500, Melvin Smith wrote:
>At 08:53 PM 3/21/2002 -0800, Brent Dax wrote:
>>Just do "$1=Parrot_sprintf_c(interpreter, "%Vd", $2);".  I've already
>>implemented this logic there; there's no sense having it in the core
>>twice.
>
>Calling the sprintf routine is kind of expensive if the op is only to 
>convert an
>int to a base10 string rep. We are talking dozen lines of C code for the op.

Hmm I did not see int_to_str() or I might have reused that...

Anyway, I had that base10 ltoa() already written from a library from years 
back.
Its a minor nit, mine does the conversion without reversing the string, 
yours is
general purpose, I see no reason not to keep both.

Knowing Dan, he will probably want to inline those 12 lines anyway so no 
sub jump.

:)

-Melvin





Re: Problems with strings on the stack (small, concise example)

2002-03-21 Thread Bryan C. Warnock

It's not the stack.  Addresses are being reused.

(I'm watching the stack on entry to stack_push.  Pop is probably working 
okay, too.  I don't know why the old contents aren't being clobbered, 
though.  Since I know when it happens, I'll try to narrow it down there.)

`parrot`stacks.c`stack_push`stack = {
   used  = 44 
   next  = 0x332000 
   prev  = 0x332000 
   entry = ({
  entry  = { # stack[0]
 num_val = 1.0956763994969e-307 
 int_val = 3388008 
 pmc_val = 0x33b268 
 string_val  = 0x33b268 
 generic_pointer = 0x33b268
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {
  entry  = {
 num_val = 1.0955949148585e-307 
 int_val = 3387912 
 pmc_val = 0x33b208 
 string_val  = 0x33b208 
 generic_pointer = 0x33b208
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {
  entry  = {
 num_val = 1.0955134302202e-307 
 int_val = 3387816 
 pmc_val = 0x33b1a8 
 string_val  = 0x33b1a8 
 generic_pointer = 0x33b1a8
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {
  entry  = {
 num_val = 1.0954319455818e-307 
 int_val = 3387720 
 pmc_val = 0x33b148 
 string_val  = 0x33b148 
 generic_pointer = 0x33b148
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {
  entry  = {
 num_val = 1.0953504609434e-307 
 int_val = 3387624 
 pmc_val = 0x33b0e8 
 string_val  = 0x33b0e8 
 generic_pointer = 0x33b0e8
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {
  entry  = {
 num_val = 1.095268976305e-307 
 int_val = 3387528 
 pmc_val = 0x33b088 
 string_val  = 0x33b088 
 generic_pointer = 0x33b088
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {

..
..
..

  entry  = { # stack[41]
 num_val = 1.0957578841353e-307 
 int_val = 3388104 
 pmc_val = 0x33b2c8 
 string_val  = 0x33b2c8 
 generic_pointer = 0x33b2c8
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {
  entry  = { # stack[42]
 num_val = 1.0956763994969e-307 
 int_val = 3388008 
 pmc_val = 0x33b268 
 string_val  = 0x33b268 
 generic_pointer = 0x33b268
  } 
  entry_type = 3 
  flags  = 0 
  cleanup= (nil)
   } {
  entry  = { # stack[43]
 num_val = 1.0955949148585e-307 
 int_val = 3387912 
 pmc_val = 0x33b208 
 string_val  = 0x33b208 
 generic_pointer = 0x33b208
  } 

..
..
..



-- 
Bryan C. Warnock
[EMAIL PROTECTED]



Retracted: [PATCH] resources.c

2002-03-21 Thread Bryan C. Warnock

Rolled into stack fix patch.

-- 
Bryan C. Warnock
[EMAIL PROTECTED]



[PATCH] resources.c (was Re: Problems with strings on the stack (small, concise example))

2002-03-21 Thread Bryan C. Warnock

Fixes a couple GC problems.

Index: resources.c
===
RCS file: /home/perlcvs/parrot/resources.c,v
retrieving revision 1.31
diff -u -r1.31 resources.c
--- resources.c 18 Mar 2002 20:15:02 -  1.31
+++ resources.c 22 Mar 2002 06:22:04 -
@@ -394,8 +394,8 @@
 chunks_traced = 0;
 /* The general stack's circular, so we need to be careful */
 while(cur_stack && ((start_stack != cur_stack) || (chunks_traced == 
0))) {
-for (i = 0; i < STACK_CHUNK_DEPTH; i++) {
-if (STACK_ENTRY_PMC == cur_stack->entry[i].flags) {
+for (i = 0; i < cur_stack->used; i++) {
+if (STACK_ENTRY_PMC == cur_stack->entry[i].entry_type) {
 last = mark_used(cur_stack->entry[i].entry.pmc_val, last);
 }
 }
@@ -471,8 +471,8 @@
   chunks_traced = 0;
   /* The general stack's circular, so we need to be careful */
   while(cur_stack && ((start_stack != cur_stack) || (chunks_traced == 0))) {
-for (i = 0; i < STACK_CHUNK_DEPTH; i++) {
-  if (STACK_ENTRY_STRING == cur_stack->entry[i].flags) {
+for (i = 0; i < cur_stack->used; i++) {
+  if (STACK_ENTRY_STRING == cur_stack->entry[i].entry_type) {
buffer_lives((Buffer *)cur_stack->entry[i].entry.string_val);
   }
 }

-- 
Bryan C. Warnock
[EMAIL PROTECTED]



(Reformatted Resend) [PATCH] resources.c

2002-03-21 Thread Bryan C. Warnock

Fixes a couple GC problems.

Index: resources.c
===
RCS file: /home/perlcvs/parrot/resources.c,v
retrieving revision 1.31
diff -u -r1.31 resources.c
--- resources.c 18 Mar 2002 20:15:02 -  1.31
+++ resources.c 22 Mar 2002 06:22:04 -
@@ -394,8 +394,8 @@
 chunks_traced = 0;
 /* The general stack's circular, so we need to be careful */
 while(cur_stack && ((start_stack != cur_stack) || (chunks_traced == 0))) {
-for (i = 0; i < STACK_CHUNK_DEPTH; i++) {
-if (STACK_ENTRY_PMC == cur_stack->entry[i].flags) {
+for (i = 0; i < cur_stack->used; i++) {
+if (STACK_ENTRY_PMC == cur_stack->entry[i].entry_type) {
 last = mark_used(cur_stack->entry[i].entry.pmc_val, last);
 }
 }
@@ -471,8 +471,8 @@
   chunks_traced = 0;
   /* The general stack's circular, so we need to be careful */
   while(cur_stack && ((start_stack != cur_stack) || (chunks_traced == 0))) {
-for (i = 0; i < STACK_CHUNK_DEPTH; i++) {
-  if (STACK_ENTRY_STRING == cur_stack->entry[i].flags) {
+for (i = 0; i < cur_stack->used; i++) {
+  if (STACK_ENTRY_STRING == cur_stack->entry[i].entry_type) {
buffer_lives((Buffer *)cur_stack->entry[i].entry.string_val);
   }
 }


-- 
Bryan C. Warnock
[EMAIL PROTECTED]



[PATCH] stacks.c

2002-03-21 Thread Bryan C. Warnock

Defer allocation as long as possible.  Make logic parallel.

Index: stacks.c
===
RCS file: /home/perlcvs/parrot/stacks.c,v
retrieving revision 1.23
diff -u -r1.23 stacks.c
--- stacks.c8 Mar 2002 03:04:03 -   1.23
+++ stacks.c22 Mar 2002 06:45:39 -
@@ -108,7 +108,21 @@
void *thing, INTVAL type, stack_cleanup_method_t cleanup)
 {
 Stack_Chunk chunk = stack->prev;
-Stack_Entry entry = &chunk->entry[chunk->used];
+Stack_Entry entry;
+
+/* Do we need a new chunk? */
+if (chunk->used == STACK_CHUNK_DEPTH) {
+/* Need to add a new chunk */
+Stack_Chunk new_chunk = mem_allocate_aligned(sizeof(*new_chunk));
+new_chunk->used = 0;
+new_chunk->next = stack;
+new_chunk->prev = chunk;
+chunk->next = new_chunk;
+stack->prev = new_chunk;
+chunk = new_chunk;
+}
+
+entry = &chunk->entry[chunk->used];

 /* Remember the type */
 entry->entry_type = type;
@@ -139,16 +153,7 @@
 break;
 }

-/* Register the new entry */
-if (++chunk->used == STACK_CHUNK_DEPTH) {
-/* Need to add a new chunk */
-Stack_Chunk new_chunk = mem_allocate_aligned(sizeof(*new_chunk));
-new_chunk->used = 0;
-new_chunk->next = stack;
-new_chunk->prev = chunk;
-chunk->next = new_chunk;
-stack->prev = new_chunk;
-}
+chunk->used++;
 }

 /* Pop off an entry and return a pointer to the contents */
@@ -176,7 +181,10 @@
 internal_exception(ERROR_STACK_EMPTY, "No entries on stack!\n");
 }

-entry = &chunk->entry[chunk->used - 1];
+/* Now decrement the SP */
+chunk->used--;
+
+entry = &chunk->entry[chunk->used];

 /* Types of 0 mean we don't care */
 if (type && entry->entry_type != type) {
@@ -189,8 +197,6 @@
 (*entry->cleanup) (entry);
 }

-/* Now decrement the SP */
-chunk->used--;

 /* Sometimes the caller doesn't care what the value was */
 if (where == NULL)
-- 
Bryan C. Warnock
[EMAIL PROTECTED]