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 <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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 if (function_table_count > 0) InitializeTables(code_table, instance); | 1248 if (function_table_count > 0) InitializeTables(code_table, instance); |
1249 | 1249 |
1250 if (num_imported_functions > 0 || !owner.is_null()) { | 1250 if (num_imported_functions > 0 || !owner.is_null()) { |
1251 // If the code was cloned, or new imports were compiled, patch. | 1251 // If the code was cloned, or new imports were compiled, patch. |
1252 PatchDirectCalls(old_code_table, code_table, num_imported_functions); | 1252 PatchDirectCalls(old_code_table, code_table, num_imported_functions); |
1253 } | 1253 } |
1254 | 1254 |
1255 FlushICache(isolate_, code_table); | 1255 FlushICache(isolate_, code_table); |
1256 | 1256 |
1257 //-------------------------------------------------------------------------- | 1257 //-------------------------------------------------------------------------- |
| 1258 // Unpack and notify signal handler of protected instructions. |
| 1259 //-------------------------------------------------------------------------- |
| 1260 { |
| 1261 for (int i = 0; i < code_table->length(); ++i) { |
| 1262 Handle<Code> code = code_table->GetValueChecked<Code>(isolate_, i); |
| 1263 |
| 1264 if (code->kind() != Code::WASM_FUNCTION) { |
| 1265 continue; |
| 1266 } |
| 1267 |
| 1268 FixedArray* protected_instructions = code->protected_instructions(); |
| 1269 |
| 1270 ProtectedInstructionList unpacked; |
| 1271 for (int i = 0; i < protected_instructions->length(); |
| 1272 i += kTrapDataSize) { |
| 1273 ProtectedInstructionData data; |
| 1274 data.instr_offset = |
| 1275 protected_instructions |
| 1276 ->GetValueChecked<Smi>(isolate_, i + kTrapCodeOffset) |
| 1277 ->value(); |
| 1278 data.landing_offset = |
| 1279 protected_instructions |
| 1280 ->GetValueChecked<Smi>(isolate_, i + kTrapLandingOffset) |
| 1281 ->value(); |
| 1282 unpacked.push_back(data); |
| 1283 } |
| 1284 // TODO(eholk): Register the protected instruction information once the |
| 1285 // trap handler is in place. |
| 1286 } |
| 1287 } |
| 1288 |
1258 // Set up and link the new instance. | 1289 // Set up and link the new instance. |
1259 //-------------------------------------------------------------------------- | 1290 //-------------------------------------------------------------------------- |
1260 { | 1291 { |
1261 Handle<Object> global_handle = | 1292 Handle<Object> global_handle = |
1262 isolate_->global_handles()->Create(*instance); | 1293 isolate_->global_handles()->Create(*instance); |
1263 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_); | 1294 Handle<WeakCell> link_to_clone = factory->NewWeakCell(compiled_module_); |
1264 Handle<WeakCell> link_to_owning_instance = factory->NewWeakCell(instance); | 1295 Handle<WeakCell> link_to_owning_instance = factory->NewWeakCell(instance); |
1265 MaybeHandle<WeakCell> link_to_original; | 1296 MaybeHandle<WeakCell> link_to_original; |
1266 MaybeHandle<WasmCompiledModule> original; | 1297 MaybeHandle<WasmCompiledModule> original; |
1267 if (!owner.is_null()) { | 1298 if (!owner.is_null()) { |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 MaybeHandle<String> WasmCompiledModule::GetFunctionName( | 2336 MaybeHandle<String> WasmCompiledModule::GetFunctionName( |
2306 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) { | 2337 Handle<WasmCompiledModule> compiled_module, uint32_t func_index) { |
2307 DCHECK_LT(func_index, compiled_module->module()->functions.size()); | 2338 DCHECK_LT(func_index, compiled_module->module()->functions.size()); |
2308 WasmFunction& function = compiled_module->module()->functions[func_index]; | 2339 WasmFunction& function = compiled_module->module()->functions[func_index]; |
2309 Isolate* isolate = compiled_module->GetIsolate(); | 2340 Isolate* isolate = compiled_module->GetIsolate(); |
2310 MaybeHandle<String> string = ExtractStringFromModuleBytes( | 2341 MaybeHandle<String> string = ExtractStringFromModuleBytes( |
2311 isolate, compiled_module, function.name_offset, function.name_length); | 2342 isolate, compiled_module, function.name_offset, function.name_length); |
2312 if (!string.is_null()) return string.ToHandleChecked(); | 2343 if (!string.is_null()) return string.ToHandleChecked(); |
2313 return {}; | 2344 return {}; |
2314 } | 2345 } |
OLD | NEW |