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

Unified Diff: runtime/vm/profiler_test.cc

Issue 1211633002: Introduce mechanism to record an allocation of a class (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/profiler.cc ('k') | no next file » | 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 992fada97668f1e638e677719724982739dbf158..561bb69e4eec9c87ed7aa4d9809dba57e892ff51 100644
--- a/runtime/vm/profiler_test.cc
+++ b/runtime/vm/profiler_test.cc
@@ -100,4 +100,36 @@ TEST_CASE(Profiler_AllocationSampleTest) {
delete sample_buffer;
}
+static RawClass* GetClass(const Library& lib, const char* name) {
+ const Class& cls = Class::Handle(
+ lib.LookupClass(String::Handle(Symbols::New(name))));
+ EXPECT(!cls.IsNull()); // No ambiguity error expected.
+ return cls.raw();
+}
+
+
+TEST_CASE(Profiler_TrivialRecordAllocation) {
+ const char* kScript =
+ "class A {\n"
+ " var a;\n"
+ " var b;\n"
+ "}\n"
+ "main() {\n"
+ " var z = new A();\n"
+ " return z;\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(lib);
+ Library& root_library = Library::Handle();
+ root_library ^= Api::UnwrapHandle(lib);
+
+ const Class& class_a = Class::Handle(GetClass(root_library, "A"));
+ EXPECT(!class_a.IsNull());
+ class_a.SetTraceAllocation(true);
+
+ Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
+ EXPECT_VALID(result);
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698