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 | 6 |
7 #include "src/utils.h" | 7 #include "src/utils.h" |
8 #include "src/wasm/decoder.h" | 8 #include "src/wasm/decoder.h" |
9 #include "src/wasm/function-body-decoder.h" | 9 #include "src/wasm/function-body-decoder.h" |
10 #include "src/wasm/wasm-external-refs.h" | 10 #include "src/wasm/wasm-external-refs.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 V(F32SConvertI64, int64_t) \ | 152 V(F32SConvertI64, int64_t) \ |
153 V(F32UConvertI64, uint64_t) \ | 153 V(F32UConvertI64, uint64_t) \ |
154 V(F32ConvertF64, double) \ | 154 V(F32ConvertF64, double) \ |
155 V(F32ReinterpretI32, int32_t) \ | 155 V(F32ReinterpretI32, int32_t) \ |
156 V(F64SConvertI32, int32_t) \ | 156 V(F64SConvertI32, int32_t) \ |
157 V(F64UConvertI32, uint32_t) \ | 157 V(F64UConvertI32, uint32_t) \ |
158 V(F64SConvertI64, int64_t) \ | 158 V(F64SConvertI64, int64_t) \ |
159 V(F64UConvertI64, uint64_t) \ | 159 V(F64UConvertI64, uint64_t) \ |
160 V(F64ConvertF32, float) \ | 160 V(F64ConvertF32, float) \ |
161 V(F64ReinterpretI64, int64_t) \ | 161 V(F64ReinterpretI64, int64_t) \ |
162 V(I32ReinterpretF32, float) \ | |
163 V(I64ReinterpretF64, double) \ | |
164 V(I32AsmjsSConvertF32, float) \ | 162 V(I32AsmjsSConvertF32, float) \ |
165 V(I32AsmjsUConvertF32, float) \ | 163 V(I32AsmjsUConvertF32, float) \ |
166 V(I32AsmjsSConvertF64, double) \ | 164 V(I32AsmjsSConvertF64, double) \ |
167 V(I32AsmjsUConvertF64, double) | 165 V(I32AsmjsUConvertF64, double) |
168 | 166 |
169 #define FOREACH_OTHER_UNOP_NAN(V) \ | 167 #define FOREACH_OTHER_UNOP_NAN(V) \ |
170 V(F32Sqrt, float) \ | 168 V(F32Sqrt, float) \ |
171 V(F64Sqrt, double) | 169 V(F64Sqrt, double) |
172 | 170 |
173 static inline int32_t ExecuteI32DivS(int32_t a, int32_t b, TrapReason* trap) { | 171 static inline int32_t ExecuteI32DivS(int32_t a, int32_t b, TrapReason* trap) { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 } | 597 } |
600 | 598 |
601 static inline double ExecuteF64ConvertF32(float a, TrapReason* trap) { | 599 static inline double ExecuteF64ConvertF32(float a, TrapReason* trap) { |
602 return static_cast<double>(a); | 600 return static_cast<double>(a); |
603 } | 601 } |
604 | 602 |
605 static inline double ExecuteF64ReinterpretI64(int64_t a, TrapReason* trap) { | 603 static inline double ExecuteF64ReinterpretI64(int64_t a, TrapReason* trap) { |
606 return bit_cast<double>(a); | 604 return bit_cast<double>(a); |
607 } | 605 } |
608 | 606 |
609 static inline int32_t ExecuteI32ReinterpretF32(float a, TrapReason* trap) { | 607 static inline int32_t ExecuteI32ReinterpretF32(WasmVal a) { |
610 return bit_cast<int32_t>(a); | 608 return a.to_unchecked<int32_t>(); |
611 } | 609 } |
612 | 610 |
613 static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { | 611 static inline int64_t ExecuteI64ReinterpretF64(WasmVal a) { |
614 return bit_cast<int64_t>(a); | 612 return a.to_unchecked<int64_t>(); |
615 } | 613 } |
616 | 614 |
617 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, | 615 static inline int32_t ExecuteGrowMemory(uint32_t delta_pages, |
618 WasmInstance* instance) { | 616 WasmInstance* instance) { |
619 // TODO(ahaas): Move memory allocation to wasm-module.cc for better | 617 // TODO(ahaas): Move memory allocation to wasm-module.cc for better |
620 // encapsulation. | 618 // encapsulation. |
621 if (delta_pages > wasm::kV8MaxWasmMemoryPages || | 619 if (delta_pages > wasm::kV8MaxWasmMemoryPages || |
622 delta_pages > instance->module->max_mem_pages) { | 620 delta_pages > instance->module->max_mem_pages) { |
623 return -1; | 621 return -1; |
624 } | 622 } |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1547 len = 1 + operand.length; | 1545 len = 1 + operand.length; |
1548 break; | 1546 break; |
1549 } | 1547 } |
1550 case kExprMemorySize: { | 1548 case kExprMemorySize: { |
1551 MemoryIndexOperand operand(&decoder, code->at(pc)); | 1549 MemoryIndexOperand operand(&decoder, code->at(pc)); |
1552 Push(pc, WasmVal(static_cast<uint32_t>(instance()->mem_size / | 1550 Push(pc, WasmVal(static_cast<uint32_t>(instance()->mem_size / |
1553 WasmModule::kPageSize))); | 1551 WasmModule::kPageSize))); |
1554 len = 1 + operand.length; | 1552 len = 1 + operand.length; |
1555 break; | 1553 break; |
1556 } | 1554 } |
1555 // We handle kExprI32ReinterpretF32 and kExprI64ReinterpretF64 specially | |
1556 // because on ia32 we may loose the signalling bit of NaNs otherwise. | |
Clemens Hammacher
2017/01/18 18:03:49
lose, not loose. I would also write signaling inst
ahaas
2017/01/18 18:13:49
I rewrote the comment.
| |
1557 case kExprI32ReinterpretF32: { | |
1558 WasmVal result(ExecuteI32ReinterpretF32(Pop())); | |
1559 Push(pc, result); | |
1560 break; | |
1561 } | |
1562 case kExprI64ReinterpretF64: { | |
1563 WasmVal result(ExecuteI64ReinterpretF64(Pop())); | |
1564 Push(pc, result); | |
1565 break; | |
1566 } | |
1557 #define EXECUTE_SIMPLE_BINOP(name, ctype, op) \ | 1567 #define EXECUTE_SIMPLE_BINOP(name, ctype, op) \ |
1558 case kExpr##name: { \ | 1568 case kExpr##name: { \ |
1559 WasmVal rval = Pop(); \ | 1569 WasmVal rval = Pop(); \ |
1560 WasmVal lval = Pop(); \ | 1570 WasmVal lval = Pop(); \ |
1561 WasmVal result(lval.to<ctype>() op rval.to<ctype>()); \ | 1571 WasmVal result(lval.to<ctype>() op rval.to<ctype>()); \ |
1562 Push(pc, result); \ | 1572 Push(pc, result); \ |
1563 break; \ | 1573 break; \ |
1564 } | 1574 } |
1565 FOREACH_SIMPLE_BINOP(EXECUTE_SIMPLE_BINOP) | 1575 FOREACH_SIMPLE_BINOP(EXECUTE_SIMPLE_BINOP) |
1566 #undef EXECUTE_SIMPLE_BINOP | 1576 #undef EXECUTE_SIMPLE_BINOP |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1839 | 1849 |
1840 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( | 1850 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( |
1841 Zone* zone, const byte* start, const byte* end) { | 1851 Zone* zone, const byte* start, const byte* end) { |
1842 ControlTransfers targets(zone, nullptr, start, end); | 1852 ControlTransfers targets(zone, nullptr, start, end); |
1843 return targets.map_; | 1853 return targets.map_; |
1844 } | 1854 } |
1845 | 1855 |
1846 } // namespace wasm | 1856 } // namespace wasm |
1847 } // namespace internal | 1857 } // namespace internal |
1848 } // namespace v8 | 1858 } // namespace v8 |
OLD | NEW |