Skip to content

Commit

Permalink
Cache line size
Browse files Browse the repository at this point in the history
  • Loading branch information
987123879113 committed Jan 13, 2025
1 parent 9d08509 commit 4d710e6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/devices/cpu/drcbearm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,21 @@ void drcbe_arm64::generate(drcuml_block &block, const instruction *instlist, uin
m_hash.block_begin(block, instlist, numinst);
m_map.block_begin(block);

// compute the base by aligning the cache top to a cache line (assumed to be 64 bytes)
uint8_t *dst = (uint8_t *)(uint64_t(m_cache.top() + 63) & ~63);
// compute the base by aligning the cache top to a cache line
auto [err, linesize] = osd_get_cache_line_size();
uintptr_t linemask = 63;
if (err)
{
osd_printf_verbose("Error getting cache line size (%s:%d %s), assuming 64 bytes\n", err.category().name(), err.value(), err.message());
}
else
{
assert(linesize);
linemask = linesize - 1;
for (unsigned shift = 1; linemask & (linemask + 1); ++shift)
linemask |= linemask >> shift;
}
uint8_t *dst = (uint8_t *)(uint64_t(m_cache.top() + linemask) & ~linemask);

CodeHolder ch;
ch.init(Environment::host(), uint64_t(dst));
Expand Down

0 comments on commit 4d710e6

Please sign in to comment.