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

Unified Diff: runtime/vm/profiler_test.cc

Issue 1213013002: Update Assembler::TryAllocate to support inline allocation tracing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
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/object.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 4f1ea87aefb14c0b5d20e89ec216d9af31b0312c..813ebeb3406c7293474dc6ba1b8143139aea61e9 100644
--- a/runtime/vm/profiler_test.cc
+++ b/runtime/vm/profiler_test.cc
@@ -313,4 +313,71 @@ TEST_CASE(Profiler_ToggleRecordAllocation) {
}
}
+
+TEST_CASE(Profiler_IntrinsicAllocation) {
+ const char* kScript = "double foo(double a, double b) => a + b;";
+ 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& double_class =
+ Class::Handle(isolate->object_store()->double_class());
+ EXPECT(!double_class.IsNull());
+
+ Dart_Handle args[2] = { Dart_NewDouble(1.0), Dart_NewDouble(2.0), };
+
+ Dart_Handle result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]);
+ EXPECT_VALID(result);
+
+ {
+ StackZone zone(isolate);
+ HANDLESCOPE(isolate);
+ Profile profile(isolate);
+ AllocationFilter filter(isolate, double_class.id());
+ profile.Build(&filter, Profile::kNoTags);
+ // We should have no allocation samples.
+ EXPECT_EQ(0, profile.sample_count());
+ }
+
+ double_class.SetTraceAllocation(true);
+ result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]);
+ EXPECT_VALID(result);
+
+ {
+ StackZone zone(isolate);
+ HANDLESCOPE(isolate);
+ Profile profile(isolate);
+ AllocationFilter filter(isolate, double_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("_Double._add", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("_Double.+", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("foo", walker.CurrentName());
+ EXPECT(!walker.Down());
+ }
+
+ double_class.SetTraceAllocation(false);
+ result = Dart_Invoke(lib, NewString("foo"), 2, &args[0]);
+ EXPECT_VALID(result);
+
+ {
+ StackZone zone(isolate);
+ HANDLESCOPE(isolate);
+ Profile profile(isolate);
+ AllocationFilter filter(isolate, double_class.id());
+ profile.Build(&filter, Profile::kNoTags);
+ // We should still only have one allocation sample.
+ EXPECT_EQ(1, profile.sample_count());
+ }
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698