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

Side by Side Diff: runtime/vm/simulator_dbc.cc

Issue 2793163002: Do not embed is_auto_setup_scope into the compilation of native calls. (Closed)
Patch Set: . Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <setjmp.h> // NOLINT 5 #include <setjmp.h> // NOLINT
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #if defined(TARGET_ARCH_DBC) 9 #if defined(TARGET_ARCH_DBC)
10 10
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 drt(args); 923 drt(args);
924 thread->set_vm_tag(VMTag::kDartTagId); 924 thread->set_vm_tag(VMTag::kDartTagId);
925 thread->set_top_exit_frame_info(0); 925 thread->set_top_exit_frame_info(0);
926 return true; 926 return true;
927 } else { 927 } else {
928 return false; 928 return false;
929 } 929 }
930 } 930 }
931 931
932 932
933 static DART_NOINLINE bool InvokeNative(Thread* thread, 933 static DART_NOINLINE bool InvokeBootstrapNative(Thread* thread,
934 Simulator* sim, 934 Simulator* sim,
935 SimulatorBootstrapNativeCall f, 935 SimulatorBootstrapNativeCall f,
936 NativeArguments* args) { 936 NativeArguments* args) {
937 SimulatorSetjmpBuffer buffer(sim); 937 SimulatorSetjmpBuffer buffer(sim);
938 if (!setjmp(buffer.buffer_)) { 938 if (!setjmp(buffer.buffer_)) {
939 thread->set_vm_tag(reinterpret_cast<uword>(f)); 939 thread->set_vm_tag(reinterpret_cast<uword>(f));
940 f(args); 940 f(args);
941 thread->set_vm_tag(VMTag::kDartTagId); 941 thread->set_vm_tag(VMTag::kDartTagId);
942 thread->set_top_exit_frame_info(0); 942 thread->set_top_exit_frame_info(0);
943 return true; 943 return true;
944 } else { 944 } else {
945 return false; 945 return false;
946 } 946 }
947 } 947 }
948 948
949 949
950 static DART_NOINLINE bool InvokeNativeWrapper(Thread* thread, 950 static DART_NOINLINE bool InvokeNativeNoScopeWrapper(Thread* thread,
951 Simulator* sim, 951 Simulator* sim,
952 Dart_NativeFunction f, 952 Dart_NativeFunction f,
953 NativeArguments* args) { 953 NativeArguments* args) {
954 SimulatorSetjmpBuffer buffer(sim); 954 SimulatorSetjmpBuffer buffer(sim);
955 if (!setjmp(buffer.buffer_)) { 955 if (!setjmp(buffer.buffer_)) {
956 thread->set_vm_tag(reinterpret_cast<uword>(f)); 956 thread->set_vm_tag(reinterpret_cast<uword>(f));
957 NativeEntry::NativeCallWrapper(reinterpret_cast<Dart_NativeArguments>(args), 957 NativeEntry::NoScopeNativeCallWrapper(
958 f); 958 reinterpret_cast<Dart_NativeArguments>(args), f);
959 thread->set_vm_tag(VMTag::kDartTagId); 959 thread->set_vm_tag(VMTag::kDartTagId);
960 thread->set_top_exit_frame_info(0); 960 thread->set_top_exit_frame_info(0);
961 return true; 961 return true;
962 } else {
963 return false;
964 }
965 }
966
967
968 static DART_NOINLINE bool InvokeNativeAutoScopeWrapper(Thread* thread,
969 Simulator* sim,
970 Dart_NativeFunction f,
971 NativeArguments* args) {
972 SimulatorSetjmpBuffer buffer(sim);
973 if (!setjmp(buffer.buffer_)) {
974 thread->set_vm_tag(reinterpret_cast<uword>(f));
975 NativeEntry::AutoScopeNativeCallWrapper(
976 reinterpret_cast<Dart_NativeArguments>(args), f);
977 thread->set_vm_tag(VMTag::kDartTagId);
978 thread->set_top_exit_frame_info(0);
979 return true;
962 } else { 980 } else {
963 return false; 981 return false;
964 } 982 }
965 } 983 }
966 984
967 // Note: all macro helpers are intended to be used only inside Simulator::Call. 985 // Note: all macro helpers are intended to be used only inside Simulator::Call.
968 986
969 // Decode opcode and A part of the given value and dispatch to the 987 // Decode opcode and A part of the given value and dispatch to the
970 // corresponding bytecode handler. 988 // corresponding bytecode handler.
971 #define DISPATCH_OP(val) \ 989 #define DISPATCH_OP(val) \
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr(); \ 1103 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr(); \
1086 goto DispatchAfterException; \ 1104 goto DispatchAfterException; \
1087 } while (0) 1105 } while (0)
1088 1106
1089 // Runtime call helpers: handle invocation and potential exception after return. 1107 // Runtime call helpers: handle invocation and potential exception after return.
1090 #define INVOKE_RUNTIME(Func, Args) \ 1108 #define INVOKE_RUNTIME(Func, Args) \
1091 if (!InvokeRuntime(thread, this, Func, Args)) { \ 1109 if (!InvokeRuntime(thread, this, Func, Args)) { \
1092 HANDLE_EXCEPTION; \ 1110 HANDLE_EXCEPTION; \
1093 } 1111 }
1094 1112
1095 #define INVOKE_NATIVE(Func, Args) \ 1113 #define INVOKE_BOOTSTRAP_NATIVE(Func, Args) \
1096 if (!InvokeNative(thread, this, Func, &Args)) { \ 1114 if (!InvokeBootstrapNative(thread, this, Func, &Args)) { \
1097 HANDLE_EXCEPTION; \ 1115 HANDLE_EXCEPTION; \
1098 } 1116 }
1099 1117
1100 #define INVOKE_NATIVE_WRAPPER(Func, Args) \ 1118 #define INVOKE_NATIVE_NO_SCOPE(Func, Args) \
1101 if (!InvokeNativeWrapper(thread, this, Func, &Args)) { \ 1119 if (!InvokeNativeNoScopeWrapper(thread, this, Func, &Args)) { \
1102 HANDLE_EXCEPTION; \ 1120 HANDLE_EXCEPTION; \
1103 } 1121 }
1104 1122
1123 #define INVOKE_NATIVE_AUTO_SCOPE(Func, Args) \
1124 if (!InvokeNativeAutoScopeWrapper(thread, this, Func, &Args)) { \
1125 HANDLE_EXCEPTION; \
1126 }
1127
1105 #define LOAD_CONSTANT(index) (pp->data()[(index)].raw_obj_) 1128 #define LOAD_CONSTANT(index) (pp->data()[(index)].raw_obj_)
1106 1129
1107 1130
1108 // Returns true if deoptimization succeeds. 1131 // Returns true if deoptimization succeeds.
1109 DART_FORCE_INLINE bool Simulator::Deoptimize(Thread* thread, 1132 DART_FORCE_INLINE bool Simulator::Deoptimize(Thread* thread,
1110 RawObjectPool** pp, 1133 RawObjectPool** pp,
1111 uint32_t** pc, 1134 uint32_t** pc,
1112 RawObject*** FP, 1135 RawObject*** FP,
1113 RawObject*** SP, 1136 RawObject*** SP,
1114 bool is_lazy) { 1137 bool is_lazy) {
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 ? FrameArguments(FP, function->ptr()->num_fixed_parameters_) 1910 ? FrameArguments(FP, function->ptr()->num_fixed_parameters_)
1888 : FP; 1911 : FP;
1889 1912
1890 SimulatorBootstrapNativeCall native_target = 1913 SimulatorBootstrapNativeCall native_target =
1891 reinterpret_cast<SimulatorBootstrapNativeCall>(SP[-1]); 1914 reinterpret_cast<SimulatorBootstrapNativeCall>(SP[-1]);
1892 intptr_t argc_tag = reinterpret_cast<intptr_t>(SP[-0]); 1915 intptr_t argc_tag = reinterpret_cast<intptr_t>(SP[-0]);
1893 SP[-0] = 0; // Note: argc_tag is not smi-tagged. 1916 SP[-0] = 0; // Note: argc_tag is not smi-tagged.
1894 SP[-1] = null_value; 1917 SP[-1] = null_value;
1895 Exit(thread, FP, SP + 1, pc); 1918 Exit(thread, FP, SP + 1, pc);
1896 NativeArguments args(thread, argc_tag, incoming_args, SP - 1); 1919 NativeArguments args(thread, argc_tag, incoming_args, SP - 1);
1897 INVOKE_NATIVE(native_target, args); 1920 INVOKE_BOOTSTRAP_NATIVE(native_target, args);
1898 SP -= 1; 1921 SP -= 1;
1899 DISPATCH(); 1922 DISPATCH();
1900 } 1923 }
1901 1924
1902 { 1925 {
1903 BYTECODE(NativeCall, 0); 1926 BYTECODE(NativeNoScopeCall, 0);
1904 RawFunction* function = FrameFunction(FP); 1927 RawFunction* function = FrameFunction(FP);
1905 RawObject** incoming_args = 1928 RawObject** incoming_args =
1906 (function->ptr()->num_optional_parameters_ == 0) 1929 (function->ptr()->num_optional_parameters_ == 0)
1930 ? FrameArguments(FP, function->ptr()->num_fixed_parameters_)
1931 : FP;
1932
1933 Dart_NativeFunction native_target =
1934 reinterpret_cast<Dart_NativeFunction>(SP[-1]);
1935 intptr_t argc_tag = reinterpret_cast<intptr_t>(SP[-0]);
1936 SP[-0] = 0; // argc_tag is not smi tagged!
1937 SP[-1] = null_value;
1938 Exit(thread, FP, SP + 1, pc);
1939 NativeArguments args(thread, argc_tag, incoming_args, SP - 1);
1940 INVOKE_NATIVE_NO_SCOPE(native_target, args);
1941 SP -= 1;
1942 DISPATCH();
1943 }
1944
1945 {
1946 BYTECODE(NativeAutoScopeCall, 0);
1947 RawFunction* function = FrameFunction(FP);
1948 RawObject** incoming_args =
1949 (function->ptr()->num_optional_parameters_ == 0)
1907 ? FrameArguments(FP, function->ptr()->num_fixed_parameters_) 1950 ? FrameArguments(FP, function->ptr()->num_fixed_parameters_)
1908 : FP; 1951 : FP;
1909 1952
1910 Dart_NativeFunction native_target = 1953 Dart_NativeFunction native_target =
1911 reinterpret_cast<Dart_NativeFunction>(SP[-1]); 1954 reinterpret_cast<Dart_NativeFunction>(SP[-1]);
1912 intptr_t argc_tag = reinterpret_cast<intptr_t>(SP[-0]); 1955 intptr_t argc_tag = reinterpret_cast<intptr_t>(SP[-0]);
1913 SP[-0] = 0; // argc_tag is not smi tagged! 1956 SP[-0] = 0; // argc_tag is not smi tagged!
1914 SP[-1] = null_value; 1957 SP[-1] = null_value;
1915 Exit(thread, FP, SP + 1, pc); 1958 Exit(thread, FP, SP + 1, pc);
1916 NativeArguments args(thread, argc_tag, incoming_args, SP - 1); 1959 NativeArguments args(thread, argc_tag, incoming_args, SP - 1);
1917 INVOKE_NATIVE_WRAPPER(native_target, args); 1960 INVOKE_NATIVE_AUTO_SCOPE(native_target, args);
1918 SP -= 1; 1961 SP -= 1;
1919 DISPATCH(); 1962 DISPATCH();
1920 } 1963 }
1921 1964
1922 { 1965 {
1923 BYTECODE(OneByteStringFromCharCode, A_X); 1966 BYTECODE(OneByteStringFromCharCode, A_X);
1924 const intptr_t char_code = Smi::Value(RAW_CAST(Smi, FP[rD])); 1967 const intptr_t char_code = Smi::Value(RAW_CAST(Smi, FP[rD]));
1925 ASSERT(char_code >= 0); 1968 ASSERT(char_code >= 0);
1926 ASSERT(char_code <= 255); 1969 ASSERT(char_code <= 255);
1927 RawString** strings = Symbols::PredefinedAddress(); 1970 RawString** strings = Symbols::PredefinedAddress();
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
3809 pc_ = pc; 3852 pc_ = pc;
3810 } 3853 }
3811 3854
3812 buf->Longjmp(); 3855 buf->Longjmp();
3813 UNREACHABLE(); 3856 UNREACHABLE();
3814 } 3857 }
3815 3858
3816 } // namespace dart 3859 } // namespace dart
3817 3860
3818 #endif // defined TARGET_ARCH_DBC 3861 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698