Reviewers: Sven Panne,

Description:
thread isolate for logging calls

[email protected]
BUG=

Please review this at https://codereview.chromium.org/23710025/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+20, -32 lines):
  M src/isolate.cc
  M src/log.cc
  M src/platform-cygwin.cc
  M src/platform-freebsd.cc
  M src/platform-linux.cc
  M src/platform-macos.cc
  M src/platform-openbsd.cc
  M src/platform-solaris.cc
  M src/platform-win32.cc
  M src/platform.h
  M src/string-stream.h
  M src/string-stream.cc


Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 8e581359dca1393b38efa29ab3f13d3ffce9399c..6fa496a9026dd810892309ff63d2483394535b18 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -866,7 +866,7 @@ void Isolate::PrintStack(FILE* out) {
     PrintStack(&accumulator);
     accumulator.OutputToFile(out);
     InitializeLoggingAndCounters();
-    accumulator.Log();
+    accumulator.Log(this);
     incomplete_message_ = NULL;
     stack_trace_nesting_level_ = 0;
     if (preallocated_message_space_ == NULL) {
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 7d1861e0de3c88af04df5cf4dca6807fec54805c..0f0ad40398f358f01cf0f35c7f65691d768b2770 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -656,7 +656,7 @@ void Profiler::Engage() {
   if (engaged_) return;
   engaged_ = true;

-  OS::LogSharedLibraryAddresses();
+  OS::LogSharedLibraryAddresses(isolate_);

   // Start thread processing the profiler buffer.
   running_ = true;
Index: src/platform-cygwin.cc
diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc
index 9618d7e50f43e19ca5284ced20e52573f5e05846..bb0f5b1a305cb79d6902c0a92feea3c75f0a88f5 100644
--- a/src/platform-cygwin.cc
+++ b/src/platform-cygwin.cc
@@ -80,7 +80,6 @@ void* OS::Allocate(const size_t requested,
   int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   if (mbase == MAP_FAILED) {
-    LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed"));
     return NULL;
   }
   *allocated = msize;
@@ -141,7 +140,7 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() {
 }


-void OS::LogSharedLibraryAddresses() {
+void OS::LogSharedLibraryAddresses(Isolate* isolate) {
   // This function assumes that the layout of the file is as follows:
   // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
// If we encounter an unexpected situation we abort scanning further entries.
@@ -152,7 +151,6 @@ void OS::LogSharedLibraryAddresses() {
   const int kLibNameLen = FILENAME_MAX + 1;
   char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen));

-  i::Isolate* isolate = Isolate::Current();
   // This loop will terminate once the scanning hits an EOF.
   while (true) {
     uintptr_t start, end;
Index: src/platform-freebsd.cc
diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
index 34ed70960175d247b9c3ff08c6681244b6e0a9d0..573359c976a9da35ae1bff31331a257c12f9336f 100644
--- a/src/platform-freebsd.cc
+++ b/src/platform-freebsd.cc
@@ -89,7 +89,6 @@ void* OS::Allocate(const size_t requested,
   void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0);

   if (mbase == MAP_FAILED) {
-    LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed"));
     return NULL;
   }
   *allocated = msize;
@@ -155,7 +154,7 @@ static unsigned StringToLong(char* buffer) {
 }


-void OS::LogSharedLibraryAddresses() {
+void OS::LogSharedLibraryAddresses(Isolate* isolate) {
   static const int MAP_LENGTH = 1024;
   int fd = open("/proc/self/maps", O_RDONLY);
   if (fd < 0) return;
@@ -189,7 +188,7 @@ void OS::LogSharedLibraryAddresses() {
     // There may be no filename in this line.  Skip to next.
     if (start_of_path == NULL) continue;
     buffer[bytes_read] = 0;
- LOG(i::Isolate::Current(), SharedLibraryEvent(start_of_path, start, end));
+    LOG(isolate SharedLibraryEvent(start_of_path, start, end));
   }
   close(fd);
 }
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index 39bf1cba60b6f29236383d72e3649c8770448e07..f97214b97cb40624899f113999d39208af4c8b92 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -145,8 +145,6 @@ void* OS::Allocate(const size_t requested,
   void* addr = OS::GetRandomMmapAddr();
void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   if (mbase == MAP_FAILED) {
-    LOG(i::Isolate::Current(),
-        StringEvent("OS::Allocate", "mmap failed"));
     return NULL;
   }
   *allocated = msize;
@@ -220,7 +218,7 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() {
 }


-void OS::LogSharedLibraryAddresses() {
+void OS::LogSharedLibraryAddresses(Isolate* isolate) {
   // This function assumes that the layout of the file is as follows:
   // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
// If we encounter an unexpected situation we abort scanning further entries.
@@ -231,7 +229,6 @@ void OS::LogSharedLibraryAddresses() {
   const int kLibNameLen = FILENAME_MAX + 1;
   char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen));

-  i::Isolate* isolate = Isolate::Current();
   // This loop will terminate once the scanning hits an EOF.
   while (true) {
     uintptr_t start, end;
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index f61873703dcc0f3f3b157ea29dd6e822cf35862c..171fe0f2d0de49c665e9df3ef6ece5b3c05034f3 100644
--- a/src/platform-macos.cc
+++ b/src/platform-macos.cc
@@ -99,7 +99,6 @@ void* OS::Allocate(const size_t requested,
                      kMmapFd,
                      kMmapFdOffset);
   if (mbase == MAP_FAILED) {
-    LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed"));
     return NULL;
   }
   *allocated = msize;
@@ -173,7 +172,7 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() {
 }


-void OS::LogSharedLibraryAddresses() {
+void OS::LogSharedLibraryAddresses(Isolate* isolate) {
   unsigned int images_count = _dyld_image_count();
   for (unsigned int i = 0; i < images_count; ++i) {
     const mach_header* header = _dyld_get_image_header(i);
@@ -192,7 +191,7 @@ void OS::LogSharedLibraryAddresses() {
     if (code_ptr == NULL) continue;
     const uintptr_t slide = _dyld_get_image_vmaddr_slide(i);
     const uintptr_t start = reinterpret_cast<uintptr_t>(code_ptr) + slide;
-    LOG(Isolate::Current(),
+    LOG(isolate,
         SharedLibraryEvent(_dyld_get_image_name(i), start, start + size));
   }
 }
Index: src/platform-openbsd.cc
diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc
index bb20df3203f2672b02eadb316d0f68732036848f..6a548ce218781861f8985b562a94cce632b75bb9 100644
--- a/src/platform-openbsd.cc
+++ b/src/platform-openbsd.cc
@@ -87,8 +87,6 @@ void* OS::Allocate(const size_t requested,
   void* addr = OS::GetRandomMmapAddr();
   void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0);
   if (mbase == MAP_FAILED) {
-    LOG(i::Isolate::Current(),
-        StringEvent("OS::Allocate", "mmap failed"));
     return NULL;
   }
   *allocated = msize;
@@ -149,7 +147,7 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() {
 }


-void OS::LogSharedLibraryAddresses() {
+void OS::LogSharedLibraryAddresses(Isolate* isolate) {
   // This function assumes that the layout of the file is as follows:
   // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
// If we encounter an unexpected situation we abort scanning further entries.
@@ -160,7 +158,6 @@ void OS::LogSharedLibraryAddresses() {
   const int kLibNameLen = FILENAME_MAX + 1;
   char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen));

-  i::Isolate* isolate = Isolate::Current();
   // This loop will terminate once the scanning hits an EOF.
   while (true) {
     uintptr_t start, end;
Index: src/platform-solaris.cc
diff --git a/src/platform-solaris.cc b/src/platform-solaris.cc
index 512d995792731cb9e0a1333cd8ec856868f4cc03..ffb69ae8a5e51e30aa55a64e5b5a32e00e933cce 100644
--- a/src/platform-solaris.cc
+++ b/src/platform-solaris.cc
@@ -104,7 +104,6 @@ void* OS::Allocate(const size_t requested,
   void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0);

   if (mbase == MAP_FAILED) {
-    LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed"));
     return NULL;
   }
   *allocated = msize;
@@ -165,7 +164,7 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() {
 }


-void OS::LogSharedLibraryAddresses() {
+void OS::LogSharedLibraryAddresses(Isolate* isolate) {
 }


Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index 2e82056f2b2200d8cab09c97cf1e768cd20d6208..9d7f656cc2f2cca1e48eb372aca84097ffd9a404 100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -829,7 +829,6 @@ void* OS::Allocate(const size_t requested,
                                         prot);

   if (mbase == NULL) {
- LOG(Isolate::Current(), StringEvent("OS::Allocate", "VirtualAlloc failed"));
     return NULL;
   }

@@ -1129,7 +1128,7 @@ TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED)


 // Load the symbols for generating stack traces.
-static bool LoadSymbols(HANDLE process_handle) {
+static bool LoadSymbols(Isolate* isolate, HANDLE process_handle) {
   static bool symbols_loaded = false;

   if (symbols_loaded) return true;
@@ -1178,7 +1177,7 @@ static bool LoadSymbols(HANDLE process_handle) {
       if (err != ERROR_MOD_NOT_FOUND &&
           err != ERROR_INVALID_HANDLE) return false;
     }
-    LOG(i::Isolate::Current(),
+    LOG(isolate,
         SharedLibraryEvent(
             module_entry.szExePath,
             reinterpret_cast<unsigned int>(module_entry.modBaseAddr),
@@ -1193,14 +1192,14 @@ static bool LoadSymbols(HANDLE process_handle) {
 }


-void OS::LogSharedLibraryAddresses() {
+void OS::LogSharedLibraryAddresses(Isolate* isolate) {
   // SharedLibraryEvents are logged when loading symbol information.
   // Only the shared libraries loaded at the time of the call to
   // LogSharedLibraryAddresses are logged.  DLLs loaded after
   // initialization are not accounted for.
   if (!LoadDbgHelpAndTlHelp32()) return;
   HANDLE process_handle = GetCurrentProcess();
-  LoadSymbols(process_handle);
+  LoadSymbols(isolate, process_handle);
 }


@@ -1226,7 +1225,7 @@ int OS::StackWalk(Vector<OS::StackFrame> frames) {
   HANDLE thread_handle = GetCurrentThread();

   // Read the symbols.
-  if (!LoadSymbols(process_handle)) return kStackWalkError;
+ if (!LoadSymbols(Isolate::Current(), process_handle)) return kStackWalkError;

   // Capture current context.
   CONTEXT context;
@@ -1332,7 +1331,7 @@ int OS::StackWalk(Vector<OS::StackFrame> frames) {
 #pragma warning(pop)

 #else  // __MINGW32__
-void OS::LogSharedLibraryAddresses() { }
+void OS::LogSharedLibraryAddresses(Isolate* isolate) { }
 void OS::SignalCodeMovingGC() { }
 int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; }
 #endif  // __MINGW32__
Index: src/platform.h
diff --git a/src/platform.h b/src/platform.h
index 428ba55b2eef763e129082475d776fd452d9efce..ee8fb92910be295b2dc68c711be979adf7388ec6 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -287,7 +287,7 @@ class OS {

   // Support for the profiler.  Can do nothing, in which case ticks
   // occuring in shared libraries will not be properly accounted for.
-  static void LogSharedLibraryAddresses();
+  static void LogSharedLibraryAddresses(Isolate* isolate);

   // Support for the profiler.  Notifies the external profiling
   // process that a code moving garbage collection starts.  Can do
Index: src/string-stream.cc
diff --git a/src/string-stream.cc b/src/string-stream.cc
index 7c45e2f5b78f52c0834f09740eb6cc9655ee4afc..45b675fa8ba3bdc14df2517460af318c6308339c 100644
--- a/src/string-stream.cc
+++ b/src/string-stream.cc
@@ -269,8 +269,8 @@ SmartArrayPointer<const char> StringStream::ToCString() const {
 }


-void StringStream::Log() {
-  LOG(Isolate::Current(), StringEvent("StackDump", buffer_));
+void StringStream::Log(Isolate* isolate) {
+  LOG(isolate, StringEvent("StackDump", buffer_));
 }


Index: src/string-stream.h
diff --git a/src/string-stream.h b/src/string-stream.h
index 255a2c30bae9df8413300ec126dc62601344ade7..e3db2a8a8684db60af4e97d05d67ac983b46890a 100644
--- a/src/string-stream.h
+++ b/src/string-stream.h
@@ -147,7 +147,7 @@ class StringStream {
   // Getting the message out.
   void OutputToFile(FILE* out);
   void OutputToStdOut() { OutputToFile(stdout); }
-  void Log();
+  void Log(Isolate* isolate);
   Handle<String> ToString(Isolate* isolate);
   SmartArrayPointer<const char> ToCString() const;
   int length() const { return length_; }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to