Skip to content

Instantly share code, notes, and snippets.

<match path="project"> rubinius </match>
<formatter medium="irc">
<lineLimit>1</lineLimit>
<wrapWidth>150</wrapWidth>
<widthLimit>150</widthLimit>
<crunchWhitespace/>
<format appliesTo="CommitToIRC">
hoshi :: /var/log>
Message from syslogd@hoshi at Fri Aug 1 10:02:17 2008 ...
hoshi kernel: [172392.427177] Uhhuh. NMI received for unknown reason 3c on CPU 0.
Message from syslogd@hoshi at Fri Aug 1 10:02:17 2008 ...
hoshi kernel: [172392.431038] Do you have a strange power saving mode enabled?
Message from syslogd@hoshi at Fri Aug 1 10:02:17 2008 ...
hoshi kernel: [172392.431038] Dazed and confused, but trying to continue
sark :: git/rbx » rake 'compile_ruby[suck.rb]'
(in /Users/evanphx/git/rbx)
Compiling suck.rb
:push_nil [1, 0, 0]
[:set_local, 0] [0, 1, 1]
:pop [-1, 1, 1]
[:push_local, 0] [1, 0, 1]
[:send_method, 0] [0, 1, 1]
:meta_push_0 [1, 1, 1]
[:send_stack, 1, 1] [-1, 2, 2]
sark :: git/rbx » cat scratch/hello.rb
puts "hello world"
sark :: git/rbx » ./vm/jit-test scratch/hello.rbc
0x800800 push %ebp
0x800801 mov %esp, %ebp
0x800803 sub $0xc, %esp
0x800809 push %edi
0x80080a push %esi
0x80080b push %ebx

Lessons Learned

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

require 'benchmark'
cm = def blah
i = 0
while i < 10
j = 0
while j < 20000000
j += 1
end
i += 1
end
module Compiler::Plugins
class StaticConstantSet < Compiler::Plugin
register Compiler::Node::Call
def self.run(compiler, call)
if !call.object and
call.method == :static and
call.arguments.size == 1 and
call.arguments.first.is? Compiler::Node::ConstSet
cf = call.arguments.first
def blah
:works
end
[:broken].each do |blah|
puts "setup"
end
p blah
class TrySink
def initialize(obj)
@object = obj
end
undef class
def method_missing(meth, *a)
if @object.respond_to? meth
struct closure {
int a;
};
void show(int i);
typedef void (*block)(struct closure* data);
void block_code(struct closure* data) {
data->a += 1;