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

Unified Diff: test/mjsunit/wasm/wasm-constants.js

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 | « test/mjsunit/wasm/unreachable.js ('k') | test/unittests/wasm/module-decoder-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/wasm-constants.js
diff --git a/test/mjsunit/wasm/wasm-constants.js b/test/mjsunit/wasm/wasm-constants.js
index 861ffa562c030db9ec4bd78b57d51d5c7b748745..f8558fced8ea9bedfb607fb44202ba6917a352cc 100644
--- a/test/mjsunit/wasm/wasm-constants.js
+++ b/test/mjsunit/wasm/wasm-constants.js
@@ -15,6 +15,38 @@ function bytes() {
return buffer;
}
+// Header declaration constants
+var kWasmH0 = 0;
+var kWasmH1 = 0x61;
+var kWasmH2 = 0x73;
+var kWasmH3 = 0x6d;
+
+var kWasmV0 = 10;
+var kWasmV1 = 0;
+var kWasmV2 = 0;
+var kWasmV3 = 0;
+
+var kHeaderSize = 8;
+
+function bytesWithHeader() {
+ var buffer = new ArrayBuffer(kHeaderSize + arguments.length);
+ var view = new Uint8Array(buffer);
+ view[0] = kWasmH0;
+ view[1] = kWasmH1;
+ view[2] = kWasmH2;
+ view[3] = kWasmH3;
+ view[4] = kWasmV0;
+ view[5] = kWasmV1;
+ view[6] = kWasmV2;
+ view[7] = kWasmV3;
+ for (var i = 0; i < arguments.length; i++) {
+ var val = arguments[i];
+ if ((typeof val) == "string") val = val.charCodeAt(0);
+ view[kHeaderSize + i] = val | 0;
+ }
+ return buffer;
+}
+
// Section declaration constants
var kDeclMemory = 0x00;
var kDeclSignatures = 0x01;
« no previous file with comments | « test/mjsunit/wasm/unreachable.js ('k') | test/unittests/wasm/module-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698