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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/encoder.h
diff --git a/src/wasm/encoder.h b/src/wasm/encoder.h
index 5d2e6c8faea1b7843ed3adb79c71fa51558f1e7e..6263284d0eef1fb47c07bf660414357c52109d75 100644
--- a/src/wasm/encoder.h
+++ b/src/wasm/encoder.h
@@ -36,13 +36,25 @@ class ZoneBuffer : public ZoneObject {
void write_u16(uint16_t x) {
EnsureSpace(2);
+#if V8_TARGET_LITTLE_ENDIAN
WriteUnalignedUInt16(pos_, x);
+#else
+ pos_[0] = x & 0xff;
+ pos_[1] = (x >> 8) & 0xff;
+#endif
pos_ += 2;
}
void write_u32(uint32_t x) {
EnsureSpace(4);
+#if V8_TARGET_LITTLE_ENDIAN
WriteUnalignedUInt32(pos_, x);
+#else
+ pos_[0] = x & 0xff;
+ pos_[1] = (x >> 8) & 0xff;
+ pos_[2] = (x >> 16) & 0xff;
+ pos_[3] = (x >> 24) & 0xff;
+#endif
pos_ += 4;
}
« 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