Skip to content

Instantly share code, notes, and snippets.

View rue's full-sized avatar

Rue Saynatkari rue

View GitHub Profile
@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}
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,
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()` */
@rue
rue / gist:8997
Created September 5, 2008 17:23 — forked from dgtized/gist:8993
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) {
#include <ucontext.h>
#include <iostream>
using namespace std;
ucontext_t retctx;
std::size_t ssize = 1024 * 64;
char* stack = new char[ssize];
@rue
rue / gist:10253
Created September 11, 2008 16:41 — forked from anonymous/gist:10246
/**
* 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; \
@rue
rue / gist:10327
Created September 11, 2008 22:09
/**
* 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
*
@rue
rue / gist:10536
Created September 13, 2008 00:24
#include <list>
#include <iostream>
#include <iterator>
int main()
{
std::list<int> l;
std::list<int>::iterator i1 = l.insert(l.end(), 1);
@rue
rue / gist:11103
Created September 16, 2008 18:59
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
------------
@rue
rue / gist:11260
Created September 17, 2008 17:26
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. */