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

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

Issue 2725333002: [wasm] Also unwrap exported debugged functions (Closed)
Patch Set: Created 3 years, 9 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/compiler/wasm-compiler.cc ('k') | no next file » | 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/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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 return nullptr; 862 return nullptr;
863 } 863 }
864 864
865 static Handle<Code> UnwrapImportWrapper(Handle<Object> import_wrapper) { 865 static Handle<Code> UnwrapImportWrapper(Handle<Object> import_wrapper) {
866 Handle<JSFunction> func = Handle<JSFunction>::cast(import_wrapper); 866 Handle<JSFunction> func = Handle<JSFunction>::cast(import_wrapper);
867 Handle<Code> export_wrapper_code = handle(func->code()); 867 Handle<Code> export_wrapper_code = handle(func->code());
868 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); 868 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
869 for (RelocIterator it(*export_wrapper_code, mask);; it.next()) { 869 for (RelocIterator it(*export_wrapper_code, mask);; it.next()) {
870 DCHECK(!it.done()); 870 DCHECK(!it.done());
871 Code* target = Code::GetCodeFromTargetAddress(it.rinfo()->target_address()); 871 Code* target = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
872 if (target->kind() == Code::WASM_INTERPRETER_ENTRY) {
873 // Don't call the interpreter entry directly, otherwise we cannot
874 // disable the breakpoint later by patching the exported code.
875 return Handle<Code>::null();
876 }
877 if (target->kind() != Code::WASM_FUNCTION && 872 if (target->kind() != Code::WASM_FUNCTION &&
878 target->kind() != Code::WASM_TO_JS_FUNCTION) 873 target->kind() != Code::WASM_TO_JS_FUNCTION &&
874 target->kind() != Code::WASM_INTERPRETER_ENTRY)
879 continue; 875 continue;
880 // There should only be this one call to wasm code. 876 // There should only be this one call to wasm code.
881 #ifdef DEBUG 877 #ifdef DEBUG
882 for (it.next(); !it.done(); it.next()) { 878 for (it.next(); !it.done(); it.next()) {
883 Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address()); 879 Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
884 DCHECK(code->kind() != Code::WASM_FUNCTION && 880 DCHECK(code->kind() != Code::WASM_FUNCTION &&
885 code->kind() != Code::WASM_TO_JS_FUNCTION); 881 code->kind() != Code::WASM_TO_JS_FUNCTION &&
882 code->kind() != Code::WASM_INTERPRETER_ENTRY);
886 } 883 }
887 #endif 884 #endif
888 return handle(target); 885 return handle(target);
889 } 886 }
890 UNREACHABLE(); 887 UNREACHABLE();
891 return Handle<Code>::null(); 888 return Handle<Code>::null();
892 } 889 }
893 890
894 Handle<Code> CompileImportWrapper(Isolate* isolate, int index, FunctionSig* sig, 891 Handle<Code> CompileImportWrapper(Isolate* isolate, int index, FunctionSig* sig,
895 Handle<JSReceiver> target, 892 Handle<JSReceiver> target,
896 Handle<String> module_name, 893 Handle<String> module_name,
897 MaybeHandle<String> import_name, 894 MaybeHandle<String> import_name,
898 ModuleOrigin origin) { 895 ModuleOrigin origin) {
899 WasmFunction* other_func = GetWasmFunctionForImportWrapper(isolate, target); 896 WasmFunction* other_func = GetWasmFunctionForImportWrapper(isolate, target);
900 if (other_func) { 897 if (other_func) {
901 if (!sig->Equals(other_func->sig)) return Handle<Code>::null(); 898 if (!sig->Equals(other_func->sig)) return Handle<Code>::null();
902 // Signature matched. Unwrap the JS->WASM wrapper and return the raw 899 // Signature matched. Unwrap the JS->WASM wrapper and return the raw
903 // WASM function code. 900 // WASM function code.
904 Handle<Code> code = UnwrapImportWrapper(target); 901 return UnwrapImportWrapper(target);
905 // If we got no code (imported function is being debugged), fall through
906 // to CompileWasmToJSWrapper.
907 if (!code.is_null()) return code;
908 } 902 }
909 // No wasm function or being debugged. Compile a new wrapper for the new 903 // No wasm function or being debugged. Compile a new wrapper for the new
910 // signature. 904 // signature.
911 return compiler::CompileWasmToJSWrapper(isolate, target, sig, index, 905 return compiler::CompileWasmToJSWrapper(isolate, target, sig, index,
912 module_name, import_name, origin); 906 module_name, import_name, origin);
913 } 907 }
914 908
915 void UpdateDispatchTablesInternal(Isolate* isolate, 909 void UpdateDispatchTablesInternal(Isolate* isolate,
916 Handle<FixedArray> dispatch_tables, int index, 910 Handle<FixedArray> dispatch_tables, int index,
917 WasmFunction* function, Handle<Code> code) { 911 WasmFunction* function, Handle<Code> code) {
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 Handle<String> module_property_name = 2717 Handle<String> module_property_name =
2724 isolate->factory()->InternalizeUtf8String("module"); 2718 isolate->factory()->InternalizeUtf8String("module");
2725 Handle<String> instance_property_name = 2719 Handle<String> instance_property_name =
2726 isolate->factory()->InternalizeUtf8String("instance"); 2720 isolate->factory()->InternalizeUtf8String("instance");
2727 JSObject::AddProperty(ret, module_property_name, module, NONE); 2721 JSObject::AddProperty(ret, module_property_name, module, NONE);
2728 JSObject::AddProperty(ret, instance_property_name, 2722 JSObject::AddProperty(ret, instance_property_name,
2729 instance_object.ToHandleChecked(), NONE); 2723 instance_object.ToHandleChecked(), NONE);
2730 2724
2731 ResolvePromise(isolate, promise, ret); 2725 ResolvePromise(isolate, promise, ret);
2732 } 2726 }
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698