Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: src/hydrogen.cc

Issue 70003004: Reland "Implement Math.sin, cos and tan using table lookup and spline interpolation." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6687 matching lines...) Expand 10 before | Expand all | Expand 10 after
6698 6698
6699 6699
6700 int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) { 6700 int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) {
6701 if (!FLAG_use_inlining) return kNotInlinable; 6701 if (!FLAG_use_inlining) return kNotInlinable;
6702 6702
6703 // Precondition: call is monomorphic and we have found a target with the 6703 // Precondition: call is monomorphic and we have found a target with the
6704 // appropriate arity. 6704 // appropriate arity.
6705 Handle<JSFunction> caller = current_info()->closure(); 6705 Handle<JSFunction> caller = current_info()->closure();
6706 Handle<SharedFunctionInfo> target_shared(target->shared()); 6706 Handle<SharedFunctionInfo> target_shared(target->shared());
6707 6707
6708 // Always inline builtins marked for inlining.
6709 if (target->IsBuiltin()) {
6710 return target_shared->inline_builtin() ? 0 : kNotInlinable;
6711 }
6712
6708 // Do a quick check on source code length to avoid parsing large 6713 // Do a quick check on source code length to avoid parsing large
6709 // inlining candidates. 6714 // inlining candidates.
6710 if (target_shared->SourceSize() > 6715 if (target_shared->SourceSize() >
6711 Min(FLAG_max_inlined_source_size, kUnlimitedMaxInlinedSourceSize)) { 6716 Min(FLAG_max_inlined_source_size, kUnlimitedMaxInlinedSourceSize)) {
6712 TraceInline(target, caller, "target text too big"); 6717 TraceInline(target, caller, "target text too big");
6713 return kNotInlinable; 6718 return kNotInlinable;
6714 } 6719 }
6715 6720
6716 // Target must be inlineable. 6721 // Target must be inlineable.
6717 if (!target->IsInlineable()) { 6722 if (!target_shared->IsInlineable()) {
6718 TraceInline(target, caller, "target not inlineable"); 6723 TraceInline(target, caller, "target not inlineable");
6719 return kNotInlinable; 6724 return kNotInlinable;
6720 } 6725 }
6721 if (target_shared->dont_inline() || target_shared->dont_optimize()) { 6726 if (target_shared->dont_inline() || target_shared->dont_optimize()) {
6722 TraceInline(target, caller, "target contains unsupported syntax [early]"); 6727 TraceInline(target, caller, "target contains unsupported syntax [early]");
6723 return kNotInlinable; 6728 return kNotInlinable;
6724 } 6729 }
6725 6730
6726 int nodes_added = target_shared->ast_node_count(); 6731 int nodes_added = target_shared->ast_node_count();
6727 return nodes_added; 6732 return nodes_added;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
7087 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); 7092 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id();
7088 switch (id) { 7093 switch (id) {
7089 case kMathExp: 7094 case kMathExp:
7090 if (!FLAG_fast_math) break; 7095 if (!FLAG_fast_math) break;
7091 // Fall through if FLAG_fast_math. 7096 // Fall through if FLAG_fast_math.
7092 case kMathRound: 7097 case kMathRound:
7093 case kMathFloor: 7098 case kMathFloor:
7094 case kMathAbs: 7099 case kMathAbs:
7095 case kMathSqrt: 7100 case kMathSqrt:
7096 case kMathLog: 7101 case kMathLog:
7097 case kMathSin:
7098 case kMathCos:
7099 case kMathTan:
7100 if (expr->arguments()->length() == 1) { 7102 if (expr->arguments()->length() == 1) {
7101 HValue* argument = Pop(); 7103 HValue* argument = Pop();
7102 Drop(1); // Receiver. 7104 Drop(1); // Receiver.
7103 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); 7105 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id);
7104 if (drop_extra) Drop(1); // Optionally drop the function. 7106 if (drop_extra) Drop(1); // Optionally drop the function.
7105 ast_context()->ReturnInstruction(op, expr->id()); 7107 ast_context()->ReturnInstruction(op, expr->id());
7106 return true; 7108 return true;
7107 } 7109 }
7108 break; 7110 break;
7109 case kMathImul: 7111 case kMathImul:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
7168 } 7170 }
7169 break; 7171 break;
7170 case kMathExp: 7172 case kMathExp:
7171 if (!FLAG_fast_math) break; 7173 if (!FLAG_fast_math) break;
7172 // Fall through if FLAG_fast_math. 7174 // Fall through if FLAG_fast_math.
7173 case kMathRound: 7175 case kMathRound:
7174 case kMathFloor: 7176 case kMathFloor:
7175 case kMathAbs: 7177 case kMathAbs:
7176 case kMathSqrt: 7178 case kMathSqrt:
7177 case kMathLog: 7179 case kMathLog:
7178 case kMathSin:
7179 case kMathCos:
7180 case kMathTan:
7181 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { 7180 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) {
7182 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 7181 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7183 HValue* argument = Pop(); 7182 HValue* argument = Pop();
7184 Drop(1); // Receiver. 7183 Drop(1); // Receiver.
7185 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); 7184 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id);
7186 ast_context()->ReturnInstruction(op, expr->id()); 7185 ast_context()->ReturnInstruction(op, expr->id());
7187 return true; 7186 return true;
7188 } 7187 }
7189 break; 7188 break;
7190 case kMathPow: 7189 case kMathPow:
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
9499 ASSERT_EQ(2, call->arguments()->length()); 9498 ASSERT_EQ(2, call->arguments()->length());
9500 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9499 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9501 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9500 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9502 HValue* right = Pop(); 9501 HValue* right = Pop();
9503 HValue* left = Pop(); 9502 HValue* left = Pop();
9504 HInstruction* result = NewUncasted<HPower>(left, right); 9503 HInstruction* result = NewUncasted<HPower>(left, right);
9505 return ast_context()->ReturnInstruction(result, call->id()); 9504 return ast_context()->ReturnInstruction(result, call->id());
9506 } 9505 }
9507 9506
9508 9507
9509 void HOptimizedGraphBuilder::GenerateMathSin(CallRuntime* call) {
9510 ASSERT_EQ(1, call->arguments()->length());
9511 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9512 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9513 result->set_transcendental_type(TranscendentalCache::SIN);
9514 Drop(1);
9515 return ast_context()->ReturnInstruction(result, call->id());
9516 }
9517
9518
9519 void HOptimizedGraphBuilder::GenerateMathCos(CallRuntime* call) {
9520 ASSERT_EQ(1, call->arguments()->length());
9521 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9522 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9523 result->set_transcendental_type(TranscendentalCache::COS);
9524 Drop(1);
9525 return ast_context()->ReturnInstruction(result, call->id());
9526 }
9527
9528
9529 void HOptimizedGraphBuilder::GenerateMathTan(CallRuntime* call) {
9530 ASSERT_EQ(1, call->arguments()->length());
9531 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9532 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9533 result->set_transcendental_type(TranscendentalCache::TAN);
9534 Drop(1);
9535 return ast_context()->ReturnInstruction(result, call->id());
9536 }
9537
9538
9539 void HOptimizedGraphBuilder::GenerateMathLog(CallRuntime* call) { 9508 void HOptimizedGraphBuilder::GenerateMathLog(CallRuntime* call) {
9540 ASSERT_EQ(1, call->arguments()->length()); 9509 ASSERT_EQ(1, call->arguments()->length());
9541 CHECK_ALIVE(VisitArgumentList(call->arguments())); 9510 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9542 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1); 9511 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9543 result->set_transcendental_type(TranscendentalCache::LOG); 9512 result->set_transcendental_type(TranscendentalCache::LOG);
9544 Drop(1); 9513 Drop(1);
9545 return ast_context()->ReturnInstruction(result, call->id()); 9514 return ast_context()->ReturnInstruction(result, call->id());
9546 } 9515 }
9547 9516
9548 9517
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
10199 if (ShouldProduceTraceOutput()) { 10168 if (ShouldProduceTraceOutput()) {
10200 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10169 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10201 } 10170 }
10202 10171
10203 #ifdef DEBUG 10172 #ifdef DEBUG
10204 graph_->Verify(false); // No full verify. 10173 graph_->Verify(false); // No full verify.
10205 #endif 10174 #endif
10206 } 10175 }
10207 10176
10208 } } // namespace v8::internal 10177 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698