Fix moving GC bugs in MonitorEnter and MonitorExit
Fixes test 088 with gcstress mode.
Change-Id: Iaeb91f62f22233e403e97e954bfdc8dc367e63c8
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index a5a8d81..8c495fc 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -83,17 +83,25 @@
template <bool kMonitorCounting>
static inline void DoMonitorEnter(Thread* self,
ShadowFrame* frame,
- Object* ref) NO_THREAD_SAFETY_ANALYSIS {
- ref->MonitorEnter(self);
- frame->GetLockCountData().AddMonitor<kMonitorCounting>(self, ref);
+ Object* ref)
+ NO_THREAD_SAFETY_ANALYSIS
+ REQUIRES(!Roles::uninterruptible_) {
+ StackHandleScope<1> hs(self);
+ Handle<Object> h_ref(hs.NewHandle(ref));
+ h_ref->MonitorEnter(self);
+ frame->GetLockCountData().AddMonitor<kMonitorCounting>(self, h_ref.Get());
}
template <bool kMonitorCounting>
static inline void DoMonitorExit(Thread* self,
ShadowFrame* frame,
- Object* ref) NO_THREAD_SAFETY_ANALYSIS {
- ref->MonitorExit(self);
- frame->GetLockCountData().RemoveMonitorOrThrow<kMonitorCounting>(self, ref);
+ Object* ref)
+ NO_THREAD_SAFETY_ANALYSIS
+ REQUIRES(!Roles::uninterruptible_) {
+ StackHandleScope<1> hs(self);
+ Handle<Object> h_ref(hs.NewHandle(ref));
+ h_ref->MonitorExit(self);
+ frame->GetLockCountData().RemoveMonitorOrThrow<kMonitorCounting>(self, h_ref.Get());
}
void AbortTransactionF(Thread* self, const char* fmt, ...)