Revision: 11702
Author: [email protected]
Date: Fri Jun 1 09:10:52 2012
Log: Expose last seen heap object id via v8 public api.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10444137
http://code.google.com/p/v8/source/detail?r=11702
Modified:
/branches/bleeding_edge/include/v8-profiler.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/heap-profiler.cc
/branches/bleeding_edge/src/heap-profiler.h
/branches/bleeding_edge/src/profile-generator.cc
/branches/bleeding_edge/src/profile-generator.h
/branches/bleeding_edge/test/cctest/test-heap-profiler.cc
=======================================
--- /branches/bleeding_edge/include/v8-profiler.h Tue Apr 17 06:10:17 2012
+++ /branches/bleeding_edge/include/v8-profiler.h Fri Jun 1 09:10:52 2012
@@ -448,11 +448,12 @@
* reports updates for all previous time intervals via the OutputStream
* object. Updates on each time interval are provided as a stream of the
* HeapStatsUpdate structure instances.
+ * The return value of the function is the last seen heap object Id.
*
* StartHeapObjectsTracking must be called before the first call to this
* method.
*/
- static void PushHeapObjectsStats(OutputStream* stream);
+ static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
/**
* Stops tracking of heap objects population statistics, cleans up all
=======================================
--- /branches/bleeding_edge/src/api.cc Wed May 23 07:24:29 2012
+++ /branches/bleeding_edge/src/api.cc Fri Jun 1 09:10:52 2012
@@ -6229,7 +6229,7 @@
}
-void HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
+SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapProfiler::PushHeapObjectsStats");
return i::HeapProfiler::PushHeapObjectsStats(stream);
=======================================
--- /branches/bleeding_edge/src/heap-profiler.cc Tue Apr 17 01:59:43 2012
+++ /branches/bleeding_edge/src/heap-profiler.cc Fri Jun 1 09:10:52 2012
@@ -97,7 +97,7 @@
}
-void HeapProfiler::PushHeapObjectsStats(v8::OutputStream* stream) {
+SnapshotObjectId HeapProfiler::PushHeapObjectsStats(v8::OutputStream*
stream) {
ASSERT(Isolate::Current()->heap_profiler() != NULL);
return
Isolate::Current()->heap_profiler()->PushHeapObjectsStatsImpl(stream);
}
@@ -158,8 +158,8 @@
}
-void HeapProfiler::PushHeapObjectsStatsImpl(OutputStream* stream) {
- snapshots_->PushHeapObjectsStats(stream);
+SnapshotObjectId HeapProfiler::PushHeapObjectsStatsImpl(OutputStream*
stream) {
+ return snapshots_->PushHeapObjectsStats(stream);
}
=======================================
--- /branches/bleeding_edge/src/heap-profiler.h Mon Apr 16 08:36:19 2012
+++ /branches/bleeding_edge/src/heap-profiler.h Fri Jun 1 09:10:52 2012
@@ -58,7 +58,7 @@
static void StartHeapObjectsTracking();
static void StopHeapObjectsTracking();
- static void PushHeapObjectsStats(OutputStream* stream);
+ static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
static int GetSnapshotsCount();
static HeapSnapshot* GetSnapshot(int index);
static HeapSnapshot* FindSnapshot(unsigned uid);
@@ -89,7 +89,7 @@
void StartHeapObjectsTrackingImpl();
void StopHeapObjectsTrackingImpl();
- void PushHeapObjectsStatsImpl(OutputStream* stream);
+ SnapshotObjectId PushHeapObjectsStatsImpl(OutputStream* stream);
HeapSnapshotsCollection* snapshots_;
unsigned next_snapshot_uid_;
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Wed May 23 07:24:29
2012
+++ /branches/bleeding_edge/src/profile-generator.cc Fri Jun 1 09:10:52
2012
@@ -1357,7 +1357,7 @@
}
-void HeapObjectsMap::PushHeapObjectsStats(OutputStream* stream) {
+SnapshotObjectId HeapObjectsMap::PushHeapObjectsStats(OutputStream*
stream) {
UpdateHeapObjectsMap();
time_intervals_.Add(TimeInterval(next_id_));
int prefered_chunk_size = stream->GetChunkSize();
@@ -1387,7 +1387,7 @@
if (stats_buffer.length() >= prefered_chunk_size) {
OutputStream::WriteResult result = stream->WriteHeapStatsChunk(
&stats_buffer.first(), stats_buffer.length());
- if (result == OutputStream::kAbort) return;
+ if (result == OutputStream::kAbort) return last_assigned_id();
stats_buffer.Clear();
}
}
@@ -1396,9 +1396,10 @@
if (!stats_buffer.is_empty()) {
OutputStream::WriteResult result = stream->WriteHeapStatsChunk(
&stats_buffer.first(), stats_buffer.length());
- if (result == OutputStream::kAbort) return;
+ if (result == OutputStream::kAbort) return last_assigned_id();
}
stream->EndOfStream();
+ return last_assigned_id();
}
=======================================
--- /branches/bleeding_edge/src/profile-generator.h Tue May 22 22:27:08 2012
+++ /branches/bleeding_edge/src/profile-generator.h Fri Jun 1 09:10:52 2012
@@ -649,7 +649,7 @@
}
void StopHeapObjectsTracking();
- void PushHeapObjectsStats(OutputStream* stream);
+ SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
static inline SnapshotObjectId GetNthGcSubrootId(int delta);
@@ -707,7 +707,7 @@
~HeapSnapshotsCollection();
bool is_tracking_objects() { return is_tracking_objects_; }
- void PushHeapObjectsStats(OutputStream* stream) {
+ SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) {
return ids_.PushHeapObjectsStats(stream);
}
void StartHeapObjectsTracking() { is_tracking_objects_ = true; }
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Tue May 22
22:27:08 2012
+++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Fri Jun 1
09:10:52 2012
@@ -691,9 +691,13 @@
} // namespace
-static TestStatsStream GetHeapStatsUpdate() {
+static TestStatsStream GetHeapStatsUpdate(
+ v8::SnapshotObjectId* object_id = NULL) {
TestStatsStream stream;
- v8::HeapProfiler::PushHeapObjectsStats(&stream);
+ v8::SnapshotObjectId last_seen_id =
+ v8::HeapProfiler::PushHeapObjectsStats(&stream);
+ if (object_id)
+ *object_id = last_seen_id;
CHECK_EQ(1, stream.eos_signaled());
return stream;
}
@@ -710,9 +714,10 @@
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
}
+ v8::SnapshotObjectId initial_id;
{
// Single chunk of data expected in update. Initial data.
- TestStatsStream stats_update = GetHeapStatsUpdate();
+ TestStatsStream stats_update = GetHeapStatsUpdate(&initial_id);
CHECK_EQ(1, stats_update.intervals_count());
CHECK_EQ(1, stats_update.updates_written());
CHECK_LT(0, stats_update.entries_size());
@@ -720,13 +725,18 @@
}
// No data expected in update because nothing has happened.
- CHECK_EQ(0, GetHeapStatsUpdate().updates_written());
- {
+ v8::SnapshotObjectId same_id;
+ CHECK_EQ(0, GetHeapStatsUpdate(&same_id).updates_written());
+ CHECK_EQ_SNAPSHOT_OBJECT_ID(initial_id, same_id);
+
+ {
+ v8::SnapshotObjectId additional_string_id;
v8::HandleScope inner_scope_1;
v8_str("string1");
{
// Single chunk of data with one new entry expected in update.
- TestStatsStream stats_update = GetHeapStatsUpdate();
+ TestStatsStream stats_update =
GetHeapStatsUpdate(&additional_string_id);
+ CHECK_LT(same_id, additional_string_id);
CHECK_EQ(1, stats_update.intervals_count());
CHECK_EQ(1, stats_update.updates_written());
CHECK_LT(0, stats_update.entries_size());
@@ -735,7 +745,9 @@
}
// No data expected in update because nothing happened.
- CHECK_EQ(0, GetHeapStatsUpdate().updates_written());
+ v8::SnapshotObjectId last_id;
+ CHECK_EQ(0, GetHeapStatsUpdate(&last_id).updates_written());
+ CHECK_EQ_SNAPSHOT_OBJECT_ID(additional_string_id, last_id);
{
v8::HandleScope inner_scope_2;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev