Reviewers: Erik Corry,

Description:
Fix issue 597: builtins and stubs are missing in profiler log when using
snapshots.

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

Please review this at http://codereview.chromium.org/574005

Affected files:
  M src/log.h
  M src/log.cc
  M src/v8.cc
  M tools/tickprocessor.js


Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 5de7429e5d244cfc69cc128add4fa1d3901d83b3..17506de3575415b00bed44d034f5178d7dd3ad27 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -1294,6 +1294,16 @@ 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()) continue;
+    LogCodeObject(obj);
+  }
+}
+
+
 void Logger::LogCompiledFunctions() {
   HandleScope scope;
   const int compiled_funcs_count = EnumerateCompiledFunctions(NULL);
Index: src/log.h
diff --git a/src/log.h b/src/log.h
index 1f6e60e1a67b6425bb20db56fe473d614824ba20..e68d45805f17882119971a879c1202e0d1fb6a6c 100644
--- 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: src/v8.cc
diff --git a/src/v8.cc b/src/v8.cc
index 3bec827aa6ff280e6414ad0668046b7880a24cd8..39533611705c7ab2dceb0046ab23146aa9e7d4d1 100644
--- 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: tools/tickprocessor.js
diff --git a/tools/tickprocessor.js b/tools/tickprocessor.js
index 35422e2ecba0a6ee6ce8c2d7bfaedc1d4300b3ad..73bdf354e44a6a9418fa6b7e0860ad0dae916d80 100644
--- a/tools/tickprocessor.js
+++ b/tools/tickprocessor.js
@@ -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 }});



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

Reply via email to