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

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

Issue 1744713003: [wasm] Add an export table. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | src/wasm/wasm-module.h » ('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 62b000da2bfd8b3d5df0b2c612a027ffe0a64946..9ba0b3b663f5bdd5c8e6f53861272faeb83d05ab 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -55,6 +55,7 @@ class ModuleDecoder : public Decoder {
module->data_segments = new std::vector<WasmDataSegment>();
module->function_table = new std::vector<uint16_t>();
module->import_table = new std::vector<WasmImport>();
+ module->export_table = new std::vector<WasmExport>();
bool sections[kMaxModuleSectionCode];
memset(sections, 0, sizeof(sections));
@@ -234,6 +235,34 @@ class ModuleDecoder : public Decoder {
}
break;
}
+ case kDeclExportTable: {
+ // Declares an export table.
+ CheckForPreviousSection(sections, kDeclFunctions, true);
+ int length;
+ uint32_t export_table_count =
+ consume_u32v(&length, "export table count");
+ module->export_table->reserve(SafeReserve(export_table_count));
+ // Decode export table.
+ for (uint32_t i = 0; i < export_table_count; i++) {
+ if (failed()) break;
+ TRACE("DecodeExportTable[%d] module+%d\n", i,
+ static_cast<int>(pc_ - start_));
+
+ module->export_table->push_back({0, 0});
+ WasmExport* exp = &module->export_table->back();
+
+ const byte* sigpos = pc_;
+ exp->func_index = consume_u16("function index");
+ if (exp->func_index >= module->functions->size()) {
+ error(sigpos, sigpos,
+ "function index %u out of bounds (%d functions)",
+ exp->func_index,
+ static_cast<int>(module->functions->size()));
+ }
+ exp->name_offset = consume_string("export name");
+ }
+ break;
+ }
case kDeclWLL: {
// Reserved for experimentation by the Web Low-level Language project
// which is augmenting the binary encoding with source code meta
« no previous file with comments | « no previous file | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698