Revision: 10465
Author:   [email protected]
Date:     Fri Jan 20 08:17:08 2012
Log: Parallelize cpplint in presubmit and fix usage of DISALLOW_* macros.

BUG=v8:1653

Review URL: https://chromiumcodereview.appspot.com/9192010
http://code.google.com/p/v8/source/detail?r=10465

Modified:
 /branches/bleeding_edge/src/full-codegen.h
 /branches/bleeding_edge/src/heap.h
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/platform-cygwin.cc
 /branches/bleeding_edge/src/platform-freebsd.cc
 /branches/bleeding_edge/src/platform-linux.cc
 /branches/bleeding_edge/src/platform-macos.cc
 /branches/bleeding_edge/src/platform-openbsd.cc
 /branches/bleeding_edge/src/platform-solaris.cc
 /branches/bleeding_edge/src/platform-win32.cc
 /branches/bleeding_edge/src/serialize.h
 /branches/bleeding_edge/tools/presubmit.py

=======================================
--- /branches/bleeding_edge/src/full-codegen.h  Mon Jan 16 04:38:59 2012
+++ /branches/bleeding_edge/src/full-codegen.h  Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -142,11 +142,13 @@
       return previous_;
     }

- protected:
+   protected:
     MacroAssembler* masm() { return codegen_->masm(); }

     FullCodeGenerator* codegen_;
     NestedStatement* previous_;
+
+   private:
     DISALLOW_COPY_AND_ASSIGN(NestedStatement);
   };

=======================================
--- /branches/bleeding_edge/src/heap.h  Fri Jan 20 05:43:21 2012
+++ /branches/bleeding_edge/src/heap.h  Fri Jan 20 08:17:08 2012
@@ -2615,6 +2615,7 @@

   AssertNoAllocation no_alloc;  // i.e. no gc allowed.

+ private:
   DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
 };
 #endif  // DEBUG || LIVE_OBJECT_LIST
=======================================
--- /branches/bleeding_edge/src/isolate.h       Wed Jan 18 08:16:11 2012
+++ /branches/bleeding_edge/src/isolate.h       Fri Jan 20 08:17:08 2012
@@ -1071,6 +1071,7 @@
     Isolate* previous_isolate;
     EntryStackItem* previous_item;

+   private:
     DISALLOW_COPY_AND_ASSIGN(EntryStackItem);
   };

=======================================
--- /branches/bleeding_edge/src/objects.h       Wed Jan 18 06:05:11 2012
+++ /branches/bleeding_edge/src/objects.h       Fri Jan 20 08:17:08 2012
@@ -7806,7 +7806,8 @@
   static const int kTagOffset          = HeapObject::kHeaderSize;
   static const int kPropertyListOffset = kTagOffset + kPointerSize;
static const int kHeaderSize = kPropertyListOffset + kPointerSize;
- protected:
+
+ private:
   DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateInfo);
 };

=======================================
--- /branches/bleeding_edge/src/platform-cygwin.cc      Mon Jan 16 04:38:59 2012
+++ /branches/bleeding_edge/src/platform-cygwin.cc      Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2006-2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -722,6 +722,7 @@
   static Mutex* mutex_;
   static SamplerThread* instance_;

+ private:
   DISALLOW_COPY_AND_ASSIGN(SamplerThread);
 };

=======================================
--- /branches/bleeding_edge/src/platform-freebsd.cc     Tue Jan 17 05:13:55 2012
+++ /branches/bleeding_edge/src/platform-freebsd.cc     Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -840,6 +840,7 @@
   static bool signal_handler_installed_;
   static struct sigaction old_signal_handler_;

+ private:
   DISALLOW_COPY_AND_ASSIGN(SignalSender);
 };

=======================================
--- /branches/bleeding_edge/src/platform-linux.cc       Tue Jan 17 05:13:55 2012
+++ /branches/bleeding_edge/src/platform-linux.cc       Fri Jan 20 08:17:08 2012
@@ -1178,6 +1178,7 @@
   static bool signal_handler_installed_;
   static struct sigaction old_signal_handler_;

+ private:
   DISALLOW_COPY_AND_ASSIGN(SignalSender);
 };

=======================================
--- /branches/bleeding_edge/src/platform-macos.cc       Tue Jan 17 05:13:55 2012
+++ /branches/bleeding_edge/src/platform-macos.cc       Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -854,6 +854,7 @@
   static Mutex* mutex_;
   static SamplerThread* instance_;

+ private:
   DISALLOW_COPY_AND_ASSIGN(SamplerThread);
 };

=======================================
--- /branches/bleeding_edge/src/platform-openbsd.cc     Tue Jan 17 05:13:55 2012
+++ /branches/bleeding_edge/src/platform-openbsd.cc     Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -923,6 +923,7 @@
   static bool signal_handler_installed_;
   static struct sigaction old_signal_handler_;

+ private:
   DISALLOW_COPY_AND_ASSIGN(SignalSender);
 };

=======================================
--- /branches/bleeding_edge/src/platform-solaris.cc     Fri Jan 20 07:43:38 2012
+++ /branches/bleeding_edge/src/platform-solaris.cc     Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -843,6 +843,7 @@
   static bool signal_handler_installed_;
   static struct sigaction old_signal_handler_;

+ private:
   DISALLOW_COPY_AND_ASSIGN(SignalSender);
 };

=======================================
--- /branches/bleeding_edge/src/platform-win32.cc       Tue Jan 17 05:13:55 2012
+++ /branches/bleeding_edge/src/platform-win32.cc       Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -2006,6 +2006,7 @@
   static Mutex* mutex_;
   static SamplerThread* instance_;

+ private:
   DISALLOW_COPY_AND_ASSIGN(SamplerThread);
 };

=======================================
--- /branches/bleeding_edge/src/serialize.h     Mon Jan 16 04:38:59 2012
+++ /branches/bleeding_edge/src/serialize.h     Fri Jan 20 08:17:08 2012
@@ -1,4 +1,4 @@
-// Copyright 2006-2009 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -581,6 +581,7 @@
   friend class ObjectSerializer;
   friend class Deserializer;

+ private:
   DISALLOW_COPY_AND_ASSIGN(Serializer);
 };

=======================================
--- /branches/bleeding_edge/tools/presubmit.py  Thu Oct  6 04:08:41 2011
+++ /branches/bleeding_edge/tools/presubmit.py  Fri Jan 20 08:17:08 2012
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2011 the V8 project authors. All rights reserved.
+# Copyright 2012 the V8 project authors. All rights reserved.
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
 # met:
@@ -42,6 +42,7 @@
 import re
 import sys
 import subprocess
+import multiprocessing
 from subprocess import PIPE

 # Disabled LINT rules and reason.
@@ -101,6 +102,33 @@
 """.split()


+LINT_OUTPUT_PATTERN = re.compile(r'^.+[:(]\d+[:)]|^Done processing')
+
+
+def CppLintWorker(command):
+  try:
+    process = subprocess.Popen(command, stderr=subprocess.PIPE)
+    process.wait()
+    out_lines = ""
+    error_count = -1
+    while True:
+      out_line = process.stderr.readline()
+      if out_line == '' and process.poll() != None:
+        break
+      m = LINT_OUTPUT_PATTERN.match(out_line)
+      if m:
+        out_lines += out_line
+        error_count += 1
+    sys.stderr.write(out_lines)
+    return error_count
+  except KeyboardInterrupt:
+    process.kill()
+  except:
+ print('Error running cpplint.py. Please make sure you have depot_tools' +
+          ' in your $PATH. Lint check skipped.')
+    process.kill()
+
+
 class FileContentsCache(object):

   def __init__(self, sums_file_name):
@@ -206,29 +234,28 @@
       return True

     filt = '-,' + ",".join(['+' + n for n in ENABLED_LINT_RULES])
-    command = ['cpplint.py', '--filter', filt] + join(files)
+    command = ['cpplint.py', '--filter', filt]
     local_cpplint = join(path, "tools", "cpplint.py")
     if exists(local_cpplint):
-      command = ['python', local_cpplint, '--filter', filt] + join(files)
-
+      command = ['python', local_cpplint, '--filter', filt]
+
+    commands = join([command + [file] for file in files])
+    count = multiprocessing.cpu_count()
+    pool = multiprocessing.Pool(count)
     try:
-      process = subprocess.Popen(command, stderr=subprocess.PIPE)
-    except:
- print('Error running cpplint.py. Please make sure you have depot_tools' +
-            ' in your $PATH. Lint check skipped.')
-      return True
-    LINT_ERROR_PATTERN = re.compile(r'^(.+)[:(]\d+[:)]')
-    while True:
-      out_line = process.stderr.readline()
-      if out_line == '' and process.poll() != None:
-        break
-      sys.stderr.write(out_line)
-      m = LINT_ERROR_PATTERN.match(out_line)
-      if m:
-        good_files_cache.RemoveFile(m.group(1))
-
+      results = pool.map_async(CppLintWorker, commands).get(999999)
+    except KeyboardInterrupt:
+      print "\nCaught KeyboardInterrupt, terminating workers."
+      sys.exit(1)
+
+    for i in range(len(files)):
+      if results[i] > 0:
+        good_files_cache.RemoveFile(files[i])
+
+    total_errors = sum(results)
+    print "Total errors found: %d" % total_errors
     good_files_cache.Save()
-    return process.returncode == 0
+    return total_errors == 0


 COPYRIGHT_HEADER_PATTERN = re.compile(

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to