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

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

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: 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 | « src/base/bits.h ('k') | src/wasm/wasm-external-refs.h » ('j') | 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 #include "src/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/handles.h" 7 #include "src/handles.h"
8 #include "src/v8.h" 8 #include "src/v8.h"
9 #include "src/zone-containers.h" 9 #include "src/zone-containers.h"
10 10
11 #include "src/wasm/ast-decoder.h" 11 #include "src/wasm/ast-decoder.h"
12 #include "src/wasm/encoder.h" 12 #include "src/wasm/encoder.h"
13 #include "src/wasm/leb-helper.h" 13 #include "src/wasm/leb-helper.h"
14 #include "src/wasm/wasm-external-refs.h"
14 #include "src/wasm/wasm-macro-gen.h" 15 #include "src/wasm/wasm-macro-gen.h"
15 #include "src/wasm/wasm-module.h" 16 #include "src/wasm/wasm-module.h"
16 #include "src/wasm/wasm-opcodes.h" 17 #include "src/wasm/wasm-opcodes.h"
17 18
18 #include "src/v8memory.h" 19 #include "src/v8memory.h"
19 20
20 #if DEBUG 21 #if DEBUG
21 #define TRACE(...) \ 22 #define TRACE(...) \
22 do { \ 23 do { \
23 if (FLAG_trace_wasm_encoder) PrintF(__VA_ARGS__); \ 24 if (FLAG_trace_wasm_encoder) PrintF(__VA_ARGS__); \
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 data_segments_(zone), 292 data_segments_(zone),
292 signatures_(zone), 293 signatures_(zone),
293 indirect_functions_(zone), 294 indirect_functions_(zone),
294 globals_(zone) {} 295 globals_(zone) {}
295 296
296 void WasmModuleWriter::WriteTo(ZoneBuffer& buffer) const { 297 void WasmModuleWriter::WriteTo(ZoneBuffer& buffer) const {
297 uint32_t exports = 0; 298 uint32_t exports = 0;
298 299
299 // == Emit magic ============================================================= 300 // == Emit magic =============================================================
300 TRACE("emit magic\n"); 301 TRACE("emit magic\n");
301 buffer.write_u32(kWasmMagic); 302 buffer.write_u32(word32_to_little_endianness(&kWasmMagic));
titzer 2016/05/27 10:47:27 What about instead making the write_u32 function a
ivica.bogosavljevic 2016/05/27 12:23:24 Say no more!
302 buffer.write_u32(kWasmVersion); 303 buffer.write_u32(word32_to_little_endianness(&kWasmVersion));
303 304
304 // == Emit signatures ======================================================== 305 // == Emit signatures ========================================================
305 if (signatures_.size() > 0) { 306 if (signatures_.size() > 0) {
306 size_t start = EmitSection(WasmSection::Code::Signatures, buffer); 307 size_t start = EmitSection(WasmSection::Code::Signatures, buffer);
307 buffer.write_size(signatures_.size()); 308 buffer.write_size(signatures_.size());
308 309
309 for (FunctionSig* sig : signatures_) { 310 for (FunctionSig* sig : signatures_) {
310 buffer.write_u8(kWasmFunctionTypeForm); 311 buffer.write_u8(kWasmFunctionTypeForm);
311 buffer.write_size(sig->parameter_count()); 312 buffer.write_size(sig->parameter_count());
312 for (size_t j = 0; j < sig->parameter_count(); j++) { 313 for (size_t j = 0; j < sig->parameter_count(); j++) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 415
415 for (auto segment : data_segments_) { 416 for (auto segment : data_segments_) {
416 segment->Write(buffer); 417 segment->Write(buffer);
417 } 418 }
418 FixupSection(buffer, start); 419 FixupSection(buffer, start);
419 } 420 }
420 } 421 }
421 } // namespace wasm 422 } // namespace wasm
422 } // namespace internal 423 } // namespace internal
423 } // namespace v8 424 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/bits.h ('k') | src/wasm/wasm-external-refs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698