[svn:parrot] r45307 - in branches/profiling_testing: . config/gen/makefiles runtime/parrot/library/ProfTest t/profiling

cotto at svn.parrot.org cotto at svn.parrot.org
Tue Mar 30 06:04:47 UTC 2010


Author: cotto
Date: Tue Mar 30 06:04:46 2010
New Revision: 45307
URL: https://trac.parrot.org/parrot/changeset/45307

Log:
[profiling] add support for profiling nqp code, make all tests pass, remove debugging output

Added:
   branches/profiling_testing/runtime/parrot/library/ProfTest/NQPProfile.nqp
Modified:
   branches/profiling_testing/MANIFEST
   branches/profiling_testing/config/gen/makefiles/root.in
   branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp
   branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp
   branches/profiling_testing/t/profiling/profiling.t

Modified: branches/profiling_testing/MANIFEST
==============================================================================
--- branches/profiling_testing/MANIFEST	Tue Mar 30 05:23:41 2010	(r45306)
+++ branches/profiling_testing/MANIFEST	Tue Mar 30 06:04:46 2010	(r45307)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sat Mar 27 22:33:09 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Mar 30 06:04:00 2010 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -1240,6 +1240,7 @@
 runtime/parrot/library/Parrot/Exception.pir                 [library]
 runtime/parrot/library/Pg.pir                               [library]
 runtime/parrot/library/ProfTest/Matcher.nqp                 [library]
+runtime/parrot/library/ProfTest/NQPProfile.nqp              [library]
 runtime/parrot/library/ProfTest/PIRProfile.nqp              [library]
 runtime/parrot/library/ProfTest/Want.nqp                    [library]
 runtime/parrot/library/Protoobject.pir                      [library]

Modified: branches/profiling_testing/config/gen/makefiles/root.in
==============================================================================
--- branches/profiling_testing/config/gen/makefiles/root.in	Tue Mar 30 05:23:41 2010	(r45306)
+++ branches/profiling_testing/config/gen/makefiles/root.in	Tue Mar 30 06:04:46 2010	(r45307)
@@ -1047,9 +1047,12 @@
 #
 
 $(LIBRARY_DIR)/ProfTest.pbc: $(LIBRARY_DIR)/ProfTest/PIRProfile.pbc \
-	$(LIBRARY_DIR)/ProfTest/Matcher.pbc  $(LIBRARY_DIR)/ProfTest/Want.pbc
+	$(LIBRARY_DIR)/ProfTest/NQPProfile.pbc $(LIBRARY_DIR)/ProfTest/Matcher.pbc \
+	$(LIBRARY_DIR)/ProfTest/Want.pbc
 	$(PBC_MERGE) -o $@ $(LIBRARY_DIR)/ProfTest/PIRProfile.pbc \
-		$(LIBRARY_DIR)/ProfTest/Matcher.pbc $(LIBRARY_DIR)/ProfTest/Want.pbc
+	$(LIBRARY_DIR)/ProfTest/NQPProfile.pbc $(LIBRARY_DIR)/ProfTest/Matcher.pbc \
+	$(LIBRARY_DIR)/ProfTest/Want.pbc
+
 
 $(LIBRARY_DIR)/ProfTest/PIRProfile.pbc: $(LIBRARY_DIR)/ProfTest/PIRProfile.pir
 	$(PARROT) -o $@ $(LIBRARY_DIR)/ProfTest/PIRProfile.pir
@@ -1057,12 +1060,21 @@
 $(LIBRARY_DIR)/ProfTest/PIRProfile.pir: $(LIBRARY_DIR)/ProfTest/PIRProfile.nqp $(NQP_RX)
 	$(NQP_RX) --target=pir $(LIBRARY_DIR)/ProfTest/PIRProfile.nqp > $@
 
+
+$(LIBRARY_DIR)/ProfTest/NQPProfile.pbc: $(LIBRARY_DIR)/ProfTest/NQPProfile.pir
+	$(PARROT) -o $@ $(LIBRARY_DIR)/ProfTest/NQPProfile.pir
+
+$(LIBRARY_DIR)/ProfTest/NQPProfile.pir: $(LIBRARY_DIR)/ProfTest/NQPProfile.nqp $(NQP_RX)
+	$(NQP_RX) --target=pir $(LIBRARY_DIR)/ProfTest/NQPProfile.nqp > $@
+
+
 $(LIBRARY_DIR)/ProfTest/Want.pbc: $(LIBRARY_DIR)/ProfTest/Want.pir
 	$(PARROT) -o $@ $(LIBRARY_DIR)/ProfTest/Want.pir
 
 $(LIBRARY_DIR)/ProfTest/Want.pir: $(LIBRARY_DIR)/ProfTest/Want.nqp $(NQP_RX)
 	$(NQP_RX) --target=pir $(LIBRARY_DIR)/ProfTest/Want.nqp > $@
 
+
 $(LIBRARY_DIR)/ProfTest/Matcher.pbc: $(LIBRARY_DIR)/ProfTest/Matcher.pir
 	$(PARROT) -o $@ $(LIBRARY_DIR)/ProfTest/Matcher.pir
 

Added: branches/profiling_testing/runtime/parrot/library/ProfTest/NQPProfile.nqp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/profiling_testing/runtime/parrot/library/ProfTest/NQPProfile.nqp	Tue Mar 30 06:04:46 2010	(r45307)
@@ -0,0 +1,7 @@
+class ProfTest::NQPProfile is ProfTest::PIRProfile;
+
+method new($nqp_code, $canonical? = 1) {
+    my $nqp_compiler := pir::compreg__ps("NQP-rx");
+    my $pir_code     := $nqp_compiler.compile($nqp_code, :target('pir'));
+    ProfTest::PIRProfile.new($pir_code, $canonical);
+}

Modified: branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp
==============================================================================
--- branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp	Tue Mar 30 05:23:41 2010	(r45306)
+++ branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp	Tue Mar 30 06:04:46 2010	(r45307)
@@ -29,7 +29,8 @@
         rule variable_line { <line_type> ':' <variable_data>* }
         rule variable_data { '{x{' <field_name> ':' <field_data> '}x}' }
         rule field_name    { <.ident> }
-        rule field_data    { <[a..zA..Z0..9_\-]>* }
+        #XXX: really need to find something better 
+        rule field_data    { <[a..zA..Z0..9_\-;\/.]>* }
     }
 
     for @pprof_lines -> $line {

Modified: branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp
==============================================================================
--- branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp	Tue Mar 30 05:23:41 2010	(r45306)
+++ branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp	Tue Mar 30 06:04:46 2010	(r45307)
@@ -153,18 +153,23 @@
 
 method new(:$ns?, :$slurp_until?) {
     self<ns> := $ns;
-    self<slurp_until> := $slurp_until;
+    if $slurp_until {
+        self<slurp_until> := $slurp_until;
+    }
     self<found_cs> := 0;
     self;
 }
 
 method accepts($prof_line) {
     if self<found_cs> && self<slurp_until> {
-        return $prof_line<variable_line><line_type> ne self<slurp_until>;
+        if pir::downcase($prof_line<variable_line><line_type>) ne self<slurp_until> {
+            return 1;
+        }
+        return 0;
     }
     elsif $prof_line<variable_line> && $prof_line<variable_line><line_type> eq 'CS' {
         if !self<ns> {
-            self<found_cs>  := 1;
+            self<found_cs> := 1;
             return 1;
         }
         my %h := self.hashify_profile_data($prof_line<variable_line><variable_data>);
@@ -179,10 +184,10 @@
 method get_str() {
     my $str := 'CS(';
     if self<ns> {
-        $str := $str ~ ', :ns(' ~ self<ns> ~ '),';
+        $str := $str ~ ':ns(' ~ self<ns> ~ ')';
     }
     if self<slurp_until> {
-        $str := $str ~ ', :slurp_until(' ~ self<ns> ~ ')';
+        $str := $str ~ ', :slurp_until(' ~ self<slurp_until> ~ ')';
     }
     $str := $str ~ ')';
     $str;

Modified: branches/profiling_testing/t/profiling/profiling.t
==============================================================================
--- branches/profiling_testing/t/profiling/profiling.t	Tue Mar 30 05:23:41 2010	(r45306)
+++ branches/profiling_testing/t/profiling/profiling.t	Tue Mar 30 06:04:46 2010	(r45307)
@@ -5,8 +5,7 @@
 }
 
 
-#basic tests
-
+plan(12);
 
 my $pir_code := 
 '.sub main
@@ -74,6 +73,31 @@
 .sub second
   .local pmc p
   p = new ['Interger']
+  p = 1
+.end";
+
+$prof := ProfTest::PIRProfile.new($pir_code);
+
+$matcher := ProfTest::Matcher.new(
+    cs(:ns('parrot;first'),  :slurp_until('cs')),
+    cs(:ns('parrot;second'), :slurp_until('cs')),
+    cs(:ns('parrot;first')),
+);
+
+ok( $matcher.matches($prof), "profile properly reflects normal control flow (simple)");
+
+
+$pir_code :=
+".sub first :main
+  .local int i
+  i = 0
+  'second'()
+  inc i
+.end
+
+.sub second
+  .local pmc p
+  p = new ['Interger']
   'third'()
   p = 1
 .end
@@ -85,14 +109,14 @@
 $prof := ProfTest::PIRProfile.new($pir_code);
 
 $matcher := ProfTest::Matcher.new(
-    cs(:ns('first'),  :slurp_until('cs')),
-    cs(:ns('second'), :slurp_until('cs')),
-    cs(:ns('third'),  :slurp_until('cs')),
-    cs(:ns('second'), :slurp_until('cs')),
-    cs(:ns('first')),
+    cs(:ns('parrot;first'),  :slurp_until('cs')),
+    cs(:ns('parrot;second'), :slurp_until('cs')),
+    cs(:ns('parrot;third'),  :slurp_until('cs')),
+    cs(:ns('parrot;second'), :slurp_until('cs')),
+    cs(:ns('parrot;first')),
 );
 
-ok( $matcher.matches($prof), "profile properly reflects normal control flow");
+ok( $matcher.matches($prof), "profile properly reflects normal control flow (slightly less simple)");
 
 
 #test: main calls foo, foo tailcalls bar, bar returns to main
@@ -100,6 +124,7 @@
 ".sub first :main
   .local int i
   i = 'foo'(9)
+  say i
 .end
 
 .sub foo
@@ -117,10 +142,10 @@
 $prof := ProfTest::PIRProfile.new($pir_code);
 
 $matcher := ProfTest::Matcher.new(
-    cs(:ns('first'), :slurp_until('cs')),
-    cs(:ns('foo'),   :slurp_until('cs')),
-    cs(:ns('bar'),   :slurp_until('cs')),
-    cs(:ns('first')),
+    cs(:ns('parrot;first'), :slurp_until('cs')),
+    cs(:ns('parrot;foo'),   :slurp_until('cs')),
+    cs(:ns('parrot;bar'),   :slurp_until('cs')),
+    cs(:ns('parrot;first')),
 );
 
 ok( $matcher.matches($prof), "profile properly reflects tailcall control flow");
@@ -128,19 +153,19 @@
 
 #Does the profile show a 'say' op on line 2?
 $matcher := ProfTest::Matcher.new(
-    op('say', :line('2')),
+    op('say', :line('3')),
 );
 
 ok( $matcher.matches($prof), "profile shows say on the correct line");
 
 
-my $nqp_code := '
-main();
+my $nqp_code :=
+'main();
 sub main() {
-    pir:say("nqp");
+    pir::say("nqp");
 }';
 
-$prof := ProfTest::NQPProfile.new($nqp_code, :annotations(1));
+$prof := ProfTest::NQPProfile.new($nqp_code);
 
 $matcher := ProfTest::Matcher.new(
     cs(:ns('parrot;main') ),
@@ -156,6 +181,6 @@
 sub cli(*@p, *%n)     { ProfTest::Want::CLI.new(|@p, |%n) }
 sub eor(*@p, *%n)     { ProfTest::Want::EndOfRunloop.new(|@p, |%n) }
 sub op(*@p, *%n)      { ProfTest::Want::Op.new(|@p, |%n) }
-sub cs(*@p, *%n)      { Proftest::Want::CS.new(|@p, |%n) }
+sub cs(*@p, *%n)      { ProfTest::Want::CS.new(|@p, |%n) }
 sub any(*@p, *%n)     { ProfTest::Want::Any.new(|@p, |%n) }
 


More information about the parrot-commits mailing list