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

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

Issue 2501873003: [wasm] Be more lenient on the names section. (Closed)
Patch Set: Fix builders to add empty import names. Created 4 years, 1 month 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.cc ('k') | test/mjsunit/wasm/wasm-module-builder.js » ('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/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/handles.h" 7 #include "src/handles.h"
8 #include "src/v8.h" 8 #include "src/v8.h"
9 #include "src/zone/zone-containers.h" 9 #include "src/zone/zone-containers.h"
10 10
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // == Emit names ============================================================= 502 // == Emit names =============================================================
503 if (has_names) { 503 if (has_names) {
504 // Emit the section code. 504 // Emit the section code.
505 buffer.write_u8(kUnknownSectionCode); 505 buffer.write_u8(kUnknownSectionCode);
506 // Emit a placeholder for the length. 506 // Emit a placeholder for the length.
507 size_t start = buffer.reserve_u32v(); 507 size_t start = buffer.reserve_u32v();
508 // Emit the section string. 508 // Emit the section string.
509 buffer.write_size(4); 509 buffer.write_size(4);
510 buffer.write(reinterpret_cast<const byte*>("name"), 4); 510 buffer.write(reinterpret_cast<const byte*>("name"), 4);
511 // Emit the names. 511 // Emit the names.
512 buffer.write_size(functions_.size()); 512 size_t count = functions_.size() + imports_.size();
513 buffer.write_size(count);
514 for (size_t i = 0; i < imports_.size(); i++) {
515 buffer.write_u8(0); // empty name for import
516 buffer.write_u8(0); // no local variables
517 }
513 for (auto function : functions_) { 518 for (auto function : functions_) {
514 buffer.write_size(function->name_.size()); 519 buffer.write_size(function->name_.size());
515 if (function->name_.size() > 0) { 520 if (function->name_.size() > 0) {
516 buffer.write(reinterpret_cast<const byte*>(&function->name_[0]), 521 buffer.write(reinterpret_cast<const byte*>(&function->name_[0]),
517 function->name_.size()); 522 function->name_.size());
518 } 523 }
519 buffer.write_u8(0); 524 buffer.write_u8(0);
520 } 525 }
521 FixupSection(buffer, start); 526 FixupSection(buffer, start);
522 } 527 }
523 } 528 }
524 529
525 void WasmModuleBuilder::WriteAsmJsOffsetTable(ZoneBuffer& buffer) const { 530 void WasmModuleBuilder::WriteAsmJsOffsetTable(ZoneBuffer& buffer) const {
526 // == Emit asm.js offset table =============================================== 531 // == Emit asm.js offset table ===============================================
527 buffer.write_size(functions_.size()); 532 buffer.write_size(functions_.size());
528 // Emit the offset table per function. 533 // Emit the offset table per function.
529 for (auto function : functions_) { 534 for (auto function : functions_) {
530 function->WriteAsmWasmOffsetTable(buffer); 535 function->WriteAsmWasmOffsetTable(buffer);
531 } 536 }
532 } 537 }
533 } // namespace wasm 538 } // namespace wasm
534 } // namespace internal 539 } // namespace internal
535 } // namespace v8 540 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | test/mjsunit/wasm/wasm-module-builder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698