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 #if V8_TARGET_LITTLE_ENDIAN | 39 WriteLittleEndianValue<uint16_t>(pos_, x); |
40 WriteUnalignedUInt16(pos_, x); | |
41 #else | |
42 pos_[0] = x & 0xff; | |
43 pos_[1] = (x >> 8) & 0xff; | |
44 #endif | |
45 pos_ += 2; | 40 pos_ += 2; |
46 } | 41 } |
47 | 42 |
48 void write_u32(uint32_t x) { | 43 void write_u32(uint32_t x) { |
49 EnsureSpace(4); | 44 EnsureSpace(4); |
50 #if V8_TARGET_LITTLE_ENDIAN | 45 WriteLittleEndianValue<uint32_t>(pos_, x); |
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 | |
58 pos_ += 4; | 46 pos_ += 4; |
59 } | 47 } |
60 | 48 |
61 void write_u32v(uint32_t val) { | 49 void write_u32v(uint32_t val) { |
62 EnsureSpace(kMaxVarInt32Size); | 50 EnsureSpace(kMaxVarInt32Size); |
63 LEBHelper::write_u32v(&pos_, val); | 51 LEBHelper::write_u32v(&pos_, val); |
64 } | 52 } |
65 | 53 |
66 void write_size(size_t val) { | 54 void write_size(size_t val) { |
67 EnsureSpace(kMaxVarInt32Size); | 55 EnsureSpace(kMaxVarInt32Size); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ZoneVector<std::pair<MachineType, bool>> globals_; | 198 ZoneVector<std::pair<MachineType, bool>> globals_; |
211 SignatureMap signature_map_; | 199 SignatureMap signature_map_; |
212 int start_function_index_; | 200 int start_function_index_; |
213 }; | 201 }; |
214 | 202 |
215 } // namespace wasm | 203 } // namespace wasm |
216 } // namespace internal | 204 } // namespace internal |
217 } // namespace v8 | 205 } // namespace v8 |
218 | 206 |
219 #endif // V8_WASM_ENCODER_H_ | 207 #endif // V8_WASM_ENCODER_H_ |
OLD | NEW |