[macruby-changes] [2632] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Sep 24 23:31:03 PDT 2009
Revision: 2632
http://trac.macosforge.org/projects/ruby/changeset/2632
Author: lsansonetti at apple.com
Date: 2009-09-24 23:31:03 -0700 (Thu, 24 Sep 2009)
Log Message:
-----------
fixed AOT compilation of literal ranges (objects should be retained)
Modified Paths:
--------------
MacRuby/trunk/compiler.cpp
MacRuby/trunk/compiler.h
MacRuby/trunk/range.c
Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp 2009-09-25 04:17:48 UTC (rev 2631)
+++ MacRuby/trunk/compiler.cpp 2009-09-25 06:31:03 UTC (rev 2632)
@@ -242,7 +242,8 @@
}
void
-RoxorCompiler::compile_single_when_argument(NODE *arg, Value *comparedToVal, BasicBlock *thenBB)
+RoxorCompiler::compile_single_when_argument(NODE *arg, Value *comparedToVal,
+ BasicBlock *thenBB)
{
Value *subnodeVal = compile_node(arg);
Value *condVal;
@@ -289,12 +290,14 @@
}
void
-RoxorCompiler::compile_when_arguments(NODE *args, Value *comparedToVal, BasicBlock *thenBB)
+RoxorCompiler::compile_when_arguments(NODE *args, Value *comparedToVal,
+ BasicBlock *thenBB)
{
switch (nd_type(args)) {
case NODE_ARRAY:
while (args != NULL) {
- compile_single_when_argument(args->nd_head, comparedToVal, thenBB);
+ compile_single_when_argument(args->nd_head, comparedToVal,
+ thenBB);
args = args->nd_next;
}
break;
@@ -2666,19 +2669,22 @@
Instruction *
RoxorCompiler::compile_range(Value *beg, Value *end, bool exclude_end,
- bool add_to_bb)
+ bool retain, bool add_to_bb)
{
if (newRangeFunc == NULL) {
- // VALUE rb_range_new(VALUE beg, VALUE end, int exclude_end);
+ // VALUE rb_range_new2(VALUE beg, VALUE end, int exclude_end,
+ // int retain);
newRangeFunc = cast<Function>(module->getOrInsertFunction(
- "rb_range_new",
- RubyObjTy, RubyObjTy, RubyObjTy, RubyObjTy, NULL));
+ "rb_range_new2",
+ RubyObjTy, RubyObjTy, RubyObjTy, Int32Ty, Int32Ty,
+ NULL));
}
std::vector<Value *> params;
params.push_back(beg);
params.push_back(end);
- params.push_back(exclude_end ? trueVal : falseVal);
+ params.push_back(ConstantInt::get(Int32Ty, exclude_end ? 1 : 0));
+ params.push_back(ConstantInt::get(Int32Ty, retain ? 1 : 0));
if (add_to_bb) {
return compile_protected_call(newRangeFunc, params);
@@ -5045,7 +5051,8 @@
case NODE_CASE:
{
Function *f = bb->getParent();
- BasicBlock *caseMergeBB = BasicBlock::Create(context, "case_merge", f);
+ BasicBlock *caseMergeBB = BasicBlock::Create(context,
+ "case_merge", f);
PHINode *pn = PHINode::Create(RubyObjTy, "case_tmp",
caseMergeBB);
@@ -5382,8 +5389,7 @@
Instruction *call = compile_range(
ConstantInt::get(RubyObjTy, beg),
ConstantInt::get(RubyObjTy, end),
- exclude_end,
- false);
+ exclude_end, true, false);
Instruction *assign = new StoreInst(call, gvar, "");
Modified: MacRuby/trunk/compiler.h
===================================================================
--- MacRuby/trunk/compiler.h 2009-09-25 04:17:48 UTC (rev 2631)
+++ MacRuby/trunk/compiler.h 2009-09-25 06:31:03 UTC (rev 2632)
@@ -314,7 +314,7 @@
Value *compile_arity(rb_vm_arity_t &arity);
Instruction *compile_range(Value *beg, Value *end, bool exclude_end,
- bool add_to_bb=true);
+ bool retain=false, bool add_to_bb=true);
Value *compile_literal(VALUE val);
virtual Value *compile_immutable_literal(VALUE val);
virtual Value *compile_global_entry(NODE *node);
Modified: MacRuby/trunk/range.c
===================================================================
--- MacRuby/trunk/range.c 2009-09-25 04:17:48 UTC (rev 2631)
+++ MacRuby/trunk/range.c 2009-09-25 06:31:03 UTC (rev 2632)
@@ -69,6 +69,16 @@
return range;
}
+VALUE
+rb_range_new2(VALUE beg, VALUE end, int exclude_end, int retain)
+{
+ VALUE range = rb_range_new(beg, end, exclude_end);
+ if (retain) {
+ GC_RETAIN(range);
+ }
+ return range;
+}
+
/*
* call-seq:
* Range.new(start, end, exclusive=false) => range
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090924/449a78fc/attachment.html>
More information about the macruby-changes
mailing list