Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (36 sloc) 2.163 kb
cb35569 @atrodo Add a quick design pod.
authored
1 =head1 Design of Lorito
2
3 =head2 Less Magic == More Magic
4
5 I've designed Lorito with a few things in mind.
6
7 =over
8
9 =item It has to be minimal
10
11 One of the mixed blessings of Parrot is the large number of opcodes. Lorito
12 takes the opposite approach and tries to keep the number of opcodes to a bare
13 minimum. This means that only isgt appears, since both isgt and islt can be
14 implemented with only one opcode. As well, there are no opcodes that can be
15 done with as a call on a PMC.
16
17 =item It has to do things very predicably
18
19 Opcodes are a fixed size, and except for a few, well documented cases, only
20 operate on a single register set at a time. So an "INT ADD" will only operate
21 on integers. Magical opcodes, like PMC ADD, don't exist. They end up method
22 calls, and only make sense when the PMC implements the methods.
23
24 =item It has simplier, more flexable PMCs
25
26 PMCs can be thought of as chunks of memory. They are addressed and manipulated
27 like a real machine would manipulate RAM. The differance is that PMCs have
28 memory bounds, method dispatch and magic pointers. Objects and PMC are
29 combined in Lorito, so a PMC has the ablity to lookup and call methods just
30 like Objects. Outside of the PMC is a table of PMC pointers. When code
31 "encodes" a PMC into the memory, it saves an index into the magic PMC table
32 so that when the memory is "decoded" a PMC is returned. This prevents
33 arbitrary pointer manipulation that can lead to serious breaches if Lorito
34 was sandboxed.
35
36 =item It has to do common things fast
37
38 Some operations happen a lot in dyanmic langages. Method lookup and dispatch
39 is one of those operations. A portion of the opcodes above and beyond the
40 inital goal of 20 are dedicated to doing method lookup and calls quickly.
41
42 =item It has to allow for arbitrary method lookups
43
44 Dynamic languages have a vast array of ways to do method lookups. Lorito
45 can't dictate one way. So, each PMC has a lookup PMC which is callable and
46 a vtable PMC. The lookup opcode calls the lookup PMC with the vtable PMC
47 and returns a callable PMC back. That puts all of the method lookup
48 responsiblity into the hands of the language writters.
49
50 =back
51
52
Something went wrong with that request. Please try again.