Fix issue 597: builtins and stubs are missing in profiler log when using snapshots.
authormikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 4 Feb 2010 21:34:03 +0000 (21:34 +0000)
committermikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 4 Feb 2010 21:34:03 +0000 (21:34 +0000)
After this fix, profiles of non-snapshotted VMs are now equivalent to
profiles of snapshotted VMs (having that --log-snapshot-positions is used,
and mksnapshot's log is given to the tick processor script.)

BUG=597

Review URL: http://codereview.chromium.org/574005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3802 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/log.cc
src/log.h
src/v8.cc
tools/tickprocessor.js

index 5de7429e5d244cfc69cc128add4fa1d3901d83b3..1281a863b64758158334bb98b1921d4dd9adb1bd 100644 (file)
@@ -1294,6 +1294,15 @@ void Logger::LogCodeObject(Object* object) {
 }
 
 
+void Logger::LogCodeObjects() {
+  AssertNoAllocation no_alloc;
+  HeapIterator iterator;
+  for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
+    if (obj->IsCode()) LogCodeObject(obj);
+  }
+}
+
+
 void Logger::LogCompiledFunctions() {
   HandleScope scope;
   const int compiled_funcs_count = EnumerateCompiledFunctions(NULL);
index 1f6e60e1a67b6425bb20db56fe473d614824ba20..e68d45805f17882119971a879c1202e0d1fb6a6c 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -292,7 +292,7 @@ class Logger {
   // Logs all accessor callbacks found in the heap.
   static void LogAccessorCallbacks();
   // Used for logging stubs found in the snapshot.
-  static void LogCodeObject(Object* code_object);
+  static void LogCodeObjects();
 
  private:
 
@@ -325,6 +325,9 @@ class Logger {
   // Emits the source code of a regexp. Used by regexp events.
   static void LogRegExpSource(Handle<JSRegExp> regexp);
 
+  // Used for logging stubs found in the snapshot.
+  static void LogCodeObject(Object* code_object);
+
   // Emits a profiler tick event. Used by the profiler thread.
   static void TickEvent(TickSample* sample, bool overflow);
 
index 3bec827aa6ff280e6414ad0668046b7880a24cd8..39533611705c7ab2dceb0046ab23146aa9e7d4d1 100644 (file)
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -114,8 +114,11 @@ bool V8::Initialize(Deserializer *des) {
 
   OProfileAgent::Initialize();
 
-  if (FLAG_log_code) {
+  // If we are deserializing, log non-function code objects and compiled
+  // functions found in the snapshot.
+  if (des != NULL && FLAG_log_code) {
     HandleScope scope;
+    LOG(LogCodeObjects());
     LOG(LogCompiledFunctions());
   }
 
index 35422e2ecba0a6ee6ce8c2d7bfaedc1d4300b3ad..73bdf354e44a6a9418fa6b7e0860ad0dae916d80 100644 (file)
@@ -67,6 +67,9 @@ function SnapshotLogProcessor() {
           processor: this.processCodeMove, backrefs: true },
       'code-delete': { parsers: [this.createAddressParser('code')],
           processor: this.processCodeDelete, backrefs: true },
+      'function-creation': null,
+      'function-move': null,
+      'function-delete': null,
       'snapshot-pos': { parsers: [this.createAddressParser('code'), parseInt],
           processor: this.processSnapshotPosition, backrefs: true }});