Abstract SetField functions with Transaction check
Abstracted several functions which set objects' fields with a check to
test whether transaction is active to determine one template argument,
this make more object modification operations support transaction.
Replaced some function calls with transaction checking version to
support clinit for app image to run under transaction.
Tests shows not breaking anything, testcase cover this situation will be
added shortly.
Test: make test-art-host -j64
Change-Id: Ic15a4428a7c7cce6832651e1894eb760354de009
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 419a4db..003cd4e 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -673,11 +673,7 @@
}
inline void Class::SetClinitThreadId(pid_t new_clinit_thread_id) {
- if (Runtime::Current()->IsActiveTransaction()) {
- SetField32<true>(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_), new_clinit_thread_id);
- } else {
- SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_), new_clinit_thread_id);
- }
+ SetField32Transaction(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_), new_clinit_thread_id);
}
inline String* Class::GetName() {
@@ -685,11 +681,7 @@
}
inline void Class::SetName(ObjPtr<String> name) {
- if (Runtime::Current()->IsActiveTransaction()) {
- SetFieldObject<true>(OFFSET_OF_OBJECT_MEMBER(Class, name_), name);
- } else {
- SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(Class, name_), name);
- }
+ SetFieldObjectTransaction(OFFSET_OF_OBJECT_MEMBER(Class, name_), name);
}
template<VerifyObjectFlags kVerifyFlags>