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

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

Issue 2049513003: [wasm] Support undefined indirect table entries, behind a flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed static casting and formatting. Created 4 years, 6 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/wasm-module.h ('k') | test/mjsunit/wasm/default-func-call.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 62b4ab274f3d8f93a30b9fb804ee344bb3b94a79..29e342b0912f3bfea593535336b808cb2535fb07 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -144,12 +144,16 @@ void LoadDataSegments(const WasmModule* module, byte* mem_addr,
Handle<FixedArray> BuildFunctionTable(Isolate* isolate,
const WasmModule* module) {
- if (module->function_table.size() == 0) {
+ // Compute the size of the indirect function table
+ uint32_t table_size = module->FunctionTableSize();
+ if (table_size == 0) {
return Handle<FixedArray>::null();
}
- int table_size = static_cast<int>(module->function_table.size());
+
Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size);
- for (int i = 0; i < table_size; i++) {
+ for (uint32_t i = 0;
+ i < static_cast<uint32_t>(module->function_table.size());
+ ++i) {
const WasmFunction* function =
&module->functions[module->function_table[i]];
fixed->set(i, Smi::FromInt(function->sig_index));
@@ -342,7 +346,9 @@ WasmModule::WasmModule()
mem_export(false),
mem_external(false),
start_function_index(-1),
- origin(kWasmOrigin) {}
+ origin(kWasmOrigin),
+ globals_size(0),
+ indirect_table_size(0) {}
static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower,
const char* error, uint32_t index,
@@ -667,12 +673,14 @@ void CompileSequentially(Isolate* isolate, const WasmModule* module,
void PopulateFunctionTable(WasmModuleInstance* instance) {
if (!instance->function_table.is_null()) {
- int table_size = static_cast<int>(instance->module->function_table.size());
- DCHECK_EQ(instance->function_table->length(), table_size * 2);
- for (int i = 0; i < table_size; i++) {
- instance->function_table->set(
- i + table_size,
- *instance->function_code[instance->module->function_table[i]]);
+ uint32_t table_size = instance->module->FunctionTableSize();
+ DCHECK_EQ(table_size * 2, instance->function_table->length());
+ uint32_t populated_table_size =
+ static_cast<uint32_t>(instance->module->function_table.size());
+ for (uint32_t i = 0; i < populated_table_size; ++i) {
+ instance->function_table->set(
+ i + table_size,
+ *instance->function_code[instance->module->function_table[i]]);
}
}
}
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/mjsunit/wasm/default-func-call.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698