Skip to content

Instantly share code, notes, and snippets.

@zhuomingliang
Forked from Benabik/gist:2500370
Created April 26, 2012 15:34
Show Gist options
  • Save zhuomingliang/2500410 to your computer and use it in GitHub Desktop.
Save zhuomingliang/2500410 to your computer and use it in GitHub Desktop.
GSoC Proposal: 6model Integration

6model Integration

Short Description

6model is the object model created for Rakudo Perl 6 and the newest iteration of the NQP lanugage. It appears to be more flexible than the PMC object model. This project is an attempt to integrate 6model into the core of Parrot.

Project Description

Parrot's object model was insufficient for Rakudo Perl 6's needs, so jnthn built a new object system that has proven to work very well. It appears to be flexible enough to enable far more object models to co-exist than the current method of PMCs and VTABLEs. It would be highly desirable to bring that system back into Parrot's core. This project aims to do that in several phases:

First, 6model is simply imported into Parrot wholesale. It is currently implemented as an extension to Parrot in the newest version of nqp. It should be possible to simply integrate the existing code as is and have users load the 6model library when desired.

Second, integrating 6model into Parrot. This mostly consists of code movement and refactoring. The 6model API should be renamed and moved into new files to match other portions of the Parrot API. At this point, the VM interface (opcodes and PMCs) may still be dynamically loaded, but the core functionality is available from C as part of core Parrot.

Third, create a 6model view of PMCs. The simplest way to do this appears to be to create a PMC REPR (memory model) and HOW (object interface) that maps 6model concepts to PMCs. This would be the basis of a wider scale conversion of Parrot to use 6model. As more sections of Parrot work on 6model objects, they would use this REPR and HOW to interact with objects still in the older model.

It is unlikely that a full conversion of Parrot to use only 6model will be accomplished by the end of a single summer. This project aims instead to provide a solid foundation for that work.

Relation to Parrot

6model would be a large enabler for high-level languages on Parrot. It is already used by the largest "customer" of Parrot: Rakudo. Integrating their object system back into the core would allow use to benefit from their advances far more directly. The GSoC 2011 project Puffin stalled on incompatibilities between Python's view of objects and Parrot's. 6model would allow a future version of Puffin to have a more "native" version of objects and hopefully interact well with objects from outside Python.

On a more practical note, 6model currently depends on the public API of Parrot so it should be fairly resilient to any other changes made to Parrot during the summer. However, if any changes are made to the way Parrot handles objects, it will increase the work needed to merge this project into master.

Tools and Technologies Used

Because this project mostly consists of alterations to the core of Parrot, it will reuse the existing build infrastructure, documentation standards, and test system for Parrot.

The newest version of NQP will be used primarily for reference and the source of the 6model code. However, no additional code will be written using it to protect the project from any possible incompatibilities between NQP's version of 6model and Parrot's. The majority of the code will be in C, but any support code needed inside the VM will be written in Winxed. This will also serve as a useful proof that 6model can be accessed by multiple languages.

All development will be commited to a new branch in the main Parrot repository on github. It may be required or useful to have a version of nqp that uses the integrated version of 6model. If this is the case, the code will be commited to a personal fork of nqp on github.

Delivered Results

The following are all portions of the final product:

  • A 6model C API in Parrot
  • A 6model API for inside the VM (possibly still loaded dynamically)
  • Integration into existing build system
  • Documentation for functions, opcodes, and PMCs
  • A simple REPR and HOW
  • A REPR and HOW for existing PMCs

Project Milestones

  • Import 6model code: This is primarily about integrating the existing 6model code with Parrot's build system. 6model will be isolated from Parrot, but built along side it.

  • Code movement: Move 6model functions into places more appropriate for core APIs.

  • Simple REPR and HOW: Build a proof of concept REPR and HOW using the now semi-integrated 6model and Winxed. This experience will also be useful for building the PMC/6model integration. This REPR should use some variety of PMC as its base to interact with existing opcodes.

  • Design 6model PMC: Combining existing PMCs with 6model is a complex task. This week is set aside for planning, discussion, and experimentation.

  • Initial 6model PMC: The initial draft of the code to treat PMCs as 6model objects should be done here.

  • Initial op conversion: Some basic opcodes or APIs should be converted to use 6model operations instead of PMC APIs.

  • Refine integration: Some lessons will likely be learned while attempting to get Parrot to use the 6model API. Use that knowledge to tweak the 6model PMCs.

  • Non-PMC objects: Attempt to get a non-PMC based object running on the system.

  • See how well NQP handles using the integrated 6model and PMCs in place of its own implementation.

Allowances

As this is fairly experimental, there are plenty of things that could cause delays. Ideally the fact that 6model is already implemented in terms of existing Parrot APIs should allow it to proceed easily, but there are plenty of unknowns involved.

If things are delayed too much, then less integration of 6model and Parrot will be performed. The lowest bar for the project will be a version of Parrot that can support custom 6model objects without additional support. However, at the least it should be possible to treat 6model objects and PMCs equally.

Additional Ideas

Any additional time available will easily be consumed by converting more portions of parrot to access objects via the 6model API instead of PMCs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment