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

Unified Diff: src/wasm/module-decoder.cc

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/encoder.cc ('k') | test/mjsunit/wasm/wasm-module-builder.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index 8a81f442426616f3408753ccd2c7254d7147e96a..965a22dc19fafe6e434832766ae3892ff8792302 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -445,16 +445,18 @@ class ModuleDecoder : public Decoder {
// Decodes a single data segment entry inside a module starting at {pc_}.
void DecodeDataSegmentInModule(WasmModule* module, WasmDataSegment* segment) {
- segment->dest_addr = consume_u32("destination");
- segment->source_offset = consume_offset("source offset");
- segment->source_size = consume_u32("source size");
- segment->init = consume_u8("init");
+ const byte* start = pc_;
+ int length;
+ segment->dest_addr = consume_u32v(&length, "destination");
+ segment->source_size = consume_u32v(&length, "source size");
+ segment->source_offset = static_cast<uint32_t>(pc_ - start_);
+ segment->init = true;
// Validate the data is in the module.
uint32_t module_limit = static_cast<uint32_t>(limit_ - start_);
if (!IsWithinLimit(module_limit, segment->source_offset,
segment->source_size)) {
- error(pc_ - sizeof(uint32_t), "segment out of bounds of module");
+ error(start, "segment out of bounds of module");
}
// Validate that the segment will fit into the (minimum) memory.
@@ -463,8 +465,10 @@ class ModuleDecoder : public Decoder {
: WasmModule::kMaxMemPages);
if (!IsWithinLimit(memory_limit, segment->dest_addr,
segment->source_size)) {
- error(pc_ - sizeof(uint32_t), "segment out of bounds of memory");
+ error(start, "segment out of bounds of memory");
}
+
+ consume_bytes(segment->source_size);
}
// Verifies the body (code) of a given function.
« no previous file with comments | « src/wasm/encoder.cc ('k') | test/mjsunit/wasm/wasm-module-builder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698