Revision: 18151
Author: [email protected]
Date: Fri Nov 29 09:54:38 2013 UTC
Log: Do not put allocated block into HeapObjectsMap
Heap allocation reported to AllocationTracker may be later divided into
several objects so it is incorrect to put the block as a new HeapObject
into the map. We will match allocated block with actual HeapObjects later
when iterating Heap (will be addressed in another patch). Since the objects
are not assigned an id immediately after creation we need to call
FindOrAddEntry when finding id for SharedFunctionInfo during stack crawling.
Removed hooks for tracking creation of AllocationMemento. AllocationMemento
is not a HeapObject and should be considered as implementation overhead.
Renamed NewObjectEvent to AllocationEvent which is more precise in case of
folded allocations and when a part of the new block becomes
AllocationMemento.
BUG=None
LOG=N
[email protected], [email protected]
Review URL: https://codereview.chromium.org/95283003
http://code.google.com/p/v8/source/detail?r=18151
Modified:
/branches/bleeding_edge/src/allocation-tracker.cc
/branches/bleeding_edge/src/allocation-tracker.h
/branches/bleeding_edge/src/builtins.cc
/branches/bleeding_edge/src/heap-inl.h
/branches/bleeding_edge/src/heap-profiler.cc
/branches/bleeding_edge/src/heap-profiler.h
/branches/bleeding_edge/src/heap-snapshot-generator.cc
/branches/bleeding_edge/src/heap-snapshot-generator.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/serialize.h
/branches/bleeding_edge/test/cctest/test-heap-profiler.cc
=======================================
--- /branches/bleeding_edge/src/allocation-tracker.cc Fri Nov 22 12:28:58
2013 UTC
+++ /branches/bleeding_edge/src/allocation-tracker.cc Fri Nov 29 09:54:38
2013 UTC
@@ -169,7 +169,7 @@
}
-void AllocationTracker::NewObjectEvent(Address addr, int size) {
+void AllocationTracker::AllocationEvent(Address addr, int size) {
DisallowHeapAllocation no_allocation;
Heap* heap = ids_->heap();
@@ -185,7 +185,8 @@
while (!it.done() && length < kMaxAllocationTraceLength) {
JavaScriptFrame* frame = it.frame();
SharedFunctionInfo* shared = frame->function()->shared();
- SnapshotObjectId id = ids_->FindEntry(shared->address());
+ SnapshotObjectId id = ids_->FindOrAddEntry(
+ shared->address(), shared->Size(), false);
allocation_trace_buffer_[length++] = id;
AddFunctionInfo(shared, id);
it.Advance();
=======================================
--- /branches/bleeding_edge/src/allocation-tracker.h Fri Nov 22 13:50:39
2013 UTC
+++ /branches/bleeding_edge/src/allocation-tracker.h Fri Nov 29 09:54:38
2013 UTC
@@ -96,7 +96,7 @@
~AllocationTracker();
void PrepareForSerialization();
- void NewObjectEvent(Address addr, int size);
+ void AllocationEvent(Address addr, int size);
AllocationTraceTree* trace_tree() { return &trace_tree_; }
HashMap* id_to_function_info() { return &id_to_function_info_; }
=======================================
--- /branches/bleeding_edge/src/builtins.cc Fri Nov 29 09:47:32 2013 UTC
+++ /branches/bleeding_edge/src/builtins.cc Fri Nov 29 09:54:38 2013 UTC
@@ -281,11 +281,6 @@
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());
- }
return new_elms;
}
=======================================
--- /branches/bleeding_edge/src/heap-inl.h Wed Nov 27 14:03:40 2013 UTC
+++ /branches/bleeding_edge/src/heap-inl.h Fri Nov 29 09:54:38 2013 UTC
@@ -236,7 +236,7 @@
space = retry_space;
} else {
if (profiler->is_tracking_allocations() && result->To(&object)) {
- profiler->NewObjectEvent(object->address(), size_in_bytes);
+ profiler->AllocationEvent(object->address(), size_in_bytes);
}
return result;
}
@@ -260,7 +260,7 @@
}
if (result->IsFailure()) old_gen_exhausted_ = true;
if (profiler->is_tracking_allocations() && result->To(&object)) {
- profiler->NewObjectEvent(object->address(), size_in_bytes);
+ profiler->AllocationEvent(object->address(), size_in_bytes);
}
return result;
}
=======================================
--- /branches/bleeding_edge/src/heap-profiler.cc Fri Nov 29 09:47:32 2013
UTC
+++ /branches/bleeding_edge/src/heap-profiler.cc Fri Nov 29 09:54:38 2013
UTC
@@ -141,8 +141,8 @@
}
-void HeapProfiler::NewObjectEvent(Address addr, int size) {
- snapshots_->NewObjectEvent(addr, size);
+void HeapProfiler::AllocationEvent(Address addr, int size) {
+ snapshots_->AllocationEvent(addr, size);
}
=======================================
--- /branches/bleeding_edge/src/heap-profiler.h Fri Nov 29 09:47:32 2013 UTC
+++ /branches/bleeding_edge/src/heap-profiler.h Fri Nov 29 09:54:38 2013 UTC
@@ -64,7 +64,7 @@
void ObjectMoveEvent(Address from, Address to, int size);
- void NewObjectEvent(Address addr, int size);
+ void AllocationEvent(Address addr, int size);
void UpdateObjectSizeEvent(Address addr, int size);
=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.cc Fri Nov 29
09:47:32 2013 UTC
+++ /branches/bleeding_edge/src/heap-snapshot-generator.cc Fri Nov 29
09:54:38 2013 UTC
@@ -444,18 +444,6 @@
to_entry->value = from_value;
}
}
-
-
-void HeapObjectsMap::NewObject(Address addr, int size) {
- if (FLAG_heap_profiler_trace_objects) {
- PrintF("New object : %p %6d. Next address is %p\n",
- addr,
- size,
- addr + size);
- }
- ASSERT(addr != NULL);
- FindOrAddEntry(addr, size, false);
-}
void HeapObjectsMap::UpdateObjectSize(Address addr, int size) {
@@ -823,11 +811,10 @@
}
-void HeapSnapshotsCollection::NewObjectEvent(Address addr, int size) {
+void HeapSnapshotsCollection::AllocationEvent(Address addr, int size) {
DisallowHeapAllocation no_allocation;
- ids_.NewObject(addr, size);
if (allocation_tracker_ != NULL) {
- allocation_tracker_->NewObjectEvent(addr, size);
+ allocation_tracker_->AllocationEvent(addr, size);
}
}
=======================================
--- /branches/bleeding_edge/src/heap-snapshot-generator.h Fri Nov 29
09:47:32 2013 UTC
+++ /branches/bleeding_edge/src/heap-snapshot-generator.h Fri Nov 29
09:54:38 2013 UTC
@@ -233,7 +233,6 @@
unsigned int size,
bool accessed = true);
void MoveObject(Address from, Address to, int size);
- void NewObject(Address addr, int size);
void UpdateObjectSize(Address addr, int size);
SnapshotObjectId last_assigned_id() const {
return next_id_ - kObjectIdStep;
@@ -318,7 +317,7 @@
void ObjectMoveEvent(Address from, Address to, int size) {
ids_.MoveObject(from, to, size);
}
- void NewObjectEvent(Address addr, int size);
+ void AllocationEvent(Address addr, int size);
void UpdateObjectSizeEvent(Address addr, int size) {
ids_.UpdateObjectSize(addr, size);
}
=======================================
--- /branches/bleeding_edge/src/heap.cc Fri Nov 29 09:47:32 2013 UTC
+++ /branches/bleeding_edge/src/heap.cc Fri Nov 29 09:54:38 2013 UTC
@@ -4885,13 +4885,6 @@
AllocationMemento* alloc_memento =
reinterpret_cast<AllocationMemento*>(
reinterpret_cast<Address>(clone) + object_size);
InitializeAllocationMemento(alloc_memento, site);
- HeapProfiler* profiler = isolate()->heap_profiler();
- if (profiler->is_tracking_allocations()) {
- profiler->UpdateObjectSizeEvent(HeapObject::cast(clone)->address(),
- object_size);
- profiler->NewObjectEvent(alloc_memento->address(),
- AllocationMemento::kSize);
- }
}
}
=======================================
--- /branches/bleeding_edge/src/serialize.h Wed Oct 23 10:47:51 2013 UTC
+++ /branches/bleeding_edge/src/serialize.h Fri Nov 29 09:54:38 2013 UTC
@@ -364,7 +364,7 @@
high_water_[space_index] = address + size;
HeapProfiler* profiler = isolate_->heap_profiler();
if (profiler->is_tracking_allocations()) {
- profiler->NewObjectEvent(address, size);
+ profiler->AllocationEvent(address, size);
}
return address;
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Thu Nov 28
08:21:26 2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Fri Nov 29
09:54:38 2013 UTC
@@ -2064,26 +2064,6 @@
static HeapProfilerExtension kHeapProfilerExtension;
v8::DeclareExtension kHeapProfilerExtensionDeclaration(
&kHeapProfilerExtension);
-
-
-// This is an example of using checking of JS allocations tracking in a
test.
-TEST(HeapObjectsTracker) {
- const char* extensions[] = { HeapProfilerExtension::kName };
- v8::ExtensionConfiguration config(1, extensions);
- LocalContext env(&config);
- v8::HandleScope scope(env->GetIsolate());
- HeapObjectsTracker tracker;
- CompileRun("var a = 1.2");
- CompileRun("var a = 1.2; var b = 1.0; var c = 1.0;");
- CompileRun(
- "var a = [];\n"
- "for (var i = 0; i < 5; ++i)\n"
- " a[i] = i;\n"
- "findUntrackedObjects();\n"
- "for (var i = 0; i < 3; ++i)\n"
- " a.shift();\n"
- "findUntrackedObjects();\n");
-}
static const v8::HeapGraphNode* GetNodeByPath(const v8::HeapSnapshot*
snapshot,
@@ -2205,6 +2185,39 @@
}
return node;
}
+
+
+TEST(ArrayGrowLeftTrim) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+ heap_profiler->StartRecordingHeapAllocations();
+
+ CompileRun(
+ "var a = [];\n"
+ "for (var i = 0; i < 5; ++i)\n"
+ " a[i] = i;\n"
+ "for (var i = 0; i < 3; ++i)\n"
+ " a.shift();\n");
+
+ const char* names[] = { "(anonymous function)" };
+ const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(
+ v8::String::NewFromUtf8(env->GetIsolate(), "Test1"));
+ i::HeapSnapshotsCollection* collection =
ToInternal(snapshot)->collection();
+ AllocationTracker* tracker = collection->allocation_tracker();
+ CHECK_NE(NULL, tracker);
+ // Resolve all function locations.
+ tracker->PrepareForSerialization();
+ // Print for better diagnostics in case of failure.
+ tracker->trace_tree()->Print(tracker);
+
+ AllocationTraceNode* node =
+ FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names)));
+ CHECK_NE(NULL, node);
+ CHECK_GE(node->allocation_count(), 2);
+ CHECK_GE(node->allocation_size(), 4 * 5);
+ heap_profiler->StopRecordingHeapAllocations();
+}
TEST(TrackHeapAllocations) {
--
--
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.