| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 V(I64Ne, uint64_t, !=) \ | 53 V(I64Ne, uint64_t, !=) \ |
| 54 V(I64LtU, uint64_t, <) \ | 54 V(I64LtU, uint64_t, <) \ |
| 55 V(I64LeU, uint64_t, <=) \ | 55 V(I64LeU, uint64_t, <=) \ |
| 56 V(I64GtU, uint64_t, >) \ | 56 V(I64GtU, uint64_t, >) \ |
| 57 V(I64GeU, uint64_t, >=) \ | 57 V(I64GeU, uint64_t, >=) \ |
| 58 V(I64LtS, int64_t, <) \ | 58 V(I64LtS, int64_t, <) \ |
| 59 V(I64LeS, int64_t, <=) \ | 59 V(I64LeS, int64_t, <=) \ |
| 60 V(I64GtS, int64_t, >) \ | 60 V(I64GtS, int64_t, >) \ |
| 61 V(I64GeS, int64_t, >=) \ | 61 V(I64GeS, int64_t, >=) \ |
| 62 V(F32Add, float, +) \ | 62 V(F32Add, float, +) \ |
| 63 V(F32Sub, float, -) \ | |
| 64 V(F32Mul, float, *) \ | 63 V(F32Mul, float, *) \ |
| 65 V(F32Div, float, /) \ | 64 V(F32Div, float, /) \ |
| 66 V(F32Eq, float, ==) \ | 65 V(F32Eq, float, ==) \ |
| 67 V(F32Ne, float, !=) \ | 66 V(F32Ne, float, !=) \ |
| 68 V(F32Lt, float, <) \ | 67 V(F32Lt, float, <) \ |
| 69 V(F32Le, float, <=) \ | 68 V(F32Le, float, <=) \ |
| 70 V(F32Gt, float, >) \ | 69 V(F32Gt, float, >) \ |
| 71 V(F32Ge, float, >=) \ | 70 V(F32Ge, float, >=) \ |
| 72 V(F64Add, double, +) \ | 71 V(F64Add, double, +) \ |
| 73 V(F64Sub, double, -) \ | |
| 74 V(F64Mul, double, *) \ | 72 V(F64Mul, double, *) \ |
| 75 V(F64Div, double, /) \ | 73 V(F64Div, double, /) \ |
| 76 V(F64Eq, double, ==) \ | 74 V(F64Eq, double, ==) \ |
| 77 V(F64Ne, double, !=) \ | 75 V(F64Ne, double, !=) \ |
| 78 V(F64Lt, double, <) \ | 76 V(F64Lt, double, <) \ |
| 79 V(F64Le, double, <=) \ | 77 V(F64Le, double, <=) \ |
| 80 V(F64Gt, double, >) \ | 78 V(F64Gt, double, >) \ |
| 81 V(F64Ge, double, >=) | 79 V(F64Ge, double, >=) |
| 82 | 80 |
| 83 #define FOREACH_OTHER_BINOP(V) \ | 81 #define FOREACH_OTHER_BINOP(V) \ |
| 84 V(I32DivS, int32_t) \ | 82 V(I32DivS, int32_t) \ |
| 85 V(I32DivU, uint32_t) \ | 83 V(I32DivU, uint32_t) \ |
| 86 V(I32RemS, int32_t) \ | 84 V(I32RemS, int32_t) \ |
| 87 V(I32RemU, uint32_t) \ | 85 V(I32RemU, uint32_t) \ |
| 88 V(I32Shl, uint32_t) \ | 86 V(I32Shl, uint32_t) \ |
| 89 V(I32ShrU, uint32_t) \ | 87 V(I32ShrU, uint32_t) \ |
| 90 V(I32ShrS, int32_t) \ | 88 V(I32ShrS, int32_t) \ |
| 91 V(I64DivS, int64_t) \ | 89 V(I64DivS, int64_t) \ |
| 92 V(I64DivU, uint64_t) \ | 90 V(I64DivU, uint64_t) \ |
| 93 V(I64RemS, int64_t) \ | 91 V(I64RemS, int64_t) \ |
| 94 V(I64RemU, uint64_t) \ | 92 V(I64RemU, uint64_t) \ |
| 95 V(I64Shl, uint64_t) \ | 93 V(I64Shl, uint64_t) \ |
| 96 V(I64ShrU, uint64_t) \ | 94 V(I64ShrU, uint64_t) \ |
| 97 V(I64ShrS, int64_t) \ | 95 V(I64ShrS, int64_t) \ |
| 98 V(I32Ror, int32_t) \ | 96 V(I32Ror, int32_t) \ |
| 99 V(I32Rol, int32_t) \ | 97 V(I32Rol, int32_t) \ |
| 100 V(I64Ror, int64_t) \ | 98 V(I64Ror, int64_t) \ |
| 101 V(I64Rol, int64_t) \ | 99 V(I64Rol, int64_t) \ |
| 100 V(F32Sub, float) \ |
| 102 V(F32Min, float) \ | 101 V(F32Min, float) \ |
| 103 V(F32Max, float) \ | 102 V(F32Max, float) \ |
| 104 V(F32CopySign, float) \ | 103 V(F32CopySign, float) \ |
| 105 V(F64Min, double) \ | 104 V(F64Min, double) \ |
| 106 V(F64Max, double) \ | 105 V(F64Max, double) \ |
| 106 V(F64Sub, double) \ |
| 107 V(F64CopySign, double) \ | 107 V(F64CopySign, double) \ |
| 108 V(I32AsmjsDivS, int32_t) \ | 108 V(I32AsmjsDivS, int32_t) \ |
| 109 V(I32AsmjsDivU, uint32_t) \ | 109 V(I32AsmjsDivU, uint32_t) \ |
| 110 V(I32AsmjsRemS, int32_t) \ | 110 V(I32AsmjsRemS, int32_t) \ |
| 111 V(I32AsmjsRemU, uint32_t) | 111 V(I32AsmjsRemU, uint32_t) |
| 112 | 112 |
| 113 #define FOREACH_OTHER_UNOP(V) \ | 113 #define FOREACH_OTHER_UNOP(V) \ |
| 114 V(I32Clz, uint32_t) \ | 114 V(I32Clz, uint32_t) \ |
| 115 V(I32Ctz, uint32_t) \ | 115 V(I32Ctz, uint32_t) \ |
| 116 V(I32Popcnt, uint32_t) \ | 116 V(I32Popcnt, uint32_t) \ |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 uint64_t q = bit_cast<uint64_t>(std::numeric_limits<double>::quiet_NaN()); | 304 uint64_t q = bit_cast<uint64_t>(std::numeric_limits<double>::quiet_NaN()); |
| 305 if ((q & kSignalingBit) != 0) { | 305 if ((q & kSignalingBit) != 0) { |
| 306 // On some machines, the signaling bit set indicates it's a quiet NaN. | 306 // On some machines, the signaling bit set indicates it's a quiet NaN. |
| 307 return bit_cast<double>(bit_cast<uint64_t>(a) | kSignalingBit); | 307 return bit_cast<double>(bit_cast<uint64_t>(a) | kSignalingBit); |
| 308 } else { | 308 } else { |
| 309 // On others, the signaling bit set indicates it's a signaling NaN. | 309 // On others, the signaling bit set indicates it's a signaling NaN. |
| 310 return bit_cast<double>(bit_cast<uint64_t>(a) & ~kSignalingBit); | 310 return bit_cast<double>(bit_cast<uint64_t>(a) & ~kSignalingBit); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 static inline float ExecuteF32Sub(float a, float b, TrapReason* trap) { |
| 315 float result = a - b; |
| 316 // Some architectures (e.g. MIPS) need extra checking to preserve the payload |
| 317 // of a NaN operand. |
| 318 if (result - result != 0) { |
| 319 if (std::isnan(a)) return quiet(a); |
| 320 if (std::isnan(b)) return quiet(b); |
| 321 } |
| 322 return result; |
| 323 } |
| 324 |
| 314 static inline float ExecuteF32Min(float a, float b, TrapReason* trap) { | 325 static inline float ExecuteF32Min(float a, float b, TrapReason* trap) { |
| 315 if (std::isnan(a)) return quiet(a); | 326 if (std::isnan(a)) return quiet(a); |
| 316 if (std::isnan(b)) return quiet(b); | 327 if (std::isnan(b)) return quiet(b); |
| 317 return std::min(a, b); | 328 return std::min(a, b); |
| 318 } | 329 } |
| 319 | 330 |
| 320 static inline float ExecuteF32Max(float a, float b, TrapReason* trap) { | 331 static inline float ExecuteF32Max(float a, float b, TrapReason* trap) { |
| 321 if (std::isnan(a)) return quiet(a); | 332 if (std::isnan(a)) return quiet(a); |
| 322 if (std::isnan(b)) return quiet(b); | 333 if (std::isnan(b)) return quiet(b); |
| 323 return std::max(a, b); | 334 return std::max(a, b); |
| 324 } | 335 } |
| 325 | 336 |
| 326 static inline float ExecuteF32CopySign(float a, float b, TrapReason* trap) { | 337 static inline float ExecuteF32CopySign(float a, float b, TrapReason* trap) { |
| 327 return copysignf(a, b); | 338 return copysignf(a, b); |
| 328 } | 339 } |
| 329 | 340 |
| 341 static inline double ExecuteF64Sub(double a, double b, TrapReason* trap) { |
| 342 double result = a - b; |
| 343 // Some architectures (e.g. MIPS) need extra checking to preserve the payload |
| 344 // of a NaN operand. |
| 345 if (result - result != 0) { |
| 346 if (std::isnan(a)) return quiet(a); |
| 347 if (std::isnan(b)) return quiet(b); |
| 348 } |
| 349 return result; |
| 350 } |
| 351 |
| 330 static inline double ExecuteF64Min(double a, double b, TrapReason* trap) { | 352 static inline double ExecuteF64Min(double a, double b, TrapReason* trap) { |
| 331 if (std::isnan(a)) return quiet(a); | 353 if (std::isnan(a)) return quiet(a); |
| 332 if (std::isnan(b)) return quiet(b); | 354 if (std::isnan(b)) return quiet(b); |
| 333 return std::min(a, b); | 355 return std::min(a, b); |
| 334 } | 356 } |
| 335 | 357 |
| 336 static inline double ExecuteF64Max(double a, double b, TrapReason* trap) { | 358 static inline double ExecuteF64Max(double a, double b, TrapReason* trap) { |
| 337 if (std::isnan(a)) return quiet(a); | 359 if (std::isnan(a)) return quiet(a); |
| 338 if (std::isnan(b)) return quiet(b); | 360 if (std::isnan(b)) return quiet(b); |
| 339 return std::max(a, b); | 361 return std::max(a, b); |
| (...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 | 1821 |
| 1800 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( | 1822 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( |
| 1801 Zone* zone, const byte* start, const byte* end) { | 1823 Zone* zone, const byte* start, const byte* end) { |
| 1802 ControlTransfers targets(zone, 0, start, end); | 1824 ControlTransfers targets(zone, 0, start, end); |
| 1803 return targets.map_; | 1825 return targets.map_; |
| 1804 } | 1826 } |
| 1805 | 1827 |
| 1806 } // namespace wasm | 1828 } // namespace wasm |
| 1807 } // namespace internal | 1829 } // namespace internal |
| 1808 } // namespace v8 | 1830 } // namespace v8 |
| OLD | NEW |