Index: src/hydrogen.cc |
=================================================================== |
--- src/hydrogen.cc (revision 5940) |
+++ src/hydrogen.cc (working copy) |
@@ -4093,6 +4093,41 @@ |
return true; |
} |
break; |
+ case kMathPow: |
+ if (argument_count == 3) { |
+ HValue* right = Pop(); |
+ HValue* left = Pop(); |
+ Pop(); // Pop receiver. |
+ // Use sqrt() if exponent is 0.5 or -0.5. |
+ if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { |
+ double exponent = HConstant::cast(right)->DoubleValue(); |
+ if (exponent == 0.5) { |
+ PushAndAdd(new HUnaryMathOperation(left, kMathPowHalf)); |
+ return true; |
+ } else if (exponent == -0.5) { |
+ PushAndAdd(graph_->GetConstant1()-> |
Kevin Millikin (Chromium)
2010/12/08 10:01:46
I don't understand why you push this on the bailou
William Hesse
2010/12/08 13:37:00
Done.
|
+ CopyToRepresentation(Representation::Double())); |
Kevin Millikin (Chromium)
2010/12/08 10:01:46
This seems too roundabout. Is there a reason not
William Hesse
2010/12/08 13:37:00
Done.
|
+ PushAndAdd(new HUnaryMathOperation(left, kMathPowHalf)); |
Kevin Millikin (Chromium)
2010/12/08 10:01:46
Nor this.
William Hesse
2010/12/08 13:37:00
Done.
|
+ HValue* right_1 = Pop(); |
+ HValue* left_1 = Pop(); |
+ PushAndAdd(new HDiv(left_1, right_1)); |
+ return true; |
+ } else if (exponent == 2.0) { |
+ PushAndAdd(new HMul(left, left)); |
+ return true; |
+ } |
+ } |
+ if (right->IsConstant() && |
+ HConstant::cast(right)->HasInteger32Value() && |
+ HConstant::cast(right)->Integer32Value() == 2) { |
+ PushAndAdd(new HMul(left, left)); |
+ return true; |
+ } |
+ |
+ PushAndAdd(new HPower(left, right)); |
+ return true; |
+ } |
+ break; |
default: |
// Either not a special math function or not yet supported for inlining. |
break; |
@@ -5020,9 +5055,9 @@ |
// Fast call to math functions. |
void HGraphBuilder::GenerateMathPow(int argument_count) { |
ASSERT_EQ(2, argument_count); |
- PushArgumentsForStubCall(argument_count); |
- PushAndAdd(new HCallStub(CodeStub::MathPow, argument_count), |
- RelocInfo::kNoPosition); |
+ HValue* right = Pop(); |
+ HValue* left = Pop(); |
+ PushAndAdd(new HPower(left, right)); |
} |