Ruby internals
(or how your code runs)
¿Interpretado o compilado?
Ruby:
Pre 1.9
1.9 +
Interpretado (no VM)
Compilado
Se introduce YARV
(Yet Another Ruby VM)
Ejecucíon de codigo en MRI:
Ejecucion en ruby 1.8
// https://github.com/ruby/ruby/blob/v1_8_6_111/
// eval.c
static VALUE /* Line 2924*/
rb_eval(self, n)
VALUE self;
NODE *n;
{
NODE * volatile contnode = 0;
NODE * volatile node = n;
int state;
volatile VALUE result = Qnil;
#define RETURN(v) \
do {
result = (v); \
goto finish; \
} while (0)
again:
if (!node) RETURN(Qnil);
ruby_current_node = node;
switch (nd_type(node)) {
case NODE_BLOCK:
/* ... */
case NODE_POSTEXE:
/* ... */
case NODE_BEGIN:
/*
.
.
.
*/
finish:
CHECK_INTS;
if (contnode) {
node = contnode;
contnode = 0;
goto again;
}
return result;
} /* Line 4144 */
puts 2 + 3
Instruction sequence de un script simple
2
Stack
3
Text
putobject 2
putobject 3
opt_plus <callinfo!mid:+, ...>
opt_send_without_block <callinfo!mid:puts, ...>
leave
deck
By jjant
deck
- 104