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

Unified Diff: src/wasm/encoder.cc

Issue 1740373002: [wasm] Add a magic word and a version number to the binary. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | src/wasm/module-decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/encoder.cc
diff --git a/src/wasm/encoder.cc b/src/wasm/encoder.cc
index d80a27533884401ae845ec185b385225c56361c7..a6b2f43983e9d1952f0274a7aa5f55e6d244f435 100644
--- a/src/wasm/encoder.cc
+++ b/src/wasm/encoder.cc
@@ -461,6 +461,8 @@ struct Sizes {
WasmModuleIndex* WasmModuleWriter::WriteTo(Zone* zone) const {
Sizes sizes = {0, 0};
+ sizes.Add(2 * sizeof(uint32_t), 0); // header
+
sizes.Add(1, 0);
sizes.Add(kDeclMemorySize, 0);
@@ -495,6 +497,10 @@ WasmModuleIndex* WasmModuleWriter::WriteTo(Zone* zone) const {
byte* header = buffer;
byte* body = buffer + sizes.header_size;
+ // -- emit magic -------------------------------------------------------------
+ EmitUint32(&header, kWasmMagic);
+ EmitUint32(&header, kWasmVersion);
+
// -- emit memory declaration ------------------------------------------------
EmitUint8(&header, kDeclMemory);
EmitUint8(&header, 16); // min memory size
« no previous file with comments | « no previous file | src/wasm/module-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698