Chromium Code Reviews| Index: src/wasm/wasm-module.cc | 
| diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc | 
| index 62b4ab274f3d8f93a30b9fb804ee344bb3b94a79..ceec1026706e7de6b4bf5396d9cc40cdd3136e45 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()); | 
| 
 
ritesht
2016/06/21 23:16:33
I have to cast this as the "set" function requires
 
 | 
| + ++i) { | 
| const WasmFunction* function = | 
| &module->functions[module->function_table[i]]; | 
| fixed->set(i, Smi::FromInt(function->sig_index)); | 
| @@ -174,7 +178,7 @@ Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size, | 
| #if DEBUG | 
| // Double check the API allocator actually zero-initialized the memory. | 
| byte* bytes = reinterpret_cast<byte*>(*backing_store); | 
| - for (size_t i = 0; i < size; i++) { | 
| + for (size_t i = 0; i < size; ++i) { | 
| DCHECK_EQ(0, bytes[i]); | 
| } | 
| #endif | 
| @@ -310,7 +314,7 @@ bool LinkFunction(Handle<Code> unlinked, | 
| void LinkModuleFunctions(Isolate* isolate, | 
| std::vector<Handle<Code>>& functions) { | 
| - for (size_t i = 0; i < functions.size(); i++) { | 
| + for (size_t i = 0; i < functions.size(); ++i) { | 
| Handle<Code> code = functions[i]; | 
| bool modified = LinkFunction(code, functions, Code::WASM_FUNCTION); | 
| if (modified) { | 
| @@ -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, | 
| @@ -514,7 +520,7 @@ void InitializeParallelCompilation( | 
| Isolate* isolate, const std::vector<WasmFunction>& functions, | 
| std::vector<compiler::WasmCompilationUnit*>& compilation_units, | 
| ModuleEnv& module_env, ErrorThrower& thrower) { | 
| - for (uint32_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); i++) { | 
| + for (uint32_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); ++i) { | 
| compilation_units[i] = new compiler::WasmCompilationUnit( | 
| &thrower, isolate, &module_env, &functions[i], i); | 
| } | 
| @@ -530,7 +536,7 @@ uint32_t* StartCompilationTasks( | 
| Min(static_cast<size_t>(FLAG_wasm_num_compilation_tasks), | 
| V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()); | 
| uint32_t* task_ids = new uint32_t[num_tasks]; | 
| - for (size_t i = 0; i < num_tasks; i++) { | 
| + for (size_t i = 0; i < num_tasks; ++i) { | 
| WasmCompilationTask* task = | 
| new WasmCompilationTask(isolate, &compilation_units, &executed_units, | 
| pending_tasks.get(), &result_mutex, &next_unit); | 
| @@ -547,7 +553,7 @@ void WaitForCompilationTasks( | 
| const size_t num_tasks = | 
| Min(static_cast<size_t>(FLAG_wasm_num_compilation_tasks), | 
| V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()); | 
| - for (size_t i = 0; i < num_tasks; i++) { | 
| + for (size_t i = 0; i < num_tasks; ++i) { | 
| // If the task has not started yet, then we abort it. Otherwise we wait for | 
| // it to finish. | 
| if (!isolate->cancelable_task_manager()->TryAbort(task_ids[i])) { | 
| @@ -646,7 +652,7 @@ void CompileSequentially(Isolate* isolate, const WasmModule* module, | 
| DCHECK(!thrower->error()); | 
| for (uint32_t i = FLAG_skip_compiling_wasm_funcs; | 
| - i < module->functions.size(); i++) { | 
| + i < module->functions.size(); ++i) { | 
| const WasmFunction& func = module->functions[i]; | 
| DCHECK_EQ(i, func.func_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]]); | 
| } | 
| } | 
| } |