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

Side by Side Diff: vm/handles_test.cc

Issue 11879005: Added code to trace zone and handles creation/deletion under flags (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 | « vm/handles_impl.h ('k') | vm/zone.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/assert.h" 5 #include "platform/assert.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 #include "vm/handles.h" 7 #include "vm/handles.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
11 #include "vm/zone.h" 11 #include "vm/zone.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 DECLARE_DEBUG_FLAG(bool, trace_handles_count); 15 DECLARE_DEBUG_FLAG(bool, trace_handles);
16 16
17 17
18 // Unit test for Zone handle allocation. 18 // Unit test for Zone handle allocation.
19 TEST_CASE(AllocateZoneHandle) { 19 TEST_CASE(AllocateZoneHandle) {
20 #if defined(DEBUG) 20 #if defined(DEBUG)
21 FLAG_trace_handles_count = true; 21 FLAG_trace_handles = true;
22 #endif 22 #endif
23 // The previously run stub code generation may have created zone handles. 23 // The previously run stub code generation may have created zone handles.
24 int initial_count = VMHandles::ZoneHandleCount(); 24 int initial_count = VMHandles::ZoneHandleCount();
25 static const int kNumHandles = 65; 25 static const int kNumHandles = 65;
26 // Create some zone handles. 26 // Create some zone handles.
27 for (int i = 0; i < kNumHandles; i++) { 27 for (int i = 0; i < kNumHandles; i++) {
28 const Smi& handle = Smi::ZoneHandle(Smi::New(i)); 28 const Smi& handle = Smi::ZoneHandle(Smi::New(i));
29 EXPECT(handle.IsSmi()); 29 EXPECT(handle.IsSmi());
30 EXPECT_EQ(i, handle.Value()); 30 EXPECT_EQ(i, handle.Value());
31 } 31 }
32 EXPECT_EQ(kNumHandles + initial_count, VMHandles::ZoneHandleCount()); 32 EXPECT_EQ(kNumHandles + initial_count, VMHandles::ZoneHandleCount());
33 // Create some more zone handles. 33 // Create some more zone handles.
34 for (int i = kNumHandles; i < (2 * kNumHandles); i++) { 34 for (int i = kNumHandles; i < (2 * kNumHandles); i++) {
35 const Smi& handle = Smi::ZoneHandle(Smi::New(i)); 35 const Smi& handle = Smi::ZoneHandle(Smi::New(i));
36 EXPECT(handle.IsSmi()); 36 EXPECT(handle.IsSmi());
37 EXPECT_EQ(i, handle.Value()); 37 EXPECT_EQ(i, handle.Value());
38 } 38 }
39 EXPECT_EQ((2 * kNumHandles) + initial_count, VMHandles::ZoneHandleCount()); 39 EXPECT_EQ((2 * kNumHandles) + initial_count, VMHandles::ZoneHandleCount());
40 } 40 }
41 41
42 42
43 // Unit test for Scope handle allocation. 43 // Unit test for Scope handle allocation.
44 TEST_CASE(AllocateScopeHandle) { 44 TEST_CASE(AllocateScopeHandle) {
45 #if defined(DEBUG) 45 #if defined(DEBUG)
46 FLAG_trace_handles_count = true; 46 FLAG_trace_handles = true;
47 #endif 47 #endif
48 int32_t handle_count = VMHandles::ScopedHandleCount(); 48 int32_t handle_count = VMHandles::ScopedHandleCount();
49 static const int kNumHandles = 65; 49 static const int kNumHandles = 65;
50 // Create some scoped handles. 50 // Create some scoped handles.
51 { 51 {
52 Isolate* isolate = Isolate::Current(); 52 Isolate* isolate = Isolate::Current();
53 HANDLESCOPE(isolate); 53 HANDLESCOPE(isolate);
54 for (int i = 0; i < kNumHandles; i++) { 54 for (int i = 0; i < kNumHandles; i++) {
55 const Smi& handle = Smi::Handle(Smi::New(i)); 55 const Smi& handle = Smi::Handle(Smi::New(i));
56 EXPECT(handle.IsSmi()); 56 EXPECT(handle.IsSmi());
(...skipping 17 matching lines...) Expand all
74 EXPECT(handle.IsSmi()); 74 EXPECT(handle.IsSmi());
75 EXPECT_EQ(i, handle.Value()); 75 EXPECT_EQ(i, handle.Value());
76 } 76 }
77 EXPECT_EQ((handle_count + (2 * kNumHandles)), 77 EXPECT_EQ((handle_count + (2 * kNumHandles)),
78 VMHandles::ScopedHandleCount()); 78 VMHandles::ScopedHandleCount());
79 } 79 }
80 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount()); 80 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount());
81 } 81 }
82 82
83 } // namespace dart 83 } // namespace dart
OLDNEW
« no previous file with comments | « vm/handles_impl.h ('k') | vm/zone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698