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

Unified Diff: test/mjsunit/wasm/wasm-module-builder.js

Issue 1776923005: [Wasm] Move data segment data inline to the data segment section (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/wasm/module-decoder.cc ('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-module-builder.js
diff --git a/test/mjsunit/wasm/wasm-module-builder.js b/test/mjsunit/wasm/wasm-module-builder.js
index 61e074b13deeb10fe73e5ce6fc507947fd5db460..86727e787854d10b1ee07e3dbdde8d8173efd24e 100644
--- a/test/mjsunit/wasm/wasm-module-builder.js
+++ b/test/mjsunit/wasm/wasm-module-builder.js
@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-function DataRef(data) {
- this.pos = -1;
- this.data = data;
-}
-
function WasmFunctionBuilder(name, sig_index) {
this.name = name;
this.sig_index = sig_index;
@@ -118,13 +113,6 @@ function emit_string(bytes, string) {
}
}
-function emit_data_ref(bytes, string) {
- bytes.push(new DataRef(string));
- bytes.push(0);
- bytes.push(0);
- bytes.push(0);
-}
-
function emit_varint(bytes, val) {
while (true) {
var v = val & 0xff;
@@ -269,10 +257,11 @@ WasmModuleBuilder.prototype.toArray = function(debug) {
emit_u8(bytes, kDeclDataSegments);
emit_varint(bytes, this.data_segments.length);
for (seg of this.data_segments) {
- emit_u32(bytes, seg.addr);
- emit_data_ref(bytes, seg.data);
- emit_u32(bytes, seg.data.length);
- emit_u8(bytes, seg.init ? 1 : 0);
+ emit_varint(bytes, seg.addr);
+ emit_varint(bytes, seg.data.length);
+ for (var i = 0; i < seg.data.length; i++) {
+ emit_u8(bytes, seg.data[i]);
+ }
}
}
@@ -288,39 +277,6 @@ WasmModuleBuilder.prototype.toArray = function(debug) {
if (debug) print("emitting end @ " + bytes.length);
emit_u8(bytes, kDeclEnd);
- // Collect references.
- var strings = new Object();
- var data_segments = [];
- var count = 0;
- for (var i = 0; i < bytes.length; i++) {
- var b = bytes[i];
- if (b instanceof DataRef) {
- data_segments.push(b);
- count++;
- }
- }
-
- if (count > 0) {
- // Emit data.
- if (debug) print("emitting data @ " + bytes.length);
- for (ref of data_segments) {
- ref.pos = bytes.length;
- for (var i = 0; i < ref.data.length; i++) {
- emit_u8(bytes, ref.data[i]);
- }
- }
- // Update references to strings and data.
- for (var i = 0; i < bytes.length; i++) {
- var b = bytes[i];
- if (b instanceof DataRef) {
- bytes[i] = b.pos & 0xFF;
- bytes[i + 1] = (b.pos >> 8) & 0xFF;
- bytes[i + 2] = (b.pos >> 16) & 0xFF;
- bytes[i + 3] = (b.pos >> 24) & 0xFF;
- }
- }
- }
-
return bytes;
}
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | test/unittests/wasm/module-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698