Modified the REPL and Debugger prompts to be more consistent, and adjusted the Debugg...
[cslatevm.git] / README
blob274a673d250a811851ffbd421fe720a5132f5908
1 Information for the Slate Distribution
2 --------------------------------------
4  Slate is a prototype-based, multi-dispatch object-oriented language that
5  runs from a highly-customizable live environment. The implementation is
6  highly portable and relatively lightweight.
8  The reference site for this Distribution is at http://www.slatelanguage.org
9  and the Google Code project at: http://code.google.com/p/slate-language/
11  Bug reports and requests for information can be made via the Slate mailing
12  list, described at: http://groups.google.com/group/slate-language
14  See the wiki for more detailed documentation:
15  http://code.google.com/p/slate-language/w/list
17  See our bug-tracker for issues:
18  http://code.google.com/p/slate-language/issues/list
20 Setup
21 -----
23 'make' builds the VM.
24 'make slate.image' builds a standard saved image.
25 'make edit' launches the VM and standard image in Emacs with a scratch area.
27 Read common.mk for more options.
29 ./slate -i kernel.image                 "initial bootstrap (see below for more details)"
30 Image saveNamed: 'my.image'.         "save current image"
31 ./slate my.image                     "load a saved image"
33 Command Line
34 ------------
36 ./slate -i <image>
38 This starts slate using <image>.
40 Run 'slate -h' for more details.
42 Learning Slate
43 --------------
45 Read the TUTORIAL
47 Bootstrapping
48 -------------
50 If you make changes to core slate files (like adding a new field to
51 CompiledMethods), sometimes the only easy way to make those changes
52 throughout the system is to bootstrap again. Here is how you generate
53 a new kernel image:
55 Run slate to get a repl.
58 load: 'src/mobius/init.slate'.
59 Image littleEndian: True bitSize: 64.
60 ] do.
65 load: 'src/mobius/init.slate'.
66 Image littleEndian: True bitSize: 32.
67 ] do.
69 Then you will load it like a regular image:
71 ./slate kernel.new.<endian>.<wordsize>.<timestamp>.image
73 Debugging
74 ---------
75 make vmclean && make DEBUG=1
76 gdb slate
77 r <image-file>
78 (on crash or Ctrl-c)
80 f <n> (change frame to one with an 'oh' object (struct object_heap*))
82 See the slate backtrace -> print print_backtrace(oh)
83 Inspect an object       -> print print_detail(oh, struct Object*)
84 See the stack           -> print print_stack_types(oh, 200)
86 Source directory structure
87 --------------------------
89 src/vm -> The C files for the VM. Interprets bytecode and provides necessary facilities for primitives, gc, etc.
90 src/mobius -> The slate files for the compiler, lexer, bootstrap, and close-to-vm? facilities etc.
91 src/lib -> The core and not-so-core libraries for slate
92 src/plugins -> C code for slate FFI calls. `make plugins' to build
93 src/ui -> The slate UI code that probably calls plugins to draw the basics. load: 'src/ui/init.slate'.
94 src/ui/gtk -> The slate GTK interface. load: 'src/ui/gtk/demo.slate'.
95 src/net -> The slate networking code. load: 'src/net/init.slate'.
97 Stack format
98 ------------
100 The caller is about to call the callee.
101 fp at the time of the activation is equal to the current stack pointer plus the function frame size (6).
103 stack[fp-6] -> the stack pointer before the stack allocation for this frame + localvars + registers is done
104 stack[fp-5] -> the absolute position (stack location) of where the callee should place its result
105 stack[fp-4] -> the current code pointer (ip) of the caller
106 stack[fp-3] -> the callee's closure/method
107 stack[fp-2] -> the callee's lexical context (nil for stack allocated frames)
108 stack[fp-1] -> frame pointer of caller
109 stack[fp+0] .. stack[fp+lvCount+registerCount] -> local variables + registers
111 When you return from a function and you want to restore the frame in
112 the interpreter object to what it was before the call, you restore
113 everything based on fp (interpreter's current fp) except the closure
114 and the lexical context which are restored based on the saved
115 framepointer (at fp-1) using the previous frame (notice callee
116 vs. caller).
118 Compiler
119 --------
121 A simple example:
123 [ | :c genCode|
124 genCode: (c generate:
126  1 + 1
128 method sourceTree result: Nil &topLevel: True) code.
129 c decompile: genCode
130 ] applyWith: VM SSACompiler new.
134 Inside a function definition:
137 [ | :c genCode|
138 genCode: (c generate:
140  block@(Method traits) on: c@(Condition traits) do: handler
141 [| context |
142   context: (c cloneSettingSlots: #(handlers exitContinuation)
143               to: {{handler}. [| :result | ^ result]}).
144   conditionStack push: context.
145   block ensure: [conditionStack pop]
149 method sourceTree result: Nil &topLevel: True) code.
150 c decompile: genCode third code
151 ] applyWith: VM SSACompiler new.
154 Inside the closure:
156 [ | :c genCode|
157 genCode: (c generate:
159  block@(Method traits) on: c@(Condition traits) do: handler
160 [| context |
161   context: (c cloneSettingSlots: #(handlers exitContinuation)
162               to: {{handler}. [| :result | ^ result]}).
163   conditionStack push: context.
164   block ensure: [conditionStack pop]
168 method sourceTree result: Nil &topLevel: True) code.
169 c decompile: (genCode third code at: 13) code
170 ] applyWith: VM SSACompiler new.
173 "see what is getting called"
174 VM SSACompiler new decompile: (#handle: findOn: {mainWindow. PaintEvent newContext: mainWindow context}) method code.
177 Finding source code
178 -------------------
180 Besides using grep (which is better since it will find bootstrap
181 code), there are a few facilities. See the slate manual for more
182 details.
184 #as: implementations do: [|:each| each definitionLocation ifNotNilDo: [|:l| inform: (l as: String) ]].
186 (#parseExpression findOn: {Syntax Parser}) definitionLocation