| 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 <iostream> |
| 5 #include <memory> | 6 #include <memory> |
| 6 | 7 |
| 7 #include "src/base/atomic-utils.h" | 8 #include "src/base/atomic-utils.h" |
| 8 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 9 | 10 |
| 10 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
| 11 #include "src/objects.h" | 12 #include "src/objects.h" |
| 12 #include "src/property-descriptor.h" | 13 #include "src/property-descriptor.h" |
| 13 #include "src/simulator.h" | 14 #include "src/simulator.h" |
| 14 #include "src/snapshot/snapshot.h" | 15 #include "src/snapshot/snapshot.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 } | 429 } |
| 429 } | 430 } |
| 430 return modified; | 431 return modified; |
| 431 } | 432 } |
| 432 | 433 |
| 433 void LinkModuleFunctions(Isolate* isolate, | 434 void LinkModuleFunctions(Isolate* isolate, |
| 434 std::vector<Handle<Code>>& functions) { | 435 std::vector<Handle<Code>>& functions) { |
| 435 for (size_t i = 0; i < functions.size(); ++i) { | 436 for (size_t i = 0; i < functions.size(); ++i) { |
| 436 Handle<Code> code = functions[i]; | 437 Handle<Code> code = functions[i]; |
| 437 LinkFunction(code, functions, Code::WASM_FUNCTION); | 438 LinkFunction(code, functions, Code::WASM_FUNCTION); |
| 439 |
| 440 // Add this object to the signal handler table. |
| 441 { |
| 442 auto* handler_data = new wasm::TrapHandlerData; |
| 443 |
| 444 handler_data->code = *code; |
| 445 |
| 446 std::cerr << "*** STORING HANDLER DATA " |
| 447 << reinterpret_cast<void*>(code->instruction_start()) << " ***" |
| 448 << std::endl; |
| 449 |
| 450 handler_data->next = wasm::gTrapHandlers; |
| 451 wasm::gTrapHandlers = handler_data; |
| 452 // TODO(eholk): make sure to clean all this up someday. |
| 453 } |
| 438 } | 454 } |
| 439 } | 455 } |
| 440 | 456 |
| 441 void FlushAssemblyCache(Isolate* isolate, Handle<FixedArray> functions) { | 457 void FlushAssemblyCache(Isolate* isolate, Handle<FixedArray> functions) { |
| 442 for (int i = 0; i < functions->length(); ++i) { | 458 for (int i = 0; i < functions->length(); ++i) { |
| 443 Handle<Code> code = functions->GetValueChecked<Code>(isolate, i); | 459 Handle<Code> code = functions->GetValueChecked<Code>(isolate, i); |
| 444 Assembler::FlushICache(isolate, code->instruction_start(), | 460 Assembler::FlushICache(isolate, code->instruction_start(), |
| 445 code->instruction_size()); | 461 code->instruction_size()); |
| 446 } | 462 } |
| 447 } | 463 } |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 CompileSequentially(isolate, this, | 1162 CompileSequentially(isolate, this, |
| 1147 temp_instance_for_compilation.function_code, thrower, | 1163 temp_instance_for_compilation.function_code, thrower, |
| 1148 &module_env); | 1164 &module_env); |
| 1149 } | 1165 } |
| 1150 if (thrower->error()) return nothing; | 1166 if (thrower->error()) return nothing; |
| 1151 | 1167 |
| 1152 // At this point, compilation has completed. Update the code table. | 1168 // At this point, compilation has completed. Update the code table. |
| 1153 for (size_t i = FLAG_skip_compiling_wasm_funcs; | 1169 for (size_t i = FLAG_skip_compiling_wasm_funcs; |
| 1154 i < temp_instance_for_compilation.function_code.size(); ++i) { | 1170 i < temp_instance_for_compilation.function_code.size(); ++i) { |
| 1155 Code* code = *temp_instance_for_compilation.function_code[i]; | 1171 Code* code = *temp_instance_for_compilation.function_code[i]; |
| 1172 |
| 1156 compiled_functions->set(static_cast<int>(i), code); | 1173 compiled_functions->set(static_cast<int>(i), code); |
| 1157 } | 1174 } |
| 1158 | 1175 |
| 1159 // Create the compiled module object, and populate with compiled functions | 1176 // Create the compiled module object, and populate with compiled functions |
| 1160 // and information needed at instantiation time. This object needs to be | 1177 // and information needed at instantiation time. This object needs to be |
| 1161 // serializable. Instantiation may occur off a deserialized version of this | 1178 // serializable. Instantiation may occur off a deserialized version of this |
| 1162 // object. | 1179 // object. |
| 1163 Handle<FixedArray> ret = | 1180 Handle<FixedArray> ret = |
| 1164 factory->NewFixedArray(kCompiledWasmObjectTableSize, TENURED); | 1181 factory->NewFixedArray(kCompiledWasmObjectTableSize, TENURED); |
| 1165 ret->set(kFunctions, *compiled_functions); | 1182 ret->set(kFunctions, *compiled_functions); |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 1738 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
| 1722 } | 1739 } |
| 1723 thrower->Error("WASM.compileRun() failed: Return value should be number"); | 1740 thrower->Error("WASM.compileRun() failed: Return value should be number"); |
| 1724 return -1; | 1741 return -1; |
| 1725 } | 1742 } |
| 1726 | 1743 |
| 1727 } // namespace testing | 1744 } // namespace testing |
| 1728 } // namespace wasm | 1745 } // namespace wasm |
| 1729 } // namespace internal | 1746 } // namespace internal |
| 1730 } // namespace v8 | 1747 } // namespace v8 |
| OLD | NEW |