[macruby-changes] [1865] MacRuby/branches/fp-optimized-experimental

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 15 17:39:02 PDT 2009


Revision: 1865
          http://trac.macosforge.org/projects/ruby/changeset/1865
Author:   pthomson at apple.com
Date:     2009-06-15 17:39:00 -0700 (Mon, 15 Jun 2009)
Log Message:
-----------
Fixed a completely boneheaded bug in the precomplation sections.

Modified Paths:
--------------
    MacRuby/branches/fp-optimized-experimental/compiler.cpp
    MacRuby/branches/fp-optimized-experimental/compiler.h

Modified: MacRuby/branches/fp-optimized-experimental/compiler.cpp
===================================================================
--- MacRuby/branches/fp-optimized-experimental/compiler.cpp	2009-06-15 23:58:51 UTC (rev 1864)
+++ MacRuby/branches/fp-optimized-experimental/compiler.cpp	2009-06-16 00:39:00 UTC (rev 1865)
@@ -1789,7 +1789,7 @@
 }
 
 PHINode *
-RoxorCompiler::compile_variable_and_integral_node(SEL sel, long fixedLong, Value *targetVal, Value *otherVal, 
+RoxorCompiler::compile_variable_and_integral_node(SEL sel, long fixedLong, bool leftIsFixed, Value *targetVal, Value *otherVal, 
 												  int argc, std::vector<Value *> &params) {
 	
 	GlobalVariable *is_redefined = GET_VM()->redefined_op_gvar(sel, true);
@@ -1828,9 +1828,17 @@
 	}
 	bb = then2BB;
 	
-	Value *unboxedLeft = ConstantInt::get(RubyObjTy, fixedLong);
-	Value *unboxedRight = BinaryOperator::CreateAShr(targetVal, twoVal, "", bb);
+	Value *unboxedLeft = NULL;
+	Value *unboxedRight = NULL;
 	
+	if (leftIsFixed) {
+		unboxedLeft = ConstantInt::get(RubyObjTy, fixedLong);
+		unboxedRight = BinaryOperator::CreateAShr(targetVal, twoVal, "", bb);
+	} else {
+		unboxedLeft = BinaryOperator::CreateAShr(targetVal, twoVal, "", bb);
+		unboxedRight = ConstantInt::get(RubyObjTy, fixedLong);
+	}
+	
 	Value *opVal;
 	bool result_is_fixnum = true;
 	if (sel == selPLUS) {
@@ -2022,7 +2030,7 @@
 }
 
 PHINode *
-RoxorCompiler::compile_variable_and_floating_node(SEL sel, double fixedDouble, Value *targetVal, Value *otherVal,
+RoxorCompiler::compile_variable_and_floating_node(SEL sel, double fixedDouble, bool leftIsFixed, Value *targetVal, Value *otherVal,
 												  int argc, std::vector<Value *> &params)
 {
 	GlobalVariable *is_redefined = GET_VM()->redefined_op_gvar(sel, true);
@@ -2060,11 +2068,22 @@
 	}
 	bb = then2BB;
 	
-	Value *left = ConstantFP::get(Type::DoubleTy, fixedDouble);
-	Value *right = BinaryOperator::CreateXor(targetVal, threeVal, "", bb);
-	right = new BitCastInst(right, Type::DoubleTy, "", bb);
 	
+	Value *left = NULL;
+	Value *right = NULL;
+	if (leftIsFixed) {
+		
+		left = ConstantFP::get(Type::DoubleTy, fixedDouble);
+		right = BinaryOperator::CreateXor(targetVal, threeVal, "", bb);
+		right = new BitCastInst(right, Type::DoubleTy, "", bb);
+	} else {
+		right = ConstantFP::get(Type::DoubleTy, fixedDouble);
+		left = BinaryOperator::CreateXor(targetVal, threeVal, "", bb);
+		left = new BitCastInst(right, Type::DoubleTy, "", bb);
+	}
+
 	
+	
 	Value *opVal;
 	bool result_is_double = true;
 	if (sel == selPLUS) {
@@ -2092,9 +2111,8 @@
 	if (result_is_double) { 
 		Value *casted = new BitCastInst(opVal, IntTy, "", bb);
 		thenVal = BinaryOperator::CreateOr(casted, threeVal, "", bb);
-		
-		then3BB = then2BB;
-		BranchInst::Create(mergeBB, then3BB);
+		then3BB = bb;
+		BranchInst::Create(mergeBB, bb);
 	}
 	else {
 		thenVal = opVal;
@@ -2183,16 +2201,16 @@
 	else if ((!(leftIsFixFloatConstant || rightIsFixFloatConstant)) && (leftIsFixnumConstant || rightIsFixnumConstant)) {
 		// One of the operands is a fixnum, the other is a variable
 		if (leftIsFixnumConstant) {
-			return compile_variable_and_integral_node(sel, leftLong, rightVal, leftVal, argc, params);
+			return compile_variable_and_integral_node(sel, leftLong, true, rightVal, leftVal, argc, params);
 		}
 		else {
-			return compile_variable_and_integral_node(sel, rightLong, leftVal, rightVal, argc, params);
+			return compile_variable_and_integral_node(sel, rightLong, false, leftVal, rightVal, argc, params);
 		}
 	} else if((!(leftIsFixnumConstant || rightIsFixnumConstant)) && (leftIsFixFloatConstant || rightIsFixFloatConstant)) {
 		if (leftIsFixFloatConstant) {
-			return compile_variable_and_floating_node(sel, leftDouble, rightVal, leftVal, argc, params);
+			return compile_variable_and_floating_node(sel, leftDouble, true, rightVal, leftVal, argc, params);
 		} else {
-			return compile_variable_and_floating_node(sel, rightDouble, leftVal, rightVal, argc, params);
+			return compile_variable_and_floating_node(sel, rightDouble, false, leftVal, rightVal, argc, params);
 		}
 	} else {
 		return compile_variable_arith_node(sel, leftVal, rightVal, argc, params);

Modified: MacRuby/branches/fp-optimized-experimental/compiler.h
===================================================================
--- MacRuby/branches/fp-optimized-experimental/compiler.h	2009-06-15 23:58:51 UTC (rev 1864)
+++ MacRuby/branches/fp-optimized-experimental/compiler.h	2009-06-16 00:39:00 UTC (rev 1865)
@@ -188,11 +188,12 @@
 	PHINode *
 	precompile_floating_arith_node(SEL sel, double leftDouble, long rightDouble, int argc, std::vector<Value *> &params);
 	PHINode *
-	compile_variable_and_integral_node(SEL sel, long fixedLong, Value *val, Value *other, int argc,
+	compile_variable_and_integral_node(SEL sel, long fixedLong, bool leftIsFixed, Value *val, Value *other, int argc,
 													  std::vector<Value *> &params);
 	PHINode *
-	compile_variable_and_floating_node(SEL sel, double fixedDouble, Value *val, Value *other,
+	compile_variable_and_floating_node(SEL sel, double fixedDouble, bool leftIsFixed, Value *val, Value *other,
 									   int argc, std::vector<Value *> &params);
+	
 	PHINode *
 	compile_variable_arith_node(SEL sel, Value *leftVal, Value *rightVal, int argc, std::vector<Value *>params);
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090615/633a2afa/attachment-0001.html>


More information about the macruby-changes mailing list