| OLD | NEW |
| 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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 | 1398 |
| 1399 DoCall(target, &pc, pc + 1 + operand.length, &limit); | 1399 DoCall(target, &pc, pc + 1 + operand.length, &limit); |
| 1400 code = target; | 1400 code = target; |
| 1401 decoder.Reset(code->start, code->end); | 1401 decoder.Reset(code->start, code->end); |
| 1402 continue; | 1402 continue; |
| 1403 } | 1403 } |
| 1404 case kExprCallImport: { | 1404 case kExprCallImport: { |
| 1405 UNIMPLEMENTED(); | 1405 UNIMPLEMENTED(); |
| 1406 break; | 1406 break; |
| 1407 } | 1407 } |
| 1408 case kExprLoadGlobal: { | 1408 case kExprGetGlobal: { |
| 1409 GlobalIndexOperand operand(&decoder, code->at(pc)); | 1409 GlobalIndexOperand operand(&decoder, code->at(pc)); |
| 1410 const WasmGlobal* global = &module()->globals[operand.index]; | 1410 const WasmGlobal* global = &module()->globals[operand.index]; |
| 1411 byte* ptr = instance()->globals_start + global->offset; | 1411 byte* ptr = instance()->globals_start + global->offset; |
| 1412 LocalType type = global->type; | 1412 LocalType type = global->type; |
| 1413 WasmVal val; | 1413 WasmVal val; |
| 1414 if (type == kAstI32) { | 1414 if (type == kAstI32) { |
| 1415 val = WasmVal(*reinterpret_cast<int32_t*>(ptr)); | 1415 val = WasmVal(*reinterpret_cast<int32_t*>(ptr)); |
| 1416 } else if (type == kAstI64) { | 1416 } else if (type == kAstI64) { |
| 1417 val = WasmVal(*reinterpret_cast<int64_t*>(ptr)); | 1417 val = WasmVal(*reinterpret_cast<int64_t*>(ptr)); |
| 1418 } else if (type == kAstF32) { | 1418 } else if (type == kAstF32) { |
| 1419 val = WasmVal(*reinterpret_cast<float*>(ptr)); | 1419 val = WasmVal(*reinterpret_cast<float*>(ptr)); |
| 1420 } else if (type == kAstF64) { | 1420 } else if (type == kAstF64) { |
| 1421 val = WasmVal(*reinterpret_cast<double*>(ptr)); | 1421 val = WasmVal(*reinterpret_cast<double*>(ptr)); |
| 1422 } else { | 1422 } else { |
| 1423 UNREACHABLE(); | 1423 UNREACHABLE(); |
| 1424 } | 1424 } |
| 1425 Push(pc, val); | 1425 Push(pc, val); |
| 1426 len = 1 + operand.length; | 1426 len = 1 + operand.length; |
| 1427 break; | 1427 break; |
| 1428 } | 1428 } |
| 1429 case kExprStoreGlobal: { | 1429 case kExprSetGlobal: { |
| 1430 GlobalIndexOperand operand(&decoder, code->at(pc)); | 1430 GlobalIndexOperand operand(&decoder, code->at(pc)); |
| 1431 const WasmGlobal* global = &module()->globals[operand.index]; | 1431 const WasmGlobal* global = &module()->globals[operand.index]; |
| 1432 byte* ptr = instance()->globals_start + global->offset; | 1432 byte* ptr = instance()->globals_start + global->offset; |
| 1433 LocalType type = global->type; | 1433 LocalType type = global->type; |
| 1434 WasmVal val = Pop(); | 1434 WasmVal val = Pop(); |
| 1435 if (type == kAstI32) { | 1435 if (type == kAstI32) { |
| 1436 *reinterpret_cast<int32_t*>(ptr) = val.to<int32_t>(); | 1436 *reinterpret_cast<int32_t*>(ptr) = val.to<int32_t>(); |
| 1437 } else if (type == kAstI64) { | 1437 } else if (type == kAstI64) { |
| 1438 *reinterpret_cast<int64_t*>(ptr) = val.to<int64_t>(); | 1438 *reinterpret_cast<int64_t*>(ptr) = val.to<int64_t>(); |
| 1439 } else if (type == kAstF32) { | 1439 } else if (type == kAstF32) { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 | 1810 |
| 1811 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( | 1811 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( |
| 1812 Zone* zone, const byte* start, const byte* end) { | 1812 Zone* zone, const byte* start, const byte* end) { |
| 1813 ControlTransfers targets(zone, 0, start, end); | 1813 ControlTransfers targets(zone, 0, start, end); |
| 1814 return targets.map_; | 1814 return targets.map_; |
| 1815 } | 1815 } |
| 1816 | 1816 |
| 1817 } // namespace wasm | 1817 } // namespace wasm |
| 1818 } // namespace internal | 1818 } // namespace internal |
| 1819 } // namespace v8 | 1819 } // namespace v8 |
| OLD | NEW |