diff options
author | dimitry <dimitry@google.com> | 2024-03-04 22:44:25 +0100 |
---|---|---|
committer | dimitry <dimitry@google.com> | 2024-03-05 00:13:49 +0100 |
commit | 11c73f3314909aaff855f8c63aa2e1cef2ab7569 (patch) | |
tree | ca945037e70e6d5777164ae9780071874833b72f | |
parent | bafc1ba07ce733e6db0558d455268cbcc0575159 (diff) | |
download | binary_translation-11c73f3314909aaff855f8c63aa2e1cef2ab7569.tar.gz |
Minor style fixes in translation cache
Test: builds
Change-Id: I93028753e1e6485790c55ffae9a85116757e9163
-rw-r--r-- | runtime_primitives/translation_cache.cc | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/runtime_primitives/translation_cache.cc b/runtime_primitives/translation_cache.cc index 87cdca39..620eec30 100644 --- a/runtime_primitives/translation_cache.cc +++ b/runtime_primitives/translation_cache.cc @@ -20,8 +20,7 @@ #include <map> #include <mutex> // std::lock_guard, std::mutex -#include "berberis/base/logging.h" -#include "berberis/base/tracing.h" +#include "berberis/base/checks.h" #include "berberis/guest_state/guest_addr.h" #include "berberis/runtime_primitives/host_code.h" #include "berberis/runtime_primitives/runtime_library.h" @@ -39,14 +38,14 @@ GuestCodeEntry* TranslationCache::AddAndLockForTranslation(GuestAddr pc, // the set of the translating regions (e.g as invalidation observes it). std::lock_guard<std::mutex> lock(mutex_); - auto host_code_ptr = GetHostCodePtr(pc); + auto* host_code_ptr = GetHostCodePtr(pc); bool added; - auto entry = AddUnsafe(pc, - host_code_ptr, - {kEntryNotTranslated, 0}, // TODO(b/232598137): set true host_size? - 1, // Non-zero size simplifies invalidation. - GuestCodeEntry::Kind::kInterpreted, - &added); + auto* entry = AddUnsafe(pc, + host_code_ptr, + {kEntryNotTranslated, 0}, // TODO(b/232598137): set true host_size? + 1, // Non-zero size simplifies invalidation. + GuestCodeEntry::Kind::kInterpreted, + &added); CHECK(entry); // Must not be translated yet. @@ -139,12 +138,12 @@ GuestCodeEntry* TranslationCache::AddAndLockForWrapping(GuestAddr pc) { // ATTENTION: kEntryWrapping is a locked state, can return the entry. bool locked; - auto entry = AddUnsafe(pc, - GetHostCodePtr(pc), - {kEntryWrapping, 0}, // TODO(b/232598137): set true host_size? - 1, // Non-zero size simplifies invalidation. - GuestCodeEntry::Kind::kUnderProcessing, - &locked); + auto* entry = AddUnsafe(pc, + GetHostCodePtr(pc), + {kEntryWrapping, 0}, // TODO(b/232598137): set true host_size? + 1, // Non-zero size simplifies invalidation. + GuestCodeEntry::Kind::kUnderProcessing, + &locked); return locked ? entry : nullptr; } @@ -154,7 +153,7 @@ void TranslationCache::SetWrappedAndUnlock(GuestAddr pc, HostCodePiece code) { std::lock_guard<std::mutex> lock(mutex_); - auto current = entry->host_code->load(); + auto* current = entry->host_code->load(); // Might have been invalidated while wrapping. if (current == kEntryInvalidating) { @@ -180,7 +179,7 @@ void TranslationCache::SetWrappedAndUnlock(GuestAddr pc, bool TranslationCache::IsHostFunctionWrapped(GuestAddr pc) { std::lock_guard<std::mutex> lock(mutex_); - if (auto entry = LookupGuestCodeEntryUnsafe(pc)) { + if (auto* entry = LookupGuestCodeEntryUnsafe(pc)) { return entry->kind == GuestCodeEntry::Kind::kHostWrapped; } return false; @@ -192,14 +191,14 @@ GuestCodeEntry* TranslationCache::AddUnsafe(GuestAddr pc, uint32_t guest_size, GuestCodeEntry::Kind kind, bool* added) { - auto [it, result] = guest_entries_.emplace( + auto [it, inserted] = guest_entries_.emplace( std::pair{pc, GuestCodeEntry{host_code_ptr, host_code_piece.size, guest_size, kind, 0}}); - if (result) { + if (inserted) { host_code_ptr->store(host_code_piece.code); } - *added = result; + *added = inserted; return &it->second; } @@ -219,7 +218,7 @@ uint32_t TranslationCache::GetInvocationCounter(GuestAddr pc) const { GuestCodeEntry* TranslationCache::LookupGuestCodeEntryUnsafe(GuestAddr pc) { auto it = guest_entries_.find(pc); - if (it != end(guest_entries_)) { + if (it != std::end(guest_entries_)) { return &it->second; } |