[Cmake-commits] CMake branch, next, updated. v3.5.1-913-ge985c24

Brad King brad.king at kitware.com
Tue Apr 12 17:28:16 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  e985c24c197f416fdf1a85a3a833e82609357841 (commit)
       via  6c76ede12f950cee51c10d1fb1988adab1477976 (commit)
       via  c54ed7813fa4efe2c6c95b6ba75c02b78b601a26 (commit)
       via  a2ce4e81d554fd176070893ad420a53516d016c7 (commit)
      from  6278587aaa4c450405bbb05c921c2df831540c8d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e985c24c197f416fdf1a85a3a833e82609357841
commit e985c24c197f416fdf1a85a3a833e82609357841
Merge: 6278587 6c76ede
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Apr 12 17:28:13 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Apr 12 17:28:13 2016 -0400

    Merge topic 'refactor-cmListFileBacktrace' into next
    
    6c76ede1 cmState: Avoid accumulating snapshot storage for backtraces
    c54ed781 cmState: Rename CallStack snapshots to IncludeFile
    a2ce4e81 CMake Nightly Date Stamp


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c76ede12f950cee51c10d1fb1988adab1477976
commit 6c76ede12f950cee51c10d1fb1988adab1477976
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Apr 12 17:07:08 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 12 17:24:57 2016 -0400

    cmState: Avoid accumulating snapshot storage for backtraces
    
    Changes during post-3.3/pre-3.4 development refactored storage of most
    configure-time information, including variable bindings and function
    scopes.  All scopes (even short-lived) were kept persistently for
    possible future debugging features, causing huge accumulated memory
    usage.  This was mostly addressed by commit v3.4.1~4^2 (cmState: Avoid
    accumulating snapshot storage for short-lived scopes, 2015-11-24).
    
    Since then we still keep short-lived scopes when they are needed for a
    backtrace.  This is because since commit v3.4.0-rc1~378^2
    (cmListFileBacktrace: Implement in terms of cmState::Snapshot,
    2015-05-29) backtraces have been lightweight objects that simply point
    into the snapshot tree.  While the intention of this approach was to
    avoid duplicating the call stack file path strings, the cost turned out
    to be holding on to the entire call stack worth of scope snapshots,
    which is much worse.
    
    Furthermore, since commit v3.4.0-rc2~1^2 (cmIfCommand: Issue CMP0054
    warning with appropriate context, 2015-10-20) all conditions used in
    `if()` commands hold a backtrace for use in diagnostic messages.  Even
    though the backtrace is short-lived it still causes the scope snapshot
    to be kept.  This means that code like
    
        function(foo)
          if(0)
          endif()
        endfunction()
    
        foreach(i RANGE 1000000)
          foo()
        endforeach()
    
    accumulates storage for the function call scope snapshots.
    
    Fix this by partially reverting commit v3.4.0-rc1~378^2 and saving the
    entire call stack during cmListFileBacktrace construction.  This way
    we can avoid keeping short-lived scope snapshot storage in all cases.

diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index d5d0184..083a0e2 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -400,12 +400,37 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
 
 cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot snapshot,
                                          cmCommandContext const& cc)
-  : Context(cc)
-  , Snapshot(snapshot)
+  : Snapshot(snapshot)
 {
-  if (this->Snapshot.IsValid())
+  if (!this->Snapshot.IsValid())
     {
-    this->Snapshot.Keep();
+    return;
+    }
+
+  // Record the entire call stack now so that the `Snapshot` we
+  // save for later refers to a long-lived scope.  This avoids
+  // having to keep short-lived scopes around just to extract
+  // their backtrace information later.
+
+  cmListFileContext lfc =
+    cmListFileContext::FromCommandContext(
+      cc, this->Snapshot.GetExecutionListFile());
+  this->push_back(lfc);
+
+  cmState::Snapshot parent = this->Snapshot.GetCallStackParent();
+  while (parent.IsValid())
+    {
+    lfc.Name = this->Snapshot.GetEntryPointCommand();
+    lfc.Line = this->Snapshot.GetEntryPointLine();
+    lfc.FilePath = parent.GetExecutionListFile();
+    if (lfc.FilePath.empty())
+      {
+      break;
+      }
+    this->push_back(lfc);
+
+    this->Snapshot = parent;
+    parent = parent.GetCallStackParent();
     }
 }
 
@@ -415,48 +440,30 @@ cmListFileBacktrace::~cmListFileBacktrace()
 
 void cmListFileBacktrace::PrintTitle(std::ostream& out) const
 {
-  if (!this->Snapshot.IsValid())
+  if (this->empty())
     {
     return;
     }
   cmOutputConverter converter(this->Snapshot);
-  cmListFileContext lfc =
-      cmListFileContext::FromCommandContext(
-        this->Context, this->Snapshot.GetExecutionListFile());
+  cmListFileContext lfc = this->front();
   lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
   out << (lfc.Line ? " at " : " in ") << lfc;
 }
 
 void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
 {
-  if (!this->Snapshot.IsValid())
-    {
-    return;
-    }
-  cmState::Snapshot parent = this->Snapshot.GetCallStackParent();
-  if (!parent.IsValid() || parent.GetExecutionListFile().empty())
+  if (this->size() <= 1)
     {
     return;
     }
+  out << "Call Stack (most recent call first):\n";
 
   cmOutputConverter converter(this->Snapshot);
-  std::string commandName = this->Snapshot.GetEntryPointCommand();
-  long commandLine = this->Snapshot.GetEntryPointLine();
-
-  out << "Call Stack (most recent call first):\n";
-  while(parent.IsValid())
+  for (const_iterator i = this->begin() + 1; i != this->end(); ++i)
     {
-    cmListFileContext lfc;
-    lfc.Name = commandName;
-    lfc.Line = commandLine;
-
-    lfc.FilePath = converter.Convert(parent.GetExecutionListFile(),
-                                     cmOutputConverter::HOME);
+    cmListFileContext lfc = *i;
+    lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
     out << "  " << lfc << "\n";
-
-    commandName = parent.GetEntryPointCommand();
-    commandLine = parent.GetEntryPointLine();
-    parent = parent.GetCallStackParent();
     }
 }
 
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 4d3055f..d3cab22 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -87,7 +87,7 @@ struct cmListFileFunction: public cmCommandContext
   std::vector<cmListFileArgument> Arguments;
 };
 
-class cmListFileBacktrace
+class cmListFileBacktrace: private std::vector<cmListFileContext>
 {
   public:
     cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(),
@@ -97,7 +97,6 @@ class cmListFileBacktrace
     void PrintTitle(std::ostream& out) const;
     void PrintCallStack(std::ostream& out) const;
   private:
-    cmCommandContext Context;
     cmState::Snapshot Snapshot;
 };
 
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index be8e418..3867dfc 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -1098,11 +1098,6 @@ void cmState::Directory::SetCurrentBinary(std::string const& dir)
   this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str());
 }
 
-void cmState::Snapshot::Keep()
-{
-  this->Position->Keep = true;
-}
-
 void cmState::Snapshot::SetListFile(const std::string& listfile)
 {
   *this->Position->ExecutionListFile = listfile;
diff --git a/Source/cmState.h b/Source/cmState.h
index ef61406..e472a45 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -63,7 +63,6 @@ public:
     std::vector<std::string> ClosureKeys() const;
     bool RaiseScope(std::string const& var, const char* varDef);
 
-    void Keep();
     void SetListFile(std::string const& listfile);
 
     std::string GetExecutionListFile() const;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c54ed7813fa4efe2c6c95b6ba75c02b78b601a26
commit c54ed7813fa4efe2c6c95b6ba75c02b78b601a26
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Apr 12 16:08:24 2016 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 12 16:08:24 2016 -0400

    cmState: Rename CallStack snapshots to IncludeFile

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7ca005d..7be6b88 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -333,7 +333,7 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
   this->Makefile->PushFunctionBlockerBarrier();
 
   this->Makefile->StateSnapshot =
-      this->Makefile->GetState()->CreateCallStackSnapshot(
+      this->Makefile->GetState()->CreateIncludeFileSnapshot(
         this->Makefile->StateSnapshot,
         this->Makefile->ContextStack.back()->Name,
         this->Makefile->ContextStack.back()->Line,
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index b8e604b..be8e418 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -931,16 +931,16 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
 }
 
 cmState::Snapshot
-cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot,
-                                 const std::string& entryPointCommand,
-                                 long entryPointLine,
-                                 const std::string& fileName)
+cmState::CreateIncludeFileSnapshot(cmState::Snapshot originSnapshot,
+                                   const std::string& entryPointCommand,
+                                   long entryPointLine,
+                                   const std::string& fileName)
 {
   PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
                                              *originSnapshot.Position);
   pos->EntryPointLine = entryPointLine;
   pos->EntryPointCommand = entryPointCommand;
-  pos->SnapshotType = CallStackType;
+  pos->SnapshotType = IncludeFileType;
   pos->Keep = true;
   pos->ExecutionListFile = this->ExecutionListFiles.Push(
         originSnapshot.Position->ExecutionListFile, fileName);
diff --git a/Source/cmState.h b/Source/cmState.h
index 6717481..ef61406 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -42,7 +42,7 @@ public:
     BuildsystemDirectoryType,
     FunctionCallType,
     MacroCallType,
-    CallStackType,
+    IncludeFileType,
     InlineListFileType,
     PolicyScopeType,
     VariableScopeType
@@ -203,10 +203,10 @@ public:
                                    std::string const& entryPointCommand,
                                    long entryPointLine,
                                    std::string const& fileName);
-  Snapshot CreateCallStackSnapshot(Snapshot originSnapshot,
-                                   std::string const& entryPointCommand,
-                                   long entryPointLine,
-                                   std::string const& fileName);
+  Snapshot CreateIncludeFileSnapshot(Snapshot originSnapshot,
+                                     std::string const& entryPointCommand,
+                                     long entryPointLine,
+                                     std::string const& fileName);
   Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot,
                                        std::string const& entryPointCommand,
                                        long entryPointLine);

-----------------------------------------------------------------------

Summary of changes:
 Source/CMakeVersion.cmake  |    2 +-
 Source/cmListFileCache.cxx |   65 ++++++++++++++++++++++++--------------------
 Source/cmListFileCache.h   |    3 +-
 Source/cmMakefile.cxx      |    2 +-
 Source/cmState.cxx         |   15 ++++------
 Source/cmState.h           |   11 ++++----
 6 files changed, 49 insertions(+), 49 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list