OLD | NEW |
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/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 4230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4241 objects_->Add(&handle); | 4241 objects_->Add(&handle); |
4242 } | 4242 } |
4243 private: | 4243 private: |
4244 GrowableArray<Object*>* objects_; | 4244 GrowableArray<Object*>* objects_; |
4245 }; | 4245 }; |
4246 | 4246 |
4247 | 4247 |
4248 TEST_CASE(PrintJSON) { | 4248 TEST_CASE(PrintJSON) { |
4249 Heap* heap = Isolate::Current()->heap(); | 4249 Heap* heap = Isolate::Current()->heap(); |
4250 heap->CollectAllGarbage(); | 4250 heap->CollectAllGarbage(); |
4251 // We don't want to print garbage objects, so wait for concurrent sweeper. | |
4252 // TODO(21620): Add heap iteration interface that excludes garbage (or | |
4253 // use ObjectGraph). | |
4254 PageSpace* old_space = heap->old_space(); | |
4255 { | |
4256 MonitorLocker ml(old_space->tasks_lock()); | |
4257 while (old_space->tasks() > 0) { | |
4258 ml.Wait(); | |
4259 } | |
4260 } | |
4261 GrowableArray<Object*> objects; | 4251 GrowableArray<Object*> objects; |
4262 ObjectAccumulator acc(&objects); | 4252 ObjectAccumulator acc(&objects); |
4263 heap->VisitObjects(&acc); | 4253 heap->IterateObjects(&acc); |
4264 for (intptr_t i = 0; i < objects.length(); ++i) { | 4254 for (intptr_t i = 0; i < objects.length(); ++i) { |
4265 JSONStream js; | 4255 JSONStream js; |
4266 objects[i]->PrintJSON(&js, false); | 4256 objects[i]->PrintJSON(&js, false); |
4267 EXPECT_SUBSTRING("\"type\":", js.ToCString()); | 4257 EXPECT_SUBSTRING("\"type\":", js.ToCString()); |
4268 } | 4258 } |
4269 } | 4259 } |
4270 | 4260 |
4271 | 4261 |
4272 // Elide a substring which starts with some prefix and ends with a ". | 4262 // Elide a substring which starts with some prefix and ends with a ". |
4273 // | 4263 // |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4743 EXPECT(iterator.MoveNext()); | 4733 EXPECT(iterator.MoveNext()); |
4744 object = iterator.CurrentKey(); | 4734 object = iterator.CurrentKey(); |
4745 EXPECT_STREQ("z", object.ToCString()); | 4735 EXPECT_STREQ("z", object.ToCString()); |
4746 object = iterator.CurrentValue(); | 4736 object = iterator.CurrentValue(); |
4747 EXPECT_STREQ("5", object.ToCString()); | 4737 EXPECT_STREQ("5", object.ToCString()); |
4748 | 4738 |
4749 EXPECT(!iterator.MoveNext()); | 4739 EXPECT(!iterator.MoveNext()); |
4750 } | 4740 } |
4751 | 4741 |
4752 } // namespace dart | 4742 } // namespace dart |
OLD | NEW |