[macruby-changes] [2325] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Aug 14 20:53:51 PDT 2009
Revision: 2325
http://trac.macosforge.org/projects/ruby/changeset/2325
Author: vincent.isambart at gmail.com
Date: 2009-08-14 20:53:51 -0700 (Fri, 14 Aug 2009)
Log Message:
-----------
when there are multiple returns in an ensure,
the function should now return the correct value
(this bug was found thanks to LLVM's module verifier)
Modified Paths:
--------------
MacRuby/trunk/compiler.cpp
MacRuby/trunk/compiler.h
MacRuby/trunk/vm.cpp
Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp 2009-08-15 03:53:45 UTC (rev 2324)
+++ MacRuby/trunk/compiler.cpp 2009-08-15 03:53:51 UTC (rev 2325)
@@ -51,6 +51,7 @@
current_rescue = false;
return_from_block = -1;
return_from_block_ids = 0;
+ ensure_pn = NULL;
dispatcherFunc = NULL;
fastPlusFunc = NULL;
@@ -1679,6 +1680,7 @@
else {
if (ensure_bb != NULL) {
BranchInst::Create(ensure_bb, bb);
+ ensure_pn->addIncoming(val, bb);
}
else {
ReturnInst::Create(val, bb);
@@ -4498,7 +4500,9 @@
Function *f = bb->getParent();
BasicBlock *old_ensure_bb = ensure_bb;
+ PHINode *old_ensure_pn = ensure_pn;
ensure_bb = BasicBlock::Create("ensure", f);
+ ensure_pn = PHINode::Create(RubyObjTy, "ensure.phi", ensure_bb);
Value *val;
if (nd_type(node->nd_head) != NODE_RESCUE) {
@@ -4515,6 +4519,7 @@
DEBUG_LEVEL_DEC();
rescue_bb = old_rescue_bb;
BranchInst::Create(ensure_bb, bb);
+ ensure_pn->addIncoming(val, bb);
bb = new_rescue_bb;
compile_landing_pad_header();
@@ -4524,10 +4529,14 @@
else {
val = compile_node(node->nd_head);
BranchInst::Create(ensure_bb, bb);
+ ensure_pn->addIncoming(val, bb);
}
+ val = ensure_pn;
+
bb = ensure_bb;
ensure_bb = old_ensure_bb;
+ ensure_pn = old_ensure_pn;
compile_node(node->nd_ensr);
return val;
Modified: MacRuby/trunk/compiler.h
===================================================================
--- MacRuby/trunk/compiler.h 2009-08-15 03:53:45 UTC (rev 2324)
+++ MacRuby/trunk/compiler.h 2009-08-15 03:53:51 UTC (rev 2325)
@@ -102,6 +102,7 @@
Value *current_loop_exit_val;
int return_from_block;
int return_from_block_ids;
+ PHINode *ensure_pn;
Function *dispatcherFunc;
Function *fastPlusFunc;
Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp 2009-08-15 03:53:45 UTC (rev 2324)
+++ MacRuby/trunk/vm.cpp 2009-08-15 03:53:51 UTC (rev 2325)
@@ -361,7 +361,7 @@
}
#if ROXOR_COMPILER_DEBUG
- if (verifyModule(*RoxorCompiler::module)) {
+ if (verifyModule(*RoxorCompiler::module, PrintMessageAction)) {
printf("Error during module verification\n");
exit(1);
}
@@ -385,7 +385,7 @@
uint64_t elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom;
- printf("compilation of LLVM function %p done, took %lld ns\n",
+ fprintf(stderr, "compilation of LLVM function %p done, took %lld ns\n",
func, elapsedNano);
#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090814/99894104/attachment-0001.html>
More information about the macruby-changes
mailing list