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

Side by Side 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, 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/profiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/profiler.h" 10 #include "vm/profiler.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Isolate* isolate = Isolate::Current(); 93 Isolate* isolate = Isolate::Current();
94 SampleBuffer* sample_buffer = new SampleBuffer(3); 94 SampleBuffer* sample_buffer = new SampleBuffer(3);
95 Sample* sample = sample_buffer->ReserveSample(); 95 Sample* sample = sample_buffer->ReserveSample();
96 sample->Init(isolate, 0, 0); 96 sample->Init(isolate, 0, 0);
97 sample->set_metadata(99); 97 sample->set_metadata(99);
98 sample->set_is_allocation_sample(true); 98 sample->set_is_allocation_sample(true);
99 EXPECT_EQ(99, sample->allocation_cid()); 99 EXPECT_EQ(99, sample->allocation_cid());
100 delete sample_buffer; 100 delete sample_buffer;
101 } 101 }
102 102
103 static RawClass* GetClass(const Library& lib, const char* name) {
104 const Class& cls = Class::Handle(
105 lib.LookupClass(String::Handle(Symbols::New(name))));
106 EXPECT(!cls.IsNull()); // No ambiguity error expected.
107 return cls.raw();
108 }
109
110
111 TEST_CASE(Profiler_TrivialRecordAllocation) {
112 const char* kScript =
113 "class A {\n"
114 " var a;\n"
115 " var b;\n"
116 "}\n"
117 "main() {\n"
118 " var z = new A();\n"
119 " return z;\n"
120 "}\n";
121
122 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
123 EXPECT_VALID(lib);
124 Library& root_library = Library::Handle();
125 root_library ^= Api::UnwrapHandle(lib);
126
127 const Class& class_a = Class::Handle(GetClass(root_library, "A"));
128 EXPECT(!class_a.IsNull());
129 class_a.SetTraceAllocation(true);
130
131 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
132 EXPECT_VALID(result);
133 }
134
103 } // namespace dart 135 } // namespace dart
OLDNEW
« 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