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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 StackZone stack_zone(arguments->thread()); | 264 StackZone stack_zone(arguments->thread()); |
265 Zone* zone = stack_zone.GetZone(); | 265 Zone* zone = stack_zone.GetZone(); |
266 | 266 |
267 DartFrameIterator iterator; | 267 DartFrameIterator iterator; |
268 StackFrame* caller_frame = iterator.NextFrame(); | 268 StackFrame* caller_frame = iterator.NextFrame(); |
269 | 269 |
270 const Code& code = Code::Handle(zone, caller_frame->LookupDartCode()); | 270 const Code& code = Code::Handle(zone, caller_frame->LookupDartCode()); |
271 const Function& func = Function::Handle(zone, code.function()); | 271 const Function& func = Function::Handle(zone, code.function()); |
272 | 272 |
273 if (FLAG_trace_natives) { | 273 if (FLAG_trace_natives) { |
274 OS::Print("Resolving native target for %s\n", func.ToCString()); | 274 THR_Print("Resolving native target for %s\n", func.ToCString()); |
275 } | 275 } |
276 | 276 |
277 target_function = | 277 target_function = |
278 ResolveNativeFunction(arguments->thread()->zone(), func, | 278 ResolveNativeFunction(arguments->thread()->zone(), func, |
279 &is_bootstrap_native, &is_auto_scope); | 279 &is_bootstrap_native, &is_auto_scope); |
280 ASSERT(target_function != NULL); | 280 ASSERT(target_function != NULL); |
281 | 281 |
282 #if defined(DEBUG) | 282 #if defined(DEBUG) |
283 { | 283 { |
284 NativeFunction current_function = NULL; | 284 NativeFunction current_function = NULL; |
(...skipping 28 matching lines...) Expand all Loading... |
313 } else if (is_auto_scope) { | 313 } else if (is_auto_scope) { |
314 trampoline = StubCode::CallAutoScopeNative_entry()->code(); | 314 trampoline = StubCode::CallAutoScopeNative_entry()->code(); |
315 } else { | 315 } else { |
316 trampoline = StubCode::CallNoScopeNative_entry()->code(); | 316 trampoline = StubCode::CallNoScopeNative_entry()->code(); |
317 } | 317 } |
318 | 318 |
319 CodePatcher::PatchNativeCallAt(caller_frame->pc(), code, | 319 CodePatcher::PatchNativeCallAt(caller_frame->pc(), code, |
320 patch_target_function, trampoline); | 320 patch_target_function, trampoline); |
321 | 321 |
322 if (FLAG_trace_natives) { | 322 if (FLAG_trace_natives) { |
323 OS::Print(" -> %p (%s)\n", target_function, | 323 THR_Print(" -> %p (%s)\n", target_function, |
324 is_bootstrap_native ? "bootstrap" : "non-bootstrap"); | 324 is_bootstrap_native ? "bootstrap" : "non-bootstrap"); |
325 } | 325 } |
326 } | 326 } |
327 VERIFY_ON_TRANSITION; | 327 VERIFY_ON_TRANSITION; |
328 | 328 |
329 // Tail-call resolved target. | 329 // Tail-call resolved target. |
330 if (is_bootstrap_native) { | 330 if (is_bootstrap_native) { |
331 target_function(arguments); | 331 target_function(arguments); |
332 } else if (is_auto_scope) { | 332 } else if (is_auto_scope) { |
333 // Because this call is within a compilation unit, Clang doesn't respect | 333 // Because this call is within a compilation unit, Clang doesn't respect |
334 // the ABI alignment here. | 334 // the ABI alignment here. |
335 NativeEntry::AutoScopeNativeCallWrapperNoStackCheck( | 335 NativeEntry::AutoScopeNativeCallWrapperNoStackCheck( |
336 args, reinterpret_cast<Dart_NativeFunction>(target_function)); | 336 args, reinterpret_cast<Dart_NativeFunction>(target_function)); |
337 } else { | 337 } else { |
338 // Because this call is within a compilation unit, Clang doesn't respect | 338 // Because this call is within a compilation unit, Clang doesn't respect |
339 // the ABI alignment here. | 339 // the ABI alignment here. |
340 NativeEntry::NoScopeNativeCallWrapperNoStackCheck( | 340 NativeEntry::NoScopeNativeCallWrapperNoStackCheck( |
341 args, reinterpret_cast<Dart_NativeFunction>(target_function)); | 341 args, reinterpret_cast<Dart_NativeFunction>(target_function)); |
342 } | 342 } |
343 } | 343 } |
344 #endif // !defined(TARGET_ARCH_DBC) | 344 #endif // !defined(TARGET_ARCH_DBC) |
345 | 345 |
346 | 346 |
347 } // namespace dart | 347 } // namespace dart |
OLD | NEW |