OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4086 case kMathSqrt: | 4086 case kMathSqrt: |
4087 if (argument_count == 2) { | 4087 if (argument_count == 2) { |
4088 HValue* argument = Pop(); | 4088 HValue* argument = Pop(); |
4089 // Pop receiver. | 4089 // Pop receiver. |
4090 Pop(); | 4090 Pop(); |
4091 HUnaryMathOperation* op = new HUnaryMathOperation(argument, id); | 4091 HUnaryMathOperation* op = new HUnaryMathOperation(argument, id); |
4092 PushAndAdd(op, expr->position()); | 4092 PushAndAdd(op, expr->position()); |
4093 return true; | 4093 return true; |
4094 } | 4094 } |
4095 break; | 4095 break; |
4096 case kMathPow: | |
4097 if (argument_count == 3) { | |
4098 HValue* right = Pop(); | |
4099 HValue* left = Pop(); | |
4100 Pop(); // Pop receiver. | |
4101 // Use sqrt() if exponent is 0.5 or -0.5. | |
4102 if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { | |
4103 double exponent = HConstant::cast(right)->DoubleValue(); | |
4104 if (exponent == 0.5) { | |
4105 PushAndAdd(new HUnaryMathOperation(left, kMathPowHalf)); | |
4106 return true; | |
4107 } else if (exponent == -0.5) { | |
4108 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.
| |
4109 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.
| |
4110 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.
| |
4111 HValue* right_1 = Pop(); | |
4112 HValue* left_1 = Pop(); | |
4113 PushAndAdd(new HDiv(left_1, right_1)); | |
4114 return true; | |
4115 } else if (exponent == 2.0) { | |
4116 PushAndAdd(new HMul(left, left)); | |
4117 return true; | |
4118 } | |
4119 } | |
4120 if (right->IsConstant() && | |
4121 HConstant::cast(right)->HasInteger32Value() && | |
4122 HConstant::cast(right)->Integer32Value() == 2) { | |
4123 PushAndAdd(new HMul(left, left)); | |
4124 return true; | |
4125 } | |
4126 | |
4127 PushAndAdd(new HPower(left, right)); | |
4128 return true; | |
4129 } | |
4130 break; | |
4096 default: | 4131 default: |
4097 // Either not a special math function or not yet supported for inlining. | 4132 // Either not a special math function or not yet supported for inlining. |
4098 break; | 4133 break; |
4099 } | 4134 } |
4100 return false; | 4135 return false; |
4101 } | 4136 } |
4102 | 4137 |
4103 | 4138 |
4104 bool HGraphBuilder::TryCallApply(Call* expr) { | 4139 bool HGraphBuilder::TryCallApply(Call* expr) { |
4105 Expression* callee = expr->expression(); | 4140 Expression* callee = expr->expression(); |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5013 | 5048 |
5014 // Fast call for custom callbacks. | 5049 // Fast call for custom callbacks. |
5015 void HGraphBuilder::GenerateCallFunction(int argument_count) { | 5050 void HGraphBuilder::GenerateCallFunction(int argument_count) { |
5016 BAILOUT("inlined runtime function: CallFunction"); | 5051 BAILOUT("inlined runtime function: CallFunction"); |
5017 } | 5052 } |
5018 | 5053 |
5019 | 5054 |
5020 // Fast call to math functions. | 5055 // Fast call to math functions. |
5021 void HGraphBuilder::GenerateMathPow(int argument_count) { | 5056 void HGraphBuilder::GenerateMathPow(int argument_count) { |
5022 ASSERT_EQ(2, argument_count); | 5057 ASSERT_EQ(2, argument_count); |
5023 PushArgumentsForStubCall(argument_count); | 5058 HValue* right = Pop(); |
5024 PushAndAdd(new HCallStub(CodeStub::MathPow, argument_count), | 5059 HValue* left = Pop(); |
5025 RelocInfo::kNoPosition); | 5060 PushAndAdd(new HPower(left, right)); |
5026 } | 5061 } |
5027 | 5062 |
5028 | 5063 |
5029 void HGraphBuilder::GenerateMathSin(int argument_count) { | 5064 void HGraphBuilder::GenerateMathSin(int argument_count) { |
5030 ASSERT_EQ(1, argument_count); | 5065 ASSERT_EQ(1, argument_count); |
5031 PushArgumentsForStubCall(argument_count); | 5066 PushArgumentsForStubCall(argument_count); |
5032 HCallStub* instr = | 5067 HCallStub* instr = |
5033 new HCallStub(CodeStub::TranscendentalCache, argument_count); | 5068 new HCallStub(CodeStub::TranscendentalCache, argument_count); |
5034 instr->set_transcendental_type(TranscendentalCache::SIN); | 5069 instr->set_transcendental_type(TranscendentalCache::SIN); |
5035 PushAndAdd(instr, RelocInfo::kNoPosition); | 5070 PushAndAdd(instr, RelocInfo::kNoPosition); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5541 } | 5576 } |
5542 | 5577 |
5543 #ifdef DEBUG | 5578 #ifdef DEBUG |
5544 if (graph_ != NULL) graph_->Verify(); | 5579 if (graph_ != NULL) graph_->Verify(); |
5545 if (chunk_ != NULL) chunk_->Verify(); | 5580 if (chunk_ != NULL) chunk_->Verify(); |
5546 if (allocator_ != NULL) allocator_->Verify(); | 5581 if (allocator_ != NULL) allocator_->Verify(); |
5547 #endif | 5582 #endif |
5548 } | 5583 } |
5549 | 5584 |
5550 } } // namespace v8::internal | 5585 } } // namespace v8::internal |
OLD | NEW |