+ All Categories
Home > Documents > Bringing Reflection to Life with First-Class...

Bringing Reflection to Life with First-Class...

Date post: 24-May-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
22
Bringing Reflection to Life with First-Class Interpreters Toon Verwaest Camillo Bruni David Gurtner Adrian Lienhard Oscar Nierstrasz Software Composition Group University of Bern Switzerland
Transcript
Page 1: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

Bringing Reflection to Lifewith First-Class Interpreters

Toon VerwaestCamillo BruniDavid GurtnerAdrian Lienhard Oscar Nierstrasz

Software Composition GroupUniversity of Bern

Switzerland

Page 2: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

2

debugging is hard

Page 3: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

3

developing debuggers is

even harder

Page 4: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

System.out.println

Page 5: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

5

Object-Flow Debugger

Lienhard '07Lienhard '07

Page 6: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

6

modifications to the

Virtual Machine

Page 7: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

7

A programming language

is a notational system for describing computation

in a machine-readable and human-readable form.

— Louden

Page 8: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

8

Human-Readable Machine-Readable

Page 9: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

9

What if we

could build a

specialized debugger

in just a few hours?

Page 10: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

10

modify the interpretation

in the language itself

in terms of

the source code

Page 11: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

11

Page 12: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

12

Page 13: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

13

Debugger interpret: [ Person new ]

Page 14: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

14

Debugger interpret: [ Person new ]

structural reflection

Page 15: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

15

continuousbehavioralreflection

Page 16: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

16

send: message to: receiver: class: classself print:

receiver class name, '>>', message.

^ self debugShellWithAction:[super

send: messageto: receiverclass: class ]

Page 17: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

17

recursive AST visitors

garbage collection

object model

Page 18: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

18

AliasInterpreter interpret: [

p := Person new.p name: 'John'.p name: 'Doe'.

]

Alias Interpreter

Page 19: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

19

interpretMethod: method| result |result := super interpretMethod: method.^ (ReturnAlias alias: result)

environment: environment

Alias Interpreter

Page 20: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

20

Performance (fib)

Pinocchio

Metacircular

2x slower than Pharo2x slower than Ruby 1.9

2x faster than Python 2.6.4 5x faster than Ruby 1.8

160x slower Pinocchio

Page 21: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

21

Performance (fib)

Pinocchio

MetacircularJava

2x slower than Pharo2x slower than Ruby 1.9

2x faster than Python 2.6.4 5x faster than Ruby 1.8

160x slower Pinocchio 160x faster than Ruby 1.8

Page 22: Bringing Reflection to Life with First-Class Interpretersscg.unibe.ch/download/pinocchio/pinocchio-2010-10-19.pdf · with First-Class Interpreters Toon Verwaest Camillo Bruni David

22

● recursive AST visitors● extensible using OO techniques● implemented practical debuggers

Future work● performance is not addressed yet


Recommended