Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Unified Diff: src/compiler/wasm-compiler.cc

Issue 1991143002: Convert SIMD wasm ops to runtime function calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review changes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index 5fcfb701482e151cd5ea7d7a621d0a4d795103f1..1f215f993f1a5f4687737239f1150c30f1b205e8 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -23,6 +23,7 @@
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/pipeline.h"
+#include "src/compiler/simd-lowering.h"
#include "src/compiler/source-position.h"
#include "src/compiler/zone-pool.h"
@@ -611,6 +612,10 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
break;
case wasm::kExprF64Mod:
return BuildF64Mod(left, right);
+ case wasm::kExprI32x4ExtractLane:
+ SetHasSimdOps(true);
+ return graph()->NewNode(jsgraph()->machine()->Int32x4ExtractLane(), left,
+ right);
case wasm::kExprI32AsmjsDivS:
return BuildI32AsmjsDivS(left, right);
case wasm::kExprI32AsmjsDivU:
@@ -884,6 +889,10 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
return BuildI64UConvertF64(input, position);
case wasm::kExprGrowMemory:
return BuildGrowMemory(input);
+ case wasm::kExprI32x4Splat:
+ SetHasSimdOps(true);
+ return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), input,
+ input, input, input);
case wasm::kExprI32AsmjsLoadMem8S:
return BuildAsmjsLoadMem(MachineType::Int8(), input);
case wasm::kExprI32AsmjsLoadMem8U:
@@ -2246,6 +2255,12 @@ Node* WasmGraphBuilder::ToJS(Node* node, Node* context, wasm::LocalType type) {
}
}
+Node* WasmGraphBuilder::BuildChangeTaggedToInt32(Node* value) {
+ value = BuildChangeTaggedToFloat64(value);
+ value = graph()->NewNode(jsgraph()->machine()->ChangeFloat64ToInt32(), value);
+ return value;
+}
+
Node* WasmGraphBuilder::BuildJavaScriptToNumber(Node* node, Node* context,
Node* effect, Node* control) {
Callable callable = CodeFactory::ToNumber(jsgraph()->isolate());
@@ -2682,6 +2697,12 @@ Node* WasmGraphBuilder::MemSize(uint32_t offset) {
}
}
+Node* WasmGraphBuilder::DefaultS128Value() {
+ Node* zero = jsgraph()->Int32Constant(0);
+ return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), zero, zero,
+ zero, zero);
+}
+
Node* WasmGraphBuilder::FunctionTable() {
DCHECK(module_ && module_->instance &&
!module_->instance->function_table.is_null());
@@ -3320,6 +3341,21 @@ SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction(
}
int index = static_cast<int>(function_->func_index);
+
+ // Run lowering pass if SIMD ops are present in the function
+ if (builder.HasSimdOps()) {
+ SimdLowering simd(jsgraph_, &builder, module_env_->instance->context);
+ GraphReducer graph_reducer(jsgraph_->zone(), graph);
+ graph_reducer.AddReducer(&simd);
+ graph_reducer.ReduceGraph();
+
+ if (FLAG_trace_turbo_graph) { // Simple textual RPO.
+ OFStream os(stdout);
+ os << "-- Graph after simd lowering -- " << std::endl;
+ os << AsRPO(*graph);
+ }
+ }
+
if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) {
OFStream os(stdout);
PrintAst(isolate_->allocator(), body, os, nullptr);

Powered by Google App Engine
This is Rietveld 408576698