summaryrefslogtreecommitdiff
path: root/view
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-11-02 16:20:23 -0400
committerkat <kat@vector35.com>2024-11-05 09:04:46 -0500
commitf7a72e5423ee0eda70762a3f87a45bb92fc84c97 (patch)
tree30dc90245d389f9cf925581d1b3c4ae681114337 /view
parent3f52136b43d52d6714df2243da9733b26718110d (diff)
[SharedCache] Optimizations for symbol resolution workflow
Diffstat (limited to 'view')
-rw-r--r--view/sharedcache/workflow/SharedCacheWorkflow.cpp56
1 files changed, 36 insertions, 20 deletions
diff --git a/view/sharedcache/workflow/SharedCacheWorkflow.cpp b/view/sharedcache/workflow/SharedCacheWorkflow.cpp
index 4b4e464e..88353bf7 100644
--- a/view/sharedcache/workflow/SharedCacheWorkflow.cpp
+++ b/view/sharedcache/workflow/SharedCacheWorkflow.cpp
@@ -120,10 +120,6 @@ void SharedCacheWorkflow::FixupStubs(Ref<AnalysisContext> ctx)
const auto bv = func->GetView();
auto workflowState = GetGlobalWorkflowState(bv);
- Ref<SharedCacheAPI::SharedCache> cache = new SharedCacheAPI::SharedCache(bv);
-
- if (!cache)
- return;
auto funcStart = func->GetStart();
auto sectionExists = !bv->GetSectionsAt(funcStart).empty();
@@ -202,6 +198,14 @@ void SharedCacheWorkflow::FixupStubs(Ref<AnalysisContext> ctx)
auto def = mssa->GetSSAVarDefinition(dest.GetSourceSSAVariable());
auto defInstr = mssa->GetInstruction(def);
auto targetOffset = defInstr.GetSourceExpr().GetSourceExpr().GetConstant();
+
+ if (bv->IsValidOffset(targetOffset))
+ return;
+
+ Ref<SharedCacheAPI::SharedCache> cache = new SharedCacheAPI::SharedCache(bv);
+
+ if (!cache)
+ return;
if (!cache->GetImageNameForAddress(targetOffset).empty())
{
cache->LoadImageContainingAddress(targetOffset);
@@ -236,6 +240,14 @@ void SharedCacheWorkflow::FixupStubs(Ref<AnalysisContext> ctx)
std::unique_lock<std::mutex> lock(workflowState->imageLoadMutex);
auto dest = instr.GetDestExpr<MLIL_JUMP>();
auto targetOffset = dest.GetConstant();
+ if (bv->IsValidOffset(targetOffset))
+ return;
+
+ Ref<SharedCacheAPI::SharedCache> cache = new SharedCacheAPI::SharedCache(bv);
+
+ if (!cache)
+ return;
+
if (!cache->GetImageNameForAddress(targetOffset).empty())
{
cache->LoadImageContainingAddress(targetOffset);
@@ -338,24 +350,28 @@ void SharedCacheWorkflow::FixupStubs(Ref<AnalysisContext> ctx)
auto def = mssa->GetSSAVarDefinition(dest.GetSourceSSAVariable());
auto defInstr = mssa->GetInstruction(def);
auto targetOffset = defInstr.GetSourceExpr().GetSourceExpr().GetConstant();
- auto sharedCache = SharedCacheAPI::SharedCache(bv);
- if (!bv->IsValidOffset(targetOffset))
+
+ if (bv->IsValidOffset(targetOffset))
+ return;
+
+ Ref<SharedCacheAPI::SharedCache> cache = new SharedCacheAPI::SharedCache(bv);
+
+ if (!cache)
+ return;
+
+ if (!cache->GetImageNameForAddress(targetOffset).empty())
{
- if (!sharedCache.GetImageNameForAddress(targetOffset).empty())
- {
- sharedCache.LoadImageContainingAddress(targetOffset);
- }
- else
- {
- sharedCache.LoadSectionAtAddress(targetOffset);
- }
- for (const auto& sectFunc : bv->GetAnalysisFunctionList())
+ cache->LoadImageContainingAddress(targetOffset);
+ }
+ else
+ {
+ cache->LoadSectionAtAddress(targetOffset);
+ }
+ for (const auto &sectFunc : bv->GetAnalysisFunctionList())
+ {
+ if (section->GetStart() <= sectFunc->GetStart() && sectFunc->GetStart() < section->GetEnd())
{
- if (section->GetStart() <= sectFunc->GetStart()
- && sectFunc->GetStart() < section->GetEnd())
- {
- func->Reanalyze();
- }
+ func->Reanalyze();
}
}
}