We now keep track of the deserialized declarations in the transaction, because ROOT needs the callbacks to be fired on deserialized bunch of declarations.

Track down (almost) all places that might trigger deserialization of declarations
and wrap it with cling::PushTransactionRAII. I could solve it much more elegantly
by putting that RAII in the callback of the ExternalASTSource, but I wanted to be
verbose and denote all the places that trigger deserializations in ROOT. This
will help us in future optimize this code, because we want to deserialize as
rare as possible.

This should make roottest a bit happier.
This commit is contained in:
Vassil Vassilev 2013-08-04 18:39:41 +02:00 committed by sftnight
parent 3643b28116
commit b202f00c12
4 changed files with 25 additions and 1 deletions

View File

@ -304,6 +304,8 @@ namespace cling {
T->setModule(getCodeGenerator()->GetModule());
// Could trigger derserialization of decls.
Transaction* deserT = beginTransaction(CompilationOptions());
for (size_t Idx = 0; Idx < T->size() /*can change in the loop!*/; ++Idx) {
// Copy DCI; it might get relocated below.
Transaction::DelayCallInfo I = (*T)[Idx];
@ -340,6 +342,8 @@ namespace cling {
}
getCodeGenerator()->HandleTranslationUnit(getCI()->getASTContext());
if (endTransaction(deserT))
commitTransaction(deserT);
}
void IncrementalParser::transformTransactionAST(Transaction* T) const {

View File

@ -821,6 +821,8 @@ namespace cling {
assert(!FoundDyLib.isEmpty() && "The shared lib exists but can't find it!");
std::string errMsg;
// TODO: !permanent case
//FIXME: This is meant to be an workaround for very hard to trace bug.
PushTransactionRAII RAII(this);
DynamicLibrary DyLib
= DynamicLibrary::getPermanentLibrary(FoundDyLib.str().c_str(), &errMsg);
if (!DyLib.isValid()) {
@ -839,6 +841,8 @@ namespace cling {
Interpreter::LoadLibResult
Interpreter::loadLibrary(const std::string& filename, bool permanent,
bool* tryCode) {
//FIXME: This is meant to be an workaround for very hard to trace bug.
PushTransactionRAII RAII(this);
// If it's not an absolute path, prepend "lib"
SmallVector<char, 128> Absolute(filename.c_str(),
filename.c_str() + filename.length());

View File

@ -87,6 +87,8 @@ namespace cling {
//
// Try parsing the type name.
//
// Could trigger deserialization of decls.
Interpreter::PushTransactionRAII RAII(m_Interpreter);
TypeResult Res(P.ParseTypeName());
if (Res.isUsable()) {
// Accept it only if the whole name was parsed.
@ -520,6 +522,9 @@ namespace cling {
SourceLocation FuncNameLoc = FuncNameInfo.getLoc();
LookupResult Result(S, FuncName, FuncNameLoc, Sema::LookupMemberName,
Sema::NotForRedeclaration);
// This might trigger deserialization.
Interpreter::PushTransactionRAII pushedT(m_Interpreter);
if (!S.LookupQualifiedName(Result, foundDC)) {
// Lookup failed.
// Destroy the scope we created first, and
@ -816,6 +821,8 @@ namespace cling {
SourceLocation FuncNameLoc = FuncNameInfo.getLoc();
LookupResult Result(S, FuncName, FuncNameLoc, Sema::LookupMemberName,
Sema::NotForRedeclaration);
// This might trigger deserialization.
Interpreter::PushTransactionRAII pushedT(m_Interpreter);
if (!S.LookupQualifiedName(Result, foundDC)) {
// Lookup failed.
// Destroy the scope we created first, and
@ -1125,6 +1132,9 @@ namespace cling {
SourceLocation FuncNameLoc = FuncNameInfo.getLoc();
LookupResult Result(S, FuncName, FuncNameLoc, Sema::LookupMemberName,
Sema::NotForRedeclaration);
// Could trigger deserialization of decls.
cling::Interpreter::PushTransactionRAII RAII(m_Interpreter);
if (!S.LookupQualifiedName(Result, foundDC)) {
// Lookup failed.
// Destroy the scope we created first, and

View File

@ -1,6 +1,6 @@
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
// version: $Id$
// version: $Id: 1b0fb422149b1f3c27b917010553d13030150d58 $
// author: Timur Pocheptsov <Timur.Pocheptsov@cern.ch>
//------------------------------------------------------------------------------
@ -1438,6 +1438,8 @@ void DisplayGlobals(llvm::raw_ostream& stream, const Interpreter* interpreter)
assert(interpreter != 0 && "DisplayGlobals, 'interpreter' parameter is null");
GlobalsPrinter printer(stream, interpreter);
// Could trigger deserialization of decls.
Interpreter::PushTransactionRAII RAII(const_cast<Interpreter*>(interpreter));
printer.DisplayGlobals();
}
@ -1448,6 +1450,8 @@ void DisplayGlobal(llvm::raw_ostream& stream, const Interpreter* interpreter,
assert(interpreter != 0 && "DisplayGlobal, 'interpreter' parameter is null");
GlobalsPrinter printer(stream, interpreter);
// Could trigger deserialization of decls.
Interpreter::PushTransactionRAII RAII(const_cast<Interpreter*>(interpreter));
printer.DisplayGlobal(name);
}
@ -1457,6 +1461,8 @@ void DisplayTypedefs(llvm::raw_ostream &stream, const Interpreter *interpreter)
assert(interpreter != 0 && "DisplayTypedefs, parameter 'interpreter' is null");
TypedefPrinter printer(stream, interpreter);
// Could trigger deserialization of decls.
Interpreter::PushTransactionRAII RAII(const_cast<Interpreter*>(interpreter));
printer.DisplayTypedefs();
}