diff options
author | Sebastien Hertz <shertz@google.com> | 2014-04-02 07:45:51 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-04-02 07:45:52 +0000 |
commit | 1246d689dc3150bbee6c5e5628747a94fba5081e (patch) | |
tree | 24fb2b8271cdc524855f52bbc94361dbf5f8c2f0 /runtime/mirror | |
parent | f689b93e904e062d83a7ae7e8cacce0b52af3323 (diff) | |
parent | ee1d79a603c77c0667b27c075a983579d5c51f7e (diff) | |
download | art-1246d689dc3150bbee6c5e5628747a94fba5081e.tar.gz art-1246d689dc3150bbee6c5e5628747a94fba5081e.tar.bz2 art-1246d689dc3150bbee6c5e5628747a94fba5081e.zip |
Merge "Cleanup transaction support"
Diffstat (limited to 'runtime/mirror')
-rw-r--r-- | runtime/mirror/class.h | 7 | ||||
-rw-r--r-- | runtime/mirror/object_test.cc | 4 | ||||
-rw-r--r-- | runtime/mirror/string.cc | 14 | ||||
-rw-r--r-- | runtime/mirror/string.h | 10 |
4 files changed, 14 insertions, 21 deletions
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index ddc07ff53e..d955b9791f 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -391,11 +391,8 @@ class MANAGED Class : public Object { void SetComponentType(Class* new_component_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(GetComponentType() == NULL); DCHECK(new_component_type != NULL); - if (Runtime::Current()->IsActiveTransaction()) { - SetFieldObject<true>(ComponentTypeOffset(), new_component_type, false); - } else { - SetFieldObject<false>(ComponentTypeOffset(), new_component_type, false); - } + // Component type is invariant: use non-transactional mode without check. + SetFieldObject<false, false>(ComponentTypeOffset(), new_component_type, false); } size_t GetComponentSize() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc index 7d8da14a28..32f30c3dc3 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -425,8 +425,8 @@ TEST_F(ObjectTest, StringLength) { EXPECT_EQ(string->GetLength(), 7); EXPECT_EQ(string->GetUtfLength(), 7); - string->SetOffset<false>(2); - string->SetCount<false>(5); + string->SetOffset(2); + string->SetCount(5); EXPECT_TRUE(string->Equals("droid")); EXPECT_EQ(string->GetLength(), 5); EXPECT_EQ(string->GetUtfLength(), 5); diff --git a/runtime/mirror/string.cc b/runtime/mirror/string.cc index d4f11b2b28..88a8e6f567 100644 --- a/runtime/mirror/string.cc +++ b/runtime/mirror/string.cc @@ -59,10 +59,11 @@ int32_t String::FastIndexOf(int32_t ch, int32_t start) { return -1; } -template<bool kTransactionActive> void String::SetArray(CharArray* new_array) { + // Array is invariant so use non-transactional mode. Also disable check as we may run inside + // a transaction. DCHECK(new_array != NULL); - SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(String, array_), new_array, false); + SetFieldObject<false, false>(OFFSET_OF_OBJECT_MEMBER(String, array_), new_array, false); } // TODO: get global references for these @@ -168,13 +169,8 @@ String* String::Alloc(Thread* self, const SirtRef<CharArray>& array) { // Hold reference in case AllocObject causes GC. String* string = down_cast<String*>(GetJavaLangString()->AllocObject(self)); if (LIKELY(string != nullptr)) { - if (Runtime::Current()->IsActiveTransaction()) { - string->SetArray<true>(array.get()); - string->SetCount<true>(array->GetLength()); - } else { - string->SetArray<false>(array.get()); - string->SetCount<false>(array->GetLength()); - } + string->SetArray(array.get()); + string->SetCount(array->GetLength()); } return string; } diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h index 1340e7d39c..de9e4c40aa 100644 --- a/runtime/mirror/string.h +++ b/runtime/mirror/string.h @@ -118,17 +118,18 @@ class MANAGED String : public Object { SetField32<false, false>(OFFSET_OF_OBJECT_MEMBER(String, hash_code_), new_hash_code, false); } - template<bool kTransactionActive> void SetCount(int32_t new_count) { + // Count is invariant so use non-transactional mode. Also disable check as we may run inside + // a transaction. DCHECK_LE(0, new_count); - SetField32<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(String, count_), new_count, false); + SetField32<false, false>(OFFSET_OF_OBJECT_MEMBER(String, count_), new_count, false); } - template<bool kTransactionActive> void SetOffset(int32_t new_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + // Offset is only used during testing so use non-transactional mode. DCHECK_LE(0, new_offset); DCHECK_GE(GetLength(), new_offset); - SetField32<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(String, offset_), new_offset, false); + SetField32<false>(OFFSET_OF_OBJECT_MEMBER(String, offset_), new_offset, false); } static String* Alloc(Thread* self, int32_t utf16_length) @@ -137,7 +138,6 @@ class MANAGED String : public Object { static String* Alloc(Thread* self, const SirtRef<CharArray>& array) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - template<bool kTransactionActive> void SetArray(CharArray* new_array) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |