@@ -111,9 +111,14 @@ void NativeEntry::MaybePropagateError(NativeArguments* arguments) {
111111 }
112112}
113113
114+ extern " C" void DRT_BootstrapNativeCall (Dart_NativeArguments args,
115+ Dart_NativeFunction func) {
116+ CHECK_STACK_ALIGNMENT;
117+ NativeEntry::BootstrapNativeCallWrapper (args, func);
118+ }
119+
114120uword NativeEntry::BootstrapNativeCallWrapperEntry () {
115- uword entry =
116- reinterpret_cast <uword>(NativeEntry::BootstrapNativeCallWrapper);
121+ uword entry = reinterpret_cast <uword>(DRT_BootstrapNativeCall);
117122#if defined(USING_SIMULATOR)
118123 entry = Simulator::RedirectExternalReference (
119124 entry, Simulator::kNativeCallWrapper ,
@@ -124,7 +129,6 @@ uword NativeEntry::BootstrapNativeCallWrapperEntry() {
124129
125130void NativeEntry::BootstrapNativeCallWrapper (Dart_NativeArguments args,
126131 Dart_NativeFunction func) {
127- CHECK_STACK_ALIGNMENT;
128132 if (func == LinkNativeCall) {
129133 func (args);
130134 return ;
@@ -151,8 +155,14 @@ void NativeEntry::BootstrapNativeCallWrapper(Dart_NativeArguments args,
151155 }
152156}
153157
158+ extern " C" void DRT_NoScopeNativeCall (Dart_NativeArguments args,
159+ Dart_NativeFunction func) {
160+ CHECK_STACK_ALIGNMENT;
161+ NativeEntry::NoScopeNativeCallWrapper (args, func);
162+ }
163+
154164uword NativeEntry::NoScopeNativeCallWrapperEntry () {
155- uword entry = reinterpret_cast <uword>(NativeEntry::NoScopeNativeCallWrapper );
165+ uword entry = reinterpret_cast <uword>(DRT_NoScopeNativeCall );
156166#if defined(USING_SIMULATOR)
157167 entry = Simulator::RedirectExternalReference (
158168 entry, Simulator::kNativeCallWrapper ,
@@ -163,13 +173,6 @@ uword NativeEntry::NoScopeNativeCallWrapperEntry() {
163173
164174void NativeEntry::NoScopeNativeCallWrapper (Dart_NativeArguments args,
165175 Dart_NativeFunction func) {
166- CHECK_STACK_ALIGNMENT;
167- NoScopeNativeCallWrapperNoStackCheck (args, func);
168- }
169-
170- void NativeEntry::NoScopeNativeCallWrapperNoStackCheck (
171- Dart_NativeArguments args,
172- Dart_NativeFunction func) {
173176 NativeArguments* arguments = reinterpret_cast <NativeArguments*>(args);
174177 // Tell MemorySanitizer 'arguments' is initialized by generated code.
175178 MSAN_UNPOISON (arguments, sizeof (*arguments));
@@ -183,9 +186,14 @@ void NativeEntry::NoScopeNativeCallWrapperNoStackCheck(
183186 ASSERT (thread->execution_state () == Thread::kThreadInGenerated );
184187}
185188
189+ extern " C" void DRT_AutoScopeNativeCall (Dart_NativeArguments args,
190+ Dart_NativeFunction func) {
191+ CHECK_STACK_ALIGNMENT;
192+ NativeEntry::AutoScopeNativeCallWrapper (args, func);
193+ }
194+
186195uword NativeEntry::AutoScopeNativeCallWrapperEntry () {
187- uword entry =
188- reinterpret_cast <uword>(NativeEntry::AutoScopeNativeCallWrapper);
196+ uword entry = reinterpret_cast <uword>(DRT_AutoScopeNativeCall);
189197#if defined(USING_SIMULATOR)
190198 entry = Simulator::RedirectExternalReference (
191199 entry, Simulator::kNativeCallWrapper ,
@@ -196,13 +204,6 @@ uword NativeEntry::AutoScopeNativeCallWrapperEntry() {
196204
197205void NativeEntry::AutoScopeNativeCallWrapper (Dart_NativeArguments args,
198206 Dart_NativeFunction func) {
199- CHECK_STACK_ALIGNMENT;
200- AutoScopeNativeCallWrapperNoStackCheck (args, func);
201- }
202-
203- void NativeEntry::AutoScopeNativeCallWrapperNoStackCheck (
204- Dart_NativeArguments args,
205- Dart_NativeFunction func) {
206207 NativeArguments* arguments = reinterpret_cast <NativeArguments*>(args);
207208 // Tell MemorySanitizer 'arguments' is initialized by generated code.
208209 MSAN_UNPOISON (arguments, sizeof (*arguments));
@@ -249,8 +250,9 @@ static NativeFunction ResolveNativeFunction(Zone* zone,
249250}
250251
251252uword NativeEntry::LinkNativeCallEntry () {
252- uword entry = reinterpret_cast <uword>(NativeEntry::LinkNativeCall);
253- return entry;
253+ // This one does not need a simulator redirect because it is always called
254+ // through BootstrapNativeCallWrapper, not directly from generated code.
255+ return reinterpret_cast <uword>(NativeEntry::LinkNativeCall);
254256}
255257
256258void NativeEntry::LinkNativeCall (Dart_NativeArguments args) {
@@ -322,14 +324,10 @@ void NativeEntry::LinkNativeCall(Dart_NativeArguments args) {
322324 NativeEntry::BootstrapNativeCallWrapper (
323325 args, reinterpret_cast <Dart_NativeFunction>(target_function));
324326 } else if (is_auto_scope) {
325- // Because this call is within a compilation unit, Clang doesn't respect
326- // the ABI alignment here.
327- NativeEntry::AutoScopeNativeCallWrapperNoStackCheck (
327+ NativeEntry::AutoScopeNativeCallWrapper (
328328 args, reinterpret_cast <Dart_NativeFunction>(target_function));
329329 } else {
330- // Because this call is within a compilation unit, Clang doesn't respect
331- // the ABI alignment here.
332- NativeEntry::NoScopeNativeCallWrapperNoStackCheck (
330+ NativeEntry::NoScopeNativeCallWrapper (
333331 args, reinterpret_cast <Dart_NativeFunction>(target_function));
334332 }
335333}
0 commit comments