Skip to content

Commit

Permalink
WIP for Spesh.pm6
Browse files Browse the repository at this point in the history
More later today / tomorrow
  • Loading branch information
lizmat committed Apr 27, 2019
1 parent 34162e9 commit f91de3e
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions lib/Spesh.pm6
Expand Up @@ -15,20 +15,30 @@


class Spesh { class Spesh {
has @.parts; has @.parts;
has $.bails; has $!bails;
has $.time; has $!time;
has @!cuids;


method bails() { method bails() {
$!bails //= [(+)] @.parts>>.bails; $!bails //= [(+)] @.parts>>.bails;
} }
method time() { method time() {
$!time //= @.parts>>.time.sum; $!time //= @.parts>>.time.sum;
} }
method cuids() {
@!cuids ?? @!cuids !! do {
for @.parts -> $part {
@!cuids[.cuid].push( $_ ) for $part.statistics;
@!cuids[.cuid].push( $_ ) for $part.actions;
}
@!cuids
}
}


role Bails { role Bails {
has $.bails; has $!bails;


method bails() { method bails(--> Bag:D) {
$!bails //= $.text $!bails //= $.text
.comb( /:r bail ':' <-[ \n ]>* / ) .comb( /:r bail ':' <-[ \n ]>* / )
.map( *.words.tail ) .map( *.words.tail )
Expand All @@ -38,18 +48,18 @@ class Spesh {
} }


role Time { role Time {
method time() { method time(--> Int:D) {
$.text.match( / <after " "> \d+ <before us " "> /, :g ).sum // 0 $.text.match( / <after " "> \d+ <before us " "> /, :g ).sum // 0
} }
} }


role Cuid-File-Line { role Cuid-File-Line {
method cuid() { method cuid(--> Int:D) {
$.text.match( $.text.match(
/:r <after 'cuid: ' > \d+ / /:r <after 'cuid: ' > \d+ /
).Int ).Int
} }
method file-line() { method file-line(--> Str:D) {
$.text.match( $.text.match(
/:r <after 'file: ' > <-[ ) ]>+ <before ')' > / /:r <after 'file: ' > <-[ ) ]>+ <before ')' > /
).Str ).Str
Expand All @@ -63,7 +73,7 @@ class Spesh {
my class Updated does Time { my class Updated does Time {
has $.text; has $.text;


method frames() { method frames(--> Int:D) {
$.text.match( $.text.match(
/:r \d+ <before " frames" > / /:r \d+ <before " frames" > /
).Int ).Int
Expand All @@ -73,12 +83,12 @@ class Spesh {
my class Statistics does Time does Cuid-File-Line { my class Statistics does Time does Cuid-File-Line {
has $.text; has $.text;


method name() { method name(--> Str:D) {
$.text.match( $.text.match(
/:r <after "Latest statistics for '" > <-[']>* <before "'" > / /:r <after "Latest statistics for '" > <-[']>* <before "'" > /
).Str ).Str
} }
method total-hits() { method total-hits(--> Int:D) {
$.text.match( $.text.match(
/:r <after "Total hits: " > \d+ / /:r <after "Total hits: " > \d+ /
).Int ).Int
Expand All @@ -88,12 +98,12 @@ class Spesh {
my class Planning does Time { my class Planning does Time {
has $.text; has $.text;


method specializations() { method specializations(--> Int:D) {
$.text.match( $.text.match(
/:r \d+ <before " specialization(s)" > / /:r \d+ <before " specialization(s)" > /
).Int ).Int
} }
method time() { method time(--> Int:D) {
$.text.match( /:r <after "planned in "> \d+ <before "us)"> /).Int $.text.match( /:r <after "planned in "> \d+ <before "us)"> /).Int
} }
} }
Expand All @@ -102,7 +112,7 @@ class Spesh {
class Observation does Bails does Time does Cuid-File-Line { class Observation does Bails does Time does Cuid-File-Line {
has $.text; has $.text;


method name() { method name(--> Str:D) {
$.text.match( $.text.match(
/:r <after "Observed type specialization of '" > <-[']>* <before "'" > / /:r <after "Observed type specialization of '" > <-[']>* <before "'" > /
).Str ).Str
Expand All @@ -112,7 +122,7 @@ class Spesh {
class GuardTree does Bails does Time does Cuid-File-Line { class GuardTree does Bails does Time does Cuid-File-Line {
has $.text; has $.text;


method name() { method name(--> Str:D) {
$.text.match( $.text.match(
/:r <after "Latest guard tree for '" > <-[']>* <before "'" > / /:r <after "Latest guard tree for '" > <-[']>* <before "'" > /
).Str ).Str
Expand All @@ -122,7 +132,7 @@ class Spesh {
class Certainty does Bails does Time does Cuid-File-Line { class Certainty does Bails does Time does Cuid-File-Line {
has $.text; has $.text;


method name() { method name(--> Str:D) {
$.text.match( $.text.match(
/:r <after "Certain specialization of '" > <-[']>* <before "'" > / /:r <after "Certain specialization of '" > <-[']>* <before "'" > /
).Str ).Str
Expand All @@ -132,28 +142,30 @@ class Spesh {
class Specialization does Bails does Time does Cuid-File-Line { class Specialization does Bails does Time does Cuid-File-Line {
has $.text; has $.text;


method time() { method time(--> Int:D) {
$.text.match( $.text.match(
/:r <after 'Specialization took ' > \d+ <before 'us' > / /:r <after 'Specialization took ' > \d+ <before 'us' > /
).Int ).Int
} }
method jitted() { $.text.contains('JIT was successful') } method jitted(--> Bool:D) {
method compilation-time() { $.text.contains('JIT was successful')
}
method compilation-time(--> Int:D) {
$.text.match( $.text.match(
/:r <after 'compilation took ' > \d+ <before 'us' > / /:r <after 'compilation took ' > \d+ <before 'us' > /
).Int ).Int
} }
method frame-size() { method frame-size(--> Int:D) {
$.text.match( $.text.match(
/:r <after 'Frame size: ' > \d+ <before ' byte' > / /:r <after 'Frame size: ' > \d+ <before ' byte' > /
).Int ).Int
} }
method bytecode-size() { method bytecode-size(--> Int:D) {
$.text.match( $.text.match(
/:r <after 'Bytecode size: ' > \d+ <before ' byte' > / /:r <after 'Bytecode size: ' > \d+ <before ' byte' > /
).Int ).Int
} }
method name() { method name(--> Str:D) {
$.text.match( $.text.match(
/:r <after "Spesh of '" > <-[']>* <before "' " > / /:r <after "Spesh of '" > <-[']>* <before "' " > /
).Str ).Str
Expand All @@ -172,7 +184,7 @@ class Spesh {
method bails() { method bails() {
$!bails //= [(+)] @.actions>>.bails; $!bails //= [(+)] @.actions>>.bails;
} }
method time() { method time(--> Int:D) {
$!time //= $!time //=
$.received.time $.received.time
+ $.updated.time + $.updated.time
Expand All @@ -197,7 +209,7 @@ class Spesh {
my constant start-Certainty = "Certain specialization of"; my constant start-Certainty = "Certain specialization of";
my constant start-Specialization = "Specialization of"; my constant start-Specialization = "Specialization of";


method new($filename) { method new($filename --> Spesh:D) {
my $handle = $filename.IO.open or die "Could not read $filename: $!"; my $handle = $filename.IO.open or die "Could not read $filename: $!";


my $status = Received; my $status = Received;
Expand Down Expand Up @@ -362,4 +374,6 @@ sub MAIN($filename where *.IO.e) {
note "Done"; note "Done";
say "Found $bails.elems() different ops getting bailed:"; say "Found $bails.elems() different ops getting bailed:";
printf("%4d: %s\n", .value, .key) for $bails.sort( *.value ); printf("%4d: %s\n", .value, .key) for $bails.sort( *.value );

say $spesh.cuids[1]>>.file-line.Bag;
} }

0 comments on commit f91de3e

Please sign in to comment.