OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/native_entry.h" | 5 #include "vm/native_entry.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (r != NULL) { | 83 if (r != NULL) { |
84 return r; | 84 return r; |
85 } | 85 } |
86 } | 86 } |
87 return NULL; | 87 return NULL; |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 uword NativeEntry::NativeCallWrapperEntry() { | 91 uword NativeEntry::NativeCallWrapperEntry() { |
92 uword entry = reinterpret_cast<uword>(NativeEntry::NativeCallWrapper); | 92 uword entry = reinterpret_cast<uword>(NativeEntry::NativeCallWrapper); |
93 #if defined(USING_SIMULATOR) | 93 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) |
| 94 // DBC does not use redirections unlike other simulators. |
94 entry = Simulator::RedirectExternalReference( | 95 entry = Simulator::RedirectExternalReference( |
95 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments); | 96 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments); |
96 #endif | 97 #endif |
97 return entry; | 98 return entry; |
98 } | 99 } |
99 | 100 |
100 | 101 |
101 bool NativeEntry::ReturnValueIsError(NativeArguments* arguments) { | 102 bool NativeEntry::ReturnValueIsError(NativeArguments* arguments) { |
102 RawObject* retval = arguments->ReturnValue(); | 103 RawObject* retval = arguments->ReturnValue(); |
103 return (retval->IsHeapObject() && | 104 return (retval->IsHeapObject() && |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } else { | 171 } else { |
171 ASSERT(thread->api_reusable_scope() != scope); | 172 ASSERT(thread->api_reusable_scope() != scope); |
172 delete scope; | 173 delete scope; |
173 } | 174 } |
174 DEOPTIMIZE_ALOT; | 175 DEOPTIMIZE_ALOT; |
175 VERIFY_ON_TRANSITION; | 176 VERIFY_ON_TRANSITION; |
176 } | 177 } |
177 } | 178 } |
178 | 179 |
179 | 180 |
| 181 // DBC does not support lazy native call linking. |
| 182 #if !defined(TARGET_ARCH_DBC) |
180 static NativeFunction ResolveNativeFunction(Zone* zone, | 183 static NativeFunction ResolveNativeFunction(Zone* zone, |
181 const Function& func, | 184 const Function& func, |
182 bool* is_bootstrap_native) { | 185 bool* is_bootstrap_native) { |
183 const Class& cls = Class::Handle(zone, func.Owner()); | 186 const Class& cls = Class::Handle(zone, func.Owner()); |
184 const Library& library = Library::Handle(zone, cls.library()); | 187 const Library& library = Library::Handle(zone, cls.library()); |
185 | 188 |
186 *is_bootstrap_native = | 189 *is_bootstrap_native = |
187 Bootstrap::IsBootstapResolver(library.native_entry_resolver()); | 190 Bootstrap::IsBootstapResolver(library.native_entry_resolver()); |
188 | 191 |
189 const String& native_name = String::Handle(zone, func.native_name()); | 192 const String& native_name = String::Handle(zone, func.native_name()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 reinterpret_cast<uword>(LinkNativeCall), | 256 reinterpret_cast<uword>(LinkNativeCall), |
254 Simulator::kBootstrapNativeCall, | 257 Simulator::kBootstrapNativeCall, |
255 NativeEntry::kNumArguments))); | 258 NativeEntry::kNumArguments))); |
256 #endif | 259 #endif |
257 ASSERT(current_trampoline.raw() == | 260 ASSERT(current_trampoline.raw() == |
258 StubCode::CallBootstrapCFunction_entry()->code()); | 261 StubCode::CallBootstrapCFunction_entry()->code()); |
259 } | 262 } |
260 #endif | 263 #endif |
261 | 264 |
262 call_through_wrapper = !is_bootstrap_native; | 265 call_through_wrapper = !is_bootstrap_native; |
263 const Code& trampoline = Code::Handle(call_through_wrapper ? | 266 const Code& trampoline = |
264 StubCode::CallNativeCFunction_entry()->code() : | 267 Code::Handle(call_through_wrapper ? |
265 StubCode::CallBootstrapCFunction_entry()->code()); | 268 StubCode::CallNativeCFunction_entry()->code() : |
| 269 StubCode::CallBootstrapCFunction_entry()->code()); |
266 | 270 |
267 NativeFunction patch_target_function = target_function; | 271 NativeFunction patch_target_function = target_function; |
268 #if defined(USING_SIMULATOR) | 272 #if defined(USING_SIMULATOR) |
269 if (!call_through_wrapper) { | 273 if (!call_through_wrapper) { |
270 patch_target_function = reinterpret_cast<NativeFunction>( | 274 patch_target_function = reinterpret_cast<NativeFunction>( |
271 Simulator::RedirectExternalReference( | 275 Simulator::RedirectExternalReference( |
272 reinterpret_cast<uword>(patch_target_function), | 276 reinterpret_cast<uword>(patch_target_function), |
273 Simulator::kBootstrapNativeCall, NativeEntry::kNumArguments)); | 277 Simulator::kBootstrapNativeCall, NativeEntry::kNumArguments)); |
274 } | 278 } |
275 #endif | 279 #endif |
(...skipping 12 matching lines...) Expand all Loading... |
288 // Tail-call resolved target. | 292 // Tail-call resolved target. |
289 if (call_through_wrapper) { | 293 if (call_through_wrapper) { |
290 // Because this call is within a compilation unit, Clang doesn't respect | 294 // Because this call is within a compilation unit, Clang doesn't respect |
291 // the ABI alignment here. | 295 // the ABI alignment here. |
292 NativeEntry::NativeCallWrapperNoStackCheck( | 296 NativeEntry::NativeCallWrapperNoStackCheck( |
293 args, reinterpret_cast<Dart_NativeFunction>(target_function)); | 297 args, reinterpret_cast<Dart_NativeFunction>(target_function)); |
294 } else { | 298 } else { |
295 target_function(arguments); | 299 target_function(arguments); |
296 } | 300 } |
297 } | 301 } |
| 302 #endif // !defined(TARGET_ARCH_DBC) |
298 | 303 |
299 | 304 |
300 } // namespace dart | 305 } // namespace dart |
OLD | NEW |