Clone now fixes depth-ord cache, move out of multivariate.

This commit is contained in:
Can Bölük 2020-08-23 03:02:13 +02:00
parent 4c00a06de8
commit 3bff85e673
2 changed files with 29 additions and 17 deletions

View file

@ -291,16 +291,6 @@ namespace vtil
// Gets a list of depth ordered block lists that can be analysed in parallel without any dependencies on previous level.
//
struct depth_ordered_list_cache
{
struct entry
{
epoch_t epoch = invalid_epoch;
std::vector<routine::depth_entry> list;
};
entry directions[ 2 ];
};
std::vector<routine::depth_entry> routine::get_depth_ordered_list( bool fwd ) const
{
// Acquire the routine mutex.
@ -309,7 +299,7 @@ namespace vtil
// Return if already cached.
//
auto& cache = context.get<depth_ordered_list_cache>().directions[ fwd ? 1 : 0 ];
auto& cache = depth_ordered_list_cache[ fwd ? 1 : 0 ];
if ( std::exchange( cache.epoch, cfg_epoch ) == cfg_epoch )
return cache.list;
@ -521,6 +511,19 @@ namespace vtil
map = map_l1;
}
// Fix depth ordered list cache.
//
for ( auto& list : copy->depth_ordered_list_cache )
{
if ( list.epoch == copy->cfg_epoch )
{
for ( auto& entry : list.list )
{
entry.block = copy->get_block( entry.block->entry_vip );
}
}
}
// Return the copy.
//
return copy;

View file

@ -105,6 +105,21 @@ namespace vtil
// Multivariate runtime context.
//
multivariate<routine> context = {};
// Cache of depth ordered lists.
//
struct depth_entry
{
size_t level_dependency;
size_t level_depth;
const basic_block* block;
};
struct depth_ordered_list
{
epoch_t epoch = invalid_epoch;
std::vector<routine::depth_entry> list;
};
mutable depth_ordered_list depth_ordered_list_cache[ 2 ];
// Epoch provided to allow external entities determine if the routine
// is modified or not since their last read from it in an easy and fast way.
@ -221,12 +236,6 @@ namespace vtil
// Gets a list of depth ordered block lists that can be analysed in parallel without any dependencies on previous level.
//
struct depth_entry
{
size_t level_dependency;
size_t level_depth;
const basic_block* block;
};
std::vector<depth_entry> get_depth_ordered_list( bool fwd ) const;
// Provide basic statistics about the complexity of the routine.