Reviewers: alph, loislo, Michael Starzinger,
Message:
This is a refactoring which I don't want to interleave with other allocation
tracker changes.
Description:
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
Please review this at https://codereview.chromium.org/94993004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+17, -26 lines):
M src/builtins.cc
M src/heap-profiler.h
M src/heap-profiler.cc
M src/heap-snapshot-generator.h
M src/heap-snapshot-generator.cc
M src/heap.cc
M src/mark-compact.cc
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index
999969dd29f3ca92e0a8d7cc772d9140ffde6289..b31adbe118912ca118ee991d91bac24324f3cb03
100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -276,15 +276,15 @@ static FixedArrayBase* LeftTrimFixedArray(Heap* heap,
FixedArrayBase* new_elms = FixedArrayBase::cast(HeapObject::FromAddress(
elms->address() + size_delta));
HeapProfiler* profiler = heap->isolate()->heap_profiler();
- if (profiler->is_profiling()) {
+ if (profiler->is_tracking_object_moves()) {
profiler->ObjectMoveEvent(elms->address(),
new_elms->address(),
new_elms->Size());
- if (profiler->is_tracking_allocations()) {
- // Report filler object as a new allocation.
- // Otherwise it will become an untracked object.
- profiler->NewObjectEvent(elms->address(), elms->Size());
- }
+ }
+ if (profiler->is_tracking_allocations()) {
+ // Report filler object as a new allocation.
+ // Otherwise it will become an untracked object.
+ profiler->NewObjectEvent(elms->address(), elms->Size());
}
return new_elms;
}
Index: src/heap-profiler.cc
diff --git a/src/heap-profiler.cc b/src/heap-profiler.cc
index
a4ec5a979f02ba0159f2f05e83b38dbcb942c0f8..b7855a971526d0a5c0f9de83d5dea7df0ba271a7
100644
--- a/src/heap-profiler.cc
+++ b/src/heap-profiler.cc
@@ -36,7 +36,8 @@ namespace internal {
HeapProfiler::HeapProfiler(Heap* heap)
: snapshots_(new HeapSnapshotsCollection(heap)),
next_snapshot_uid_(1),
- is_tracking_allocations_(false) {
+ is_tracking_allocations_(false),
+ is_tracking_object_moves_(false) {
}
@@ -84,6 +85,7 @@ HeapSnapshot* HeapProfiler::TakeSnapshot(
}
}
snapshots_->SnapshotGenerationFinished(result);
+ is_tracking_object_moves_ = true;
return result;
}
@@ -98,6 +100,7 @@ HeapSnapshot* HeapProfiler::TakeSnapshot(
void HeapProfiler::StartHeapObjectsTracking() {
snapshots_->StartHeapObjectsTracking();
+ is_tracking_object_moves_ = true;
}
@@ -159,7 +162,6 @@ void HeapProfiler::StartHeapAllocationsRecording() {
StartHeapObjectsTracking();
heap()->DisableInlineAllocation();
is_tracking_allocations_ = true;
- snapshots_->UpdateHeapObjectsMap();
}
Index: src/heap-profiler.h
diff --git a/src/heap-profiler.h b/src/heap-profiler.h
index
f2e8100f5da2f27dbbc2ea114938f69d012cf02f..4af1e4987befbdd8071c271f39d777711fd5deec
100644
--- a/src/heap-profiler.h
+++ b/src/heap-profiler.h
@@ -73,15 +73,10 @@ class HeapProfiler {
v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
Object** wrapper);
- INLINE(bool is_profiling()) {
- return snapshots_->is_tracking_objects();
- }
-
void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info);
- bool is_tracking_allocations() {
- return is_tracking_allocations_;
- }
+ bool is_tracking_object_moves() const { return
is_tracking_object_moves_; }
+ bool is_tracking_allocations() const { return is_tracking_allocations_; }
void StartHeapAllocationsRecording();
void StopHeapAllocationsRecording();
@@ -97,6 +92,7 @@ class HeapProfiler {
unsigned next_snapshot_uid_;
List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_;
bool is_tracking_allocations_;
+ bool is_tracking_object_moves_;
};
} } // namespace v8::internal
Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index
7e74d86ae3a8973992f9ee8ac596e6c59e9241e1..79a1516412876ce898853d652969e35f8228a726
100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -747,8 +747,7 @@ size_t HeapObjectsMap::GetUsedMemorySize() const {
HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap)
- : is_tracking_objects_(false),
- names_(heap),
+ : names_(heap),
ids_(heap),
allocation_tracker_(NULL) {
}
@@ -770,7 +769,6 @@ void
HeapSnapshotsCollection::StartHeapObjectsTracking() {
if (allocation_tracker_ == NULL) {
allocation_tracker_ = new AllocationTracker(&ids_, names());
}
- is_tracking_objects_ = true;
}
@@ -785,7 +783,6 @@ void HeapSnapshotsCollection::StopHeapObjectsTracking()
{
HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(const char* name,
unsigned uid) {
- is_tracking_objects_ = true; // Start watching for heap objects moves.
return new HeapSnapshot(this, name, uid);
}
Index: src/heap-snapshot-generator.h
diff --git a/src/heap-snapshot-generator.h b/src/heap-snapshot-generator.h
index
c69d5e55ab9ee0be56150fb02b94541af58a8937..64a217c53275780c5b4472a3d53a46a035e8a2b9
100644
--- a/src/heap-snapshot-generator.h
+++ b/src/heap-snapshot-generator.h
@@ -294,7 +294,6 @@ class HeapSnapshotsCollection {
Heap* heap() const { return ids_.heap(); }
- bool is_tracking_objects() { return is_tracking_objects_; }
SnapshotObjectId PushHeapObjectsStats(OutputStream* stream) {
return ids_.PushHeapObjectsStats(stream);
}
@@ -330,10 +329,7 @@ class HeapSnapshotsCollection {
int FindUntrackedObjects() { return ids_.FindUntrackedObjects(); }
- void UpdateHeapObjectsMap() { ids_.UpdateHeapObjectsMap(); }
-
private:
- bool is_tracking_objects_; // Whether tracking object moves is needed.
List<HeapSnapshot*> snapshots_;
StringsStorage names_;
// Mapping from HeapObject addresses to objects' uids.
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
86efe4b7d372d0d0260776d21a19a965654ef7d7..0f2f9e08809672fdfc8c7f03290fa08c2fcbffea
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2196,7 +2196,7 @@ class ScavengingVisitor : public StaticVisitorBase {
RecordCopiedObject(heap, target);
Isolate* isolate = heap->isolate();
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(),
size);
}
@@ -2447,7 +2447,7 @@ void Heap::SelectScavengingVisitorsTable() {
isolate()->logger()->is_logging() ||
isolate()->cpu_profiler()->is_profiling() ||
(isolate()->heap_profiler() != NULL &&
- isolate()->heap_profiler()->is_profiling());
+ isolate()->heap_profiler()->is_tracking_object_moves());
if (!incremental_marking()->IsMarking()) {
if (!logging_and_profiling) {
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
b60768bfc07a5d46c3fa1e027edaf87a2d2bea82..0e6b9804e09fe6776b0b61d97362d1d3ecf223ab
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -2768,7 +2768,7 @@ void MarkCompactCollector::MigrateObject(Address dst,
int size,
AllocationSpace dest) {
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);
}
ASSERT(heap()->AllowedToBeMigrated(HeapObject::FromAddress(src), dest));
--
--
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.