[macruby-changes] [1866] MacRuby/branches/fp-optimized-experimental/compiler.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 15 17:51:36 PDT 2009
Revision: 1866
http://trac.macosforge.org/projects/ruby/changeset/1866
Author: pthomson at apple.com
Date: 2009-06-15 17:51:35 -0700 (Mon, 15 Jun 2009)
Log Message:
-----------
Fixed some, but not all, zero-division issues.
Modified Paths:
--------------
MacRuby/branches/fp-optimized-experimental/compiler.cpp
Modified: MacRuby/branches/fp-optimized-experimental/compiler.cpp
===================================================================
--- MacRuby/branches/fp-optimized-experimental/compiler.cpp 2009-06-16 00:39:00 UTC (rev 1865)
+++ MacRuby/branches/fp-optimized-experimental/compiler.cpp 2009-06-16 00:51:35 UTC (rev 1866)
@@ -1789,9 +1789,11 @@
}
PHINode *
-RoxorCompiler::compile_variable_and_integral_node(SEL sel, long fixedLong, bool leftIsFixed, Value *targetVal, Value *otherVal,
+RoxorCompiler::compile_variable_and_integral_node(SEL sel, long fixedLong, bool leftToRight, Value *targetVal, Value *otherVal,
int argc, std::vector<Value *> ¶ms) {
-
+ if ((!leftToRight) && (fixedLong == 0) && (sel == selDIV)) {
+ return NULL; // division by zero
+ }
GlobalVariable *is_redefined = GET_VM()->redefined_op_gvar(sel, true);
// Either one or both of the operands was not a fixable constant.
Value *is_redefined_val = new LoadInst(is_redefined, "", bb);
@@ -1831,7 +1833,7 @@
Value *unboxedLeft = NULL;
Value *unboxedRight = NULL;
- if (leftIsFixed) {
+ if (leftToRight) {
unboxedLeft = ConstantInt::get(RubyObjTy, fixedLong);
unboxedRight = BinaryOperator::CreateAShr(targetVal, twoVal, "", bb);
} else {
@@ -2030,9 +2032,12 @@
}
PHINode *
-RoxorCompiler::compile_variable_and_floating_node(SEL sel, double fixedDouble, bool leftIsFixed, Value *targetVal, Value *otherVal,
+RoxorCompiler::compile_variable_and_floating_node(SEL sel, double fixedDouble, bool leftToRight, Value *targetVal, Value *otherVal,
int argc, std::vector<Value *> ¶ms)
{
+ if ((!leftToRight) && (fixedDouble == 0.0) && (sel == selDIV)) {
+ return NULL; // division by zero
+ }
GlobalVariable *is_redefined = GET_VM()->redefined_op_gvar(sel, true);
// Either one or both of the operands was not a fixable constant.
Value *is_redefined_val = new LoadInst(is_redefined, "", bb);
@@ -2071,8 +2076,7 @@
Value *left = NULL;
Value *right = NULL;
- if (leftIsFixed) {
-
+ if (leftToRight) {
left = ConstantFP::get(Type::DoubleTy, fixedDouble);
right = BinaryOperator::CreateXor(targetVal, threeVal, "", bb);
right = new BitCastInst(right, Type::DoubleTy, "", bb);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090615/1a5a2db5/attachment.html>
More information about the macruby-changes
mailing list