Index: src/wasm/wasm-module.cc |
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc |
index 386a9ce5af8a2994d11bd5182ed246e9950cd30d..c793899cdff0ef2e8f6cd3287a79a064cd642f31 100644 |
--- a/src/wasm/wasm-module.cc |
+++ b/src/wasm/wasm-module.cc |
@@ -144,12 +144,15 @@ 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 |
+ int table_size = module->FunctionTableSize(); |
Mircea Trofin
2016/06/21 19:46:14
uint32_t table_size
|
+ if (table_size == 0) { |
return Handle<FixedArray>::null(); |
} |
- int table_size = static_cast<int>(module->function_table.size()); |
+ int populated_table_size = static_cast<int>(module->function_table.size()); |
Mircea Trofin
2016/06/21 19:46:14
could you avoid the cast to int here? in fact, you
|
+ |
Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); |
- for (int i = 0; i < table_size; i++) { |
+ for (int i = 0; i < populated_table_size; i++) { |
const WasmFunction* function = |
&module->functions[module->function_table[i]]; |
fixed->set(i, Smi::FromInt(function->sig_index)); |
@@ -342,7 +345,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, |
@@ -673,9 +678,12 @@ 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++) { |
+ int table_size = instance->module->FunctionTableSize(); |
Mircea Trofin
2016/06/21 19:46:14
same note as above about avoiding the cast - I rea
|
+ DCHECK_EQ(table_size * 2, instance->function_table->length()); |
+ int populated_table_size = |
+ static_cast<int>(instance->module->function_table.size()); |
+ DCHECK_LE(populated_table_size * 2, instance->function_table->length()); |
+ for (int i = 0; i < populated_table_size; i++) { |
instance->function_table->set( |
i + table_size, |
*instance->function_code[instance->module->function_table[i]]); |