Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: src/wasm/encoder.h

Issue 2013393002: Fix wrong endianness of wasm header in WasmModuleWriter on big-endian platforms (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address code review remarks Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 WriteUnalignedUInt16(pos_, x); 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);
50 #if V8_TARGET_LITTLE_ENDIAN
45 WriteUnalignedUInt32(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
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 ZoneVector<std::pair<MachineType, bool>> globals_; 231 ZoneVector<std::pair<MachineType, bool>> globals_;
220 SignatureMap signature_map_; 232 SignatureMap signature_map_;
221 int start_function_index_; 233 int start_function_index_;
222 }; 234 };
223 235
224 } // namespace wasm 236 } // namespace wasm
225 } // namespace internal 237 } // namespace internal
226 } // namespace v8 238 } // namespace v8
227 239
228 #endif // V8_WASM_ENCODER_H_ 240 #endif // V8_WASM_ENCODER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698