Revision: 10098
Author: [email protected]
Date: Wed Nov 30 08:47:54 2011
Log: MIPS: Implement Math.tan in generated code.
Port r10067 (593c1ea) and r10069 (87a06dc).
BUG=
TEST=
Review URL: http://codereview.chromium.org/8743009
Patch from Daniel Kalmar <[email protected]>.
http://code.google.com/p/v8/source/detail?r=10098
Modified:
/branches/bleeding_edge/src/mips/code-stubs-mips.cc
/branches/bleeding_edge/src/mips/full-codegen-mips.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.h
=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Wed Nov 30 08:36:00
2011
+++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Wed Nov 30 08:47:54
2011
@@ -3360,6 +3360,9 @@
__ Branch(&calculate, ne, a2, Operand(t0));
__ Branch(&calculate, ne, a3, Operand(t1));
// Cache hit. Load result, cleanup and return.
+ Counters* counters = masm->isolate()->counters();
+ __ IncrementCounter(
+ counters->transcendental_cache_hit(), 1, scratch0, scratch1);
if (tagged) {
// Pop input value from stack and load result into v0.
__ Drop(1);
@@ -3372,6 +3375,9 @@
} // if (CpuFeatures::IsSupported(FPU))
__ bind(&calculate);
+ Counters* counters = masm->isolate()->counters();
+ __ IncrementCounter(
+ counters->transcendental_cache_miss(), 1, scratch0, scratch1);
if (tagged) {
__ bind(&invalid_cache);
__ TailCallExternalReference(ExternalReference(RuntimeFunction(),
@@ -3455,20 +3461,25 @@
__ mov_d(f12, f4);
}
AllowExternalCallThatCantCauseGC scope(masm);
+ Isolate* isolate = masm->isolate();
switch (type_) {
case TranscendentalCache::SIN:
__ CallCFunction(
- ExternalReference::math_sin_double_function(masm->isolate()),
+ ExternalReference::math_sin_double_function(isolate),
0, 1);
break;
case TranscendentalCache::COS:
__ CallCFunction(
- ExternalReference::math_cos_double_function(masm->isolate()),
+ ExternalReference::math_cos_double_function(isolate),
+ 0, 1);
+ break;
+ case TranscendentalCache::TAN:
+ __
CallCFunction(ExternalReference::math_tan_double_function(isolate),
0, 1);
break;
case TranscendentalCache::LOG:
__ CallCFunction(
- ExternalReference::math_log_double_function(masm->isolate()),
+ ExternalReference::math_log_double_function(isolate),
0, 1);
break;
default:
@@ -3484,6 +3495,7 @@
// Add more cases when necessary.
case TranscendentalCache::SIN: return Runtime::kMath_sin;
case TranscendentalCache::COS: return Runtime::kMath_cos;
+ case TranscendentalCache::TAN: return Runtime::kMath_tan;
case TranscendentalCache::LOG: return Runtime::kMath_log;
default:
UNIMPLEMENTED();
=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Thu Nov 24
07:17:04 2011
+++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Wed Nov 30
08:47:54 2011
@@ -3199,6 +3199,19 @@
__ CallStub(&stub);
context()->Plug(v0);
}
+
+
+void FullCodeGenerator::EmitMathTan(CallRuntime* expr) {
+ // Load the argument on the stack and call the stub.
+ TranscendentalCacheStub stub(TranscendentalCache::TAN,
+ TranscendentalCacheStub::TAGGED);
+ ZoneList<Expression*>* args = expr->arguments();
+ ASSERT(args->length() == 1);
+ VisitForStackValue(args->at(0));
+ __ mov(a0, result_register()); // Stub requires parameter in a0 and on
tos.
+ __ CallStub(&stub);
+ context()->Plug(v0);
+}
void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Nov 29
04:39:28 2011
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Wed Nov 30
08:47:54 2011
@@ -3068,6 +3068,14 @@
TranscendentalCacheStub::UNTAGGED);
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
}
+
+
+void LCodeGen::DoMathTan(LUnaryMathOperation* instr) {
+ ASSERT(ToDoubleRegister(instr->result()).is(f4));
+ TranscendentalCacheStub stub(TranscendentalCache::TAN,
+ TranscendentalCacheStub::UNTAGGED);
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
+}
void LCodeGen::DoMathCos(LUnaryMathOperation* instr) {
@@ -3109,6 +3117,9 @@
case kMathSin:
DoMathSin(instr);
break;
+ case kMathTan:
+ DoMathTan(instr);
+ break;
case kMathLog:
DoMathLog(instr);
break;
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Thu Nov 24
07:17:04 2011
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Wed Nov 30
08:47:54 2011
@@ -242,6 +242,7 @@
void DoMathSqrt(LUnaryMathOperation* instr);
void DoMathPowHalf(LUnaryMathOperation* instr);
void DoMathLog(LUnaryMathOperation* instr);
+ void DoMathTan(LUnaryMathOperation* instr);
void DoMathCos(LUnaryMathOperation* instr);
void DoMathSin(LUnaryMathOperation* instr);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev