diff --git a/runtime/PRESUBMIT.py b/runtime/PRESUBMIT.py index b20a5374945..bee8c74dbe6 100644 --- a/runtime/PRESUBMIT.py +++ b/runtime/PRESUBMIT.py @@ -19,7 +19,6 @@ USE_PYTHON3 = True BANNED_FUNCTIONS = [ ['\\bmemcpy\\(', 'memcpy'], ['\\bpthread_detach\\(', 'pthread_detach'], - ['\\bdetach\\(', 'std::thread::detach'], ] diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 142bda92faf..a7ad3513e4f 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -742,6 +742,7 @@ DART_EXPORT bool Dart_IsError(Dart_Handle handle) { DART_EXPORT void Dart_KillIsolate(Dart_Isolate handle) { Isolate* isolate = reinterpret_cast(handle); CHECK_ISOLATE(isolate); + TransitionNativeToVM transition(Thread::Current()); Isolate::KillIfExists(isolate, Isolate::kKillMsg); } diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc index 6712acee2d5..fca41536284 100644 --- a/runtime/vm/dart_api_impl_test.cc +++ b/runtime/vm/dart_api_impl_test.cc @@ -2649,7 +2649,9 @@ static Dart_NativeFunction OptExternalByteDataNativeResolver( } TEST_CASE(DartAPI_OptimizedExternalByteDataAccess) { + TransitionNativeToVM transition1(thread); NoBackgroundCompilerScope no_background_compiler(thread); + TransitionVMToNative transition2(thread); const char* kScriptChars = R"( import 'dart:typed_data'; diff --git a/runtime/vm/lockers.cc b/runtime/vm/lockers.cc index ed816904844..8c061ffffa2 100644 --- a/runtime/vm/lockers.cc +++ b/runtime/vm/lockers.cc @@ -112,6 +112,7 @@ bool SafepointRwLock::EnterRead() { // // Though if the lock was already acquired by this thread before entering a // safepoint, we do allow the nested acquire (which is a NOP). + ASSERT(thread == nullptr || thread->execution_state() == Thread::kThreadInVM); DEBUG_ASSERT(thread == nullptr || thread->CanAcquireSafepointLocks() || IsCurrentThreadReader()); @@ -178,6 +179,7 @@ void SafepointRwLock::EnterWrite() { // // Though if the lock was already acquired by this thread before entering a // safepoint, we do allow the nested acquire (which is a NOP). + ASSERT(thread == nullptr || thread->execution_state() == Thread::kThreadInVM); DEBUG_ASSERT(thread == nullptr || thread->CanAcquireSafepointLocks() || IsCurrentThreadWriter()); diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc index 6246f2a388d..a01b8314174 100644 --- a/runtime/vm/object_test.cc +++ b/runtime/vm/object_test.cc @@ -5811,7 +5811,6 @@ TEST_CASE(DartAPI_BreakpointLockRace) { &done); while (!done) { - ReloadParticipationScope allow_reload(thread); { TransitionNativeToVM transition(thread); const String& name = String::Handle(String::New(TestCase::url())); diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc index 68de665e252..a099665fad6 100644 --- a/runtime/vm/thread.cc +++ b/runtime/vm/thread.cc @@ -1477,6 +1477,9 @@ bool Thread::CanAcquireSafepointLocks() const { // Example: We own reload safepoint operation, load kernel, which allocates // symbols, where the symbol implementation acquires the symbol lock (we know // other mutators at reload safepoint do not hold symbol lock). + if (current_safepoint_level() == SafepointLevel::kGCAndDeoptAndReload) { + return false; + } return isolate_group()->safepoint_handler()->InnermostSafepointOperation( this) >= SafepointLevel::kGCAndDeoptAndReload; }