Bringing Reflection to Life with First-Class...

Post on 24-May-2020

1 views 0 download

transcript

Bringing Reflection to Lifewith First-Class Interpreters

Toon VerwaestCamillo BruniDavid GurtnerAdrian Lienhard Oscar Nierstrasz

Software Composition GroupUniversity of Bern

Switzerland

2

debugging is hard

3

developing debuggers is

even harder

System.out.println

5

Object-Flow Debugger

Lienhard '07Lienhard '07

6

modifications to the

Virtual Machine

7

A programming language

is a notational system for describing computation

in a machine-readable and human-readable form.

— Louden

8

Human-Readable Machine-Readable

9

What if we

could build a

specialized debugger

in just a few hours?

10

modify the interpretation

in the language itself

in terms of

the source code

11

12

13

Debugger interpret: [ Person new ]

14

Debugger interpret: [ Person new ]

structural reflection

15

continuousbehavioralreflection

16

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

receiver class name, '>>', message.

^ self debugShellWithAction:[super

send: messageto: receiverclass: class ]

17

recursive AST visitors

garbage collection

object model

18

AliasInterpreter interpret: [

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

]

Alias Interpreter

19

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

environment: environment

Alias Interpreter

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

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

22

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

Future work● performance is not addressed yet