forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
288 lines (216 loc) · 10.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!DOCTYPE html>
<html>
<head>
<title>Bootstrapping - Rubinius</title>
<meta content='text/html;charset=utf-8' http-equiv='content-type'>
<meta content='en' http-equiv='content-language'>
<meta content='Rubinius is an implementation of the Ruby programming language. The Rubinius bytecode virtual machine is written in C++. The bytecode compiler is written in pure Ruby. The vast majority of the core library is also written in Ruby, with some supporting primitives that interact with the VM directly.' name='description'>
<meta content='Less Than Three. <3. http://less.thanthree.com' name='author'>
<link href='/' rel='home'>
<link href='/' rel='start'>
<link href='/doc/en/build-system' rel='prev' title='Build System'>
<link href='/doc/en/virtual-machine' rel='next' title='Virtual Machine'>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script><![endif]-->
<script src="/javascripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="/javascripts/paging_keys.js" type="text/javascript"></script>
<script src="/javascripts/application.js" type="text/javascript"></script>
<style>article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style>
<link href="/stylesheets/blueprint/screen.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/blueprint/print.css" media="print" rel="stylesheet" type="text/css" />
<!--[if IE]><link href="/stylesheets/blueprint/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE]><link href="/stylesheets/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<link href="/stylesheets/pygments.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='container'>
<div class='span-21 doc_menu'>
<header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a id="blog" href="/blog/">Blog</a></li>
<li><a id="documentation" href="/doc/en/">Documentation</a></li>
<li><a href="/projects/">Projects</a></li>
<li><a href="/roadmap/">Roadmap</a></li>
<li><a href="/releases/">Releases</a></li>
</ul>
</nav>
</header>
</div>
<div class='span-3 last'>
<div id='version'>
<a href="/releases/1.2.3">1.2.3</a>
</div>
</div>
</div>
<div class="container languages">
<nav>
<span class="label">Languages:</span>
<ul>
<li><a href="/doc/de/"
>de</a></li>
<li><a href="/doc/en/"
class="current"
>en</a></li>
<li><a href="/doc/es/"
>es</a></li>
<li><a href="/doc/ja/"
>ja</a></li>
<li><a href="/doc/pl/"
>pl</a></li>
<li><a href="/doc/ru/"
>ru</a></li>
</ul>
</nav>
</div>
<div class="container doc_page_nav">
<span class="label">Previous:</span>
<a href="/doc/en/build-system">Build System</a>
<span class="label">Up:</span>
<a href="/doc/en/">Table of Contents</a>
<span class="label">Next:</span>
<a href="/doc/en/virtual-machine">Virtual Machine</a>
</div>
<div class="container documentation">
<h2>Bootstrapping</h2>
<p>Bootstrapping is the process of building up functionality of the system until
all Ruby code can be executed. There are seven stages to the bootstrap process:</p>
<ol>
<li>
<p>VM: The virtual machine is able to load and execute bytecode, send
messages (i.e. look up and execute methods), and all primitive functions
are available, but not yet hooked up as Ruby methods.</p>
<p>The Class class has to be manually set up this early in the process by
setting its class to be itself and its superclass to be Module. In
addition to Class and Module, a couple of other base classes are created
here including Object, Tuple, LookupTable, and MethodTable.</p>
<p>Now that classes can be defined, 35 or so built in classes are told to
initialize themselves, symbols for top level methods (:object_id, :call,
:protected, etc) are created, basic exceptions are defined, and
primitives are registered. Finally IO gets hooked up. Also at this stage,
several fundamental Ruby methods are bound to primitives.</p>
<p>At this point there is enough defined behavior to begin to load up the
rest of the runtime kernel which is all defined in ruby. This has to be
done in several passes as the language grows.</p>
</li>
<li>
<p>alpha: This starts the loading of Ruby code. The ability to open classes
and modules and define methods exists. The minimum functionality to
support the following methods is implemented in kernel/alpha.rb:</p>
<p>attr_reader :sym
attr_writer :sym
attr_accessor :sym
private :sym
protected :sym
module_function :sym
include mod</p>
<p>Also, it is possible to raise exceptions and cause the running process to
exit. This stage lays the foundation for the next two stages.</p>
</li>
<li>
<p>bootstrap: This stage continues to add the minimum functionality to
support loading platform and common. The primitive functions are added
for most of the kernel classes.</p>
</li>
<li>
<p>platform: The FFI (foreign function interface) system is implemented and
Ruby method interfaces to platform-specific functions are created. Once
this is set up, platform specific things such as pointers, file access,
math, and POSIX commands are attached.</p>
</li>
<li>
<p>common: The vast majority of the Ruby core library classes are
implemented. The Ruby core classes are kept as implementation-neutral as
possible. Also, most of the functionality for Rubinius specific classes
is added.</p>
</li>
<li>
<p>delta: Final versions of methods like #attr_reader, etc. are added. Also,
implementation-specific versions of methods that override the versions
provided in common are added.</p>
</li>
<li>
<p>loader: The compiled version of kernel/loader.rb is run.</p>
<p>The final stage sets up the life cycle of a ruby process. It starts by
connecting the VM to the system, sets up load paths, and reads
customization scripts from the home directory. It traps signals, and
processes command line arguments.</p>
<p>After that, it either runs the script passed to it from the command line
or boots up the interactive ruby shell. When that finishes, it runs any
at_exit blocks that had been registered, finalizes all objects, and
exits.</p>
</li>
</ol>
<h2 id="load-order">Load Order</h2>
<p>The files in the kernel directories bootstrap, platform, common, and delta,
implement the respective bootstrapping stages above. The order in
which these directories are loaded is specified in runtime/index.</p>
<p>When an rbc file is loaded, code at the script level and in class or module
bodies is executed. For instance, when loading</p>
<pre><code>class SomeClass
attr_accessor :value
end
</code></pre>
<p>the call to #attr_accessor will be run. This requires that any code called in
script, class, or module bodies be loaded before the file that calls the code.
The kernel/alpha.rb defines most of the code that will be needed at the script
or module level. However, other load order dependencies exist between some of
the platform, common, delta, and compiler files.</p>
<p>These load order dependencies are addressed by the load_order.txt file located
in each of the kernel/** directories. If you modify code that adds a load
order dependency, you must edit the load_order.txt files to place the depended
on file above the file that depends on it. Also, if you add a new file to one
of the kernel directories, you must add the file name to the load_order.txt
file in that directory. These files are copied to the appropriate runtime/**
directories during build. During each of the bootstrap stages above, the VM
loads the files listed in load_order.txt in order.</p>
</div>
<div class="container doc_page_nav">
<span class="label">Previous:</span>
<a href="/doc/en/build-system">Build System</a>
<span class="label">Up:</span>
<a href="/doc/en/">Table of Contents</a>
<span class="label">Next:</span>
<a href="/doc/en/virtual-machine">Virtual Machine</a>
</div>
<div class="container">
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'rubinius';
var disqus_identifier = '/doc/en/bootstrapping/';
var disqus_url = 'http://rubini.us/doc/en/bootstrapping/';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
<footer>
<div class='container'>
<nav>
<ul>
<li><a href="http://twitter.com/rubinius">Follow Rubinius on Twitter</a></li>
<li><a href="http://github.com/evanphx/rubinius">Fork Rubinius on github</a></li>
<li><a href="http://engineyard.com">An Engine Yard project</a></li>
<li id='credit'>
Site design by
<a href="http://less.thanthree.com">Less Than Three</a>
</li>
</ul>
</nav>
</div>
</footer>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-12328521-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>