OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 7471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7482 } | 7482 } |
7483 } | 7483 } |
7484 | 7484 |
7485 if (result == NULL) { | 7485 if (result == NULL) { |
7486 result = NewUncasted<HPower>(left, right); | 7486 result = NewUncasted<HPower>(left, right); |
7487 } | 7487 } |
7488 ast_context()->ReturnInstruction(result, expr->id()); | 7488 ast_context()->ReturnInstruction(result, expr->id()); |
7489 return true; | 7489 return true; |
7490 } | 7490 } |
7491 break; | 7491 break; |
| 7492 case kMathRandom: |
| 7493 if (argument_count == 1 && check_type == RECEIVER_MAP_CHECK) { |
| 7494 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); |
| 7495 Drop(1); // Receiver. |
| 7496 HGlobalObject* global_object = Add<HGlobalObject>(); |
| 7497 HRandom* result = New<HRandom>(global_object); |
| 7498 ast_context()->ReturnInstruction(result, expr->id()); |
| 7499 return true; |
| 7500 } |
| 7501 break; |
7492 case kMathMax: | 7502 case kMathMax: |
7493 case kMathMin: | 7503 case kMathMin: |
7494 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { | 7504 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { |
7495 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); | 7505 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); |
7496 HValue* right = Pop(); | 7506 HValue* right = Pop(); |
7497 HValue* left = Pop(); | 7507 HValue* left = Pop(); |
7498 Drop(1); // Receiver. | 7508 Drop(1); // Receiver. |
7499 HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin | 7509 HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin |
7500 : HMathMinMax::kMathMax; | 7510 : HMathMinMax::kMathMax; |
7501 HInstruction* result = NewUncasted<HMathMinMax>(left, right, op); | 7511 HInstruction* result = NewUncasted<HMathMinMax>(left, right, op); |
(...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9856 return ast_context()->ReturnControl(result, call->id()); | 9866 return ast_context()->ReturnControl(result, call->id()); |
9857 } | 9867 } |
9858 | 9868 |
9859 | 9869 |
9860 void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) { | 9870 void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) { |
9861 // %_Log is ignored in optimized code. | 9871 // %_Log is ignored in optimized code. |
9862 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); | 9872 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); |
9863 } | 9873 } |
9864 | 9874 |
9865 | 9875 |
| 9876 // Fast support for Math.random(). |
| 9877 void HOptimizedGraphBuilder::GenerateRandomHeapNumber(CallRuntime* call) { |
| 9878 HGlobalObject* global_object = Add<HGlobalObject>(); |
| 9879 HRandom* result = New<HRandom>(global_object); |
| 9880 return ast_context()->ReturnInstruction(result, call->id()); |
| 9881 } |
| 9882 |
| 9883 |
9866 // Fast support for StringAdd. | 9884 // Fast support for StringAdd. |
9867 void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) { | 9885 void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) { |
9868 ASSERT_EQ(2, call->arguments()->length()); | 9886 ASSERT_EQ(2, call->arguments()->length()); |
9869 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9887 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
9870 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 9888 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
9871 HValue* right = Pop(); | 9889 HValue* right = Pop(); |
9872 HValue* left = Pop(); | 9890 HValue* left = Pop(); |
9873 HInstruction* result = New<HStringAdd>(left, right, STRING_ADD_CHECK_BOTH); | 9891 HInstruction* result = New<HStringAdd>(left, right, STRING_ADD_CHECK_BOTH); |
9874 return ast_context()->ReturnInstruction(result, call->id()); | 9892 return ast_context()->ReturnInstruction(result, call->id()); |
9875 } | 9893 } |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10652 if (ShouldProduceTraceOutput()) { | 10670 if (ShouldProduceTraceOutput()) { |
10653 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10671 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10654 } | 10672 } |
10655 | 10673 |
10656 #ifdef DEBUG | 10674 #ifdef DEBUG |
10657 graph_->Verify(false); // No full verify. | 10675 graph_->Verify(false); // No full verify. |
10658 #endif | 10676 #endif |
10659 } | 10677 } |
10660 | 10678 |
10661 } } // namespace v8::internal | 10679 } } // namespace v8::internal |
OLD | NEW |