[vm] Adds mutator thread asserts around bytecode reading
Change-Id: If5ee92e69f04da8c22983ccdb3d6d9006a2010a5
Reviewed-on: https://dart-review.googlesource.com/c/80562
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
diff --git a/runtime/vm/compiler/frontend/bytecode_reader.cc b/runtime/vm/compiler/frontend/bytecode_reader.cc
index 0e9c427..587eb27 100644
--- a/runtime/vm/compiler/frontend/bytecode_reader.cc
+++ b/runtime/vm/compiler/frontend/bytecode_reader.cc
@@ -57,6 +57,8 @@
return;
}
+ ASSERT(Thread::Current()->IsMutatorThread());
+
AlternativeReadingScope alt(&helper_->reader_, &H.metadata_payloads(),
md_offset);
@@ -766,6 +768,7 @@
ASSERT(!FLAG_precompiled_mode);
ASSERT(!function.HasBytecode());
ASSERT(thread->sticky_error() == Error::null());
+ ASSERT(Thread::Current()->IsMutatorThread());
LongJumpScope jump;
if (setjmp(*jump.Set()) == 0) {
diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc
index e90f251..83c5fe9 100644
--- a/runtime/vm/compiler/jit/compiler.cc
+++ b/runtime/vm/compiler/jit/compiler.cc
@@ -228,6 +228,7 @@
// Compile a function. Should call only if the function has not been compiled.
// Arg0: function object.
DEFINE_RUNTIME_ENTRY(CompileFunction, 1) {
+ ASSERT(thread->IsMutatorThread());
const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
Object& result = Object::Handle(zone);
@@ -1329,6 +1330,7 @@
RawError* Compiler::ReadAllBytecode(const Class& cls) {
Thread* thread = Thread::Current();
+ ASSERT(thread->IsMutatorThread());
Zone* zone = thread->zone();
Error& error = Error::Handle(zone, cls.EnsureIsFinalized(thread));
ASSERT(error.IsNull());
@@ -1370,6 +1372,7 @@
LongJumpScope jump;
if (setjmp(*jump.Set()) == 0) {
Thread* const thread = Thread::Current();
+ ASSERT(thread->IsMutatorThread());
NoOOBMessageScope no_msg_scope(thread);
NoReloadScope no_reload_scope(thread->isolate(), thread);
// Under lazy compilation initializer has not yet been created, so create
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index f6bf794..44f95e8 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -12505,6 +12505,7 @@
#if !defined(DART_PRECOMPILED_RUNTIME)
RawError* Library::ReadAllBytecode() {
Thread* thread = Thread::Current();
+ ASSERT(thread->IsMutatorThread());
Zone* zone = thread->zone();
Error& error = Error::Handle(zone);
const GrowableObjectArray& libs = GrowableObjectArray::Handle(