Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/base/atomic-utils.h" | 5 #include "src/base/atomic-utils.h" |
| 6 #include "src/macro-assembler.h" | 6 #include "src/macro-assembler.h" |
| 7 #include "src/objects.h" | 7 #include "src/objects.h" |
| 8 #include "src/property-descriptor.h" | 8 #include "src/property-descriptor.h" |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 CHECK_LE(segment.source_size, mem_size); | 137 CHECK_LE(segment.source_size, mem_size); |
| 138 CHECK_LE(segment.dest_addr + segment.source_size, mem_size); | 138 CHECK_LE(segment.dest_addr + segment.source_size, mem_size); |
| 139 byte* addr = mem_addr + segment.dest_addr; | 139 byte* addr = mem_addr + segment.dest_addr; |
| 140 memcpy(addr, module->module_start + segment.source_offset, | 140 memcpy(addr, module->module_start + segment.source_offset, |
| 141 segment.source_size); | 141 segment.source_size); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, | 145 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, |
| 146 const WasmModule* module) { | 146 const WasmModule* module) { |
| 147 if (module->function_table.size() == 0) { | 147 // Compute the size of the indirect function table |
| 148 int table_size = module->FunctionTableSize(); | |
|
Mircea Trofin
2016/06/21 19:46:14
uint32_t table_size
| |
| 149 if (table_size == 0) { | |
| 148 return Handle<FixedArray>::null(); | 150 return Handle<FixedArray>::null(); |
| 149 } | 151 } |
| 150 int table_size = static_cast<int>(module->function_table.size()); | 152 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
| |
| 153 | |
| 151 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); | 154 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); |
| 152 for (int i = 0; i < table_size; i++) { | 155 for (int i = 0; i < populated_table_size; i++) { |
| 153 const WasmFunction* function = | 156 const WasmFunction* function = |
| 154 &module->functions[module->function_table[i]]; | 157 &module->functions[module->function_table[i]]; |
| 155 fixed->set(i, Smi::FromInt(function->sig_index)); | 158 fixed->set(i, Smi::FromInt(function->sig_index)); |
| 156 } | 159 } |
| 157 return fixed; | 160 return fixed; |
| 158 } | 161 } |
| 159 | 162 |
| 160 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size, | 163 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size, |
| 161 byte** backing_store) { | 164 byte** backing_store) { |
| 162 *backing_store = nullptr; | 165 *backing_store = nullptr; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 } // namespace | 338 } // namespace |
| 336 | 339 |
| 337 WasmModule::WasmModule() | 340 WasmModule::WasmModule() |
| 338 : module_start(nullptr), | 341 : module_start(nullptr), |
| 339 module_end(nullptr), | 342 module_end(nullptr), |
| 340 min_mem_pages(0), | 343 min_mem_pages(0), |
| 341 max_mem_pages(0), | 344 max_mem_pages(0), |
| 342 mem_export(false), | 345 mem_export(false), |
| 343 mem_external(false), | 346 mem_external(false), |
| 344 start_function_index(-1), | 347 start_function_index(-1), |
| 345 origin(kWasmOrigin) {} | 348 origin(kWasmOrigin), |
| 349 globals_size(0), | |
| 350 indirect_table_size(0) {} | |
| 346 | 351 |
| 347 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, | 352 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, |
| 348 const char* error, uint32_t index, | 353 const char* error, uint32_t index, |
| 349 wasm::WasmName module_name, | 354 wasm::WasmName module_name, |
| 350 wasm::WasmName function_name) { | 355 wasm::WasmName function_name) { |
| 351 if (!function_name.is_empty()) { | 356 if (!function_name.is_empty()) { |
| 352 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", | 357 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", |
| 353 index, module_name.length(), module_name.start(), | 358 index, module_name.length(), module_name.start(), |
| 354 function_name.length(), function_name.start(), error); | 359 function_name.length(), function_name.start(), error); |
| 355 } else { | 360 } else { |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 str.start()); | 671 str.start()); |
| 667 break; | 672 break; |
| 668 } | 673 } |
| 669 // Install the code into the linker table. | 674 // Install the code into the linker table. |
| 670 functions[i] = code; | 675 functions[i] = code; |
| 671 } | 676 } |
| 672 } | 677 } |
| 673 | 678 |
| 674 void PopulateFunctionTable(WasmModuleInstance* instance) { | 679 void PopulateFunctionTable(WasmModuleInstance* instance) { |
| 675 if (!instance->function_table.is_null()) { | 680 if (!instance->function_table.is_null()) { |
| 676 int table_size = static_cast<int>(instance->module->function_table.size()); | 681 int table_size = instance->module->FunctionTableSize(); |
|
Mircea Trofin
2016/06/21 19:46:14
same note as above about avoiding the cast - I rea
| |
| 677 DCHECK_EQ(instance->function_table->length(), table_size * 2); | 682 DCHECK_EQ(table_size * 2, instance->function_table->length()); |
| 678 for (int i = 0; i < table_size; i++) { | 683 int populated_table_size = |
| 684 static_cast<int>(instance->module->function_table.size()); | |
| 685 DCHECK_LE(populated_table_size * 2, instance->function_table->length()); | |
| 686 for (int i = 0; i < populated_table_size; i++) { | |
| 679 instance->function_table->set( | 687 instance->function_table->set( |
| 680 i + table_size, | 688 i + table_size, |
| 681 *instance->function_code[instance->module->function_table[i]]); | 689 *instance->function_code[instance->module->function_table[i]]); |
| 682 } | 690 } |
| 683 } | 691 } |
| 684 } | 692 } |
| 685 } // namespace | 693 } // namespace |
| 686 | 694 |
| 687 void SetDeoptimizationData(Factory* factory, Handle<JSObject> js_object, | 695 void SetDeoptimizationData(Factory* factory, Handle<JSObject> js_object, |
| 688 std::vector<Handle<Code>>& functions) { | 696 std::vector<Handle<Code>>& functions) { |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1116 Object* info = wasm->GetInternalField(kWasmDebugInfo); | 1124 Object* info = wasm->GetInternalField(kWasmDebugInfo); |
| 1117 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info); | 1125 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info); |
| 1118 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm)); | 1126 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm)); |
| 1119 wasm->SetInternalField(kWasmDebugInfo, *new_info); | 1127 wasm->SetInternalField(kWasmDebugInfo, *new_info); |
| 1120 return *new_info; | 1128 return *new_info; |
| 1121 } | 1129 } |
| 1122 | 1130 |
| 1123 } // namespace wasm | 1131 } // namespace wasm |
| 1124 } // namespace internal | 1132 } // namespace internal |
| 1125 } // namespace v8 | 1133 } // namespace v8 |
| OLD | NEW |