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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap_test.cc
===================================================================
--- runtime/vm/heap_test.cc (revision 34144)
+++ runtime/vm/heap_test.cc (working copy)
@@ -161,4 +161,48 @@
EXPECT_EQ(0, class_stats->recent.old_count);
}
+
+class FindOnly : public FindObjectVisitor {
+ public:
+ FindOnly(Isolate* isolate, RawObject* target)
+ : FindObjectVisitor(isolate), target_(target) {
+ ASSERT(isolate->no_gc_scope_depth() != 0);
+ }
+ virtual ~FindOnly() { }
+
+ virtual bool FindObject(RawObject* obj) const {
+ return obj == target_;
+ }
+ private:
+ RawObject* target_;
+};
+
+
+class FindNothing : public FindObjectVisitor {
+ public:
+ FindNothing() : FindObjectVisitor(Isolate::Current()) { }
+ virtual ~FindNothing() { }
+ virtual bool FindObject(RawObject* obj) const { return false; }
+};
+
+
+TEST_CASE(FindObject) {
+ Isolate* isolate = Isolate::Current();
+ Heap* heap = isolate->heap();
+ Heap::Space spaces[2] = {Heap::kOld, Heap::kNew};
+ for (size_t space = 0; space < ARRAY_SIZE(spaces); ++space) {
+ const String& obj = String::Handle(String::New("x", spaces[space]));
+ {
+ NoGCScope no_gc;
+ FindOnly find_only(isolate, obj.raw());
+ EXPECT(obj.raw() == heap->FindObject(&find_only));
+ }
+ }
+ {
+ NoGCScope no_gc;
+ FindNothing find_nothing;
+ EXPECT(Object::null() == heap->FindObject(&find_nothing));
+ }
+}
+
} // namespace dart.
« 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