Skip to content

Commit

Permalink
Skip re-decoding on invalid cached decode info. It's redundant.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 committed Dec 19, 2024
1 parent 74da310 commit 6bcc33b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions clients/drcachesim/tools/common/decode_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,21 @@ template <class DecodeInfo> class decode_cache_t : public decode_cache_base_t {
it_inserted.first;
bool exists = !it_inserted.second;
if (exists &&
// If the prior cached info was invalid, we try decoding it again.
info->second.is_valid() &&
// We can return the cached decode info if:
// - we're using the module mapper, where we don't support JIT
// encodings that may change; or
// We can return the cached DecodeInfo if:
// - we're using the module mapper, where we don't support the
// change-prone JIT encodings; or
// - we're using embedded encodings from the trace, and the
// current instr explicitly says the encoding isn't new.
// current instr explicitly says the encoding in the current
// memref_instr isn't new.
(use_module_mapper_ || !memref_instr.encoding_is_new)) {
// We return the cached DecodeInfo even if it is !is_valid();
// attempting decoding again is not useful because the encoding
// hasn't changed.
cached_decode_info = &info->second;
return "";
} else if (exists) {
// We may end up here if the existing DecodeInfo in the cache:
// - is invalid; or
// - is valid but now we have an instr with encoding_is_new set,
// and we're using the embedded encodings from the trace.
// In both these cases we create a new DecodeInfo.
// We may end up here if we're using the embedded encodings from
// the trace and now we have a new instr at trace_pc.
info->second = DecodeInfo();
}
cached_decode_info = &info->second;
Expand Down Expand Up @@ -334,6 +333,7 @@ template <class DecodeInfo> class decode_cache_t : public decode_cache_base_t {
}
return "decode_from_copy failed";
}
// Also sets is_valid_.
info->second.set_decode_info(dcontext_, memref_instr, instr);
return "";
}
Expand Down

0 comments on commit 6bcc33b

Please sign in to comment.