Skip to content

Commit b591571

Browse files
[vm] Fix symbol creation during DeoptSafepointOperationScope.
TEST=reload stress mode Bug: #60337 Change-Id: Ieb85a832b72f0940155b6c3480abb91d5c803805 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416042 Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 18a44b3 commit b591571

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

runtime/vm/object.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18724,7 +18724,6 @@ void Code::NotifyCodeObservers(const Function& function,
1872418724
bool optimized) {
1872518725
#if !defined(PRODUCT)
1872618726
ASSERT(!function.IsNull());
18727-
ASSERT(!Thread::Current()->OwnsGCSafepoint());
1872818727
// Calling ToLibNamePrefixedQualifiedCString is very expensive,
1872918728
// try to avoid it.
1873018729
if (CodeObservers::AreActive()) {
@@ -18740,7 +18739,6 @@ void Code::NotifyCodeObservers(const char* name,
1874018739
#if !defined(PRODUCT)
1874118740
ASSERT(name != nullptr);
1874218741
ASSERT(!code.IsNull());
18743-
ASSERT(!Thread::Current()->OwnsGCSafepoint());
1874418742
if (CodeObservers::AreActive()) {
1874518743
const auto& instrs = Instructions::Handle(code.instructions());
1874618744
CodeObservers::NotifyAll(name, instrs.PayloadStart(),

runtime/vm/symbols.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ StringPtr Symbols::NewSymbol(Thread* thread, const StringType& str) {
345345
if (symbol.IsNull()) {
346346
IsolateGroup* group = thread->isolate_group();
347347
ObjectStore* object_store = group->object_store();
348-
RELEASE_ASSERT(thread->CanAcquireSafepointLocks());
349348

350349
// Most common case: The symbol is already in the table.
351350
{
@@ -359,11 +358,18 @@ StringPtr Symbols::NewSymbol(Thread* thread, const StringType& str) {
359358
}
360359
// Otherwise we'll have to get exclusive access and get-or-insert it.
361360
if (symbol.IsNull()) {
362-
SafepointMutexLocker ml(group->symbols_mutex());
363-
data = object_store->symbol_table();
364-
CanonicalStringSet table(&key, &value, &data);
365-
symbol ^= table.InsertNewOrGet(str);
366-
object_store->set_symbol_table(table.Release());
361+
if (thread->OwnsSafepoint()) {
362+
data = object_store->symbol_table();
363+
CanonicalStringSet table(&key, &value, &data);
364+
symbol ^= table.InsertNewOrGet(str);
365+
object_store->set_symbol_table(table.Release());
366+
} else {
367+
SafepointMutexLocker ml(group->symbols_mutex());
368+
data = object_store->symbol_table();
369+
CanonicalStringSet table(&key, &value, &data);
370+
symbol ^= table.InsertNewOrGet(str);
371+
object_store->set_symbol_table(table.Release());
372+
}
367373
}
368374
}
369375
ASSERT(symbol.IsSymbol());

0 commit comments

Comments
 (0)