Commit 6627d81c authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Use a C wrapper function to calculate F64Pow.

This CL more or less reverts commit https://codereview.chromium.org/2107733002/
The use of the MathPow code stub that was introduced by that commit caused
problems on arm64, and the MathPow code stub was also an obstacle in the
implementation of parallel code generation.

In addition this CL turns on the mjsunit/wasm/embenchen tests for arm64
which were turned off because of problems with MathPow on arm64.

R=titzer@chromium.org, bradnelson@chromium.org

Review-Url: https://codereview.chromium.org/2166793002
Cr-Commit-Position: refs/heads/master@{#37911}
parent 7da34f8a
...@@ -1156,6 +1156,11 @@ ExternalReference ExternalReference::f64_asin_wrapper_function( ...@@ -1156,6 +1156,11 @@ ExternalReference ExternalReference::f64_asin_wrapper_function(
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_asin_wrapper))); return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_asin_wrapper)));
} }
ExternalReference ExternalReference::wasm_float64_pow(Isolate* isolate) {
return ExternalReference(
Redirect(isolate, FUNCTION_ADDR(wasm::float64_pow_wrapper)));
}
static void f64_mod_wrapper(double* param0, double* param1) { static void f64_mod_wrapper(double* param0, double* param1) {
WriteDoubleValue(param0, WriteDoubleValue(param0,
modulo(ReadDoubleValue(param0), ReadDoubleValue(param1))); modulo(ReadDoubleValue(param0), ReadDoubleValue(param1)));
......
...@@ -928,6 +928,7 @@ class ExternalReference BASE_EMBEDDED { ...@@ -928,6 +928,7 @@ class ExternalReference BASE_EMBEDDED {
static ExternalReference wasm_word64_ctz(Isolate* isolate); static ExternalReference wasm_word64_ctz(Isolate* isolate);
static ExternalReference wasm_word32_popcnt(Isolate* isolate); static ExternalReference wasm_word32_popcnt(Isolate* isolate);
static ExternalReference wasm_word64_popcnt(Isolate* isolate); static ExternalReference wasm_word64_popcnt(Isolate* isolate);
static ExternalReference wasm_float64_pow(Isolate* isolate);
static ExternalReference f64_acos_wrapper_function(Isolate* isolate); static ExternalReference f64_acos_wrapper_function(Isolate* isolate);
static ExternalReference f64_asin_wrapper_function(Isolate* isolate); static ExternalReference f64_asin_wrapper_function(Isolate* isolate);
......
...@@ -609,8 +609,7 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right, ...@@ -609,8 +609,7 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
case wasm::kExprF64Max: case wasm::kExprF64Max:
return BuildF64Max(left, right); return BuildF64Max(left, right);
case wasm::kExprF64Pow: case wasm::kExprF64Pow:
op = m->Float64Pow(); return BuildF64Pow(left, right);
break;
case wasm::kExprF64Atan2: case wasm::kExprF64Atan2:
op = m->Float64Atan2(); op = m->Float64Atan2();
break; break;
...@@ -1490,6 +1489,13 @@ Node* WasmGraphBuilder::BuildF64Asin(Node* input) { ...@@ -1490,6 +1489,13 @@ Node* WasmGraphBuilder::BuildF64Asin(Node* input) {
return BuildCFuncInstruction(ref, type, input); return BuildCFuncInstruction(ref, type, input);
} }
Node* WasmGraphBuilder::BuildF64Pow(Node* left, Node* right) {
MachineType type = MachineType::Float64();
ExternalReference ref =
ExternalReference::wasm_float64_pow(jsgraph()->isolate());
return BuildCFuncInstruction(ref, type, left, right);
}
Node* WasmGraphBuilder::BuildF64Mod(Node* left, Node* right) { Node* WasmGraphBuilder::BuildF64Mod(Node* left, Node* right) {
MachineType type = MachineType::Float64(); MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference ref =
......
...@@ -291,6 +291,7 @@ class WasmGraphBuilder { ...@@ -291,6 +291,7 @@ class WasmGraphBuilder {
Node* BuildF64Acos(Node* input); Node* BuildF64Acos(Node* input);
Node* BuildF64Asin(Node* input); Node* BuildF64Asin(Node* input);
Node* BuildF64Pow(Node* left, Node* right);
Node* BuildF64Mod(Node* left, Node* right); Node* BuildF64Mod(Node* left, Node* right);
Node* BuildIntToFloatConversionInstruction( Node* BuildIntToFloatConversionInstruction(
......
...@@ -185,6 +185,8 @@ void ExternalReferenceTable::AddReferences(Isolate* isolate) { ...@@ -185,6 +185,8 @@ void ExternalReferenceTable::AddReferences(Isolate* isolate) {
"wasm::float64_to_int64_wrapper"); "wasm::float64_to_int64_wrapper");
Add(ExternalReference::wasm_float64_to_uint64(isolate).address(), Add(ExternalReference::wasm_float64_to_uint64(isolate).address(),
"wasm::float64_to_uint64_wrapper"); "wasm::float64_to_uint64_wrapper");
Add(ExternalReference::wasm_float64_pow(isolate).address(),
"wasm::float64_pow");
Add(ExternalReference::wasm_int64_div(isolate).address(), "wasm::int64_div"); Add(ExternalReference::wasm_int64_div(isolate).address(), "wasm::int64_div");
Add(ExternalReference::wasm_int64_mod(isolate).address(), "wasm::int64_mod"); Add(ExternalReference::wasm_int64_mod(isolate).address(), "wasm::int64_mod");
Add(ExternalReference::wasm_uint64_div(isolate).address(), Add(ExternalReference::wasm_uint64_div(isolate).address(),
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "include/v8config.h" #include "include/v8config.h"
#include "src/base/bits.h" #include "src/base/bits.h"
#include "src/utils.h"
#include "src/wasm/wasm-external-refs.h" #include "src/wasm/wasm-external-refs.h"
namespace v8 { namespace v8 {
...@@ -194,6 +195,14 @@ uint32_t word64_popcnt_wrapper(uint64_t* input) { ...@@ -194,6 +195,14 @@ uint32_t word64_popcnt_wrapper(uint64_t* input) {
return static_cast<uint32_t>(base::bits::CountPopulation(*input)); return static_cast<uint32_t>(base::bits::CountPopulation(*input));
} }
void float64_pow_wrapper(double* param0, double* param1) {
double x = ReadDoubleValue(param0);
double y = ReadDoubleValue(param1);
if (std::isnan(y) || ((x == 1 || x == -1) && std::isinf(y))) {
WriteDoubleValue(param0, std::numeric_limits<double>::quiet_NaN());
}
WriteDoubleValue(param0, Pow(x, y));
}
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -58,6 +58,9 @@ uint32_t word64_ctz_wrapper(uint64_t* input); ...@@ -58,6 +58,9 @@ uint32_t word64_ctz_wrapper(uint64_t* input);
uint32_t word32_popcnt_wrapper(uint32_t* input); uint32_t word32_popcnt_wrapper(uint32_t* input);
uint32_t word64_popcnt_wrapper(uint64_t* input); uint32_t word64_popcnt_wrapper(uint64_t* input);
void float64_pow_wrapper(double* param0, double* param1);
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -240,6 +240,12 @@ TEST(RunCallWord64Popcnt) { ...@@ -240,6 +240,12 @@ TEST(RunCallWord64Popcnt) {
ExternalReference ref = ExternalReference::wasm_word64_popcnt(m.isolate()); ExternalReference ref = ExternalReference::wasm_word64_popcnt(m.isolate());
TestExternalReference(&m, ref, wasm::word64_popcnt_wrapper, uint64_t(1774)); TestExternalReference(&m, ref, wasm::word64_popcnt_wrapper, uint64_t(1774));
} }
TEST(RunCallFloat64Pow) {
BufferedRawMachineAssemblerTester<int32_t> m;
ExternalReference ref = ExternalReference::wasm_float64_pow(m.isolate());
TestExternalReference(&m, ref, wasm::float64_pow_wrapper, 1.5, 1.5);
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -200,7 +200,7 @@ ...@@ -200,7 +200,7 @@
'wasm/asm-wasm-switch': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]], 'wasm/asm-wasm-switch': [PASS, ['arch in [arm, arm64, mips, mipsel, mips64, mips64el]', SKIP]],
# TODO(branelson): Figure out why ignition + asm->wasm fails embenchen. # TODO(branelson): Figure out why ignition + asm->wasm fails embenchen.
'wasm/embenchen/*': [PASS, ['arch == arm64', SKIP], ['ignition == True', SKIP]], 'wasm/embenchen/*': [PASS, ['ignition == True', SKIP]],
# case-insensitive unicode regexp relies on case mapping provided by ICU. # case-insensitive unicode regexp relies on case mapping provided by ICU.
'es6/unicode-regexp-ignore-case': [PASS, ['no_i18n == True', FAIL]], 'es6/unicode-regexp-ignore-case': [PASS, ['no_i18n == True', FAIL]],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment