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

Side by Side Diff: runtime/vm/heap_test.cc

Issue 206583003: Add 'address' vm service message that finds heap objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/scavenger.h » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "vm/dart_api_impl.h" 6 #include "vm/dart_api_impl.h"
7 #include "vm/globals.h" 7 #include "vm/globals.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 EXPECT_EQ(1, class_stats->pre_gc.old_count); 154 EXPECT_EQ(1, class_stats->pre_gc.old_count);
155 EXPECT_EQ(0, class_stats->post_gc.old_count); 155 EXPECT_EQ(0, class_stats->post_gc.old_count);
156 EXPECT_EQ(0, class_stats->recent.old_count); 156 EXPECT_EQ(0, class_stats->recent.old_count);
157 // Perform GC. 157 // Perform GC.
158 heap->CollectGarbage(Heap::kOld); 158 heap->CollectGarbage(Heap::kOld);
159 EXPECT_EQ(0, class_stats->pre_gc.old_count); 159 EXPECT_EQ(0, class_stats->pre_gc.old_count);
160 EXPECT_EQ(0, class_stats->post_gc.old_count); 160 EXPECT_EQ(0, class_stats->post_gc.old_count);
161 EXPECT_EQ(0, class_stats->recent.old_count); 161 EXPECT_EQ(0, class_stats->recent.old_count);
162 } 162 }
163 163
164
165 class FindOnly : public FindObjectVisitor {
166 public:
167 FindOnly(Isolate* isolate, RawObject* target)
168 : FindObjectVisitor(isolate), target_(target) {
169 ASSERT(isolate->no_gc_scope_depth() != 0);
170 }
171 virtual ~FindOnly() { }
172
173 virtual bool FindObject(RawObject* obj) const {
174 return obj == target_;
175 }
176 private:
177 RawObject* target_;
178 };
179
180
181 class FindNothing : public FindObjectVisitor {
182 public:
183 FindNothing() : FindObjectVisitor(Isolate::Current()) { }
184 virtual ~FindNothing() { }
185 virtual bool FindObject(RawObject* obj) const { return false; }
186 };
187
188
189 TEST_CASE(FindObject) {
190 Isolate* isolate = Isolate::Current();
191 Heap* heap = isolate->heap();
192 Heap::Space spaces[2] = {Heap::kOld, Heap::kNew};
193 for (size_t space = 0; space < ARRAY_SIZE(spaces); ++space) {
194 const String& obj = String::Handle(String::New("x", spaces[space]));
195 {
196 NoGCScope no_gc;
197 FindOnly find_only(isolate, obj.raw());
198 EXPECT(obj.raw() == heap->FindObject(&find_only));
199 }
200 }
201 {
202 NoGCScope no_gc;
203 FindNothing find_nothing;
204 EXPECT(Object::null() == heap->FindObject(&find_nothing));
205 }
206 }
207
164 } // namespace dart. 208 } // namespace dart.
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698