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

Unified Diff: runtime/vm/profiler_test.cc

Issue 1227963004: Trace typed data allocations (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/intrinsifier_x64.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 f24629ff7967c1dc371974f8b2ce73a215ca589d..9759876070cbab4c9d478e3e40404cc8b45f43f5 100644
--- a/runtime/vm/profiler_test.cc
+++ b/runtime/vm/profiler_test.cc
@@ -103,7 +103,7 @@ TEST_CASE(Profiler_AllocationSampleTest) {
static RawClass* GetClass(const Library& lib, const char* name) {
const Class& cls = Class::Handle(
- lib.LookupClass(String::Handle(Symbols::New(name))));
+ lib.LookupClassAllowPrivate(String::Handle(Symbols::New(name))));
EXPECT(!cls.IsNull()); // No ambiguity error expected.
return cls.raw();
}
@@ -483,4 +483,62 @@ TEST_CASE(Profiler_ArrayAllocation) {
}
}
+
+TEST_CASE(Profiler_TypedArrayAllocation) {
+ const char* kScript =
+ "import 'dart:typed_data';\n"
+ "List foo() => new Float32List(4);\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 Library& typed_data_library =
+ Library::Handle(isolate->object_store()->typed_data_library());
+
+ const Class& float32_list_class =
+ Class::Handle(GetClass(typed_data_library, "_Float32Array"));
+ EXPECT(!float32_list_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, float32_list_class.id());
+ profile.Build(&filter, Profile::kNoTags);
+ // We should have no allocation samples.
+ EXPECT_EQ(0, profile.sample_count());
+ }
+
+ float32_list_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, float32_list_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("_Float32Array._new", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("_Float32Array._Float32Array", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("Float32List.Float32List", walker.CurrentName());
+ EXPECT(walker.Down());
+ EXPECT_STREQ("foo", walker.CurrentName());
+ EXPECT(!walker.Down());
+ }
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698