Index: src/compiler/wasm-compiler.cc |
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc |
index e25a72809c0e1d2644e72baf10b9c5d1ec7db0a1..54921c2676baf7ae8a7a3d42fd5ce6ca7d64dbe0 100644 |
--- a/src/compiler/wasm-compiler.cc |
+++ b/src/compiler/wasm-compiler.cc |
@@ -697,6 +697,15 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, |
return BuildF32Max(left, right); |
case wasm::kExprF64Max: |
return BuildF64Max(left, right); |
+ case wasm::kExprF64Pow: { |
+ return BuildF64Pow(left, right); |
+ } |
+ case wasm::kExprF64Atan2: { |
+ return BuildF64Atan2(left, right); |
+ } |
+ case wasm::kExprF64Mod: { |
+ return BuildF64Mod(left, right); |
+ } |
default: |
op = UnsupportedOpcode(opcode); |
} |
@@ -913,6 +922,30 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) { |
return BuildI64Popcnt(input); |
} |
} |
+ case wasm::kExprF64Acos: { |
+ return BuildF64Acos(input); |
+ } |
+ case wasm::kExprF64Asin: { |
+ return BuildF64Asin(input); |
+ } |
+ case wasm::kExprF64Atan: { |
+ return BuildF64Atan(input); |
+ } |
+ case wasm::kExprF64Cos: { |
+ return BuildF64Cos(input); |
+ } |
+ case wasm::kExprF64Sin: { |
+ return BuildF64Sin(input); |
+ } |
+ case wasm::kExprF64Tan: { |
+ return BuildF64Tan(input); |
+ } |
+ case wasm::kExprF64Exp: { |
+ return BuildF64Exp(input); |
+ } |
+ case wasm::kExprF64Log: { |
+ return BuildF64Log(input); |
+ } |
#endif |
default: |
op = UnsupportedOpcode(opcode); |
@@ -1418,66 +1451,144 @@ Node* WasmGraphBuilder::BuildF32Trunc(Node* input) { |
MachineType type = MachineType::Float32(); |
ExternalReference ref = |
ExternalReference::f32_trunc_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
Node* WasmGraphBuilder::BuildF32Floor(Node* input) { |
MachineType type = MachineType::Float32(); |
ExternalReference ref = |
ExternalReference::f32_floor_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
Node* WasmGraphBuilder::BuildF32Ceil(Node* input) { |
MachineType type = MachineType::Float32(); |
ExternalReference ref = |
ExternalReference::f32_ceil_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
Node* WasmGraphBuilder::BuildF32NearestInt(Node* input) { |
MachineType type = MachineType::Float32(); |
ExternalReference ref = |
ExternalReference::f32_nearest_int_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
Node* WasmGraphBuilder::BuildF64Trunc(Node* input) { |
MachineType type = MachineType::Float64(); |
ExternalReference ref = |
ExternalReference::f64_trunc_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
Node* WasmGraphBuilder::BuildF64Floor(Node* input) { |
MachineType type = MachineType::Float64(); |
ExternalReference ref = |
ExternalReference::f64_floor_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
Node* WasmGraphBuilder::BuildF64Ceil(Node* input) { |
MachineType type = MachineType::Float64(); |
ExternalReference ref = |
ExternalReference::f64_ceil_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
Node* WasmGraphBuilder::BuildF64NearestInt(Node* input) { |
MachineType type = MachineType::Float64(); |
ExternalReference ref = |
ExternalReference::f64_nearest_int_wrapper_function(jsgraph()->isolate()); |
- return BuildRoundingInstruction(input, ref, type); |
+ return BuildCFuncInstruction(ref, type, input); |
+} |
+ |
+Node* WasmGraphBuilder::BuildF64Acos(Node* input) { |
+ MachineType type = MachineType::Float64(); |
+ ExternalReference ref = |
+ ExternalReference::f64_acos_wrapper_function(jsgraph()->isolate()); |
+ return BuildCFuncInstruction(ref, type, input); |
+} |
+ |
+Node* WasmGraphBuilder::BuildF64Asin(Node* input) { |
+ MachineType type = MachineType::Float64(); |
+ ExternalReference ref = |
+ ExternalReference::f64_asin_wrapper_function(jsgraph()->isolate()); |
+ 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 = |
+ ExternalReference::f64_cos_wrapper_function(jsgraph()->isolate()); |
+ return BuildCFuncInstruction(ref, type, input); |
+} |
+ |
+Node* WasmGraphBuilder::BuildF64Sin(Node* input) { |
+ MachineType type = MachineType::Float64(); |
+ ExternalReference ref = |
+ ExternalReference::f64_sin_wrapper_function(jsgraph()->isolate()); |
+ return BuildCFuncInstruction(ref, type, input); |
} |
-Node* WasmGraphBuilder::BuildRoundingInstruction(Node* input, |
- ExternalReference ref, |
- MachineType type) { |
- // We do truncation by calling a C function which calculates the truncation |
- // for us. The input is passed to the C function as a double* to avoid double |
- // parameters. For this we reserve a slot on the stack, store the parameter in |
- // that slot, pass a pointer to the slot to the C function, and after calling |
- // the C function we collect the return value from the stack slot. |
+Node* WasmGraphBuilder::BuildF64Tan(Node* input) { |
+ MachineType type = MachineType::Float64(); |
+ ExternalReference ref = |
+ ExternalReference::f64_tan_wrapper_function(jsgraph()->isolate()); |
+ return BuildCFuncInstruction(ref, type, input); |
+} |
+ |
+Node* WasmGraphBuilder::BuildF64Exp(Node* input) { |
+ MachineType type = MachineType::Float64(); |
+ ExternalReference ref = |
+ ExternalReference::f64_exp_wrapper_function(jsgraph()->isolate()); |
+ return BuildCFuncInstruction(ref, type, input); |
+} |
+ |
+Node* WasmGraphBuilder::BuildF64Log(Node* input) { |
+ MachineType type = MachineType::Float64(); |
+ ExternalReference ref = |
+ ExternalReference::f64_log_wrapper_function(jsgraph()->isolate()); |
+ 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 = |
+ ExternalReference::f64_pow_wrapper_function(jsgraph()->isolate()); |
+ return BuildCFuncInstruction(ref, type, left, right); |
+} |
+ |
+Node* WasmGraphBuilder::BuildF64Mod(Node* left, Node* right) { |
+ MachineType type = MachineType::Float64(); |
+ ExternalReference ref = |
+ ExternalReference::f64_mod_wrapper_function(jsgraph()->isolate()); |
+ return BuildCFuncInstruction(ref, type, left, right); |
+} |
+ |
+Node* WasmGraphBuilder::BuildCFuncInstruction(ExternalReference ref, |
+ MachineType type, Node* input0, |
+ Node* input1) { |
+ // We do truncation by calling a C function which calculates the result. |
+ // The input is passed to the C function as a double* to avoid double |
+ // parameters. For this we reserve slots on the stack, store the parameters |
+ // in those slots, pass a pointer to the slot to the C function, |
+ // and after calling the C function we collect the return value from |
+ // the stack slot. |
Node* stack_slot_param = |
graph()->NewNode(jsgraph()->machine()->StackSlot(type.representation())); |
@@ -1486,7 +1597,12 @@ Node* WasmGraphBuilder::BuildRoundingInstruction(Node* input, |
StoreRepresentation(type.representation(), kNoWriteBarrier)); |
*effect_ = |
graph()->NewNode(store_op, stack_slot_param, jsgraph()->Int32Constant(0), |
- input, *effect_, *control_); |
+ input0, *effect_, *control_); |
+ if (input1 != nullptr) { |
+ *effect_ = graph()->NewNode(store_op, stack_slot_param, |
+ jsgraph()->Int32Constant(8), input1, *effect_, |
+ *control_); |
+ } |
Signature<MachineType>::Builder sig_builder(jsgraph()->zone(), 0, 1); |
sig_builder.AddParam(MachineType::Pointer()); |
@@ -1547,7 +1663,6 @@ Node* WasmGraphBuilder::BuildWasmCall(wasm::FunctionSig* sig, Node** args) { |
return call; |
} |
- |
Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args) { |
DCHECK_NULL(args[0]); |