Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Unified Diff: runtime/vm/native_entry.cc

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: self-review-comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698