Name: Brian Gernhardt
IRC: benabik on irc.perl.org, irc.freenode.net
The nqp_pct branch of parrot.git contains an updated version of POST that can output bytecode directly. This project will update PAST to use this new version of POST and get the branch ready for merge to master.
Because the new POST library is written in NQP, rewriting PAST in NQP is a natural step in the process. Having this library written in a higher level language makes it more accessable for newcomers to the Parrot and opens up more room for experimentation.
Using the new POST tree from PAST means that any language that uses the Parrot Compiler Toolkit can gain the benefits of the bytecode generation code there. This should bring speed benefits, as parrot no longer has to spend time parsing text it spent time generating. In addition, it will reduce parrot's dependence on IMCC (the current PIR parser) which will help pave the way for other options such as PIRATE (from which the new POST classes are derived).
Finally, a period of the summer will be set aside for improvements to PAST and POST. Although this is initially to help bring POST's bytecode into feature parity with the current PIR method, it is also an opportunity for new features to be attempted and tested.
The main deliverable is an updated version of PAST that uses the new POST classes in the nqp_pct branch. This will include updating PAST to be written in NQP to match the new POST classes. This update should result in no changes to existing API, although new classes or functions may be added as needed.
Both PAST and POST already have documentation and tests, and the resulting code is expected to match the current documentation and pass the existing test suite. Any alterations or additions to the API will include updated tests and documentation.
The updated POST library was created from work on pirate, and there are new tests there for the added functionality. These tests will be integrated into the main parrot tests for the POST library in t/compilers/pct.
One of the eventual goals of this work is to allow removal of IMCC from the main parrot frontend. If time allows, a proof of concept frontend based on PIRATE will be developed either in a fork of the PIRATE repository or in a separate branch from the earlier work (so the earlier work can be merged separately).
This project can be divided into three roughly equal sections: converting existing PAST classes to NQP, converting PAST to use new POST types and implementing new features.
The conversion of the PAST classes to NQP is motivated by a desire to match the new POST nodes. In addition, PIR is a low level enough language that adding new features would require significantly more time. The conversion will ease my development effort later, give me a thorough understanding of the code, and make further development in this area simpler.
While the POST library in nqp_pct has the same Op, Label, and Sub classes as the original it also has a variety of new classes to make code generation simpler and more efficient. The PAST::Compiler class will need to be made aware of the new types and make use of them where appropriate.
Finally, although the POST library provides bytecode generation it currently lacks complete feature parity with PIR generation. In particular, it lacks support for annotation and debug information. These features are available via the Packfile PMC and should be possible to be generated once PAST is updated to provide the information to POST. An evaluation will be done at the beginning of this portion of the summer to determine if any other features need to be implemented, since the conversion of the PAST library will likely expose any gaps.
A week near each evaluation will be dedicated to bugfixes and other issues. This extra time should help to both produce a high quality result and absorb any excess time caused by unforeseen issues. A goal for the project is to get the new PAST and POST libraries ready for production use, which in this case means being merged to Parrot's master branch. A week at the very end of GSoC will be allocated to code cleanup to address any issues that could prevent such a merge.
There is one major gap in this proposal: POST nodes containing inline PIR code. Unfortunately, implementing such nodes requires a full PIR parser. If time allows, pirate will be used to implement these nodes but this is not considered a major goal for the summer.
If either inline nodes get implemented or too little time appears to be left for that project, a new parrot frontend will be created. It will be written in PIR or NQP and rely on PIRATE for compiling PIR. This frontend will act as a starting point for a parrot executable that no longer relys on IMCC.
This schedule is written in terms of milestones, so the work listed on each date will be done in the week(s) prior.
May 16: My course-load for this quarter is heavy, but I intend to spend as much time as possible on IRC and reading existing sources and documentation. If time allows, I will create at least the skeleton of the library with the outline of code, tests and documentation.
May 16 - 20: Finals week at RIT. No GSoC work is likely during this time.
May 24 GSoC Start Date
May 30 PAST NQP Framework: Convert PAST into NQP-based files via Q:PIR constructs. This will involve splitting Node.pir into separate files for each class, providing a NQP structure for each sub and updating the build framework.
June 6 PAST::Node in NQP: Conversion of PAST::Node and it's seven subclasses into full NQP code.
June 13 PAST::Compiler in NQP: Convert PAST::Compiler to NQP.
June 20 Design PAST to newPOST Conversions: Emphasis for this week is on design rather than code. A complete list of what PAST constructs map to which newPOST constructs will be needed to have a roadmap for the next few weeks.
June 27: Begin converting PAST::Compiler to use the new POST classes using the conversions decided in the previous week.
July 4 Initial Conversions: At this point simple programs using PAST (likely via a simple HLL like Squaak) should compile directly to PBC via newPOST.
July 11 Midterm Evaluation, PAST::Compiler finished: All the conversions designed in June should be complete so new work can proceed. A list of any features found missing in POST should also be produced.
July 18 Bugfix: Before diving into any new features, this week is dedicated to fixing and cleaning up the code.
July 25 Evaluate NQP-rx's use of PAST: NQP itself is implemented using PAST and POST. Check for any constructs used in NQP that are not implmemented. Produce a list of missing features and prioritize them.
August 1 Annotations and Debugging: These features are known to be missing and will be added at this point, unless any other feature is deemed to be more important.
August 6 Additional Feature: If no other features are needed, an attempt at compile inline PIR nodes using pirate will be done.
August 16 Suggested 'Pencils down': Cleanup for possible merge to parrot.git. Additional eview will be solicited via parrot-dev and #parrot to help identify issues.
August 22 Final 'Pencils down', evaluation: Bugfixes and Buffer. This week is after the suggested "pencils down" date, so no work is planned for the final week. However it will be an opportunity to perform any last bugfixes or catch up for any time lost earlier.
Trac listed cotto and bacek as possible mentors for this project. I have spoken with bacek on #parrot regarding this proposal and have performed significant updates to it as a result.
- POST (parrot.git:compilers/pct/src/POST/)
- pirate (A PIR compiler written in PCT)
- Parrot in Parrot, A New Frontend
I whole-heartedly support open source licenses and will be more than happy to use the Artistic 2.0 license suggested by Parrot.
My name is Brian C Gernhardt and I'm currently attending the Rochester Institute of Technology to obtain my Masters in Computer Science. I did contracting for 4 years after getting my bachelor's degree (in CS from RIT). My current focus has been language design, and I just completed a project where I implemented a compiler on the JVM.
I've been following Parrot for a couple years due to my interest in Perl 6 and Rakudo. I try to regularly produce smoke reports, which has already resulted in a couple of Trac tickets (#1544 & #2001). For my compiler class, I wrote an introduction to the Parrot Compiler Toolkit. I've also worked on other open source projects. I've worked the most on git but have also worked on Ruby on Rails, Radiant and fink.
I've also been interested in a bytecode generator since I read the entry for it in the Parrot glossary:
Bytecode Generation: bcg will be part of the Parrot Compiler tools. It will aid in converting POST to bytecode.
Since my initials and the initials of the library match, I thought it would be an appropriate section of Parrot for me to work on.
I am 29 and currently attending the Rochester Institute of Technology to obtain my Master's in Computer Science. I have completed a quarter of graduate classes and can produce a transcript to prove such.