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

Side by Side Diff: src/hydrogen.cc

Issue 50563003: 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: 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 6303 matching lines...) Expand 10 before | Expand all | Expand 10 after
6314 6314
6315 6315
6316 int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) { 6316 int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) {
6317 if (!FLAG_use_inlining) return kNotInlinable; 6317 if (!FLAG_use_inlining) return kNotInlinable;
6318 6318
6319 // Precondition: call is monomorphic and we have found a target with the 6319 // Precondition: call is monomorphic and we have found a target with the
6320 // appropriate arity. 6320 // appropriate arity.
6321 Handle<JSFunction> caller = current_info()->closure(); 6321 Handle<JSFunction> caller = current_info()->closure();
6322 Handle<SharedFunctionInfo> target_shared(target->shared()); 6322 Handle<SharedFunctionInfo> target_shared(target->shared());
6323 6323
6324 // Always inline builtins marked for inlining.
6325 if (target->IsBuiltin()) {
6326 return target_shared->inline_builtin() ? 0 : kNotInlinable;
6327 }
6328
6324 // Do a quick check on source code length to avoid parsing large 6329 // Do a quick check on source code length to avoid parsing large
6325 // inlining candidates. 6330 // inlining candidates.
6326 if (target_shared->SourceSize() > 6331 if (target_shared->SourceSize() >
6327 Min(FLAG_max_inlined_source_size, kUnlimitedMaxInlinedSourceSize)) { 6332 Min(FLAG_max_inlined_source_size, kUnlimitedMaxInlinedSourceSize)) {
6328 TraceInline(target, caller, "target text too big"); 6333 TraceInline(target, caller, "target text too big");
6329 return kNotInlinable; 6334 return kNotInlinable;
6330 } 6335 }
6331 6336
6332 // Target must be inlineable. 6337 // Target must be inlineable.
6333 if (!target->IsInlineable()) { 6338 if (!target_shared->IsInlineable()) {
6334 TraceInline(target, caller, "target not inlineable"); 6339 TraceInline(target, caller, "target not inlineable");
6335 return kNotInlinable; 6340 return kNotInlinable;
6336 } 6341 }
6337 if (target_shared->dont_inline() || target_shared->dont_optimize()) { 6342 if (target_shared->dont_inline() || target_shared->dont_optimize()) {
6338 TraceInline(target, caller, "target contains unsupported syntax [early]"); 6343 TraceInline(target, caller, "target contains unsupported syntax [early]");
6339 return kNotInlinable; 6344 return kNotInlinable;
6340 } 6345 }
6341 6346
6342 int nodes_added = target_shared->ast_node_count(); 6347 int nodes_added = target_shared->ast_node_count();
6343 return nodes_added; 6348 return nodes_added;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
6721 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); 6726 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id();
6722 switch (id) { 6727 switch (id) {
6723 case kMathExp: 6728 case kMathExp:
6724 if (!FLAG_fast_math) break; 6729 if (!FLAG_fast_math) break;
6725 // Fall through if FLAG_fast_math. 6730 // Fall through if FLAG_fast_math.
6726 case kMathRound: 6731 case kMathRound:
6727 case kMathFloor: 6732 case kMathFloor:
6728 case kMathAbs: 6733 case kMathAbs:
6729 case kMathSqrt: 6734 case kMathSqrt:
6730 case kMathLog: 6735 case kMathLog:
6731 case kMathSin:
6732 case kMathCos:
6733 case kMathTan:
6734 if (expr->arguments()->length() == 1) { 6736 if (expr->arguments()->length() == 1) {
6735 HValue* argument = Pop(); 6737 HValue* argument = Pop();
6736 Drop(1); // Receiver. 6738 Drop(1); // Receiver.
6737 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); 6739 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id);
6738 if (drop_extra) Drop(1); // Optionally drop the function. 6740 if (drop_extra) Drop(1); // Optionally drop the function.
6739 ast_context()->ReturnInstruction(op, expr->id()); 6741 ast_context()->ReturnInstruction(op, expr->id());
6740 return true; 6742 return true;
6741 } 6743 }
6742 break; 6744 break;
6743 case kMathImul: 6745 case kMathImul:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6802 } 6804 }
6803 break; 6805 break;
6804 case kMathExp: 6806 case kMathExp:
6805 if (!FLAG_fast_math) break; 6807 if (!FLAG_fast_math) break;
6806 // Fall through if FLAG_fast_math. 6808 // Fall through if FLAG_fast_math.
6807 case kMathRound: 6809 case kMathRound:
6808 case kMathFloor: 6810 case kMathFloor:
6809 case kMathAbs: 6811 case kMathAbs:
6810 case kMathSqrt: 6812 case kMathSqrt:
6811 case kMathLog: 6813 case kMathLog:
6812 case kMathSin:
6813 case kMathCos:
6814 case kMathTan:
6815 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { 6814 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) {
6816 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 6815 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
6817 HValue* argument = Pop(); 6816 HValue* argument = Pop();
6818 Drop(1); // Receiver. 6817 Drop(1); // Receiver.
6819 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); 6818 HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id);
6820 ast_context()->ReturnInstruction(op, expr->id()); 6819 ast_context()->ReturnInstruction(op, expr->id());
6821 return true; 6820 return true;
6822 } 6821 }
6823 break; 6822 break;
6824 case kMathPow: 6823 case kMathPow:
(...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after
9124 ASSERT_EQ(2, call->arguments()->length()); 9123 ASSERT_EQ(2, call->arguments()->length());
9125 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9124 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9126 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9125 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9127 HValue* right = Pop(); 9126 HValue* right = Pop();
9128 HValue* left = Pop(); 9127 HValue* left = Pop();
9129 HInstruction* result = NewUncasted<HPower>(left, right); 9128 HInstruction* result = NewUncasted<HPower>(left, right);
9130 return ast_context()->ReturnInstruction(result, call->id()); 9129 return ast_context()->ReturnInstruction(result, call->id());
9131 } 9130 }
9132 9131
9133 9132
9134 void HOptimizedGraphBuilder::GenerateMathSin(CallRuntime* call) {
9135 ASSERT_EQ(1, call->arguments()->length());
9136 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9137 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9138 result->set_transcendental_type(TranscendentalCache::SIN);
9139 Drop(1);
9140 return ast_context()->ReturnInstruction(result, call->id());
9141 }
9142
9143
9144 void HOptimizedGraphBuilder::GenerateMathCos(CallRuntime* call) {
9145 ASSERT_EQ(1, call->arguments()->length());
9146 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9147 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9148 result->set_transcendental_type(TranscendentalCache::COS);
9149 Drop(1);
9150 return ast_context()->ReturnInstruction(result, call->id());
9151 }
9152
9153
9154 void HOptimizedGraphBuilder::GenerateMathTan(CallRuntime* call) {
9155 ASSERT_EQ(1, call->arguments()->length());
9156 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9157 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9158 result->set_transcendental_type(TranscendentalCache::TAN);
9159 Drop(1);
9160 return ast_context()->ReturnInstruction(result, call->id());
9161 }
9162
9163
9164 void HOptimizedGraphBuilder::GenerateMathLog(CallRuntime* call) { 9133 void HOptimizedGraphBuilder::GenerateMathLog(CallRuntime* call) {
9165 ASSERT_EQ(1, call->arguments()->length()); 9134 ASSERT_EQ(1, call->arguments()->length());
9166 CHECK_ALIVE(VisitArgumentList(call->arguments())); 9135 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9167 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1); 9136 HCallStub* result = New<HCallStub>(CodeStub::TranscendentalCache, 1);
9168 result->set_transcendental_type(TranscendentalCache::LOG); 9137 result->set_transcendental_type(TranscendentalCache::LOG);
9169 Drop(1); 9138 Drop(1);
9170 return ast_context()->ReturnInstruction(result, call->id()); 9139 return ast_context()->ReturnInstruction(result, call->id());
9171 } 9140 }
9172 9141
9173 9142
9174 void HOptimizedGraphBuilder::GenerateMathSqrt(CallRuntime* call) { 9143 void HOptimizedGraphBuilder::GenerateMathSqrt(CallRuntime* call) {
9175 ASSERT(call->arguments()->length() == 1); 9144 ASSERT(call->arguments()->length() == 1);
9176 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9145 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9177 HValue* value = Pop(); 9146 HValue* value = Pop();
9178 HInstruction* result = New<HUnaryMathOperation>(value, kMathSqrt); 9147 HInstruction* result = New<HUnaryMathOperation>(value, kMathSqrt);
9179 return ast_context()->ReturnInstruction(result, call->id()); 9148 return ast_context()->ReturnInstruction(result, call->id());
9180 } 9149 }
9181 9150
9182 9151
9152 void HOptimizedGraphBuilder::GenerateMathFloor(CallRuntime* call) {
9153 ASSERT(call->arguments()->length() == 1);
9154 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9155 HValue* value = Pop();
9156 HInstruction* result = New<HUnaryMathOperation>(value, kMathFloor);
9157 return ast_context()->ReturnInstruction(result, call->id());
9158 }
9159
9160
9183 // Check whether two RegExps are equivalent 9161 // Check whether two RegExps are equivalent
9184 void HOptimizedGraphBuilder::GenerateIsRegExpEquivalent(CallRuntime* call) { 9162 void HOptimizedGraphBuilder::GenerateIsRegExpEquivalent(CallRuntime* call) {
9185 return Bailout(kInlinedRuntimeFunctionIsRegExpEquivalent); 9163 return Bailout(kInlinedRuntimeFunctionIsRegExpEquivalent);
9186 } 9164 }
9187 9165
9188 9166
9189 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { 9167 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) {
9190 ASSERT(call->arguments()->length() == 1); 9168 ASSERT(call->arguments()->length() == 1);
9191 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9169 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9192 HValue* value = Pop(); 9170 HValue* value = Pop();
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
9824 if (ShouldProduceTraceOutput()) { 9802 if (ShouldProduceTraceOutput()) {
9825 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9803 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9826 } 9804 }
9827 9805
9828 #ifdef DEBUG 9806 #ifdef DEBUG
9829 graph_->Verify(false); // No full verify. 9807 graph_->Verify(false); // No full verify.
9830 #endif 9808 #endif
9831 } 9809 }
9832 9810
9833 } } // namespace v8::internal 9811 } } // 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