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

Side by Side Diff: src/wasm/function-body-decoder.cc

Issue 2638133002: [Turbofan] Add other integer SIMD types, add more integer ops. (Closed)
Patch Set: Fix value helper. Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/flags.h" 8 #include "src/flags.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/zone/zone-containers.h" 10 #include "src/zone/zone-containers.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 error(pc, pc + 1, "invalid break depth: %u", operand.depth); 341 error(pc, pc + 1, "invalid break depth: %u", operand.depth);
342 return false; 342 return false;
343 } 343 }
344 344
345 bool Validate(const byte* pc, BranchTableOperand& operand, 345 bool Validate(const byte* pc, BranchTableOperand& operand,
346 size_t block_depth) { 346 size_t block_depth) {
347 // TODO(titzer): add extra redundant validation for br_table here? 347 // TODO(titzer): add extra redundant validation for br_table here?
348 return true; 348 return true;
349 } 349 }
350 350
351 inline bool Validate(const byte* pc, LaneOperand& operand) { 351 inline bool Validate(const byte* pc, LaneOperand& operand,
titzer 2017/01/25 09:47:25 Can we put the opcode first, just for analogy to t
bbudge 2017/01/26 02:04:43 Done. (put opcode before operand)
352 if (operand.lane < 0 || operand.lane > 3) { 352 WasmOpcode opcode) {
353 error(pc_, pc_ + 2, "invalid extract lane value"); 353 uint8_t num_lanes = 0;
354 switch (opcode) {
355 case kExprF32x4ExtractLane:
356 case kExprF32x4ReplaceLane:
357 case kExprI32x4ExtractLane:
358 case kExprI32x4ReplaceLane:
359 num_lanes = 4;
360 break;
361 case kExprI16x8ExtractLane:
362 case kExprI16x8ReplaceLane:
363 num_lanes = 8;
364 break;
365 case kExprI8x16ExtractLane:
366 case kExprI8x16ReplaceLane:
367 num_lanes = 16;
368 break;
369 default:
370 UNREACHABLE();
371 break;
372 }
373 if (operand.lane < 0 || operand.lane >= num_lanes) {
374 error(pc_, pc_ + 2, "invalid lane value");
354 return false; 375 return false;
355 } else { 376 } else {
356 return true; 377 return true;
357 } 378 }
358 } 379 }
359 380
360 static unsigned OpcodeLength(Decoder* decoder, const byte* pc) { 381 static unsigned OpcodeLength(Decoder* decoder, const byte* pc) {
361 switch (static_cast<byte>(*pc)) { 382 switch (static_cast<byte>(*pc)) {
362 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: 383 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
363 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) 384 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE)
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 ElementSizeLog2Of(mem_type.representation())); 1352 ElementSizeLog2Of(mem_type.representation()));
1332 Value val = Pop(1, type); 1353 Value val = Pop(1, type);
1333 Value index = Pop(0, kWasmI32); 1354 Value index = Pop(0, kWasmI32);
1334 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, 1355 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment,
1335 val.node, position()); 1356 val.node, position());
1336 return 1 + operand.length; 1357 return 1 + operand.length;
1337 } 1358 }
1338 1359
1339 unsigned ExtractLane(WasmOpcode opcode, ValueType type) { 1360 unsigned ExtractLane(WasmOpcode opcode, ValueType type) {
1340 LaneOperand operand(this, pc_); 1361 LaneOperand operand(this, pc_);
1341 if (Validate(pc_, operand)) { 1362 if (Validate(pc_, operand, opcode)) {
1342 compiler::NodeVector inputs(1, zone_); 1363 compiler::NodeVector inputs(1, zone_);
1343 inputs[0] = Pop(0, ValueType::kSimd128).node; 1364 inputs[0] = Pop(0, ValueType::kSimd128).node;
1344 TFNode* node = BUILD(SimdLaneOp, opcode, operand.lane, inputs); 1365 TFNode* node = BUILD(SimdLaneOp, opcode, operand.lane, inputs);
1345 Push(type, node); 1366 Push(type, node);
1346 } 1367 }
1347 return operand.length; 1368 return operand.length;
1348 } 1369 }
1349 1370
1350 unsigned ReplaceLane(WasmOpcode opcode, ValueType type) { 1371 unsigned ReplaceLane(WasmOpcode opcode, ValueType type) {
1351 LaneOperand operand(this, pc_); 1372 LaneOperand operand(this, pc_);
1352 if (Validate(pc_, operand)) { 1373 if (Validate(pc_, operand, opcode)) {
1353 compiler::NodeVector inputs(2, zone_); 1374 compiler::NodeVector inputs(2, zone_);
1354 inputs[1] = Pop(1, type).node; 1375 inputs[1] = Pop(1, type).node;
1355 inputs[0] = Pop(0, ValueType::kSimd128).node; 1376 inputs[0] = Pop(0, ValueType::kSimd128).node;
1356 TFNode* node = BUILD(SimdLaneOp, opcode, operand.lane, inputs); 1377 TFNode* node = BUILD(SimdLaneOp, opcode, operand.lane, inputs);
1357 Push(ValueType::kSimd128, node); 1378 Push(ValueType::kSimd128, node);
1358 } 1379 }
1359 return operand.length; 1380 return operand.length;
1360 } 1381 }
1361 1382
1362 unsigned DecodeSimdOpcode(WasmOpcode opcode) { 1383 unsigned DecodeSimdOpcode(WasmOpcode opcode) {
1363 unsigned len = 0; 1384 unsigned len = 0;
1364 switch (opcode) { 1385 switch (opcode) {
1365 case kExprI32x4ExtractLane: {
1366 len = ExtractLane(opcode, ValueType::kWord32);
1367 break;
1368 }
1369 case kExprF32x4ExtractLane: { 1386 case kExprF32x4ExtractLane: {
1370 len = ExtractLane(opcode, ValueType::kFloat32); 1387 len = ExtractLane(opcode, ValueType::kFloat32);
1371 break; 1388 break;
1372 } 1389 }
1373 case kExprI32x4ReplaceLane: { 1390 case kExprI32x4ExtractLane:
1374 len = ReplaceLane(opcode, ValueType::kWord32); 1391 case kExprI16x8ExtractLane:
1392 case kExprI8x16ExtractLane: {
1393 len = ExtractLane(opcode, ValueType::kWord32);
1375 break; 1394 break;
1376 } 1395 }
1377 case kExprF32x4ReplaceLane: { 1396 case kExprF32x4ReplaceLane: {
1378 len = ReplaceLane(opcode, ValueType::kFloat32); 1397 len = ReplaceLane(opcode, ValueType::kFloat32);
1379 break; 1398 break;
1380 } 1399 }
1400 case kExprI32x4ReplaceLane:
1401 case kExprI16x8ReplaceLane:
1402 case kExprI8x16ReplaceLane: {
1403 len = ReplaceLane(opcode, ValueType::kWord32);
1404 break;
1405 }
1381 default: { 1406 default: {
1382 FunctionSig* sig = WasmOpcodes::Signature(opcode); 1407 FunctionSig* sig = WasmOpcodes::Signature(opcode);
1383 if (sig != nullptr) { 1408 if (sig != nullptr) {
1384 compiler::NodeVector inputs(sig->parameter_count(), zone_); 1409 compiler::NodeVector inputs(sig->parameter_count(), zone_);
1385 for (size_t i = sig->parameter_count(); i > 0; i--) { 1410 for (size_t i = sig->parameter_count(); i > 0; i--) {
1386 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1)); 1411 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1));
1387 inputs[i - 1] = val.node; 1412 inputs[i - 1] = val.node;
1388 } 1413 }
1389 TFNode* node = BUILD(SimdOp, opcode, inputs); 1414 TFNode* node = BUILD(SimdOp, opcode, inputs);
1390 Push(GetReturnType(sig), node); 1415 Push(GetReturnType(sig), node);
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 2042 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
2018 const byte* start, const byte* end) { 2043 const byte* start, const byte* end) {
2019 Decoder decoder(start, end); 2044 Decoder decoder(start, end);
2020 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start, 2045 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start,
2021 static_cast<int>(num_locals), zone); 2046 static_cast<int>(num_locals), zone);
2022 } 2047 }
2023 2048
2024 } // namespace wasm 2049 } // namespace wasm
2025 } // namespace internal 2050 } // namespace internal
2026 } // namespace v8 2051 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698