35 : FLAG_profile_vm_(FLAG_profile_vm),
36 FLAG_profile_vm_allocation_(FLAG_profile_vm_allocation) {
37 FLAG_profile_vm =
false;
38 FLAG_profile_vm_allocation =
false;
42 FLAG_profile_vm = FLAG_profile_vm_;
43 FLAG_profile_vm_allocation = FLAG_profile_vm_allocation_;
47 const bool FLAG_profile_vm_;
48 const bool FLAG_profile_vm_allocation_;
55 : FLAG_max_profile_depth_(FLAG_max_profile_depth) {
62 const intptr_t FLAG_max_profile_depth_;
77 intptr_t
sum()
const {
return sum_; }
85 buffer->VisitSamples(visitor);
116 EXPECT_EQ(0, visitor.
sum());
124 EXPECT_EQ(2, visitor.
sum());
131 EXPECT_EQ(6, visitor.
sum());
138 EXPECT_EQ(12, visitor.
sum());
148 EXPECT_EQ(18, visitor.
sum());
164 EXPECT_EQ(0, visitor.
visited());
171 EXPECT_EQ(1, visitor.
visited());
178 EXPECT_EQ(2, visitor.
visited());
185 EXPECT_EQ(3, visitor.
visited());
192 EXPECT_EQ(3, visitor.
visited());
207 delete sample_buffer;
222static ClassPtr
GetClass(
const Library& lib,
const char*
name) {
253 int64_t time_origin_micros = -1,
254 int64_t time_extent_micros = -1)
260 enable_vm_ticks_(
false) {}
263 if (!enable_vm_ticks_ && (sample->
vm_tag() == VMTag::kVMTagId)) {
274 bool enable_vm_ticks_;
278 if (!FLAG_profiler) {
279 FLAG_profiler =
true;
288 as_functions_(as_func),
290 sample_(
profile->SampleAt(0)) {
296 return UpdateFunctionIndex();
299 return (index_ < sample_->
length());
316 if (!as_functions_) {
338 intptr_t
line, column;
339 if (
script.GetTokenLocation(token_pos, &
line, &column)) {
340 const intptr_t token_len =
script.GetTokenLength(token_pos);
343 if (!str.IsNull())
return str.ToCString();
357 return code->inclusive_ticks();
369 return code->exclusive_ticks();
377 uword pc = sample_->
At(index_);
378 int64_t timestamp = sample_->
timestamp();
382 static constexpr intptr_t kInvalidInlinedIndex = -1;
384 bool UpdateFunctionIndex() {
385 if (inlined_index_ != kInvalidInlinedIndex) {
386 if (inlined_index_ - 1 >= 0) {
393 return (index_ < sample_->
length());
396 void ClearInliningData() {
397 inlined_index_ = kInvalidInlinedIndex;
398 inlined_functions_ =
nullptr;
399 inlined_token_positions_ =
nullptr;
402 ProfileFunction* GetFunction() {
405 ProfileFunction*
function = GetInlinedFunction();
410 const uword pc = sample_->
At(index_);
411 ProfileCode* profile_code =
413 ASSERT(profile_code !=
nullptr);
414 function = profile_code->function();
417 TokenPosition token_position = TokenPosition::kNoSource;
419 if (profile_code->code().IsCode()) {
420 code ^= profile_code->code().ptr();
421 inlined_functions_cache_.
Get(pc,
code, sample_, index_,
423 &inlined_token_positions_, &token_position);
426 if (
code.IsNull() || (inlined_functions_ ==
nullptr) ||
427 (inlined_functions_->length() <= 1)) {
434 inlined_index_ = inlined_functions_->length() - 1;
440 ProfileFunction* GetInlinedFunction() {
441 if ((inlined_index_ != kInvalidInlinedIndex) &&
442 (inlined_index_ < inlined_functions_->
length())) {
443 return profile_->
FindFunction(*(*inlined_functions_)[inlined_index_]);
451 ProcessedSample* sample_;
452 ProfileCodeInlinedFunctionsCache inlined_functions_cache_;
453 GrowableArray<const Function*>* inlined_functions_;
454 GrowableArray<TokenPosition>* inlined_token_positions_;
455 intptr_t inlined_index_;
462 const char* kScript =
483 Invoke(root_library,
"main");
486 const int64_t allocation_extent_micros =
487 after_allocations_micros - before_allocations_micros;
495 before_allocations_micros,
496 allocation_extent_micros);
499 EXPECT_EQ(1,
profile.sample_count());
503 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
504#if defined(TARGET_ARCH_IA32)
505 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
507 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
510 EXPECT_STREQ(
"[Unoptimized] B.boo", walker.
CurrentName());
512 EXPECT_STREQ(
"[Unoptimized] main", walker.
CurrentName());
527 EXPECT_EQ(0,
profile.sample_count());
532 Isolate* isolate = thread->isolate();
536 profile.Build(thread, isolate, &filter,
nullptr);
538 EXPECT_EQ(0,
profile.sample_count());
546 const char* kScript =
565 Invoke(root_library,
"main");
575 EXPECT_EQ(0,
profile.sample_count());
581 Invoke(root_library,
"main");
591 EXPECT_EQ(1,
profile.sample_count());
594 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
595#if defined(TARGET_ARCH_IA32)
596 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
598 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
601 EXPECT_STREQ(
"[Unoptimized] B.boo", walker.
CurrentName());
603 EXPECT_STREQ(
"[Unoptimized] main", walker.
CurrentName());
610 Invoke(root_library,
"main");
620 EXPECT_EQ(1,
profile.sample_count());
628 const char* kScript =
647 Invoke(root_library,
"main");
657 EXPECT_EQ(0,
profile.sample_count());
664 Invoke(root_library,
"main");
665 Invoke(root_library,
"main");
666 Invoke(root_library,
"main");
676 EXPECT_EQ(3,
profile.sample_count());
680 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
681#if defined(TARGET_ARCH_IA32)
682 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
684 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
688 EXPECT_STREQ(
"[Unoptimized] B.boo", walker.
CurrentName());
691 EXPECT_STREQ(
"[Unoptimized] main", walker.
CurrentName());
701 const char* kScript =
720 Invoke(root_library,
"main");
730 EXPECT_EQ(0,
profile.sample_count());
737 Invoke(root_library,
"main");
738 Invoke(root_library,
"main");
739 Invoke(root_library,
"main");
749 EXPECT_EQ(3,
profile.sample_count());
752 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
754#if defined(TARGET_ARCH_IA32)
755 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
757 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
775 const char* kScript =
"double foo(double a, double b) => a + b;";
777 Isolate* isolate = thread->isolate();
779 const Class& double_class =
798 EXPECT_EQ(0,
profile.sample_count());
810 EXPECT_EQ(1,
profile.sample_count());
813 EXPECT_STREQ(
"Double_add", walker.
VMTagName());
814 EXPECT_STREQ(
"[Unoptimized] double._add", walker.
CurrentName());
816 EXPECT_STREQ(
"[Unoptimized] double.+", walker.
CurrentName());
818 EXPECT_STREQ(
"[Unoptimized] foo", walker.
CurrentName());
831 EXPECT_EQ(1,
profile.sample_count());
839 const char* kScript =
840 "List foo() => List.filled(4, null);\n"
841 "List bar() => List.filled(0, null, growable: true);\n";
843 Isolate* isolate = thread->isolate();
845 const Class& array_class =
849 Invoke(root_library,
"foo");
857 EXPECT_EQ(0,
profile.sample_count());
861 Invoke(root_library,
"foo");
869 EXPECT_EQ(1,
profile.sample_count());
872 EXPECT_STREQ(
"DRT_AllocateArray", walker.
VMTagName());
873 EXPECT_STREQ(
"[Stub] AllocateArray", walker.
CurrentName());
875 EXPECT_STREQ(
"[Unoptimized] new _List", walker.
CurrentName());
877 EXPECT_STREQ(
"[Unoptimized] foo", walker.
CurrentName());
882 Invoke(root_library,
"foo");
890 EXPECT_EQ(1,
profile.sample_count());
897 Invoke(root_library,
"bar");
903 Invoke(root_library,
"bar");
912 EXPECT_EQ(0,
profile.sample_count());
920 const char* kScript =
923 " var msg = msg1 + msg1;\n"
924 " return (x) { return '$msg + $msg'; }(msg);\n"
927 Isolate* isolate = thread->isolate();
932 Invoke(root_library,
"foo");
940 EXPECT_EQ(0,
profile.sample_count());
944 Invoke(root_library,
"foo");
952 EXPECT_EQ(1,
profile.sample_count());
955 EXPECT_STREQ(
"DRT_AllocateContext", walker.
VMTagName());
956 EXPECT_STREQ(
"[Stub] AllocateContext", walker.
CurrentName());
958 EXPECT_STREQ(
"[Unoptimized] foo", walker.
CurrentName());
963 Invoke(root_library,
"foo");
971 EXPECT_EQ(1,
profile.sample_count());
979 const char* kScript =
983 " var msg = msg1 + msg1;\n"
984 " var msg2 = msg + msg;\n"
985 " return (x, y, z, w) { return '$x + $y + $z'; }(msg, msg2, msg, msg);\n"
988 " var msg = msg1 + msg1;\n"
989 " var msg2 = msg + msg;\n"
990 " return (x, y) { return '$x + $y'; }(msg, msg2);\n"
994 Isolate* isolate = thread->isolate();
996 const Class& closure_class =
1002 Invoke(root_library,
"foo");
1011 EXPECT_EQ(1,
profile.sample_count());
1014 EXPECT_SUBSTRING(
"DRT_AllocateClosure", walker.
VMTagName());
1015 EXPECT_STREQ(
"[Stub] AllocateClosure", walker.
CurrentName());
1025 Invoke(root_library,
"bar");
1034 EXPECT_EQ(1,
profile.sample_count());
1042 const char* kScript =
1043 "import 'dart:typed_data';\n"
1044 "List foo() => new Float32List(4);\n";
1046 Isolate* isolate = thread->isolate();
1048 const Library& typed_data_library =
1051 const Class& float32_list_class =
1055 Invoke(root_library,
"foo");
1063 EXPECT_EQ(0,
profile.sample_count());
1067 Invoke(root_library,
"foo");
1075 EXPECT_EQ(1,
profile.sample_count());
1078 EXPECT_STREQ(
"DRT_AllocateTypedData", walker.
VMTagName());
1079 EXPECT_STREQ(
"[Stub] AllocateFloat32Array", walker.
CurrentName());
1081 EXPECT_STREQ(
"[Unoptimized] new Float32List", walker.
CurrentName());
1083 EXPECT_STREQ(
"[Unoptimized] foo", walker.
CurrentName());
1088 Invoke(root_library,
"foo");
1096 EXPECT_EQ(1,
profile.sample_count());
1100 Invoke(root_library,
"foo");
1108 EXPECT_EQ(2,
profile.sample_count());
1116 const char* kScript =
"String foo(String a, String b) => a + b;";
1118 Isolate* isolate = thread->isolate();
1120 const Class& one_byte_string_class =
1139 EXPECT_EQ(0,
profile.sample_count());
1151 EXPECT_EQ(1,
profile.sample_count());
1154 EXPECT_STREQ(
"String_concat", walker.
VMTagName());
1155 EXPECT_STREQ(
"[Unoptimized] _StringBase.+", walker.
CurrentName());
1157 EXPECT_STREQ(
"[Unoptimized] foo", walker.
CurrentName());
1170 EXPECT_EQ(1,
profile.sample_count());
1182 EXPECT_EQ(2,
profile.sample_count());
1190 const char* kScript =
"String foo(String a, String b) => '$a | $b';";
1192 Isolate* isolate = thread->isolate();
1194 const Class& one_byte_string_class =
1213 EXPECT_EQ(0,
profile.sample_count());
1225 EXPECT_EQ(1,
profile.sample_count());
1228 EXPECT_STREQ(
"Internal_allocateOneByteString", walker.
VMTagName());
1230 EXPECT_STREQ(
"[Unoptimized] String._allocate", walker.
CurrentName());
1232 EXPECT_STREQ(
"[Unoptimized] String._concatAll", walker.
CurrentName());
1234 EXPECT_STREQ(
"[Unoptimized] _StringBase._interpolate",
1237 EXPECT_STREQ(
"[Unoptimized] foo", walker.
CurrentName());
1250 EXPECT_EQ(1,
profile.sample_count());
1262 EXPECT_EQ(2,
profile.sample_count());
1272 const char* kScript =
1278 " static choo(bool alloc) {\n"
1279 " if (alloc) return new A();\n"
1280 " return alloc && alloc && !alloc;\n"
1282 " static foo(bool alloc) {\n"
1285 " static boo(bool alloc) {\n"
1286 " for (var i = 0; i < 50000; i++) {\n"
1304 Invoke(root_library,
"main");
1306 Invoke(root_library,
"mainA");
1317 EXPECT_EQ(0,
profile.sample_count());
1324 Invoke(root_library,
"mainA");
1334 EXPECT_EQ(50000,
profile.sample_count());
1338 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1339#if defined(TARGET_ARCH_IA32)
1340 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1342 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1346 EXPECT_STREQ(
"[Optimized] B.boo", walker.
CurrentName());
1349 EXPECT_STREQ(
"[Unoptimized] mainA", walker.
CurrentName());
1358 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1359#if defined(TARGET_ARCH_IA32)
1360 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1362 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1396 const char* kScript =
1399 "bool alloc = false;"
1402 " if (alloc) new A();\n"
1406 "right() => maybeAlloc();\n"
1412 "wrong() => doNothing();\n"
1421 " for (var i = 0; i < 20000; i++) {\n"
1436 Invoke(root_library,
"mainNoAlloc");
1437 Invoke(root_library,
"mainAlloc");
1443 EXPECT(!func.is_inlinable());
1446 EXPECT(func.is_inlinable());
1448 EXPECT(func.is_inlinable());
1450 EXPECT(!func.is_inlinable());
1452 EXPECT(!func.is_inlinable());
1462 EXPECT_EQ(0,
profile.sample_count());
1468 Invoke(root_library,
"mainAlloc");
1477 EXPECT_EQ(1,
profile.sample_count());
1481 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1482#if defined(TARGET_ARCH_IA32)
1483 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1485 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1505 const char* kScript =
1512 " return new A();\n"
1516 "init() => secondInit();\n"
1517 "secondInit() => apple();\n"
1518 "apple() => banana();\n"
1519 "banana() => cantaloupe();\n"
1520 "cantaloupe() => dog();\n"
1521 "dog() => elephant();\n"
1522 "elephant() => fred();\n"
1523 "fred() => granola();\n"
1524 "granola() => haystack();\n"
1525 "haystack() => ice();\n"
1526 "ice() => jeep();\n"
1527 "jeep() => kindle();\n"
1528 "kindle() => lemon();\n"
1529 "lemon() => mayo();\n"
1530 "mayo() => napkin();\n"
1531 "napkin() => orange();\n"
1532 "orange() => B.boo();\n"
1543 Invoke(root_library,
"main");
1553 EXPECT_EQ(1,
profile.sample_count());
1556 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1557#if defined(TARGET_ARCH_IA32)
1558 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1560 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1563 EXPECT_STREQ(
"[Unoptimized] B.boo", walker.
CurrentName());
1565 EXPECT_STREQ(
"[Unoptimized] orange", walker.
CurrentName());
1567 EXPECT_STREQ(
"[Unoptimized] napkin", walker.
CurrentName());
1569 EXPECT_STREQ(
"[Unoptimized] mayo", walker.
CurrentName());
1571 EXPECT_STREQ(
"[Unoptimized] lemon", walker.
CurrentName());
1573 EXPECT_STREQ(
"[Unoptimized] kindle", walker.
CurrentName());
1575 EXPECT_STREQ(
"[Unoptimized] jeep", walker.
CurrentName());
1577 EXPECT_STREQ(
"[Unoptimized] ice", walker.
CurrentName());
1579 EXPECT_STREQ(
"[Unoptimized] haystack", walker.
CurrentName());
1581 EXPECT_STREQ(
"[Unoptimized] granola", walker.
CurrentName());
1583 EXPECT_STREQ(
"[Unoptimized] fred", walker.
CurrentName());
1585 EXPECT_STREQ(
"[Unoptimized] elephant", walker.
CurrentName());
1587 EXPECT_STREQ(
"[Unoptimized] dog", walker.
CurrentName());
1589 EXPECT_STREQ(
"[Unoptimized] cantaloupe", walker.
CurrentName());
1591 EXPECT_STREQ(
"[Unoptimized] banana", walker.
CurrentName());
1593 EXPECT_STREQ(
"[Unoptimized] apple", walker.
CurrentName());
1595 EXPECT_STREQ(
"[Unoptimized] secondInit", walker.
CurrentName());
1597 EXPECT_STREQ(
"[Unoptimized] init", walker.
CurrentName());
1599 EXPECT_STREQ(
"[Unoptimized] go", walker.
CurrentName());
1601 EXPECT_STREQ(
"[Unoptimized] main", walker.
CurrentName());
1610 const char* kScript =
1614 " @pragma('vm:never-inline') A() { }\n"
1617 " @pragma('vm:prefer-inline')\n"
1619 " return new A();\n"
1631 Invoke(root_library,
"main");
1637 Invoke(root_library,
"main");
1647 EXPECT_EQ(1,
profile.sample_count());
1650 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1651#if defined(TARGET_ARCH_IA32)
1652 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1654 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1674 const char* kScript =
1678 " @pragma('vm:never-inline') A() { }\n"
1681 " @pragma('vm:prefer-inline')\n"
1683 " return new A();\n"
1702 Invoke(root_library,
"main");
1704 if (
code.is_optimized()) {
1714 Invoke(root_library,
"main");
1728 EXPECT_EQ(1,
profile.sample_count());
1732 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1733#if defined(TARGET_ARCH_IA32)
1734 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1736 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1756 const char* kScript =
1760 " @pragma('vm:never-inline') A() { }\n"
1763 " @pragma('vm:never-inline')\n"
1764 " static oats() {\n"
1767 " @pragma('vm:prefer-inline')\n"
1769 " return new A();\n"
1773 " @pragma('vm:never-inline') bacon() {\n"
1776 " @pragma('vm:prefer-inline') fox() {\n"
1777 " return B.oats();\n"
1781 " new C()..bacon();\n"
1789 Invoke(root_library,
"main");
1795 Invoke(root_library,
"main");
1805 EXPECT_EQ(1,
profile.sample_count());
1808 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1809#if defined(TARGET_ARCH_IA32)
1810 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1812 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1847 const char* kScript =
1851 " @pragma('vm:never-inline') A() { }\n"
1854 " @pragma('vm:never-inline')\n"
1855 " static oats() {\n"
1858 " @pragma('vm:prefer-inline')\n"
1860 " return new A();\n"
1864 " @pragma('vm:never-inline') bacon() {\n"
1867 " @pragma('vm:prefer-inline') fox() {\n"
1868 " return B.oats();\n"
1872 " new C()..bacon();\n"
1887 Invoke(root_library,
"main");
1889 if (
code.is_optimized()) {
1899 Invoke(root_library,
"main");
1913 EXPECT_EQ(1,
profile.sample_count());
1916 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
1917#if defined(TARGET_ARCH_IA32)
1918 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
1920 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
1955 const char* kScript =
1959 " @pragma('vm:never-inline') A() { }\n"
1962 " @pragma('vm:never-inline')\n"
1963 " static oats() {\n"
1966 " @pragma('vm:prefer-inline')\n"
1968 " return new A();\n"
1972 " @pragma('vm:never-inline') bacon() {\n"
1973 " return this + this;\n"
1975 " @pragma('vm:prefer-inline') operator+(C other) {\n"
1978 " @pragma('vm:prefer-inline') fox() {\n"
1979 " return B.oats();\n"
1983 " new C()..bacon();\n"
1991 Invoke(root_library,
"main");
1997 Invoke(root_library,
"main");
2007 EXPECT_EQ(1,
profile.sample_count());
2010 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
2011#if defined(TARGET_ARCH_IA32)
2012 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
2014 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
2055 const char* kScript =
2059 " @pragma('vm:never-inline') A() { }\n"
2062 " @pragma('vm:never-inline')\n"
2063 " static oats() {\n"
2066 " @pragma('vm:prefer-inline')\n"
2068 " return new A();\n"
2072 " @pragma('vm:never-inline') bacon() {\n"
2073 " return this + this;\n"
2075 " @pragma('vm:prefer-inline') operator+(C other) {\n"
2078 " @pragma('vm:prefer-inline') fox() {\n"
2079 " return B.oats();\n"
2083 " new C()..bacon();\n"
2098 Invoke(root_library,
"main");
2100 if (
code.is_optimized()) {
2110 Invoke(root_library,
"main");
2124 EXPECT_EQ(1,
profile.sample_count());
2127 EXPECT_STREQ(
"DRT_AllocateObject", walker.
VMTagName());
2128#if defined(TARGET_ARCH_IA32)
2129 EXPECT_STREQ(
"[Stub] Allocate A", walker.
CurrentName());
2131 EXPECT_STREQ(
"[Stub] AllocateObjectSlow", walker.
CurrentName());
2171 ASSERT(sample !=
nullptr);
2177 while (pc_offsets[
i] != 0) {
2185 const intptr_t return_address_offset =
i > 0 ? 1 : 0;
2186 sample->
SetAt(
i, pc_offsets[
i] + return_address_offset);
2195 for (
uword pc_offset = 0; pc_offset <
code.Size(); pc_offset++) {
2196 code.GetInlinedFunctionsAtInstruction(pc_offset, &functions,
2198 if (token_positions[0] == tp) {
2199 return code.PayloadStart() + pc_offset;
2208 const char* kScript =
2209 "int doWork(i) => i * i;\n"
2212 " for (int i = 0; i < 100; i++) {\n"
2213 " sum += doWork(i);\n"
2231 ASSERT(sample_block_buffer !=
nullptr);
2236 Invoke(root_library,
"main");
2268 EXPECT(squarePositionPc != 0);
2271 EXPECT(callPositionPc != 0);
2274 uword controlFlowPc =
2276 EXPECT(controlFlowPc != 0);
2297 uword sample3[] = {controlFlowPc,
2310 main.end_token_pos());
2314 EXPECT_SUBSTRING(
"\"positions\":[\"ControlFlow\",19]",
js.ToCString());
2316 EXPECT_SUBSTRING(
"\"exclusiveTicks\":[1,2]",
js.ToCString());
2318 EXPECT_SUBSTRING(
"\"inclusiveTicks\":[1,2]",
js.ToCString());
2321 EXPECT_SUBSTRING(
"\"positions\":[95]",
js.ToCString());
2323 EXPECT_SUBSTRING(
"\"exclusiveTicks\":[0]",
js.ToCString());
2325 EXPECT_SUBSTRING(
"\"inclusiveTicks\":[2]",
js.ToCString());
2332 EXPECT_EQ(
table->length(), 0);
2335 int64_t timestamp = 0;
2340 EXPECT_EQ(
table->InsertCode(code1), 0);
2343 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2344 EXPECT_EQ(
table->FindCodeForPC(55), code1);
2345 EXPECT_EQ(
table->FindCodeForPC(59), code1);
2351 EXPECT_EQ(
table->InsertCode(code2), 0);
2354 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2355 EXPECT_EQ(
table->FindCodeForPC(10), code2);
2356 EXPECT_EQ(
table->FindCodeForPC(19), code2);
2362 EXPECT_EQ(
table->InsertCode(code3), 2);
2365 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2366 EXPECT_EQ(
table->FindCodeForPC(10), code2);
2367 EXPECT_EQ(
table->FindCodeForPC(80), code3);
2368 EXPECT_EQ(
table->FindCodeForPC(89), code3);
2374 EXPECT_EQ(
table->InsertCode(code4), 2);
2377 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2378 EXPECT_EQ(
table->FindCodeForPC(10), code2);
2379 EXPECT_EQ(
table->FindCodeForPC(80), code3);
2380 EXPECT_EQ(
table->FindCodeForPC(65), code4);
2381 EXPECT_EQ(
table->FindCodeForPC(74), code4);
2387 EXPECT_EQ(
table->InsertCode(code5), 0);
2390 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2391 EXPECT_EQ(
table->FindCodeForPC(10), code2);
2392 EXPECT_EQ(
table->FindCodeForPC(80), code3);
2393 EXPECT_EQ(
table->FindCodeForPC(65), code4);
2394 EXPECT_EQ(
table->FindCodeForPC(15), code2);
2395 EXPECT_EQ(
table->FindCodeForPC(24), code2);
2401 EXPECT_EQ(
table->InsertCode(code6), 1);
2404 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2405 EXPECT_EQ(
table->FindCodeForPC(10), code2);
2406 EXPECT_EQ(
table->FindCodeForPC(80), code3);
2407 EXPECT_EQ(
table->FindCodeForPC(65), code4);
2408 EXPECT_EQ(
table->FindCodeForPC(15), code2);
2409 EXPECT_EQ(
table->FindCodeForPC(24), code2);
2410 EXPECT_EQ(
table->FindCodeForPC(45), code1);
2411 EXPECT_EQ(
table->FindCodeForPC(54), code1);
2412 EXPECT_EQ(
table->FindCodeForPC(55), code1);
2417 EXPECT_EQ(
table->InsertCode(code7), 0);
2420 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2421 EXPECT_EQ(
table->FindCodeForPC(10), code2);
2422 EXPECT_EQ(
table->FindCodeForPC(80), code3);
2423 EXPECT_EQ(
table->FindCodeForPC(65), code4);
2424 EXPECT_EQ(
table->FindCodeForPC(15), code2);
2425 EXPECT_EQ(
table->FindCodeForPC(24), code2);
2426 EXPECT_EQ(
table->FindCodeForPC(45), code1);
2427 EXPECT_EQ(
table->FindCodeForPC(54), code1);
2428 EXPECT_EQ(
table->FindCodeForPC(20), code2);
2429 EXPECT_EQ(
table->FindCodeForPC(49), code1);
2430 EXPECT_EQ(
table->FindCodeForPC(50), code1);
2439 const char* kScript =
"main() => null;\n";
2443 for (intptr_t
i = 0;
i < 100000;
i++) {
2446 Invoke(root_library,
"main");
static void sample1(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
static void sample2(void *dst, const uint8_t *src, int width, int bpp, int deltaSrc, int offset, const SkPMColor ctable[])
static void do_work(int howMuchWork)
bool FilterSample(Sample *sample)
void set_enable_vm_ticks(bool enable)
AllocationFilter(Dart_Port port, intptr_t cid, int64_t time_origin_micros=-1, int64_t time_extent_micros=-1)
static Dart_Handle NewHandle(Thread *thread, ObjectPtr raw)
static ObjectPtr UnwrapHandle(Dart_Handle object)
void SetTraceAllocation(bool trace_allocation) const
void DumpSourcePositions(bool relative_addresses=false) const
~DisableNativeProfileScope()
DisableNativeProfileScope()
bool HasOptimizedCode() const
ObjectStore * object_store() const
static IsolateGroup * Current()
static Isolate * Current()
void set_current_sample_block(SampleBlock *block)
IsolateGroup * group() const
void set_current_allocation_sample_block(SampleBlock *block)
Dart_Port main_port() const
MaxProfileDepthScope(intptr_t new_max_depth)
static OSThread * Current()
static int64_t GetCurrentMonotonicMicros()
static ClassPtr context_class()
static Object & ZoneHandle()
uword At(intptr_t index) const
int64_t timestamp() const
void Get(uword pc, const Code &code, ProcessedSample *sample, intptr_t frame_index, GrowableArray< const Function * > **inlined_functions, GrowableArray< TokenPosition > **inlined_token_positions, TokenPosition *token_position)
TokenPosition token_pos() const
const Function * function() const
intptr_t inclusive_ticks() const
bool GetSinglePosition(ProfileFunctionSourcePosition *pfsp)
intptr_t exclusive_ticks() const
const char * Name() const
ProfileSampleBufferTestHelper(Dart_Port port)
void VisitSample(Sample *sample)
intptr_t CurrentInclusiveTicks()
const char * CurrentName()
intptr_t CurrentExclusiveTicks()
const char * CurrentToken()
ProfileStackWalker(Profile *profile, bool as_func=false)
ProfileCode * GetCodeFromPC(uword pc, int64_t timestamp)
ProfileFunction * FindFunction(const Function &function)
static void ClearSamples()
static void SetSampleDepth(intptr_t depth)
static void set_sample_block_buffer(SampleBlockBuffer *buffer)
static SampleBlockBuffer * sample_block_buffer()
static void SetSamplePeriod(intptr_t period)
SampleBlockBufferOverrideScope(SampleBlockBuffer *buffer)
~SampleBlockBufferOverrideScope()
void VisitSamples(SampleVisitor *visitor)
Sample * ReserveAllocationSample(Isolate *isolate)
Sample * ReserveCPUSample(Isolate *isolate)
void FreeCompletedBlocks()
void set_thread_task(Thread::TaskKind task)
uword At(intptr_t i) const
void set_is_allocation_sample(bool allocation_sample)
void Init(Dart_Port port, int64_t timestamp, ThreadId tid)
bool is_allocation_sample() const
intptr_t allocation_cid() const
void SetAt(intptr_t i, uword pc)
void set_metadata(intptr_t metadata)
void PrintJSON(JSONStream *js, const Script &script, TokenPosition start_pos=TokenPosition::kMinSource, TokenPosition end_pos=TokenPosition::kMaxSource)
static StringPtr New(Thread *thread, const char *cstr)
static Dart_Handle LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri=RESOLVED_USER_TEST_URI, bool finalize=true, bool allow_compile_errors=false)
static Thread * Current()
Isolate * isolate() const
static void EnterIsolate(Isolate *isolate)
static void ExitIsolate(bool isolate_shutdown=false)
static TokenPosition Deserialize(int32_t value)
static const char * TagName(uword id)
struct _Dart_Handle * Dart_Handle
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Dart_NativeFunction function
LibraryPtr LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri)
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_NewDouble(double value)
ObjectPtr Invoke(const Library &lib, const char *name)
FunctionPtr GetFunction(const Library &lib, const char *name)
static void InsertFakeSample(uword *pc_offsets)
ISOLATE_UNIT_TEST_CASE(StackAllocatedDestruction)
const int64_t kValidTimeStamp
static void VisitSamples(SampleBlockBuffer *buffer, SampleVisitor *visitor)
static void EnableProfiler()
ClassPtr GetClass(const Library &lib, const char *name)
TEST_CASE(DirectoryCurrent)
Dart_Handle NewString(const char *str)
static uword FindPCForTokenPosition(const Code &code, TokenPosition tp)
DART_EXPORT int64_t Dart_TimelineGetMicros()
DECLARE_FLAG(bool, show_invisible_frames)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
#define EXPECT_VALID(handle)