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

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

Issue 2626263004: [wasm] Implement WebAssembly.Module.customSections. (Closed)
Patch Set: Fix semantics 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
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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 if (decoder.pc() != table_end) { 1253 if (decoder.pc() != table_end) {
1254 decoder.error("broken asm offset table"); 1254 decoder.error("broken asm offset table");
1255 } 1255 }
1256 table.push_back(std::move(func_asm_offsets)); 1256 table.push_back(std::move(func_asm_offsets));
1257 } 1257 }
1258 if (decoder.more()) decoder.error("unexpected additional bytes"); 1258 if (decoder.more()) decoder.error("unexpected additional bytes");
1259 1259
1260 return decoder.toResult(std::move(table)); 1260 return decoder.toResult(std::move(table));
1261 } 1261 }
1262 1262
1263 std::vector<CustomSectionOffset> DecodeCustomSections(const byte* start,
1264 const byte* end) {
1265 Decoder decoder(start, end);
1266 decoder.consume_bytes(4, "wasm magic");
1267 decoder.consume_bytes(4, "wasm version");
1268
1269 std::vector<CustomSectionOffset> result;
1270
1271 while (decoder.more()) {
1272 byte section_code = decoder.consume_u8("section code");
1273 uint32_t section_length = decoder.consume_u32v("section length");
1274 uint32_t section_start = decoder.pc_offset();
1275 if (section_code != 0) {
1276 // Skip known sections.
1277 decoder.consume_bytes(section_length, "section bytes");
1278 continue;
1279 }
1280 uint32_t name_length = decoder.consume_u32v("name length");
1281 uint32_t name_offset = decoder.pc_offset();
1282 decoder.consume_bytes(name_length, "section name");
1283 uint32_t payload_offset = decoder.pc_offset();
1284 uint32_t payload_length = section_length - (payload_offset - section_start);
1285 decoder.consume_bytes(payload_length);
1286 result.push_back({section_start, name_offset, name_length, payload_offset,
1287 payload_length, section_length});
1288 }
1289
1290 return result;
1291 }
1292
1263 } // namespace wasm 1293 } // namespace wasm
1264 } // namespace internal 1294 } // namespace internal
1265 } // namespace v8 1295 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.h ('k') | src/wasm/wasm-js.cc » ('j') | src/wasm/wasm-js.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698