Commit c7053c8a authored by yurys@chromium.org's avatar yurys@chromium.org

Move heap profiler state flags to HeapProfiler

- moved is_tracking_objects_ flag to HeapProfiler and renamed it to is_tracking_objects_moves_
- Removed redundant call to UpdateHeapObjectsMap

BUG=None
LOG=N
R=loislo@chromium.org, mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/94993004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18149 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ba068987
...@@ -276,15 +276,15 @@ static FixedArrayBase* LeftTrimFixedArray(Heap* heap, ...@@ -276,15 +276,15 @@ static FixedArrayBase* LeftTrimFixedArray(Heap* heap,
FixedArrayBase* new_elms = FixedArrayBase::cast(HeapObject::FromAddress( FixedArrayBase* new_elms = FixedArrayBase::cast(HeapObject::FromAddress(
elms->address() + size_delta)); elms->address() + size_delta));
HeapProfiler* profiler = heap->isolate()->heap_profiler(); HeapProfiler* profiler = heap->isolate()->heap_profiler();
if (profiler->is_profiling()) { if (profiler->is_tracking_object_moves()) {
profiler->ObjectMoveEvent(elms->address(), profiler->ObjectMoveEvent(elms->address(),
new_elms->address(), new_elms->address(),
new_elms->Size()); new_elms->Size());
if (profiler->is_tracking_allocations()) { }
// Report filler object as a new allocation. if (profiler->is_tracking_allocations()) {
// Otherwise it will become an untracked object. // Report filler object as a new allocation.
profiler->NewObjectEvent(elms->address(), elms->Size()); // Otherwise it will become an untracked object.
} profiler->NewObjectEvent(elms->address(), elms->Size());
} }
return new_elms; return new_elms;
} }
......
...@@ -36,7 +36,8 @@ namespace internal { ...@@ -36,7 +36,8 @@ namespace internal {
HeapProfiler::HeapProfiler(Heap* heap) HeapProfiler::HeapProfiler(Heap* heap)
: snapshots_(new HeapSnapshotsCollection(heap)), : snapshots_(new HeapSnapshotsCollection(heap)),
next_snapshot_uid_(1), next_snapshot_uid_(1),
is_tracking_allocations_(false) { is_tracking_allocations_(false),
is_tracking_object_moves_(false) {
} }
...@@ -84,6 +85,7 @@ HeapSnapshot* HeapProfiler::TakeSnapshot( ...@@ -84,6 +85,7 @@ HeapSnapshot* HeapProfiler::TakeSnapshot(
} }
} }
snapshots_->SnapshotGenerationFinished(result); snapshots_->SnapshotGenerationFinished(result);
is_tracking_object_moves_ = true;
return result; return result;
} }
...@@ -98,6 +100,7 @@ HeapSnapshot* HeapProfiler::TakeSnapshot( ...@@ -98,6 +100,7 @@ HeapSnapshot* HeapProfiler::TakeSnapshot(
void HeapProfiler::StartHeapObjectsTracking() { void HeapProfiler::StartHeapObjectsTracking() {
snapshots_->StartHeapObjectsTracking(); snapshots_->StartHeapObjectsTracking();
is_tracking_object_moves_ = true;
} }
...@@ -159,7 +162,6 @@ void HeapProfiler::StartHeapAllocationsRecording() { ...@@ -159,7 +162,6 @@ void HeapProfiler::StartHeapAllocationsRecording() {
StartHeapObjectsTracking(); StartHeapObjectsTracking();
heap()->DisableInlineAllocation(); heap()->DisableInlineAllocation();
is_tracking_allocations_ = true; is_tracking_allocations_ = true;
snapshots_->UpdateHeapObjectsMap();
} }
......
...@@ -73,15 +73,10 @@ class HeapProfiler { ...@@ -73,15 +73,10 @@ class HeapProfiler {
v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id, v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
Object** wrapper); Object** wrapper);
INLINE(bool is_profiling()) {
return snapshots_->is_tracking_objects();
}
void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);
bool is_tracking_allocations() { bool is_tracking_object_moves() const { return is_tracking_object_moves_; }
return is_tracking_allocations_; bool is_tracking_allocations() const { return is_tracking_allocations_; }
}
void StartHeapAllocationsRecording(); void StartHeapAllocationsRecording();
void StopHeapAllocationsRecording(); void StopHeapAllocationsRecording();
...@@ -97,6 +92,7 @@ class HeapProfiler { ...@@ -97,6 +92,7 @@ class HeapProfiler {
unsigned next_snapshot_uid_; unsigned next_snapshot_uid_;
List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_; List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_;
bool is_tracking_allocations_; bool is_tracking_allocations_;
bool is_tracking_object_moves_;
}; };
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -747,8 +747,7 @@ size_t HeapObjectsMap::GetUsedMemorySize() const { ...@@ -747,8 +747,7 @@ size_t HeapObjectsMap::GetUsedMemorySize() const {
HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap) HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap)
: is_tracking_objects_(false), : names_(heap),
names_(heap),
ids_(heap), ids_(heap),
allocation_tracker_(NULL) { allocation_tracker_(NULL) {
} }
...@@ -770,7 +769,6 @@ void HeapSnapshotsCollection::StartHeapObjectsTracking() { ...@@ -770,7 +769,6 @@ void HeapSnapshotsCollection::StartHeapObjectsTracking() {
if (allocation_tracker_ == NULL) { if (allocation_tracker_ == NULL) {
allocation_tracker_ = new AllocationTracker(&ids_, names()); allocation_tracker_ = new AllocationTracker(&ids_, names());
} }
is_tracking_objects_ = true;
} }
...@@ -785,7 +783,6 @@ void HeapSnapshotsCollection::StopHeapObjectsTracking() { ...@@ -785,7 +783,6 @@ void HeapSnapshotsCollection::StopHeapObjectsTracking() {
HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(const char* name, HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(const char* name,
unsigned uid) { unsigned uid) {
is_tracking_objects_ = true; // Start watching for heap objects moves.
return new HeapSnapshot(this, name, uid); return new HeapSnapshot(this, name, uid);
} }
......
...@@ -294,7 +294,6 @@ class HeapSnapshotsCollection { ...@@ -294,7 +294,6 @@ class HeapSnapshotsCollection {
Heap* heap() const { return ids_.heap(); } Heap* heap() const { return ids_.heap(); }
bool is_tracking_objects() { return is_tracking_objects_; }
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) { SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) {
return ids_.PushHeapObjectsStats(stream); return ids_.PushHeapObjectsStats(stream);
} }
...@@ -330,10 +329,7 @@ class HeapSnapshotsCollection { ...@@ -330,10 +329,7 @@ class HeapSnapshotsCollection {
int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); } int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); }
void UpdateHeapObjectsMap() { ids_.UpdateHeapObjectsMap(); }
private: private:
bool is_tracking_objects_; // Whether tracking object moves is needed.
List<HeapSnapshot*> snapshots_; List<HeapSnapshot*> snapshots_;
StringsStorage names_; StringsStorage names_;
// Mapping from HeapObject addresses to objects' uids. // Mapping from HeapObject addresses to objects' uids.
......
...@@ -2196,7 +2196,7 @@ class ScavengingVisitor : public StaticVisitorBase { ...@@ -2196,7 +2196,7 @@ class ScavengingVisitor : public StaticVisitorBase {
RecordCopiedObject(heap, target); RecordCopiedObject(heap, target);
Isolate* isolate = heap->isolate(); Isolate* isolate = heap->isolate();
HeapProfiler* heap_profiler = isolate->heap_profiler(); HeapProfiler* heap_profiler = isolate->heap_profiler();
if (heap_profiler->is_profiling()) { if (heap_profiler->is_tracking_object_moves()) {
heap_profiler->ObjectMoveEvent(source->address(), target->address(), heap_profiler->ObjectMoveEvent(source->address(), target->address(),
size); size);
} }
...@@ -2447,7 +2447,7 @@ void Heap::SelectScavengingVisitorsTable() { ...@@ -2447,7 +2447,7 @@ void Heap::SelectScavengingVisitorsTable() {
isolate()->logger()->is_logging() || isolate()->logger()->is_logging() ||
isolate()->cpu_profiler()->is_profiling() || isolate()->cpu_profiler()->is_profiling() ||
(isolate()->heap_profiler() != NULL && (isolate()->heap_profiler() != NULL &&
isolate()->heap_profiler()->is_profiling()); isolate()->heap_profiler()->is_tracking_object_moves());
if (!incremental_marking()->IsMarking()) { if (!incremental_marking()->IsMarking()) {
if (!logging_and_profiling) { if (!logging_and_profiling) {
......
...@@ -2768,7 +2768,7 @@ void MarkCompactCollector::MigrateObject(Address dst, ...@@ -2768,7 +2768,7 @@ void MarkCompactCollector::MigrateObject(Address dst,
int size, int size,
AllocationSpace dest) { AllocationSpace dest) {
HeapProfiler* heap_profiler = heap()->isolate()->heap_profiler(); HeapProfiler* heap_profiler = heap()->isolate()->heap_profiler();
if (heap_profiler->is_profiling()) { if (heap_profiler->is_tracking_object_moves()) {
heap_profiler->ObjectMoveEvent(src, dst, size); heap_profiler->ObjectMoveEvent(src, dst, size);
} }
ASSERT(heap()->AllowedToBeMigrated(HeapObject::FromAddress(src), dest)); ASSERT(heap()->AllowedToBeMigrated(HeapObject::FromAddress(src), dest));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment