Index: runtime/vm/native_entry.cc |
diff --git a/runtime/vm/native_entry.cc b/runtime/vm/native_entry.cc |
index 92a99e8c7d59d24b3270c4f286be79947a2e1c2e..5ae182ccbb3c07fa2a7d4a1c7dfa1eaeec21384d 100644 |
--- a/runtime/vm/native_entry.cc |
+++ b/runtime/vm/native_entry.cc |
@@ -12,6 +12,7 @@ |
#include "vm/dart_api_state.h" |
#include "vm/object_store.h" |
#include "vm/reusable_handles.h" |
+#include "vm/safepoint.h" |
#include "vm/stack_frame.h" |
#include "vm/symbols.h" |
#include "vm/tags.h" |
@@ -33,12 +34,16 @@ NativeFunction NativeEntry::ResolveNative(const Library& library, |
// class belongs in. |
return NULL; |
} |
- Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries. |
- Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
- Dart_NativeFunction native_function = |
- resolver(Api::NewHandle(Thread::Current(), function_name.raw()), |
- number_of_arguments, auto_setup_scope); |
- Dart_ExitScope(); // Exit the Dart API scope. |
+ Dart_NativeFunction native_function = NULL; |
+ { |
+ Thread* T = Thread::Current(); |
+ TransitionVMToNative transition(T); |
+ Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries. |
+ Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
+ native_function = resolver(Api::NewHandle(T, function_name.raw()), |
+ number_of_arguments, auto_setup_scope); |
+ Dart_ExitScope(); // Exit the Dart API scope. |
+ } |
return reinterpret_cast<NativeFunction>(native_function); |
} |
@@ -101,6 +106,7 @@ void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, |
ApiLocalScope* current_top_scope = thread->api_top_scope(); |
ApiLocalScope* scope = thread->api_reusable_scope(); |
TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func)); |
+ TransitionGeneratedToNative transition(thread); |
if (scope == NULL) { |
scope = new ApiLocalScope(current_top_scope, |
thread->top_exit_frame_info()); |
@@ -173,6 +179,7 @@ void NativeEntry::LinkNativeCall(Dart_NativeArguments args) { |
#endif |
{ |
+ TransitionGeneratedToVM transition(arguments->thread()); |
StackZone zone(arguments->thread()); |
DartFrameIterator iterator; |