Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1008)

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 95283003: Do not put allocated block into HeapObjectsMap (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reupload take 3 Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 458493b6d5d32237f5ffad9371a22f90f99d9967..74556338cc95ff6d57f8d041aa3063fdb14bfacb 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2064,26 +2064,6 @@ 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,
const char* path[],
int depth) {
@@ -2205,6 +2185,39 @@ static AllocationTraceNode* FindNode(
}
+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::HandleScope scope(v8::Isolate::GetCurrent());
LocalContext env;
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698