OLD | NEW |
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 #ifndef V8_WASM_FUNCTION_BODY_DECODER_H_ | 5 #ifndef V8_WASM_FUNCTION_BODY_DECODER_H_ |
6 #define V8_WASM_FUNCTION_BODY_DECODER_H_ | 6 #define V8_WASM_FUNCTION_BODY_DECODER_H_ |
7 | 7 |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "src/base/compiler-specific.h" | 10 #include "src/base/compiler-specific.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 unsigned length; | 63 unsigned length; |
64 inline ImmI64Operand(Decoder* decoder, const byte* pc) { | 64 inline ImmI64Operand(Decoder* decoder, const byte* pc) { |
65 value = decoder->checked_read_i64v(pc, 1, &length, "immi64"); | 65 value = decoder->checked_read_i64v(pc, 1, &length, "immi64"); |
66 } | 66 } |
67 }; | 67 }; |
68 | 68 |
69 struct ImmF32Operand { | 69 struct ImmF32Operand { |
70 float value; | 70 float value; |
71 unsigned length; | 71 unsigned length; |
72 inline ImmF32Operand(Decoder* decoder, const byte* pc) { | 72 inline ImmF32Operand(Decoder* decoder, const byte* pc) { |
73 value = bit_cast<float>(decoder->checked_read_u32(pc, 1, "immf32")); | 73 // Avoid bit_cast because it might not preserve the signalling bit of a NaN. |
| 74 uint32_t tmp = decoder->checked_read_u32(pc, 1, "immf32"); |
| 75 memcpy(&value, &tmp, sizeof(value)); |
74 length = 4; | 76 length = 4; |
75 } | 77 } |
76 }; | 78 }; |
77 | 79 |
78 struct ImmF64Operand { | 80 struct ImmF64Operand { |
79 double value; | 81 double value; |
80 unsigned length; | 82 unsigned length; |
81 inline ImmF64Operand(Decoder* decoder, const byte* pc) { | 83 inline ImmF64Operand(Decoder* decoder, const byte* pc) { |
82 value = bit_cast<double>(decoder->checked_read_u64(pc, 1, "immf64")); | 84 // Avoid bit_cast because it might not preserve the signalling bit of a NaN. |
| 85 uint64_t tmp = decoder->checked_read_u64(pc, 1, "immf64"); |
| 86 memcpy(&value, &tmp, sizeof(value)); |
83 length = 8; | 87 length = 8; |
84 } | 88 } |
85 }; | 89 }; |
86 | 90 |
87 struct GlobalIndexOperand { | 91 struct GlobalIndexOperand { |
88 uint32_t index; | 92 uint32_t index; |
89 ValueType type; | 93 ValueType type; |
90 const WasmGlobal* global; | 94 const WasmGlobal* global; |
91 unsigned length; | 95 unsigned length; |
92 | 96 |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 468 } |
465 | 469 |
466 bool has_next() { return pc_ < end_; } | 470 bool has_next() { return pc_ < end_; } |
467 }; | 471 }; |
468 | 472 |
469 } // namespace wasm | 473 } // namespace wasm |
470 } // namespace internal | 474 } // namespace internal |
471 } // namespace v8 | 475 } // namespace v8 |
472 | 476 |
473 #endif // V8_WASM_FUNCTION_BODY_DECODER_H_ | 477 #endif // V8_WASM_FUNCTION_BODY_DECODER_H_ |
OLD | NEW |