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

Side by Side Diff: src/wasm/module-decoder.cc

Issue 2626263004: [wasm] Implement WebAssembly.Module.customSections. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/wasm/module-decoder.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/wasm/module-decoder.h" 5 #include "src/wasm/module-decoder.h"
6 6
7 #include "src/base/functional.h" 7 #include "src/base/functional.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 if (decoder.pc() != table_end) { 1232 if (decoder.pc() != table_end) {
1233 decoder.error("broken asm offset table"); 1233 decoder.error("broken asm offset table");
1234 } 1234 }
1235 table.push_back(std::move(func_asm_offsets)); 1235 table.push_back(std::move(func_asm_offsets));
1236 } 1236 }
1237 if (decoder.more()) decoder.error("unexpected additional bytes"); 1237 if (decoder.more()) decoder.error("unexpected additional bytes");
1238 1238
1239 return decoder.toResult(std::move(table)); 1239 return decoder.toResult(std::move(table));
1240 } 1240 }
1241 1241
1242 std::vector<CustomSectionOffset> DecodeCustomSections(const byte* start,
1243 const byte* end) {
1244 Decoder decoder(start, end);
1245 decoder.consume_bytes(4, "wasm magic");
1246 decoder.consume_bytes(4, "wasm version");
1247
1248 std::vector<CustomSectionOffset> result;
1249
1250 while (decoder.more()) {
1251 byte section_code = decoder.consume_u8("section code");
ahaas 2017/01/13 15:01:26 The section code should be a varuint7.
1252 uint32_t section_length = decoder.consume_u32v("section length");
1253 uint32_t section_start = decoder.pc_offset();
1254 if (section_code != 0) {
1255 // Skip known sections.
1256 decoder.consume_bytes(section_length, "section bytes");
1257 continue;
1258 }
1259 uint32_t name_length = decoder.consume_u32v("name length");
1260 uint32_t name_offset = decoder.pc_offset();
1261 decoder.consume_bytes(name_length, "section name");
1262 uint32_t payload_offset = decoder.pc_offset();
1263 uint32_t payload_length = section_length - (payload_offset - section_start);
1264 decoder.consume_bytes(payload_length);
1265 result.push_back({section_start, name_offset, name_length, payload_offset,
1266 payload_length, section_length});
1267 }
1268
1269 return result;
1270 }
1271
1242 } // namespace wasm 1272 } // namespace wasm
1243 } // namespace internal 1273 } // namespace internal
1244 } // namespace v8 1274 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.h ('k') | src/wasm/wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698