| 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 "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/become.h" | 8 #include "vm/become.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 EXPECT(Dart_IsList(result)); | 67 EXPECT(Dart_IsList(result)); |
| 68 TransitionNativeToVM transition(thread); | 68 TransitionNativeToVM transition(thread); |
| 69 Isolate* isolate = Isolate::Current(); | 69 Isolate* isolate = Isolate::Current(); |
| 70 Heap* heap = isolate->heap(); | 70 Heap* heap = isolate->heap(); |
| 71 heap->CollectGarbage(Heap::kOld); | 71 heap->CollectGarbage(Heap::kOld); |
| 72 Dart_ExitScope(); | 72 Dart_ExitScope(); |
| 73 heap->CollectGarbage(Heap::kOld); | 73 heap->CollectGarbage(Heap::kOld); |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 #ifndef PRODUCT |
| 77 class ClassHeapStatsTestHelper { | 78 class ClassHeapStatsTestHelper { |
| 78 public: | 79 public: |
| 79 static ClassHeapStats* GetHeapStatsForCid(ClassTable* class_table, | 80 static ClassHeapStats* GetHeapStatsForCid(ClassTable* class_table, |
| 80 intptr_t cid) { | 81 intptr_t cid) { |
| 81 return class_table->PreliminaryStatsAt(cid); | 82 return class_table->PreliminaryStatsAt(cid); |
| 82 } | 83 } |
| 83 | 84 |
| 84 static void DumpClassHeapStats(ClassHeapStats* stats) { | 85 static void DumpClassHeapStats(ClassHeapStats* stats) { |
| 85 OS::Print("%" Pd " ", stats->recent.new_count); | 86 OS::Print("%" Pd " ", stats->recent.new_count); |
| 86 OS::Print("%" Pd " ", stats->post_gc.new_count); | 87 OS::Print("%" Pd " ", stats->post_gc.new_count); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 EXPECT(!Dart_IsNull(result2)); | 225 EXPECT(!Dart_IsNull(result2)); |
| 225 intptr_t after = class_stats->recent.new_size; | 226 intptr_t after = class_stats->recent.new_size; |
| 226 const intptr_t expected_size = Array::InstanceSize(1234); | 227 const intptr_t expected_size = Array::InstanceSize(1234); |
| 227 // Invoking the method might involve some additional tiny array allocations, | 228 // Invoking the method might involve some additional tiny array allocations, |
| 228 // so we allow slightly more than expected. | 229 // so we allow slightly more than expected. |
| 229 static const intptr_t kTolerance = 10 * kWordSize; | 230 static const intptr_t kTolerance = 10 * kWordSize; |
| 230 EXPECT_LE(expected_size, after - before); | 231 EXPECT_LE(expected_size, after - before); |
| 231 EXPECT_GT(expected_size + kTolerance, after - before); | 232 EXPECT_GT(expected_size + kTolerance, after - before); |
| 232 Dart_ExitScope(); | 233 Dart_ExitScope(); |
| 233 } | 234 } |
| 235 #endif // !PRODUCT |
| 234 | 236 |
| 235 | 237 |
| 236 class FindOnly : public FindObjectVisitor { | 238 class FindOnly : public FindObjectVisitor { |
| 237 public: | 239 public: |
| 238 explicit FindOnly(RawObject* target) : target_(target) { | 240 explicit FindOnly(RawObject* target) : target_(target) { |
| 239 #if defined(DEBUG) | 241 #if defined(DEBUG) |
| 240 EXPECT_GT(Thread::Current()->no_safepoint_scope_depth(), 0); | 242 EXPECT_GT(Thread::Current()->no_safepoint_scope_depth(), 0); |
| 241 #endif | 243 #endif |
| 242 } | 244 } |
| 243 virtual ~FindOnly() { } | 245 virtual ~FindOnly() { } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 360 |
| 359 EXPECT(before_obj.raw() == after_obj.raw()); | 361 EXPECT(before_obj.raw() == after_obj.raw()); |
| 360 EXPECT(!after_obj.raw()->IsRemembered()); | 362 EXPECT(!after_obj.raw()->IsRemembered()); |
| 361 | 363 |
| 362 heap->CollectAllGarbage(); | 364 heap->CollectAllGarbage(); |
| 363 | 365 |
| 364 EXPECT(before_obj.raw() == after_obj.raw()); | 366 EXPECT(before_obj.raw() == after_obj.raw()); |
| 365 } | 367 } |
| 366 | 368 |
| 367 } // namespace dart | 369 } // namespace dart |
| OLD | NEW |