Day 135: Eighth day at Leo's: Test.pm runs on Parrot!

autrijus on 2005-06-18T23:54:56

The END block in Test.pm now runs correctly, and the entire module has been compiled to Parrot:

$ ./pugs -BPIR ext/Test/lib/Test.pm
1..0

As seen on #perl6:

* putter pictures trying to explain to someone,
  yes, it said "1..0", so we were quite happy...

With this, the zeroth phase -- that is, the sanity phase -- of PugsAST/PIR bootstrapping is done. Note that it currently passes none of the other 7000 tests; it's just sanity, and nothing more.

We also implemented these features on the PIR backend:

  • Tail call optimisation, so we don't run into Parrot's 1k-level recursion limit.
  • Optional parameter support: sub foo ($x, ?$y=$x) {say "$x = $y"}
  • Keyed access: say %*ENV<USER>
  • Symbolic dereference: &::("say").("Hello!")

Even when unoptimised, the PIR backend is already nearly an order of magnitude faster than Pugs's main Eval runloop. However, because of Parrot's current heavy penalty against snapshotting a continuation, we're still much slower than Perl 5 for common control structures, especially with large number of loop iterations. Let's hope Leo's O(1) CPS fix will land soon...

There are lots of things left to do before we can run our own harness in PIR, mostly at the Parrot side:

  • require and use needs to be redispatched to Parrot.
  • Static numbering of lexical pad levels needs more work -- currently I just used store_globals for everything.
  • The alligator is still eating the cc in call/cc, so we're forced into the slow and non-reentrant store_global passing style.
  • Optional parameters are currently discarded even if passed through.
  • Named parameters needs to hook up with the Pair PMC -- it requires callconv fix in the Parrot side.
  • Numerous builtins are still missing.

With the current level of PIR support in 6.2.8, I think our YAPC::NA Hackathon can devote some time into bringing the primitives into shape; then we can subject PugsAST/PIR/Parrot to our existing 7000+ tests, and see if there are any serious glitches left to be found.

But, sleep first. See you tomorrow!