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

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2500443004: [wasm] OOB traps: build protected instruction list during codegen (Closed)
Patch Set: Removing spurious changes Created 4 years 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/v8.gyp ('k') | src/wasm/wasm-objects.h » ('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 <memory> 5 #include <memory>
6 6
7 #include "src/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 if (function_table_count > 0) InitializeTables(code_table, instance); 1253 if (function_table_count > 0) InitializeTables(code_table, instance);
1254 1254
1255 if (num_imported_functions > 0 || !owner.is_null()) { 1255 if (num_imported_functions > 0 || !owner.is_null()) {
1256 // If the code was cloned, or new imports were compiled, patch. 1256 // If the code was cloned, or new imports were compiled, patch.
1257 PatchDirectCalls(old_code_table, code_table, num_imported_functions); 1257 PatchDirectCalls(old_code_table, code_table, num_imported_functions);
1258 } 1258 }
1259 1259
1260 FlushICache(isolate_, code_table); 1260 FlushICache(isolate_, code_table);
1261 1261
1262 //-------------------------------------------------------------------------- 1262 //--------------------------------------------------------------------------
1263 // Unpack and notify signal handler of protected instructions.
1264 //--------------------------------------------------------------------------
1265 {
1266 for (int i = 0; i < code_table->length(); ++i) {
1267 Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i);
1268
1269 if (code->kind() != Code::WASM_FUNCTION) {
1270 continue;
1271 }
1272
1273 FixedArray* protected_instructions = code->protected_instructions();
1274
1275 Zone zone(isolate_->allocator(), "Wasm Module");
1276 ZoneVector<trap_handler::ProtectedInstructionData> unpacked(&zone);
1277 for (int i = 0; i < protected_instructions->length();
1278 i += Code::kTrapDataSize) {
1279 trap_handler::ProtectedInstructionData data;
1280 data.instr_offset =
1281 protected_instructions
1282 ->GetValueChecked<Smi>(isolate_, i + Code::kTrapCodeOffset)
1283 ->value();
1284 data.landing_offset =
1285 protected_instructions
1286 ->GetValueChecked<Smi>(isolate_, i + Code::kTrapLandingOffset)
1287 ->value();
1288 unpacked.emplace_back(data);
1289 }
1290 // TODO(eholk): Register the protected instruction information once the
1291 // trap handler is in place.
1292 }
1293 }
1294
1263 // Set up and link the new instance. 1295 // Set up and link the new instance.
1264 //-------------------------------------------------------------------------- 1296 //--------------------------------------------------------------------------
1265 { 1297 {
1266 Handle<Object> global_handle = 1298 Handle<Object> global_handle =
1267 isolate_->global_handles()->Create(*instance); 1299 isolate_->global_handles()->Create(*instance);
1268 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_); 1300 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_);
1269 Handle<WeakCell> link_to_owning_instance = factory->NewWeakCell(instance); 1301 Handle<WeakCell> link_to_owning_instance = factory->NewWeakCell(instance);
1270 MaybeHandle<WeakCell> link_to_original; 1302 MaybeHandle<WeakCell> link_to_original;
1271 MaybeHandle<WasmCompiledModule> original; 1303 MaybeHandle<WasmCompiledModule> original;
1272 if (!owner.is_null()) { 1304 if (!owner.is_null()) {
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 MaybeHandle<String> WasmCompiledModule::GetFunctionName( 2383 MaybeHandle<String> WasmCompiledModule::GetFunctionName(
2352 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) { 2384 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) {
2353 DCHECK_LT(func_index, compiled_module->module()->functions.size()); 2385 DCHECK_LT(func_index, compiled_module->module()->functions.size());
2354 WasmFunction& function = compiled_module->module()->functions[func_index]; 2386 WasmFunction& function = compiled_module->module()->functions[func_index];
2355 Isolate* isolate = compiled_module->GetIsolate(); 2387 Isolate* isolate = compiled_module->GetIsolate();
2356 MaybeHandle<String> string = ExtractStringFromModuleBytes( 2388 MaybeHandle<String> string = ExtractStringFromModuleBytes(
2357 isolate, compiled_module, function.name_offset, function.name_length); 2389 isolate, compiled_module, function.name_offset, function.name_length);
2358 if (!string.is_null()) return string.ToHandleChecked(); 2390 if (!string.is_null()) return string.ToHandleChecked();
2359 return {}; 2391 return {};
2360 } 2392 }
OLDNEW
« no previous file with comments | « src/v8.gyp ('k') | src/wasm/wasm-objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698