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_ENCODER_H_ | 5 #ifndef V8_WASM_ENCODER_H_ |
6 #define V8_WASM_ENCODER_H_ | 6 #define V8_WASM_ENCODER_H_ |
7 | 7 |
8 #include "src/signature.h" | 8 #include "src/signature.h" |
9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 end_ = buffer_ + initial; | 29 end_ = buffer_ + initial; |
30 } | 30 } |
31 | 31 |
32 void write_u8(uint8_t x) { | 32 void write_u8(uint8_t x) { |
33 EnsureSpace(1); | 33 EnsureSpace(1); |
34 *(pos_++) = x; | 34 *(pos_++) = x; |
35 } | 35 } |
36 | 36 |
37 void write_u16(uint16_t x) { | 37 void write_u16(uint16_t x) { |
38 EnsureSpace(2); | 38 EnsureSpace(2); |
39 WriteLittleEndianValue<uint16_t>(pos_, x); | 39 #if V8_TARGET_LITTLE_ENDIAN |
| 40 WriteUnalignedUInt16(pos_, x); |
| 41 #else |
| 42 pos_[0] = x & 0xff; |
| 43 pos_[1] = (x >> 8) & 0xff; |
| 44 #endif |
40 pos_ += 2; | 45 pos_ += 2; |
41 } | 46 } |
42 | 47 |
43 void write_u32(uint32_t x) { | 48 void write_u32(uint32_t x) { |
44 EnsureSpace(4); | 49 EnsureSpace(4); |
45 WriteLittleEndianValue<uint32_t>(pos_, x); | 50 #if V8_TARGET_LITTLE_ENDIAN |
| 51 WriteUnalignedUInt32(pos_, x); |
| 52 #else |
| 53 pos_[0] = x & 0xff; |
| 54 pos_[1] = (x >> 8) & 0xff; |
| 55 pos_[2] = (x >> 16) & 0xff; |
| 56 pos_[3] = (x >> 24) & 0xff; |
| 57 #endif |
46 pos_ += 4; | 58 pos_ += 4; |
47 } | 59 } |
48 | 60 |
49 void write_u32v(uint32_t val) { | 61 void write_u32v(uint32_t val) { |
50 EnsureSpace(kMaxVarInt32Size); | 62 EnsureSpace(kMaxVarInt32Size); |
51 LEBHelper::write_u32v(&pos_, val); | 63 LEBHelper::write_u32v(&pos_, val); |
52 } | 64 } |
53 | 65 |
54 void write_size(size_t val) { | 66 void write_size(size_t val) { |
55 EnsureSpace(kMaxVarInt32Size); | 67 EnsureSpace(kMaxVarInt32Size); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 ZoneVector<std::pair<MachineType, bool>> globals_; | 210 ZoneVector<std::pair<MachineType, bool>> globals_; |
199 SignatureMap signature_map_; | 211 SignatureMap signature_map_; |
200 int start_function_index_; | 212 int start_function_index_; |
201 }; | 213 }; |
202 | 214 |
203 } // namespace wasm | 215 } // namespace wasm |
204 } // namespace internal | 216 } // namespace internal |
205 } // namespace v8 | 217 } // namespace v8 |
206 | 218 |
207 #endif // V8_WASM_ENCODER_H_ | 219 #endif // V8_WASM_ENCODER_H_ |
OLD | NEW |