Revision: 3065 http://trac.macosforge.org/projects/ruby/changeset/3065 Author: lsansonetti@apple.com Date: 2009-11-30 18:42:59 -0800 (Mon, 30 Nov 2009) Log Message: ----------- prepare MacRuby for another LLVM transition Modified Paths: -------------- MacRuby/trunk/compiler.cpp MacRuby/trunk/rakelib/builder.rb MacRuby/trunk/vm.cpp Modified: MacRuby/trunk/compiler.cpp =================================================================== --- MacRuby/trunk/compiler.cpp 2009-11-30 21:04:26 UTC (rev 3064) +++ MacRuby/trunk/compiler.cpp 2009-12-01 02:42:59 UTC (rev 3065) @@ -1116,7 +1116,11 @@ Instruction *slot_insn = dyn_cast<Instruction>(slot); if (slot_insn != NULL) { +#if LLVM_TOT + Instruction *insn = slot_insn->clone(); +#else Instruction *insn = slot_insn->clone(context); +#endif BasicBlock::InstListType &list = bb->getInstList(); list.insert(list.end(), insn); return insn; @@ -1849,12 +1853,17 @@ Intrinsic::eh_exception); Value *eh_ptr = CallInst::Create(eh_exception_f, "", bb); -#if __LP64__ +#if LLVM_TOT Function *eh_selector_f = Intrinsic::getDeclaration(module, + Intrinsic::eh_selector); +#else +# if __LP64__ + Function *eh_selector_f = Intrinsic::getDeclaration(module, Intrinsic::eh_selector_i64); -#else +# else Function *eh_selector_f = Intrinsic::getDeclaration(module, Intrinsic::eh_selector_i32); +# endif #endif std::vector<Value *> params; @@ -1882,12 +1891,17 @@ if (eh_type != typeid(void)) { // TODO: this doesn't work yet, the type id must be a GlobalVariable... -#if __LP64__ +#if LLVM_TOT Function *eh_typeid_for_f = Intrinsic::getDeclaration(module, - Intrinsic::eh_typeid_for_i64); + Intrinsic::eh_typeid_for); #else +# if __LP64__ Function *eh_typeid_for_f = Intrinsic::getDeclaration(module, + Intrinsic::eh_typeid_for_i64); +# else + Function *eh_typeid_for_f = Intrinsic::getDeclaration(module, Intrinsic::eh_typeid_for_i32); +# endif #endif std::vector<Value *> params; params.push_back(compile_const_pointer((void *)&eh_type)); @@ -2943,7 +2957,11 @@ Instruction *slot_insn = dyn_cast<Instruction>(ivar_slot); if (slot_insn != NULL) { +#if LLVM_TOT + Instruction *insn = slot_insn->clone(); +#else Instruction *insn = slot_insn->clone(context); +#endif list.insert(list_iter, insn); params.push_back(insn); } @@ -5711,13 +5729,17 @@ list.insert(list.begin(), load); } + Function *ivarSlotAlloc = cast<Function>(module->getOrInsertFunction( + "rb_vm_ivar_slot_allocate", + Int32PtrTy, NULL)); + for (std::vector<GlobalVariable *>::iterator i = ivar_slots.begin(); i != ivar_slots.end(); ++i) { GlobalVariable *gvar = *i; - Instruction *call = new MallocInst(Int32Ty, ""); + Instruction *call = CallInst::Create(ivarSlotAlloc, ""); Instruction *assign1 = new StoreInst(ConstantInt::getSigned(Int32Ty, -1), call, ""); Instruction *assign2 = new StoreInst(call, gvar, ""); Modified: MacRuby/trunk/rakelib/builder.rb =================================================================== --- MacRuby/trunk/rakelib/builder.rb 2009-11-30 21:04:26 UTC (rev 3064) +++ MacRuby/trunk/rakelib/builder.rb 2009-12-01 02:42:59 UTC (rev 3065) @@ -92,7 +92,7 @@ CFLAGS = "-I. -I./include -I./onig -I/usr/include/libxml2 #{ARCHFLAGS} -fno-common -pipe -O3 -g -Wall -fexceptions" CFLAGS << " -Wno-parentheses -Wno-deprecated-declarations -Werror" if NO_WARN_BUILD OBJC_CFLAGS = CFLAGS + " -fobjc-gc-only" -CXXFLAGS = `#{LLVM_CONFIG} --cxxflags #{LLVM_MODULES}`.strip +CXXFLAGS = `#{LLVM_CONFIG} --cxxflags #{LLVM_MODULES}`.sub(/-DNDEBUG/, '').strip CXXFLAGS << " -I. -I./include -g -Wall #{ARCHFLAGS}" CXXFLAGS << " -Wno-parentheses -Wno-deprecated-declarations -Werror" if NO_WARN_BUILD LDFLAGS = `#{LLVM_CONFIG} --ldflags --libs #{LLVM_MODULES}`.strip.gsub(/\n/, '') @@ -116,7 +116,7 @@ OBJS_CFLAGS = { # Make sure everything gets inlined properly + compile as Objective-C++. - 'dispatcher' => '-Winline --param inline-unit-growth=10000 --param large-function-growth=10000 -x objective-c++' + 'dispatcher' => '--param inline-unit-growth=10000 --param large-function-growth=10000 -x objective-c++' } class Builder Modified: MacRuby/trunk/vm.cpp =================================================================== --- MacRuby/trunk/vm.cpp 2009-11-30 21:04:26 UTC (rev 3064) +++ MacRuby/trunk/vm.cpp 2009-12-01 02:42:59 UTC (rev 3065) @@ -29,6 +29,9 @@ #include <llvm/Support/raw_ostream.h> #include <llvm/Intrinsics.h> #include <llvm/Bitcode/ReaderWriter.h> +#if LLVM_TOT +# include <llvm/LLVMContext.h> +#endif using namespace llvm; #if ROXOR_COMPILER_DEBUG @@ -174,9 +177,19 @@ FunctionEnd)); } +#if LLVM_TOT + void deallocateFunctionBody(void *data) { + mm->deallocateFunctionBody(data); + } + + void deallocateExceptionTable(void *data) { + mm->deallocateExceptionTable(data); + } +#else void deallocateMemForFunction(const Function *F) { mm->deallocateMemForFunction(F); } +#endif uint8_t* startExceptionTable(const Function* F, uintptr_t &ActualSize) { @@ -1304,6 +1317,13 @@ } extern "C" +int * +rb_vm_ivar_slot_allocate(void) +{ + return (int *)malloc(sizeof(int)); +} + +extern "C" VALUE rb_vm_ivar_get(VALUE obj, ID name, int *slot_cache) {
participants (1)
-
source_changes@macosforge.org