Doxygen
Loading...
Searching...
No Matches
symbolresolver.cpp File Reference
#include <unordered_map>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include "symbolresolver.h"
#include "util.h"
#include "doxygen.h"
#include "namespacedef.h"
#include "config.h"
#include "defargs.h"
#include "trace.h"
#include "cache.h"
#include "filedef.h"
Include dependency graph for symbolresolver.cpp:

Go to the source code of this file.

Classes

struct  CacheStatistics
struct  CacheStatsWrapper
class  AccessStack
 Helper class representing the stack of items considered while resolving the scope. More...
struct  AccessStack::AccessElem
 Element in the stack. More...
struct  SymbolResolver::Private

Macros

#define AUTO_TRACE(...)
#define AUTO_TRACE_ADD(...)
#define AUTO_TRACE_EXIT(...)

Typedefs

using LookupCache = Cache<std::string,LookupInfo>
using VisitedKeys = StringVector
using VisitedNamespaceKeys = StringVector
using VisitedNamespaces = std::unordered_map<std::string,const Definition *>

Functions

static void mergeStatistics (CacheStatistics &stats, LookupCache &cache)
static size_t getCacheSize ()
static LookupCachegetTypeLookupCache ()
static LookupCachegetSymbolLookupCache ()
static bool isCodeSymbol (Definition::DefType defType)
static int computeIdealCacheParam (size_t v)

Variables

static std::recursive_mutex g_cacheTypedefMutex
static CacheStatistics g_typeCacheStatistics
static CacheStatistics g_symbolCacheStatistics
THREAD_LOCAL std::unordered_map< std::string, std::pair< DString, const MemberDef * > > g_substMap

Macro Definition Documentation

◆ AUTO_TRACE

#define AUTO_TRACE ( ...)
Value:
(void)0

Definition at line 36 of file symbolresolver.cpp.

◆ AUTO_TRACE_ADD

#define AUTO_TRACE_ADD ( ...)
Value:
(void)0

Definition at line 37 of file symbolresolver.cpp.

◆ AUTO_TRACE_EXIT

#define AUTO_TRACE_EXIT ( ...)
Value:
(void)0

Definition at line 38 of file symbolresolver.cpp.

Typedef Documentation

◆ LookupCache

using LookupCache = Cache<std::string,LookupInfo>

Definition at line 55 of file symbolresolver.cpp.

◆ VisitedKeys

Definition at line 165 of file symbolresolver.cpp.

◆ VisitedNamespaceKeys

Definition at line 166 of file symbolresolver.cpp.

◆ VisitedNamespaces

using VisitedNamespaces = std::unordered_map<std::string,const Definition *>

Definition at line 167 of file symbolresolver.cpp.

Function Documentation

◆ computeIdealCacheParam()

int computeIdealCacheParam ( size_t v)
static

Definition at line 1855 of file symbolresolver.cpp.

1856{
1857 //printf("computeIdealCacheParam(v=%u)\n",v);
1858
1859 int r=0;
1860 while (v!=0)
1861 {
1862 v >>= 1;
1863 r++;
1864 }
1865 // r = log2(v)
1866
1867 // convert to a valid cache size value
1868 return std::max(0,std::min(r-16,9));
1869}

Referenced by SymbolResolver::showCacheUsage().

◆ getCacheSize()

size_t getCacheSize ( )
static

Definition at line 81 of file symbolresolver.cpp.

82{
83 int cacheSize = Config_getInt(LOOKUP_CACHE_SIZE);
84 if (cacheSize<0) cacheSize=0;
85 if (cacheSize>9) cacheSize=9;
86 return 65536u << cacheSize;
87}
#define Config_getInt(name)
Definition config.h:34

References Config_getInt.

Referenced by getSymbolLookupCache(), and getTypeLookupCache().

◆ getSymbolLookupCache()

LookupCache & getSymbolLookupCache ( )
static

Definition at line 95 of file symbolresolver.cpp.

96{
98 return wrapper.cache();
99}
#define THREAD_LOCAL
Definition doxygen.h:29
static size_t getCacheSize()
static CacheStatistics g_symbolCacheStatistics

References g_symbolCacheStatistics, getCacheSize(), and THREAD_LOCAL.

Referenced by SymbolResolver::resolveSymbol(), and SymbolResolver::showCacheUsage().

◆ getTypeLookupCache()

LookupCache & getTypeLookupCache ( )
static

◆ isCodeSymbol()

◆ mergeStatistics()

void mergeStatistics ( CacheStatistics & stats,
LookupCache & cache )
static

Definition at line 57 of file symbolresolver.cpp.

58{
59 std::lock_guard lock(stats.mutex);
60 stats.size = std::max(stats.size, cache.size());
61 stats.capacity = std::max(stats.capacity, cache.capacity());
62 stats.hits = std::max(stats.hits, cache.hits());
63 stats.misses = std::max(stats.misses, cache.misses());
64}
size_t capacity() const
Returns the maximum number of values that can be stored in the cache.
Definition cache.h:132
size_t size() const
Returns the number of values stored in the cache.
Definition cache.h:126
uint64_t misses() const
Returns how many of the find() calls did not found a value in the cache.
Definition cache.h:144
uint64_t hits() const
Returns how many of the find() calls did find a value in the cache.
Definition cache.h:138

References Cache< K, V >::capacity(), CacheStatistics::capacity, Cache< K, V >::hits(), CacheStatistics::hits, Cache< K, V >::misses(), CacheStatistics::misses, CacheStatistics::mutex, Cache< K, V >::size(), and CacheStatistics::size.

Referenced by SymbolResolver::showCacheUsage(), and CacheStatsWrapper::~CacheStatsWrapper().

Variable Documentation

◆ g_cacheTypedefMutex

std::recursive_mutex g_cacheTypedefMutex
static

Definition at line 41 of file symbolresolver.cpp.

Referenced by SymbolResolver::Private::newResolveTypedef().

◆ g_substMap

THREAD_LOCAL std::unordered_map<std::string, std::pair<DString,const MemberDef *> > g_substMap

Definition at line 101 of file symbolresolver.cpp.

Referenced by SymbolResolver::Private::substTypedef().

◆ g_symbolCacheStatistics

CacheStatistics g_symbolCacheStatistics
static

Definition at line 53 of file symbolresolver.cpp.

Referenced by getSymbolLookupCache(), and SymbolResolver::showCacheUsage().

◆ g_typeCacheStatistics

CacheStatistics g_typeCacheStatistics
static

Definition at line 52 of file symbolresolver.cpp.

Referenced by getTypeLookupCache(), and SymbolResolver::showCacheUsage().