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

Side by Side Diff: src/wasm/wasm-interpreter.cc

Issue 2165633006: [wasm] Remove special memory type for (internal) globals and use local type instead. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] Remove special memory type for (internal) globals and use local type instead. Created 4 years, 5 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
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/wasm/wasm-interpreter.h" 5 #include "src/wasm/wasm-interpreter.h"
6 #include "src/wasm/ast-decoder.h" 6 #include "src/wasm/ast-decoder.h"
7 #include "src/wasm/decoder.h" 7 #include "src/wasm/decoder.h"
8 #include "src/wasm/wasm-external-refs.h" 8 #include "src/wasm/wasm-external-refs.h"
9 #include "src/wasm/wasm-module.h" 9 #include "src/wasm/wasm-module.h"
10 10
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 continue; 1400 continue;
1401 } 1401 }
1402 case kExprCallImport: { 1402 case kExprCallImport: {
1403 UNIMPLEMENTED(); 1403 UNIMPLEMENTED();
1404 break; 1404 break;
1405 } 1405 }
1406 case kExprLoadGlobal: { 1406 case kExprLoadGlobal: {
1407 GlobalIndexOperand operand(&decoder, code->at(pc)); 1407 GlobalIndexOperand operand(&decoder, code->at(pc));
1408 const WasmGlobal* global = &module()->globals[operand.index]; 1408 const WasmGlobal* global = &module()->globals[operand.index];
1409 byte* ptr = instance()->globals_start + global->offset; 1409 byte* ptr = instance()->globals_start + global->offset;
1410 MachineType type = global->type; 1410 LocalType type = global->type;
1411 WasmVal val; 1411 WasmVal val;
1412 if (type == MachineType::Int8()) { 1412 if (type == kAstI32) {
1413 val =
1414 WasmVal(static_cast<int32_t>(*reinterpret_cast<int8_t*>(ptr)));
1415 } else if (type == MachineType::Uint8()) {
1416 val =
1417 WasmVal(static_cast<int32_t>(*reinterpret_cast<uint8_t*>(ptr)));
1418 } else if (type == MachineType::Int16()) {
1419 val =
1420 WasmVal(static_cast<int32_t>(*reinterpret_cast<int16_t*>(ptr)));
1421 } else if (type == MachineType::Uint16()) {
1422 val = WasmVal(
1423 static_cast<int32_t>(*reinterpret_cast<uint16_t*>(ptr)));
1424 } else if (type == MachineType::Int32()) {
1425 val = WasmVal(*reinterpret_cast<int32_t*>(ptr)); 1413 val = WasmVal(*reinterpret_cast<int32_t*>(ptr));
1426 } else if (type == MachineType::Uint32()) { 1414 } else if (type == kAstI64) {
1427 val = WasmVal(*reinterpret_cast<uint32_t*>(ptr));
1428 } else if (type == MachineType::Int64()) {
1429 val = WasmVal(*reinterpret_cast<int64_t*>(ptr)); 1415 val = WasmVal(*reinterpret_cast<int64_t*>(ptr));
1430 } else if (type == MachineType::Uint64()) { 1416 } else if (type == kAstF32) {
1431 val = WasmVal(*reinterpret_cast<uint64_t*>(ptr));
1432 } else if (type == MachineType::Float32()) {
1433 val = WasmVal(*reinterpret_cast<float*>(ptr)); 1417 val = WasmVal(*reinterpret_cast<float*>(ptr));
1434 } else if (type == MachineType::Float64()) { 1418 } else if (type == kAstF64) {
1435 val = WasmVal(*reinterpret_cast<double*>(ptr)); 1419 val = WasmVal(*reinterpret_cast<double*>(ptr));
1436 } else { 1420 } else {
1437 UNREACHABLE(); 1421 UNREACHABLE();
1438 } 1422 }
1439 Push(pc, val); 1423 Push(pc, val);
1440 len = 1 + operand.length; 1424 len = 1 + operand.length;
1441 break; 1425 break;
1442 } 1426 }
1443 case kExprStoreGlobal: { 1427 case kExprStoreGlobal: {
1444 GlobalIndexOperand operand(&decoder, code->at(pc)); 1428 GlobalIndexOperand operand(&decoder, code->at(pc));
1445 const WasmGlobal* global = &module()->globals[operand.index]; 1429 const WasmGlobal* global = &module()->globals[operand.index];
1446 byte* ptr = instance()->globals_start + global->offset; 1430 byte* ptr = instance()->globals_start + global->offset;
1447 MachineType type = global->type; 1431 LocalType type = global->type;
1448 WasmVal val = Pop(); 1432 WasmVal val = Pop();
1449 if (type == MachineType::Int8()) { 1433 if (type == kAstI32) {
1450 *reinterpret_cast<int8_t*>(ptr) =
1451 static_cast<int8_t>(val.to<int32_t>());
1452 } else if (type == MachineType::Uint8()) {
1453 *reinterpret_cast<uint8_t*>(ptr) =
1454 static_cast<uint8_t>(val.to<uint32_t>());
1455 } else if (type == MachineType::Int16()) {
1456 *reinterpret_cast<int16_t*>(ptr) =
1457 static_cast<int16_t>(val.to<int32_t>());
1458 } else if (type == MachineType::Uint16()) {
1459 *reinterpret_cast<uint16_t*>(ptr) =
1460 static_cast<uint16_t>(val.to<uint32_t>());
1461 } else if (type == MachineType::Int32()) {
1462 *reinterpret_cast<int32_t*>(ptr) = val.to<int32_t>(); 1434 *reinterpret_cast<int32_t*>(ptr) = val.to<int32_t>();
1463 } else if (type == MachineType::Uint32()) { 1435 } else if (type == kAstI64) {
1464 *reinterpret_cast<uint32_t*>(ptr) = val.to<uint32_t>();
1465 } else if (type == MachineType::Int64()) {
1466 *reinterpret_cast<int64_t*>(ptr) = val.to<int64_t>(); 1436 *reinterpret_cast<int64_t*>(ptr) = val.to<int64_t>();
1467 } else if (type == MachineType::Uint64()) { 1437 } else if (type == kAstF32) {
1468 *reinterpret_cast<uint64_t*>(ptr) = val.to<uint64_t>();
1469 } else if (type == MachineType::Float32()) {
1470 *reinterpret_cast<float*>(ptr) = val.to<float>(); 1438 *reinterpret_cast<float*>(ptr) = val.to<float>();
1471 } else if (type == MachineType::Float64()) { 1439 } else if (type == kAstF64) {
1472 *reinterpret_cast<double*>(ptr) = val.to<double>(); 1440 *reinterpret_cast<double*>(ptr) = val.to<double>();
1473 } else { 1441 } else {
1474 UNREACHABLE(); 1442 UNREACHABLE();
1475 } 1443 }
1476 Push(pc, val); 1444 Push(pc, val);
1477 len = 1 + operand.length; 1445 len = 1 + operand.length;
1478 break; 1446 break;
1479 } 1447 }
1480 1448
1481 #define LOAD_CASE(name, ctype, mtype) \ 1449 #define LOAD_CASE(name, ctype, mtype) \
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1808
1841 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1809 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1842 Zone* zone, const byte* start, const byte* end) { 1810 Zone* zone, const byte* start, const byte* end) {
1843 ControlTransfers targets(zone, 0, start, end); 1811 ControlTransfers targets(zone, 0, start, end);
1844 return targets.map_; 1812 return targets.map_;
1845 } 1813 }
1846 1814
1847 } // namespace wasm 1815 } // namespace wasm
1848 } // namespace internal 1816 } // namespace internal
1849 } // namespace v8 1817 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698