| 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/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
| 8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
| 9 #include "src/base/atomic-utils.h" | 9 #include "src/base/atomic-utils.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | 867 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); |
| 868 Handle<Code> code; | 868 Handle<Code> code; |
| 869 for (RelocIterator it(*export_wrapper_code, mask); !it.done(); it.next()) { | 869 for (RelocIterator it(*export_wrapper_code, mask); !it.done(); it.next()) { |
| 870 RelocInfo* rinfo = it.rinfo(); | 870 RelocInfo* rinfo = it.rinfo(); |
| 871 Address target_address = rinfo->target_address(); | 871 Address target_address = rinfo->target_address(); |
| 872 Code* target = Code::GetCodeFromTargetAddress(target_address); | 872 Code* target = Code::GetCodeFromTargetAddress(target_address); |
| 873 if (target->kind() == Code::WASM_FUNCTION || | 873 if (target->kind() == Code::WASM_FUNCTION || |
| 874 target->kind() == Code::WASM_TO_JS_FUNCTION) { | 874 target->kind() == Code::WASM_TO_JS_FUNCTION) { |
| 875 ++found; | 875 ++found; |
| 876 code = handle(target); | 876 code = handle(target); |
| 877 } else if (target->kind() == Code::WASM_INTERPRETER_ENTRY) { |
| 878 // Don't call the interpreter entry directly, otherwise we cannot disable |
| 879 // the breakpoint later by patching the exported code. |
| 880 return Handle<Code>::null(); |
| 877 } | 881 } |
| 878 } | 882 } |
| 879 DCHECK_EQ(1, found); | 883 DCHECK_EQ(1, found); |
| 880 return code; | 884 return code; |
| 881 } | 885 } |
| 882 | 886 |
| 883 static Handle<Code> CompileImportWrapper(Isolate* isolate, int index, | 887 static Handle<Code> CompileImportWrapper(Isolate* isolate, int index, |
| 884 FunctionSig* sig, | 888 FunctionSig* sig, |
| 885 Handle<JSReceiver> target, | 889 Handle<JSReceiver> target, |
| 886 Handle<String> module_name, | 890 Handle<String> module_name, |
| 887 MaybeHandle<String> import_name, | 891 MaybeHandle<String> import_name, |
| 888 ModuleOrigin origin) { | 892 ModuleOrigin origin) { |
| 889 WasmFunction* other_func = GetWasmFunctionForImportWrapper(isolate, target); | 893 WasmFunction* other_func = GetWasmFunctionForImportWrapper(isolate, target); |
| 890 if (other_func) { | 894 if (other_func) { |
| 891 if (sig->Equals(other_func->sig)) { | 895 if (!sig->Equals(other_func->sig)) return Handle<Code>::null(); |
| 892 // Signature matched. Unwrap the JS->WASM wrapper and return the raw | 896 // Signature matched. Unwrap the JS->WASM wrapper and return the raw |
| 893 // WASM function code. | 897 // WASM function code. |
| 894 return UnwrapImportWrapper(target); | 898 Handle<Code> code = UnwrapImportWrapper(target); |
| 895 } else { | 899 // If we got no code (imported function is being debugged), fall through |
| 896 return Handle<Code>::null(); | 900 // to CompileWasmToJSWrapper. |
| 897 } | 901 if (!code.is_null()) return code; |
| 898 } else { | |
| 899 // Signature mismatch. Compile a new wrapper for the new signature. | |
| 900 return compiler::CompileWasmToJSWrapper(isolate, target, sig, index, | |
| 901 module_name, import_name, origin); | |
| 902 } | 902 } |
| 903 // No wasm function or being debugged. Compile a new wrapper for the new |
| 904 // signature. |
| 905 return compiler::CompileWasmToJSWrapper(isolate, target, sig, index, |
| 906 module_name, import_name, origin); |
| 903 } | 907 } |
| 904 | 908 |
| 905 static void UpdateDispatchTablesInternal(Isolate* isolate, | 909 static void UpdateDispatchTablesInternal(Isolate* isolate, |
| 906 Handle<FixedArray> dispatch_tables, | 910 Handle<FixedArray> dispatch_tables, |
| 907 int index, WasmFunction* function, | 911 int index, WasmFunction* function, |
| 908 Handle<Code> code) { | 912 Handle<Code> code) { |
| 909 DCHECK_EQ(0, dispatch_tables->length() % 4); | 913 DCHECK_EQ(0, dispatch_tables->length() % 4); |
| 910 for (int i = 0; i < dispatch_tables->length(); i += 4) { | 914 for (int i = 0; i < dispatch_tables->length(); i += 4) { |
| 911 int table_index = Smi::cast(dispatch_tables->get(i + 1))->value(); | 915 int table_index = Smi::cast(dispatch_tables->get(i + 1))->value(); |
| 912 Handle<FixedArray> function_table( | 916 Handle<FixedArray> function_table( |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 Handle<String> module_property_name = | 2714 Handle<String> module_property_name = |
| 2711 isolate->factory()->InternalizeUtf8String("module"); | 2715 isolate->factory()->InternalizeUtf8String("module"); |
| 2712 Handle<String> instance_property_name = | 2716 Handle<String> instance_property_name = |
| 2713 isolate->factory()->InternalizeUtf8String("instance"); | 2717 isolate->factory()->InternalizeUtf8String("instance"); |
| 2714 JSObject::AddProperty(ret, module_property_name, module, NONE); | 2718 JSObject::AddProperty(ret, module_property_name, module, NONE); |
| 2715 JSObject::AddProperty(ret, instance_property_name, | 2719 JSObject::AddProperty(ret, instance_property_name, |
| 2716 instance_object.ToHandleChecked(), NONE); | 2720 instance_object.ToHandleChecked(), NONE); |
| 2717 | 2721 |
| 2718 ResolvePromise(isolate, promise, ret); | 2722 ResolvePromise(isolate, promise, ret); |
| 2719 } | 2723 } |
| OLD | NEW |