[wasm] Use the new Float64Atan(2) TF operators in wasm.

R=bmeurer@chromium.org, bradnelson@chromium.org
BUG=v8:5086, v8:5095

Review-Url: https://codereview.chromium.org/2062773002
Cr-Commit-Position: refs/heads/master@{#36931}
This commit is contained in:
ahaas 2016-06-13 05:56:03 -07:00 committed by Commit bot
parent 552ba59eb2
commit ab46151aea
5 changed files with 5 additions and 59 deletions

View File

@ -1322,15 +1322,6 @@ ExternalReference ExternalReference::f64_asin_wrapper_function(
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_asin_wrapper)));
}
static void f64_atan_wrapper(double* param) {
WriteDoubleValue(param, base::ieee754::atan(ReadDoubleValue(param)));
}
ExternalReference ExternalReference::f64_atan_wrapper_function(
Isolate* isolate) {
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_atan_wrapper)));
}
static void f64_cos_wrapper(double* param) {
WriteDoubleValue(param, std::cos(ReadDoubleValue(param)));
}
@ -1377,30 +1368,6 @@ ExternalReference ExternalReference::f64_pow_wrapper_function(
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_pow_wrapper)));
}
static void f64_atan2_wrapper(double* param0, double* param1) {
double x = ReadDoubleValue(param0);
double y = ReadDoubleValue(param1);
// TODO(bradnelson): Find a good place to put this to share
// with the same code in src/runtime/runtime-math.cc
static const double kPiDividedBy4 = 0.78539816339744830962;
if (std::isinf(x) && std::isinf(y)) {
// Make sure that the result in case of two infinite arguments
// is a multiple of Pi / 4. The sign of the result is determined
// by the first argument (x) and the sign of the second argument
// determines the multiplier: one or three.
int multiplier = (x < 0) ? -1 : 1;
if (y < 0) multiplier *= 3;
WriteDoubleValue(param0, multiplier * kPiDividedBy4);
} else {
WriteDoubleValue(param0, base::ieee754::atan2(x, y));
}
}
ExternalReference ExternalReference::f64_atan2_wrapper_function(
Isolate* isolate) {
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_atan2_wrapper)));
}
static void f64_mod_wrapper(double* param0, double* param1) {
WriteDoubleValue(param0,
modulo(ReadDoubleValue(param0), ReadDoubleValue(param1)));

View File

@ -968,12 +968,10 @@ class ExternalReference BASE_EMBEDDED {
static ExternalReference f64_acos_wrapper_function(Isolate* isolate);
static ExternalReference f64_asin_wrapper_function(Isolate* isolate);
static ExternalReference f64_atan_wrapper_function(Isolate* isolate);
static ExternalReference f64_cos_wrapper_function(Isolate* isolate);
static ExternalReference f64_sin_wrapper_function(Isolate* isolate);
static ExternalReference f64_tan_wrapper_function(Isolate* isolate);
static ExternalReference f64_exp_wrapper_function(Isolate* isolate);
static ExternalReference f64_atan2_wrapper_function(Isolate* isolate);
static ExternalReference f64_pow_wrapper_function(Isolate* isolate);
static ExternalReference f64_mod_wrapper_function(Isolate* isolate);

View File

@ -607,7 +607,8 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
case wasm::kExprF64Pow:
return BuildF64Pow(left, right);
case wasm::kExprF64Atan2:
return BuildF64Atan2(left, right);
op = m->Float64Atan2();
break;
case wasm::kExprF64Mod:
return BuildF64Mod(left, right);
case wasm::kExprI32AsmjsDivS:
@ -781,9 +782,9 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
case wasm::kExprF64Asin: {
return BuildF64Asin(input);
}
case wasm::kExprF64Atan: {
return BuildF64Atan(input);
}
case wasm::kExprF64Atan:
op = m->Float64Atan();
break;
case wasm::kExprF64Cos: {
return BuildF64Cos(input);
}
@ -1348,13 +1349,6 @@ Node* WasmGraphBuilder::BuildF64Asin(Node* input) {
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Atan(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref =
ExternalReference::f64_atan_wrapper_function(jsgraph()->isolate());
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Cos(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref =
@ -1383,13 +1377,6 @@ Node* WasmGraphBuilder::BuildF64Exp(Node* input) {
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Atan2(Node* left, Node* right) {
MachineType type = MachineType::Float64();
ExternalReference ref =
ExternalReference::f64_atan2_wrapper_function(jsgraph()->isolate());
return BuildCFuncInstruction(ref, type, left, right);
}
Node* WasmGraphBuilder::BuildF64Pow(Node* left, Node* right) {
MachineType type = MachineType::Float64();
ExternalReference ref =

View File

@ -275,13 +275,11 @@ class WasmGraphBuilder {
Node* BuildF64Acos(Node* input);
Node* BuildF64Asin(Node* input);
Node* BuildF64Atan(Node* input);
Node* BuildF64Cos(Node* input);
Node* BuildF64Sin(Node* input);
Node* BuildF64Tan(Node* input);
Node* BuildF64Exp(Node* input);
Node* BuildF64Pow(Node* left, Node* right);
Node* BuildF64Atan2(Node* left, Node* right);
Node* BuildF64Mod(Node* left, Node* right);
Node* BuildIntToFloatConversionInstruction(

View File

@ -154,8 +154,6 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
"f64_acos_wrapper");
Add(ExternalReference::f64_asin_wrapper_function(isolate).address(),
"f64_asin_wrapper");
Add(ExternalReference::f64_atan_wrapper_function(isolate).address(),
"f64_atan_wrapper");
Add(ExternalReference::f64_cos_wrapper_function(isolate).address(),
"f64_cos_wrapper");
Add(ExternalReference::f64_sin_wrapper_function(isolate).address(),
@ -166,8 +164,6 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
"f64_exp_wrapper");
Add(ExternalReference::f64_pow_wrapper_function(isolate).address(),
"f64_pow_wrapper");
Add(ExternalReference::f64_atan2_wrapper_function(isolate).address(),
"f64_atan2_wrapper");
Add(ExternalReference::f64_mod_wrapper_function(isolate).address(),
"f64_mod_wrapper");
Add(ExternalReference::log_enter_external_function(isolate).address(),