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

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

Issue 2143153002: Don't track allocations in product mode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: other archs Created 4 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/heap.cc ('k') | runtime/vm/object.cc » ('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/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
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
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
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
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698