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

Unified Diff: runtime/vm/profiler_test.cc

Issue 1226143011: Trace allocation of arrays (Closed) Base URL: git@github.com:dart-lang/sdk.git@try_allocate_realz
Patch Set: Created 5 years, 5 months 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 | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler_test.cc
diff --git a/runtime/vm/profiler_test.cc b/runtime/vm/profiler_test.cc
index 813ebeb3406c7293474dc6ba1b8143139aea61e9..f24629ff7967c1dc371974f8b2ce73a215ca589d 100644
--- a/runtime/vm/profiler_test.cc
+++ b/runtime/vm/profiler_test.cc
@@ -380,4 +380,107 @@ TEST_CASE(Profiler_IntrinsicAllocation) {
}
}
+
+TEST_CASE(Profiler_ArrayAllocation) {
+ const char* kScript =
+ "List foo() => new List(4);\n"
+ "List bar() => new List();\n";
+ Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(lib);
+ Library& root_library = Library::Handle();
+ root_library ^= Api::UnwrapHandle(lib);
+ Isolate* isolate = Isolate::Current();
+
+ const Class& array_class =
+ Class::Handle(isolate->object_store()->array_class());
+ EXPECT(!array_class.IsNull());
+
+ Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 0, NULL);
+ EXPECT_VALID(result);
+
+ {
+ StackZone zone(isolate);
+ HANDLESCOPE(isolate);
+ Profile profile(isolate);
+ AllocationFilter filter(isolate, array_class.id());
+ profile.Build(&filter, Profile::kNoTags);
+ // We should have no allocation samples.
+ EXPECT_EQ(0, profile.sample_count());
+ }
+
+ array_class.SetTraceAllocation(true);
+ result = Dart_Invoke(lib, NewString("foo"), 0, NULL);
+ EXPECT_VALID(result);
+
+ {
+ StackZone zone(isolate);
+ HANDLESCOPE(isolate);
+ Profile profile(isolate);
+ AllocationFilter filter(isolate, array_class.id());
+ profile.Build(&filter, Profile::kNoTags);
+ // We should have one allocation sample.
+ EXPECT_EQ(1, profile.sample_count());
+ ProfileTrieWalker walker(&profile);
+
+ walker.Reset(Profile::kExclusiveCode);
+ EXPECT(walker.Down());
+ EXPECT_STREQ("_List._List", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("List.List", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("foo", walker.CurrentName());
+ EXPECT(!walker.Down());
+ }
+
+ array_class.SetTraceAllocation(false);
+ result = Dart_Invoke(lib, NewString("foo"), 0, NULL);
+ EXPECT_VALID(result);
+
+ {
+ StackZone zone(isolate);
+ HANDLESCOPE(isolate);
+ Profile profile(isolate);
+ AllocationFilter filter(isolate, array_class.id());
+ profile.Build(&filter, Profile::kNoTags);
+ // We should still only have one allocation sample.
+ EXPECT_EQ(1, profile.sample_count());
+ }
+
+ // Clear the samples.
+ ProfilerService::ClearSamples();
+
+ // Compile bar (many List objects allocated).
+ result = Dart_Invoke(lib, NewString("bar"), 0, NULL);
+ EXPECT_VALID(result);
+
+ // Enable again.
+ array_class.SetTraceAllocation(true);
+
+ // Run bar.
+ result = Dart_Invoke(lib, NewString("bar"), 0, NULL);
+ EXPECT_VALID(result);
+
+ {
+ StackZone zone(isolate);
+ HANDLESCOPE(isolate);
+ Profile profile(isolate);
+ AllocationFilter filter(isolate, array_class.id());
+ profile.Build(&filter, Profile::kNoTags);
+ // We should still only have one allocation sample.
+ EXPECT_EQ(1, profile.sample_count());
+ ProfileTrieWalker walker(&profile);
+
+ walker.Reset(Profile::kExclusiveCode);
+ EXPECT(walker.Down());
+ EXPECT_STREQ("_List._List", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("_GrowableList._GrowableList", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("List.List", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("bar", walker.CurrentName());
+ EXPECT(!walker.Down());
+ }
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698