Commit 9c89f33a authored by Vicky Kontoura's avatar Vicky Kontoura Committed by Commit Bot

[wasm] Support fast transformation for kF32, kF64 in js-to-wasm wrapper

This CL extends fast-path transformations of JavaScript parameters
when calling an exported WebAssembly function from JavaScript
to support types kF32 and kF64.

Bug: v8:10943
Change-Id: I730a04c426614460777cad7c6552533868cd902e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2424263Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Vicky Kontoura <vkont@google.com>
Cr-Commit-Position: refs/heads/master@{#70070}
parent 11eb95fb
......@@ -6226,14 +6226,26 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
}
}
Node* SmiToFloat32(Node* input) {
return graph()->NewNode(mcgraph()->machine()->RoundInt32ToFloat32(),
BuildChangeSmiToInt32(input));
}
Node* SmiToFloat64(Node* input) {
return graph()->NewNode(mcgraph()->machine()->ChangeInt32ToFloat64(),
BuildChangeSmiToInt32(input));
}
Node* FromJSFast(Node* input, wasm::ValueType type) {
switch (type.kind()) {
case wasm::ValueType::kI32:
return BuildChangeSmiToInt32(input);
case wasm::ValueType::kRef:
case wasm::ValueType::kOptRef:
case wasm::ValueType::kF32:
return SmiToFloat32(input);
case wasm::ValueType::kF64:
return SmiToFloat64(input);
case wasm::ValueType::kRef:
case wasm::ValueType::kOptRef:
case wasm::ValueType::kI64:
case wasm::ValueType::kRtt:
case wasm::ValueType::kS128:
......@@ -6379,8 +6391,6 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
switch (type.kind()) {
case wasm::ValueType::kRef:
case wasm::ValueType::kOptRef:
case wasm::ValueType::kF32:
case wasm::ValueType::kF64:
case wasm::ValueType::kI64:
case wasm::ValueType::kRtt:
case wasm::ValueType::kS128:
......@@ -6390,25 +6400,29 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
case wasm::ValueType::kStmt:
return false;
case wasm::ValueType::kI32:
case wasm::ValueType::kF32:
case wasm::ValueType::kF64:
break;
}
}
return true;
}
Node* CanTransformFast(Node* input, wasm::ValueType type) {
switch (type.kind()) {
case wasm::ValueType::kI32: {
Node* is_smi = gasm_->Word32Equal(
Node* IsSmi(Node* input) {
return gasm_->Word32Equal(
gasm_->Word32And(BuildTruncateIntPtrToInt32(input),
gasm_->Int32Constant(kSmiTagMask)),
gasm_->Int32Constant(0));
return is_smi;
}
Node* CanTransformFast(Node* input, wasm::ValueType type) {
switch (type.kind()) {
case wasm::ValueType::kI32:
case wasm::ValueType::kF64:
case wasm::ValueType::kF32:
return IsSmi(input);
case wasm::ValueType::kRef:
case wasm::ValueType::kOptRef:
case wasm::ValueType::kF32:
case wasm::ValueType::kF64:
case wasm::ValueType::kI64:
case wasm::ValueType::kRtt:
case wasm::ValueType::kS128:
......
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