cvsuser 03/03/14 17:42:29
Modified: . MANIFEST core.ops
Added: examples/benchmarks primes2_p.pasm
Log:
Added a PMC version of the primes 2 benchmark to better model performance
with variables against python/perl/ruby.
Updated core.ops to add missing ops needed to make it work
Revision Changes Path
1.326 +1 -0 parrot/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.325
retrieving revision 1.326
diff -u -w -r1.325 -r1.326
--- MANIFEST 12 Mar 2003 03:51:31 -0000 1.325
+++ MANIFEST 15 Mar 2003 01:42:26 -0000 1.326
@@ -211,6 +211,7 @@
examples/benchmarks/primes.pl
examples/benchmarks/primes2.c
examples/benchmarks/primes2.pasm
+examples/benchmarks/primes2_p.pasm
examples/benchmarks/primes2.py
examples/benchmarks/stress.pasm
examples/benchmarks/stress.pl
1.264 +33 -0 parrot/core.ops
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.263
retrieving revision 1.264
diff -u -w -r1.263 -r1.264
--- core.ops 14 Mar 2003 20:20:07 -0000 1.263
+++ core.ops 15 Mar 2003 01:42:26 -0000 1.264
@@ -731,6 +731,8 @@
=item B<eq>(in PMC, in PMC, inconst INT)
+=item B<eq>(in PMC, in INT, inconst INT)
+
Branch if $1 is equal to $2.
=cut
@@ -763,6 +765,13 @@
goto NEXT();
}
+op eq (in PMC, in INT, inconst INT) {
+ if ($1->vtable->get_integer(interpreter, $1) == $2) {
+ goto OFFSET($3);
+ }
+ goto NEXT();
+}
+
########################################
=item B<ne>(in INT, in INT, inconst INT)
@@ -815,6 +824,8 @@
=item B<lt>(in PMC, in PMC, inconst INT)
+=item B<lt>(in PMC, in INT, inconst INT)
+
Branch if $1 is less than $2.
=cut
@@ -847,6 +858,13 @@
goto NEXT();
}
+op lt (in PMC, in INT, inconst INT) {
+ if ($1->vtable->get_integer(interpreter, $1) < $2) {
+ goto OFFSET($3);
+ }
+ goto NEXT();
+}
+
########################################
=item B<le>(in INT, in INT, inconst INT)
@@ -857,6 +875,8 @@
=item B<le>(in PMC, in PMC, inconst INT)
+=item B<le>(in PMC, in INT, inconst INT)
+
Branch if $1 is less than or equal to $2.
=cut
@@ -889,6 +909,13 @@
goto NEXT();
}
+op le(in PMC, in INT, inconst INT) {
+ if ($1->vtable->get_integer(interpreter, $1) <= $2) {
+ goto OFFSET($3);
+ }
+ goto NEXT();
+}
+
########################################
=item B<gt>(in INT, in INT, inconst INT)
@@ -1277,6 +1304,12 @@
inline op cmod(out INT, in INT, in INT) {
$1 = $2 % $3;
+ goto NEXT();
+}
+
+
+inline op cmod(out PMC, in PMC, in PMC) {
+ $2->vtable->modulus(interpreter, $2, $3, $1);
goto NEXT();
}
1.1 parrot/examples/benchmarks/primes2_p.pasm
Index: primes2_p.pasm
===================================================================
new P1, .PerlInt
set P1, 0
new P3, .PerlInt
set P3, 0
new P4, .PerlInt
set P4, 10000
new P6, .PerlInt
new P5, .PerlInt
new P7, .PerlInt
new P8, .PerlInt
new P9, .PerlInt
set P9, 0
LOOP:
save P1
bsr PRPMECHECK
restore I9
unless I9, NOTPRPME
#PSPRPME:
inc P9
assign P7, P1
NOTPRPME:
inc P1
ne P1,P4, LOOP
DONE:
# end
print "N primes calculated to "
print P1
print " is "
print P9
print "\n"
print "last is: "
print P7
print "\n"
end
PRPMECHECK:
saveall
restore P5
lt P5,1,ret0
assign P6,P5
dec P6
NLOOP:
le P6, 1, ret1
cmod P8, P5, P6
eq P8, 0, ret0
dec P6
branch NLOOP
# is prime
ret1:
set I0, 1
save I0
restoreall
ret
ret0:
set I0, 0
save I0
restoreall
ret