Skip to content

Instantly share code, notes, and snippets.

View gist:8077
@offset = 0
@active_branches = [0]
@inactive_branches = {}
@max_stack = 0
stream.each {|inst|
case inst
when git, gif
@active_branches.each {|n| @inactive_branches[label.ip] = n}
View gist:8145
Breakpoint 2, op_send_super_stack_with_block (task=0x1818288, js=0x18183fc, index=0, count=1) at vm/gen/instructions.cpp:373
373 bool res = task->send_message(msg);
(gdb) p msg
$1 = (class rubinius::Message &) @0x1b7edf0: {
state = 0x1009400,
arguments = 0x0,
task = 0x1818288,
argument_start = 0,
send_site = 0x181813c,
name = 0x923,
View gist:8567
STATE /* state */; /**< Access to the VM state. */
Array* arguments; /**< Arguments from the call. */
Task* task; /**< Access to the Task the method call runs in. */
size_t argument_start; /**< NOT USED. Index where arguments would start. */
/** SendSite in which this call originates. */
SendSite* send_site;
/** Name of the method being called (comes from SendSite) */
SYMBOL name;
/** Receiver in the call, i.e. obj in `obj.foo()` */
View gist:8997
diff --git a/vm/exception.hpp b/vm/exception.hpp
index 1c4ffb0..9732b42 100644
--- a/vm/exception.hpp
+++ b/vm/exception.hpp
@@ -70,10 +70,8 @@ namespace rubinius {
static void raise(size_t expected, size_t given);
static void raise(const char* reason);
- ArgumentError(size_t e, size_t g) : expected(e), given(g) { }
- ArgumentError(const char* reason) {
View gist:9542
#include <ucontext.h>
#include <iostream>
using namespace std;
ucontext_t retctx;
std::size_t ssize = 1024 * 64;
char* stack = new char[ssize];
View gist:10253
/**
* Create a writer method.
*
* For attr_writer(foo, SomeClass), creates void foo(STATE, SomeClass* obj)
* that sets the instance variable my_foo to the object given and runs the write
* barrier.
*/
#define attr_writer(name, type) void name(STATE, type* obj) { \
my_ ## name = obj; \
View gist:10327
/**
* This method always executes on the separate stack created for the context.
*
* Fortunately for us, Message always has an Array of arguments.
*
* Arity -3: VALUE func(VALUE argument_array);
* Arity -2: VALUE func(VALUE receiver, VALUE argument_array);
* Arity -1: VALUE func(int argument_count, VALUE*, VALUE receiver);
* Otherwise: VALUE func(VALUE receiver, VALUE arg1[, VALUE arg2, ...]); // Currently max 10 args
*
View gist:10536
#include <list>
#include <iostream>
#include <iterator>
int main()
{
std::list<int> l;
std::list<int>::iterator i1 = l.insert(l.end(), 1);
View gist:11103
Object Creation in C++
========================
Concerning creating objects of the builtin classes in Rubinius (i.e.
classes existing in `vm/builtin/`.) Internal-only objects do not use
this model.
Ruby Model
------------
View gist:11260
Action my_action; /**< Action requested to be performed. */
ucontext_t my_c_call_point; /**< Point to execute actual C dispatch (subtend stack) */
ucontext_t my_dispatch_point; /**< Point of return to dispatch code (vm stack) */
Message* my_message; /**< Message representing this call. */
NativeMethod* my_method; /**< Function-like object that actually implements the method. */
HandleStorage my_handles; /**< Object handles for this call. */
Object* my_return_value; /**< Return value from the call. */
VM* my_state; /**< VM state for this invocation. */
Task* my_task; /**< Task in which we are running. */