| 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 6335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6346 | 6346 |
| 6347 | 6347 |
| 6348 int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) { | 6348 int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) { |
| 6349 if (!FLAG_use_inlining) return kNotInlinable; | 6349 if (!FLAG_use_inlining) return kNotInlinable; |
| 6350 | 6350 |
| 6351 // Precondition: call is monomorphic and we have found a target with the | 6351 // Precondition: call is monomorphic and we have found a target with the |
| 6352 // appropriate arity. | 6352 // appropriate arity. |
| 6353 Handle<JSFunction> caller = current_info()->closure(); | 6353 Handle<JSFunction> caller = current_info()->closure(); |
| 6354 Handle<SharedFunctionInfo> target_shared(target->shared()); | 6354 Handle<SharedFunctionInfo> target_shared(target->shared()); |
| 6355 | 6355 |
| 6356 // Always inline builtins marked for inlining. | |
| 6357 if (target->IsBuiltin()) { | |
| 6358 return target_shared->inline_builtin() ? 0 : kNotInlinable; | |
| 6359 } | |
| 6360 | |
| 6361 // Do a quick check on source code length to avoid parsing large | 6356 // Do a quick check on source code length to avoid parsing large |
| 6362 // inlining candidates. | 6357 // inlining candidates. |
| 6363 if (target_shared->SourceSize() > | 6358 if (target_shared->SourceSize() > |
| 6364 Min(FLAG_max_inlined_source_size, kUnlimitedMaxInlinedSourceSize)) { | 6359 Min(FLAG_max_inlined_source_size, kUnlimitedMaxInlinedSourceSize)) { |
| 6365 TraceInline(target, caller, "target text too big"); | 6360 TraceInline(target, caller, "target text too big"); |
| 6366 return kNotInlinable; | 6361 return kNotInlinable; |
| 6367 } | 6362 } |
| 6368 | 6363 |
| 6369 // Target must be inlineable. | 6364 // Target must be inlineable. |
| 6370 if (!target_shared->IsInlineable()) { | 6365 if (!target->IsInlineable()) { |
| 6371 TraceInline(target, caller, "target not inlineable"); | 6366 TraceInline(target, caller, "target not inlineable"); |
| 6372 return kNotInlinable; | 6367 return kNotInlinable; |
| 6373 } | 6368 } |
| 6374 if (target_shared->dont_inline() || target_shared->dont_optimize()) { | 6369 if (target_shared->dont_inline() || target_shared->dont_optimize()) { |
| 6375 TraceInline(target, caller, "target contains unsupported syntax [early]"); | 6370 TraceInline(target, caller, "target contains unsupported syntax [early]"); |
| 6376 return kNotInlinable; | 6371 return kNotInlinable; |
| 6377 } | 6372 } |
| 6378 | 6373 |
| 6379 int nodes_added = target_shared->ast_node_count(); | 6374 int nodes_added = target_shared->ast_node_count(); |
| 6380 return nodes_added; | 6375 return nodes_added; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6740 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); | 6735 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); |
| 6741 switch (id) { | 6736 switch (id) { |
| 6742 case kMathExp: | 6737 case kMathExp: |
| 6743 if (!FLAG_fast_math) break; | 6738 if (!FLAG_fast_math) break; |
| 6744 // Fall through if FLAG_fast_math. | 6739 // Fall through if FLAG_fast_math. |
| 6745 case kMathRound: | 6740 case kMathRound: |
| 6746 case kMathFloor: | 6741 case kMathFloor: |
| 6747 case kMathAbs: | 6742 case kMathAbs: |
| 6748 case kMathSqrt: | 6743 case kMathSqrt: |
| 6749 case kMathLog: | 6744 case kMathLog: |
| 6745 case kMathSin: |
| 6746 case kMathCos: |
| 6747 case kMathTan: |
| 6750 if (expr->arguments()->length() == 1) { | 6748 if (expr->arguments()->length() == 1) { |
| 6751 HValue* argument = Pop(); | 6749 HValue* argument = Pop(); |
| 6752 Drop(1); // Receiver. | 6750 Drop(1); // Receiver. |
| 6753 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); | 6751 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); |
| 6754 if (drop_extra) Drop(1); // Optionally drop the function. | 6752 if (drop_extra) Drop(1); // Optionally drop the function. |
| 6755 ast_context()->ReturnInstruction(op, expr->id()); | 6753 ast_context()->ReturnInstruction(op, expr->id()); |
| 6756 return true; | 6754 return true; |
| 6757 } | 6755 } |
| 6758 break; | 6756 break; |
| 6759 case kMathImul: | 6757 case kMathImul: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6818 } | 6816 } |
| 6819 break; | 6817 break; |
| 6820 case kMathExp: | 6818 case kMathExp: |
| 6821 if (!FLAG_fast_math) break; | 6819 if (!FLAG_fast_math) break; |
| 6822 // Fall through if FLAG_fast_math. | 6820 // Fall through if FLAG_fast_math. |
| 6823 case kMathRound: | 6821 case kMathRound: |
| 6824 case kMathFloor: | 6822 case kMathFloor: |
| 6825 case kMathAbs: | 6823 case kMathAbs: |
| 6826 case kMathSqrt: | 6824 case kMathSqrt: |
| 6827 case kMathLog: | 6825 case kMathLog: |
| 6826 case kMathSin: |
| 6827 case kMathCos: |
| 6828 case kMathTan: |
| 6828 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { | 6829 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { |
| 6829 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); | 6830 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); |
| 6830 HValue* argument = Pop(); | 6831 HValue* argument = Pop(); |
| 6831 Drop(1); // Receiver. | 6832 Drop(1); // Receiver. |
| 6832 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); | 6833 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); |
| 6833 ast_context()->ReturnInstruction(op, expr->id()); | 6834 ast_context()->ReturnInstruction(op, expr->id()); |
| 6834 return true; | 6835 return true; |
| 6835 } | 6836 } |
| 6836 break; | 6837 break; |
| 6837 case kMathPow: | 6838 case kMathPow: |
| (...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9137 ASSERT_EQ(2, call->arguments()->length()); | 9138 ASSERT_EQ(2, call->arguments()->length()); |
| 9138 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9139 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 9139 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 9140 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
| 9140 HValue* right = Pop(); | 9141 HValue* right = Pop(); |
| 9141 HValue* left = Pop(); | 9142 HValue* left = Pop(); |
| 9142 HInstruction* result = NewUncasted<HPower>(left, right); | 9143 HInstruction* result = NewUncasted<HPower>(left, right); |
| 9143 return ast_context()->ReturnInstruction(result, call->id()); | 9144 return ast_context()->ReturnInstruction(result, call->id()); |
| 9144 } | 9145 } |
| 9145 | 9146 |
| 9146 | 9147 |
| 9148 void HOptimizedGraphBuilder::GenerateMathSin(CallRuntime* call) { |
| 9149 ASSERT_EQ(1, call->arguments()->length()); |
| 9150 CHECK_ALIVE(VisitArgumentList(call->arguments())); |
| 9151 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1); |
| 9152 result->set_transcendental_type(TranscendentalCache::SIN); |
| 9153 Drop(1); |
| 9154 return ast_context()->ReturnInstruction(result, call->id()); |
| 9155 } |
| 9156 |
| 9157 |
| 9158 void HOptimizedGraphBuilder::GenerateMathCos(CallRuntime* call) { |
| 9159 ASSERT_EQ(1, call->arguments()->length()); |
| 9160 CHECK_ALIVE(VisitArgumentList(call->arguments())); |
| 9161 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1); |
| 9162 result->set_transcendental_type(TranscendentalCache::COS); |
| 9163 Drop(1); |
| 9164 return ast_context()->ReturnInstruction(result, call->id()); |
| 9165 } |
| 9166 |
| 9167 |
| 9168 void HOptimizedGraphBuilder::GenerateMathTan(CallRuntime* call) { |
| 9169 ASSERT_EQ(1, call->arguments()->length()); |
| 9170 CHECK_ALIVE(VisitArgumentList(call->arguments())); |
| 9171 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1); |
| 9172 result->set_transcendental_type(TranscendentalCache::TAN); |
| 9173 Drop(1); |
| 9174 return ast_context()->ReturnInstruction(result, call->id()); |
| 9175 } |
| 9176 |
| 9177 |
| 9147 void HOptimizedGraphBuilder::GenerateMathLog(CallRuntime* call) { | 9178 void HOptimizedGraphBuilder::GenerateMathLog(CallRuntime* call) { |
| 9148 ASSERT_EQ(1, call->arguments()->length()); | 9179 ASSERT_EQ(1, call->arguments()->length()); |
| 9149 CHECK_ALIVE(VisitArgumentList(call->arguments())); | 9180 CHECK_ALIVE(VisitArgumentList(call->arguments())); |
| 9150 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1); | 9181 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1); |
| 9151 result->set_transcendental_type(TranscendentalCache::LOG); | 9182 result->set_transcendental_type(TranscendentalCache::LOG); |
| 9152 Drop(1); | 9183 Drop(1); |
| 9153 return ast_context()->ReturnInstruction(result, call->id()); | 9184 return ast_context()->ReturnInstruction(result, call->id()); |
| 9154 } | 9185 } |
| 9155 | 9186 |
| 9156 | 9187 |
| 9157 void HOptimizedGraphBuilder::GenerateMathSqrt(CallRuntime* call) { | 9188 void HOptimizedGraphBuilder::GenerateMathSqrt(CallRuntime* call) { |
| 9158 ASSERT(call->arguments()->length() == 1); | 9189 ASSERT(call->arguments()->length() == 1); |
| 9159 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9190 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 9160 HValue* value = Pop(); | 9191 HValue* value = Pop(); |
| 9161 HInstruction* result = New<HUnaryMathOperation>(value, kMathSqrt); | 9192 HInstruction* result = New<HUnaryMathOperation>(value, kMathSqrt); |
| 9162 return ast_context()->ReturnInstruction(result, call->id()); | 9193 return ast_context()->ReturnInstruction(result, call->id()); |
| 9163 } | 9194 } |
| 9164 | 9195 |
| 9165 | |
| 9166 void HOptimizedGraphBuilder::GenerateMathFloor(CallRuntime* call) { | |
| 9167 ASSERT(call->arguments()->length() == 1); | |
| 9168 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | |
| 9169 HValue* value = Pop(); | |
| 9170 HInstruction* result = New<HUnaryMathOperation>(value, kMathFloor); | |
| 9171 return ast_context()->ReturnInstruction(result, call->id()); | |
| 9172 } | |
| 9173 | |
| 9174 | 9196 |
| 9175 // Check whether two RegExps are equivalent | 9197 // Check whether two RegExps are equivalent |
| 9176 void HOptimizedGraphBuilder::GenerateIsRegExpEquivalent(CallRuntime* call) { | 9198 void HOptimizedGraphBuilder::GenerateIsRegExpEquivalent(CallRuntime* call) { |
| 9177 return Bailout(kInlinedRuntimeFunctionIsRegExpEquivalent); | 9199 return Bailout(kInlinedRuntimeFunctionIsRegExpEquivalent); |
| 9178 } | 9200 } |
| 9179 | 9201 |
| 9180 | 9202 |
| 9181 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { | 9203 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { |
| 9182 ASSERT(call->arguments()->length() == 1); | 9204 ASSERT(call->arguments()->length() == 1); |
| 9183 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 9205 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9816 if (ShouldProduceTraceOutput()) { | 9838 if (ShouldProduceTraceOutput()) { |
| 9817 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9839 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 9818 } | 9840 } |
| 9819 | 9841 |
| 9820 #ifdef DEBUG | 9842 #ifdef DEBUG |
| 9821 graph_->Verify(false); // No full verify. | 9843 graph_->Verify(false); // No full verify. |
| 9822 #endif | 9844 #endif |
| 9823 } | 9845 } |
| 9824 | 9846 |
| 9825 } } // namespace v8::internal | 9847 } } // namespace v8::internal |
| OLD | NEW |