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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 uint32_t table_size = module->FunctionTableSize();
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
151 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); 153 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size);
152 for (int i = 0; i < table_size; i++) { 154 for (uint32_t i = 0;
155 i < static_cast<uint32_t>(module->function_table.size());
156 ++i) {
153 const WasmFunction* function = 157 const WasmFunction* function =
154 &module->functions[module->function_table[i]]; 158 &module->functions[module->function_table[i]];
155 fixed->set(i, Smi::FromInt(function->sig_index)); 159 fixed->set(i, Smi::FromInt(function->sig_index));
156 } 160 }
157 return fixed; 161 return fixed;
158 } 162 }
159 163
160 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size, 164 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size,
161 byte** backing_store) { 165 byte** backing_store) {
162 *backing_store = nullptr; 166 *backing_store = nullptr;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } // namespace 339 } // namespace
336 340
337 WasmModule::WasmModule() 341 WasmModule::WasmModule()
338 : module_start(nullptr), 342 : module_start(nullptr),
339 module_end(nullptr), 343 module_end(nullptr),
340 min_mem_pages(0), 344 min_mem_pages(0),
341 max_mem_pages(0), 345 max_mem_pages(0),
342 mem_export(false), 346 mem_export(false),
343 mem_external(false), 347 mem_external(false),
344 start_function_index(-1), 348 start_function_index(-1),
345 origin(kWasmOrigin) {} 349 origin(kWasmOrigin),
350 globals_size(0),
351 indirect_table_size(0) {}
346 352
347 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, 353 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower,
348 const char* error, uint32_t index, 354 const char* error, uint32_t index,
349 wasm::WasmName module_name, 355 wasm::WasmName module_name,
350 wasm::WasmName function_name) { 356 wasm::WasmName function_name) {
351 if (!function_name.is_empty()) { 357 if (!function_name.is_empty()) {
352 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", 358 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s",
353 index, module_name.length(), module_name.start(), 359 index, module_name.length(), module_name.start(),
354 function_name.length(), function_name.start(), error); 360 function_name.length(), function_name.start(), error);
355 } else { 361 } else {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 str.start()); 666 str.start());
661 break; 667 break;
662 } 668 }
663 // Install the code into the linker table. 669 // Install the code into the linker table.
664 functions[i] = code; 670 functions[i] = code;
665 } 671 }
666 } 672 }
667 673
668 void PopulateFunctionTable(WasmModuleInstance* instance) { 674 void PopulateFunctionTable(WasmModuleInstance* instance) {
669 if (!instance->function_table.is_null()) { 675 if (!instance->function_table.is_null()) {
670 int table_size = static_cast<int>(instance->module->function_table.size()); 676 uint32_t table_size = instance->module->FunctionTableSize();
671 DCHECK_EQ(instance->function_table->length(), table_size * 2); 677 DCHECK_EQ(table_size * 2, instance->function_table->length());
672 for (int i = 0; i < table_size; i++) { 678 uint32_t populated_table_size =
673 instance->function_table->set( 679 static_cast<uint32_t>(instance->module->function_table.size());
674 i + table_size, 680 for (uint32_t i = 0; i < populated_table_size; ++i) {
675 *instance->function_code[instance->module->function_table[i]]); 681 instance->function_table->set(
682 i + table_size,
683 *instance->function_code[instance->module->function_table[i]]);
676 } 684 }
677 } 685 }
678 } 686 }
679 } // namespace 687 } // namespace
680 688
681 void SetDeoptimizationData(Factory* factory, Handle<JSObject> js_object, 689 void SetDeoptimizationData(Factory* factory, Handle<JSObject> js_object,
682 std::vector<Handle<Code>>& functions) { 690 std::vector<Handle<Code>>& functions) {
683 for (size_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); ++i) { 691 for (size_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); ++i) {
684 Handle<Code> code = functions[i]; 692 Handle<Code> code = functions[i];
685 DCHECK(code->deoptimization_data() == nullptr || 693 DCHECK(code->deoptimization_data() == nullptr ||
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 Object* info = wasm->GetInternalField(kWasmDebugInfo); 1123 Object* info = wasm->GetInternalField(kWasmDebugInfo);
1116 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info); 1124 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info);
1117 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm)); 1125 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm));
1118 wasm->SetInternalField(kWasmDebugInfo, *new_info); 1126 wasm->SetInternalField(kWasmDebugInfo, *new_info);
1119 return *new_info; 1127 return *new_info;
1120 } 1128 }
1121 1129
1122 } // namespace wasm 1130 } // namespace wasm
1123 } // namespace internal 1131 } // namespace internal
1124 } // namespace v8 1132 } // namespace v8
OLDNEW
« 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