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 entry = Simulator::RedirectExternalReference( | 94 entry = Simulator::RedirectExternalReference( |
95 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments); | 95 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments); |
96 #endif | 96 #endif |
97 return entry; | 97 return entry; |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 bool NativeEntry::ReturnValueIsError(NativeArguments* arguments) { | 101 bool NativeEntry::ReturnValueIsError(NativeArguments* arguments) { |
102 RawObject* retval = arguments->ReturnValue(); | 102 RawObject* retval = arguments->ReturnValue(); |
103 return (retval->IsHeapObject() && | 103 return (retval->IsHeapObject() && |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 const int num_params = NativeArguments::ParameterCountForResolution(func); | 192 const int num_params = NativeArguments::ParameterCountForResolution(func); |
193 bool auto_setup_scope = true; | 193 bool auto_setup_scope = true; |
194 return NativeEntry::ResolveNative( | 194 return NativeEntry::ResolveNative( |
195 library, native_name, num_params, &auto_setup_scope); | 195 library, native_name, num_params, &auto_setup_scope); |
196 } | 196 } |
197 | 197 |
198 | 198 |
199 uword NativeEntry::LinkNativeCallEntry() { | 199 uword NativeEntry::LinkNativeCallEntry() { |
200 uword entry = reinterpret_cast<uword>(NativeEntry::LinkNativeCall); | 200 uword entry = reinterpret_cast<uword>(NativeEntry::LinkNativeCall); |
201 #if defined(USING_SIMULATOR) | 201 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) |
202 entry = Simulator::RedirectExternalReference( | 202 entry = Simulator::RedirectExternalReference( |
203 entry, Simulator::kBootstrapNativeCall, NativeEntry::kNumArguments); | 203 entry, Simulator::kBootstrapNativeCall, NativeEntry::kNumArguments); |
204 #endif | 204 #endif |
205 return entry; | 205 return entry; |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 void NativeEntry::LinkNativeCall(Dart_NativeArguments args) { | 209 void NativeEntry::LinkNativeCall(Dart_NativeArguments args) { |
210 CHECK_STACK_ALIGNMENT; | 210 CHECK_STACK_ALIGNMENT; |
211 VERIFY_ON_TRANSITION; | 211 VERIFY_ON_TRANSITION; |
(...skipping 17 matching lines...) Expand all Loading... |
229 | 229 |
230 if (FLAG_trace_natives) { | 230 if (FLAG_trace_natives) { |
231 OS::Print("Resolving native target for %s\n", func.ToCString()); | 231 OS::Print("Resolving native target for %s\n", func.ToCString()); |
232 } | 232 } |
233 | 233 |
234 bool is_bootstrap_native = false; | 234 bool is_bootstrap_native = false; |
235 target_function = ResolveNativeFunction( | 235 target_function = ResolveNativeFunction( |
236 arguments->thread()->zone(), func, &is_bootstrap_native); | 236 arguments->thread()->zone(), func, &is_bootstrap_native); |
237 ASSERT(target_function != NULL); | 237 ASSERT(target_function != NULL); |
238 | 238 |
239 #if defined(DEBUG) | 239 #if defined(DEBUG) && !defined(TARGET_ARCH_DBC) |
240 { | 240 { |
241 NativeFunction current_function = NULL; | 241 NativeFunction current_function = NULL; |
242 const Code& current_trampoline = Code::Handle( | 242 const Code& current_trampoline = Code::Handle( |
243 CodePatcher::GetNativeCallAt(caller_frame->pc(), | 243 CodePatcher::GetNativeCallAt(caller_frame->pc(), |
244 code, | 244 code, |
245 ¤t_function)); | 245 ¤t_function)); |
246 #if !defined(USING_SIMULATOR) | 246 #if !defined(USING_SIMULATOR) |
247 ASSERT(current_function == | 247 ASSERT(current_function == |
248 reinterpret_cast<NativeFunction>(LinkNativeCall)); | 248 reinterpret_cast<NativeFunction>(LinkNativeCall)); |
249 #else | 249 #else |
250 ASSERT(current_function == | 250 ASSERT(current_function == |
251 reinterpret_cast<NativeFunction>( | 251 reinterpret_cast<NativeFunction>( |
252 Simulator::RedirectExternalReference( | 252 Simulator::RedirectExternalReference( |
253 reinterpret_cast<uword>(LinkNativeCall), | 253 reinterpret_cast<uword>(LinkNativeCall), |
254 Simulator::kBootstrapNativeCall, | 254 Simulator::kBootstrapNativeCall, |
255 NativeEntry::kNumArguments))); | 255 NativeEntry::kNumArguments))); |
256 #endif | 256 #endif |
257 ASSERT(current_trampoline.raw() == | 257 ASSERT(current_trampoline.raw() == |
258 StubCode::CallBootstrapCFunction_entry()->code()); | 258 StubCode::CallBootstrapCFunction_entry()->code()); |
259 } | 259 } |
260 #endif | 260 #endif |
261 | 261 |
262 call_through_wrapper = !is_bootstrap_native; | 262 call_through_wrapper = !is_bootstrap_native; |
263 const Code& trampoline = Code::Handle(call_through_wrapper ? | 263 const Code& trampoline = |
264 StubCode::CallNativeCFunction_entry()->code() : | 264 #if !defined(TARGET_ARCH_DBC) |
265 StubCode::CallBootstrapCFunction_entry()->code()); | 265 Code::Handle(call_through_wrapper ? |
| 266 StubCode::CallNativeCFunction_entry()->code() : |
| 267 StubCode::CallBootstrapCFunction_entry()->code()); |
| 268 #else |
| 269 Code::Handle(); |
| 270 #endif |
266 | 271 |
267 NativeFunction patch_target_function = target_function; | 272 NativeFunction patch_target_function = target_function; |
268 #if defined(USING_SIMULATOR) | 273 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) |
269 if (!call_through_wrapper) { | 274 if (!call_through_wrapper) { |
270 patch_target_function = reinterpret_cast<NativeFunction>( | 275 patch_target_function = reinterpret_cast<NativeFunction>( |
271 Simulator::RedirectExternalReference( | 276 Simulator::RedirectExternalReference( |
272 reinterpret_cast<uword>(patch_target_function), | 277 reinterpret_cast<uword>(patch_target_function), |
273 Simulator::kBootstrapNativeCall, NativeEntry::kNumArguments)); | 278 Simulator::kBootstrapNativeCall, NativeEntry::kNumArguments)); |
274 } | 279 } |
275 #endif | 280 #endif |
276 | 281 |
277 CodePatcher::PatchNativeCallAt( | 282 CodePatcher::PatchNativeCallAt( |
278 caller_frame->pc(), code, patch_target_function, trampoline); | 283 caller_frame->pc(), code, patch_target_function, trampoline); |
(...skipping 12 matching lines...) Expand all Loading... |
291 // the ABI alignment here. | 296 // the ABI alignment here. |
292 NativeEntry::NativeCallWrapperNoStackCheck( | 297 NativeEntry::NativeCallWrapperNoStackCheck( |
293 args, reinterpret_cast<Dart_NativeFunction>(target_function)); | 298 args, reinterpret_cast<Dart_NativeFunction>(target_function)); |
294 } else { | 299 } else { |
295 target_function(arguments); | 300 target_function(arguments); |
296 } | 301 } |
297 } | 302 } |
298 | 303 |
299 | 304 |
300 } // namespace dart | 305 } // namespace dart |
OLD | NEW |