Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design of the Parrot Virtual Machine The OO-ish bits

Similar presentations


Presentation on theme: "Design of the Parrot Virtual Machine The OO-ish bits"— Presentation transcript:

1 Design of the Parrot Virtual Machine The OO-ish bits
Dan Sugalski

2 Important notes The OO parts of the design aren’t complete
This is not a pure OO system I am not an OO guy We care about speed We don’t care about theoretical purity July 22, 2019 Design of the Parrot VM

3 Quick parrot design recap
Register based Bytecode driven Mostly language neutral July 22, 2019 Design of the Parrot VM

4 Multiple language support
Perl 6 Perl 5 Ruby Python JVM .NET Z-Machine July 22, 2019 Design of the Parrot VM

5 Challenges of the design
Several conflicting object systems Runtime instantiation of much of the system Dynamic redefinition of classes, methods, and types of objects Dynamic redefinition of inheritance hierarchies Object system differences must be invisible to user code July 22, 2019 Design of the Parrot VM

6 Programmer view of objects
Programmer shouldn’t care about the source of an object Programmer shouldn’t have to make any allowances for the source of an object when calling its methods It all ought to just work July 22, 2019 Design of the Parrot VM

7 Required end-user functionality
Check for Class parentage Method existence Call method Get property Set property July 22, 2019 Design of the Parrot VM

8 Implementation of objects
Objects are an opaque and fundamental variable type All variables have a core set of vtable functions Call method and the other minimal functionality is shared across all variables Since it all looks the same at this level, usage is consistent regardless of object type July 22, 2019 Design of the Parrot VM

9 Usage example my $foo; $foo = Some::Class.new();
$foo.a_method(12, 15); July 22, 2019 Design of the Parrot VM

10 Advantages of this scheme
Programs are isolated from the implementation details Doesn’t place many real restrictions on the implementation of objects Offers class authors plenty of flexibility July 22, 2019 Design of the Parrot VM

11 Disadvantages of this scheme
Programs are isolated from the implementation details Doesn’t place many real restrictions on the implementation of objects Offers class authors plenty of flexibility July 22, 2019 Design of the Parrot VM

12 Parrot’s object model requirements
Support at least two wildly different implementation models Be more efficient than perl 5’s object system July 22, 2019 Design of the Parrot VM

13 Required functionality
Untyped variables Runtime class changes on objects Runtime class mutation Runtime inheritance hierarchy changes Multiple inheritance Signature-based dispatch Cross-class-scheme inheritance July 22, 2019 Design of the Parrot VM

14 Requirements for classes
More stringent Need: List of methods in class List of immediate parent classes Parent class method search list Duplication capabilities Parent class method search scheme Redispatch scheme Attribute count Duplication capabilities mean whether the class can be really in the class hierarchy twice, or if multiple occurrences are thrown away so only one is in there July 22, 2019 Design of the Parrot VM

15 Easy Answer Do all inheritance with delegation At least conceptually
Does allow for inheritance from disparate object systems Performance is potentially an issue Shortcuts are definitely in order July 22, 2019 Design of the Parrot VM

16 Calling convention provides
Real self Current self Class offset Attribute start offset July 22, 2019 Design of the Parrot VM


Download ppt "Design of the Parrot Virtual Machine The OO-ish bits"

Similar presentations


Ads by Google