Revision: 4533 http://trac.macosforge.org/projects/ruby/changeset/4533 Author: lsansonetti@apple.com Date: 2010-09-21 18:00:06 -0700 (Tue, 21 Sep 2010) Log Message: ----------- issue write barriers when storing objects into Binding slots (this should fix most of the macirb crashers) Modified Paths: -------------- MacRuby/trunk/compiler.cpp MacRuby/trunk/compiler.h MacRuby/trunk/kernel.c Modified: MacRuby/trunk/compiler.cpp =================================================================== --- MacRuby/trunk/compiler.cpp 2010-09-20 23:04:00 UTC (rev 4532) +++ MacRuby/trunk/compiler.cpp 2010-09-22 01:00:06 UTC (rev 4533) @@ -154,6 +154,7 @@ reset_compiler_state(); + writeBarrierFunc = get_function("vm_gc_wb"); dispatchFunc = get_function("vm_dispatch"); fastPlusFunc = get_function("vm_fast_plus"); fastMinusFunc = get_function("vm_fast_minus"); @@ -6108,7 +6109,7 @@ } Value * -RoxorCompiler::compile_lvar_slot(ID name) +RoxorCompiler::compile_lvar_slot(ID name, bool *need_wb) { std::map<ID, Value *>::iterator iter = lvars.find(name); if (iter != lvars.end()) { @@ -6123,6 +6124,9 @@ printf("get_binding_lvar %s (%p)\n", rb_id2name(name), *(void **)var); #endif Value *int_val = ConstantInt::get(IntTy, (long)var); + if (need_wb != NULL) { + *need_wb = true; + } return new IntToPtrInst(int_val, RubyObjPtrTy, "", bb); } assert(current_block); @@ -6135,6 +6139,12 @@ } Value * +RoxorCompiler::compile_lvar_slot(ID name) +{ + return compile_lvar_slot(name, NULL); +} + +Value * RoxorCompiler::compile_dvar_assignment(ID vid, Value *val) { if (running_block != NULL) { @@ -6162,14 +6172,21 @@ bb = merge_bb; } - return compile_lvar_assignment(vid, val); } Value * RoxorCompiler::compile_lvar_assignment(ID vid, Value *val) { - new StoreInst(val, compile_lvar_slot(vid), bb); + bool need_wb = false; + Value *slot = compile_lvar_slot(vid, &need_wb); + if (need_wb) { + Value *args[] = { slot, val }; + return CallInst::Create(writeBarrierFunc, args, args + 2, "", bb); + } + else { + new StoreInst(val, slot, bb); + } return val; } Modified: MacRuby/trunk/compiler.h =================================================================== --- MacRuby/trunk/compiler.h 2010-09-20 23:04:00 UTC (rev 4532) +++ MacRuby/trunk/compiler.h 2010-09-22 01:00:06 UTC (rev 4533) @@ -141,6 +141,7 @@ bool block_declaration; AllocaInst *dispatch_argv; + Function *writeBarrierFunc; Function *dispatchFunc; Function *fastPlusFunc; Function *fastMinusFunc; @@ -411,6 +412,7 @@ void compile_rethrow_exception(void); void compile_pop_exception(int pos=0); Value *compile_lvar_slot(ID name); + Value *compile_lvar_slot(ID name, bool *need_wb); bool compile_lvars(ID *tbl); Value *compile_new_struct(Value *klass, std::vector<Value *> &fields); Value *compile_new_opaque(Value *klass, Value *val); Modified: MacRuby/trunk/kernel.c =================================================================== --- MacRuby/trunk/kernel.c 2010-09-20 23:04:00 UTC (rev 4532) +++ MacRuby/trunk/kernel.c 2010-09-22 01:00:06 UTC (rev 4533) @@ -25,6 +25,13 @@ #endif PRIMITIVE VALUE +vm_gc_wb(void *slot, void *val) +{ + GC_WB(slot, val); + return (VALUE)val; +} + +PRIMITIVE VALUE vm_ivar_get(VALUE obj, ID name, void *cache_p) { struct icache *cache = (struct icache *)cache_p;
participants (1)
-
source_changes@macosforge.org