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

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
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..599d8f79090609ca9c65bc59149f828ad301ee71 100644
--- a/test/mjsunit/wasm/wasm-constants.js
+++ b/test/mjsunit/wasm/wasm-constants.js
@@ -15,6 +15,39 @@ 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;
+ print(view[1]);
binji 2016/02/27 19:26:56 did you leave this in while testing?
titzer 2016/02/27 23:05:09 Good catch. Removed.
+ 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;

Powered by Google App Engine
This is Rietveld 408576698