diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-12 00:39:05 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-12 00:39:05 +0000 |
commit | fc7052d4a241ee6fc70afea7c1c9560147f0a49c (patch) | |
tree | 52ea40cc7c5c28d06dfb3ef50f0cb516acacca39 /include/clang/Basic/FileManager.h | |
parent | b7b5d13de34272b31681e7eafa9851e39bde2ef9 (diff) |
Add lightweight shim "clang::StatSysCallCache" that caches 'stat' system calls
for use by FileManager. FileManager now takes a StatSysCallCache* in its
constructor (which defaults to NULL). This will be used for evaluating whether
or not caching 'stat' system calls in PTH is a performance win. This shim adds
no observable performance impact in the case where the 'StatSysCallCache*' is
null.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileManager.h')
-rw-r--r-- | include/clang/Basic/FileManager.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index aff9758f81..7f733fb9ff 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -22,6 +22,7 @@ #include <string> // FIXME: Enhance libsystem to support inode and other fields in stat. #include <sys/types.h> +#include <sys/stat.h> namespace clang { class FileManager; @@ -68,6 +69,14 @@ public: } }; +// FIXME: This is a lightweight shim that is used by FileManager to cache +// 'stat' system calls. We will use it with PTH to identify if caching +// stat calls in PTH files is a performance win. +class StatSysCallCache { +public: + virtual ~StatSysCallCache() {} + virtual int stat(const char *path, struct stat *buf) = 0; +}; /// FileManager - Implements support for file system lookup, file system /// caching, and directory search management. This also handles more advanced @@ -97,8 +106,15 @@ class FileManager { // Statistics. unsigned NumDirLookups, NumFileLookups; unsigned NumDirCacheMisses, NumFileCacheMisses; + + // Caching. + StatSysCallCache *StatCache; + int stat_cached(const char* path, struct stat* buf) { + return StatCache ? StatCache->stat(path, buf) : stat(path, buf); + } + public: - FileManager(); + FileManager(StatSysCallCache *statCache = 0); ~FileManager(); /// getDirectory - Lookup, cache, and verify the specified directory. This |