mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-21 06:14:08 -06:00
ide: C++ parser MT optimisations
git-svn-id: svn://ultimatepp.org/upp/trunk@14647 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
193c4435e7
commit
9a987167e8
2 changed files with 36 additions and 46 deletions
|
|
@ -221,6 +221,7 @@ void Parse(CppBase& base, const String& src, int file, int filetype, const Strin
|
|||
const Index<String>& namespace_using);
|
||||
|
||||
|
||||
// PreprocessParse CAN be run in parallel
|
||||
void PreprocessParse(CppBase& base, Stream& in, int file, const String& path,
|
||||
Event<int, const String&> error);
|
||||
String PreprocessCpp(const String& src, const String& path);
|
||||
|
|
@ -241,6 +242,8 @@ String ParseTemplatedType(const String& type, Vector<String>& tparam);
|
|||
bool HasCPPFileKeyword(const String& path, const String& id);
|
||||
|
||||
String GetPPMD5(const String& fn);
|
||||
|
||||
// GetDependeciesMD5 CAN be run in parallel
|
||||
String GetDependeciesMD5(const String& path, Index<String>& visited);
|
||||
|
||||
Index<String> GetExpressionType(const CppBase& codebase, const ParserContext& parser, const Vector<String>& xp);
|
||||
|
|
|
|||
|
|
@ -242,8 +242,6 @@ void BaseInfoSync(Progress& pi)
|
|||
pi.SetText("Gathering files");
|
||||
pi.SetTotal(wspc.GetCount());
|
||||
|
||||
{
|
||||
RTIMESTOP("GatherSources");
|
||||
for(int pass = 0; pass < 2; pass++)
|
||||
for(int i = 0; i < wspc.GetCount(); i++) {
|
||||
pi.Step();
|
||||
|
|
@ -256,7 +254,6 @@ void BaseInfoSync(Progress& pi)
|
|||
GatherSources(path, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SweepPPFiles(GetAllSources());
|
||||
}
|
||||
|
|
@ -275,33 +272,16 @@ String GetSourceFilePath(int file)
|
|||
return source_file.GetKey(file);
|
||||
}
|
||||
|
||||
Index<String> sTimePath;
|
||||
|
||||
Time GetDependsTime(const Vector<int>& file)
|
||||
{
|
||||
LTIMING("CreateTimePrint");
|
||||
Time tm = Time::Low();
|
||||
INTERLOCKED {
|
||||
static Index<String> path;
|
||||
for(int i = 0; i < file.GetCount(); i++)
|
||||
if(file[i] < sTimePath.GetCount())
|
||||
tm = max(tm, GetFileTimeCached(sTimePath[file[i]]));
|
||||
}
|
||||
return tm;
|
||||
}
|
||||
|
||||
bool CheckFile0(SourceFileInfo& f, const String& path)
|
||||
{
|
||||
static Index<String> sTimePath;
|
||||
static Mutex sTimePathMutex;
|
||||
static Index<String> sTimePath; // map of f.depends indices to real filenames
|
||||
auto GetDependsTime = [&](const Vector<int>& file) {
|
||||
LTIMING("CreateTimePrint");
|
||||
Time tm = Time::Low();
|
||||
INTERLOCKED {
|
||||
static Index<String> path;
|
||||
for(int i = 0; i < file.GetCount(); i++)
|
||||
if(file[i] < sTimePath.GetCount())
|
||||
tm = max(tm, GetFileTimeCached(sTimePath[file[i]]));
|
||||
}
|
||||
for(int i = 0; i < file.GetCount(); i++)
|
||||
if(file[i] < sTimePath.GetCount())
|
||||
tm = max(tm, GetFileTimeCached(sTimePath[file[i]]));
|
||||
return tm;
|
||||
};
|
||||
|
||||
|
|
@ -310,8 +290,11 @@ bool CheckFile0(SourceFileInfo& f, const String& path)
|
|||
f.time = ftm;
|
||||
if(findarg(ToLower(GetFileExt(path)), ".lay", ".iml", ".sch") >= 0)
|
||||
return tmok;
|
||||
if(!IsNull(f.depends_time) && tmok && f.depends_time == GetDependsTime(f.depends) && f.dependencies_md5sum.GetCount())
|
||||
return true;
|
||||
{
|
||||
Mutex::Lock __(sTimePathMutex);
|
||||
if(!IsNull(f.depends_time) && tmok && f.depends_time == GetDependsTime(f.depends) && f.dependencies_md5sum.GetCount())
|
||||
return true;
|
||||
}
|
||||
Index<String> visited;
|
||||
String md5 = GetDependeciesMD5(path, visited);
|
||||
bool r = f.dependencies_md5sum == md5 && tmok;
|
||||
|
|
@ -320,6 +303,7 @@ bool CheckFile0(SourceFileInfo& f, const String& path)
|
|||
#endif
|
||||
f.depends.Clear();
|
||||
f.dependencies_md5sum = md5;
|
||||
Mutex::Lock __(sTimePathMutex);
|
||||
for(int i = 0; i < visited.GetCount(); i++)
|
||||
f.depends.Add(sTimePath.FindAdd(visited[i]));
|
||||
f.depends_time = GetDependsTime(f.depends);
|
||||
|
|
@ -341,34 +325,38 @@ void UpdateCodeBase2(Progress& pi)
|
|||
Mutex::Lock __(CppBaseMutex);
|
||||
Index<int> parse_file;
|
||||
{
|
||||
CodeBaseLock __; //TODO: MT?
|
||||
pi.SetText("Checking source files");
|
||||
VectorMap<int, bool> filecheck;
|
||||
{
|
||||
CodeBaseLock __;
|
||||
for(const String& path : GetAllSources())
|
||||
filecheck.GetAdd(GetSourceFileIndex(path));
|
||||
}
|
||||
|
||||
pi.SetPos(0);
|
||||
Index<int> keep_file;
|
||||
CLOG("Gathered files: " << GetAllSourceMasters());
|
||||
const Index<String>& src = GetAllSources();
|
||||
pi.SetTotal(src.GetCount());
|
||||
for(int i = 0; i < src.GetCount(); i++) {
|
||||
pi.Step();
|
||||
String path = src[i];
|
||||
pi.SetTotal(filecheck.GetCount());
|
||||
CoFor(filecheck.GetCount(), [&](int i) {
|
||||
int q = filecheck.GetKey(i);
|
||||
filecheck[i] = CheckFile0(source_file[q], source_file.GetKey(q));
|
||||
});
|
||||
|
||||
CodeBaseLock __;
|
||||
|
||||
Index<int> keep_file;
|
||||
|
||||
for(String path : GetAllSources()) {
|
||||
int q = GetSourceFileIndex(path);
|
||||
SourceFileInfo& f = source_file[q];
|
||||
LLOG("== CHECK == " << q << ": " << path);
|
||||
if(CheckFile0(f, path))
|
||||
if(filecheck.Get(q, false))
|
||||
keep_file.Add(q);
|
||||
else {
|
||||
LLOG("PARSE: " << path);
|
||||
else
|
||||
parse_file.Add(q);
|
||||
}
|
||||
}
|
||||
|
||||
CodeBase().Sweep(keep_file);
|
||||
|
||||
for(int i = 0; i < source_file.GetCount(); i++) {
|
||||
if(keep_file.Find(i) < 0 && parse_file.Find(i) < 0 && !source_file.IsUnlinked(i)) {
|
||||
for(int i = 0; i < source_file.GetCount(); i++)
|
||||
if(keep_file.Find(i) < 0 && parse_file.Find(i) < 0 && !source_file.IsUnlinked(i))
|
||||
source_file.Unlink(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAS_CLOG
|
||||
|
|
@ -381,7 +369,6 @@ void UpdateCodeBase2(Progress& pi)
|
|||
pi.SetPos(0);
|
||||
pi.AlignText(ALIGN_LEFT);
|
||||
LLOG("=========================");
|
||||
RTIMESTOP("Parsing files");
|
||||
CoFor(parse_file.GetCount(), [&](int i) {
|
||||
String path = source_file.GetKey(parse_file[i]);
|
||||
pi.SetText(GetFileName(GetFileFolder(path)) + "/" + GetFileName(path));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue