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

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

Issue 8528010: Changes to pass the current isolate to all runtime and native calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « runtime/vm/handles.cc ('k') | runtime/vm/heap.h » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assert.h" 5 #include "vm/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"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_count = 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 HANDLESCOPE(); 52 Isolate* isolate = Isolate::Current();
53 HANDLESCOPE(isolate);
53 for (int i = 0; i < kNumHandles; i++) { 54 for (int i = 0; i < kNumHandles; i++) {
54 const Smi& handle = Smi::Handle(Smi::New(i)); 55 const Smi& handle = Smi::Handle(Smi::New(i));
55 EXPECT(handle.IsSmi()); 56 EXPECT(handle.IsSmi());
56 EXPECT_EQ(i, handle.Value()); 57 EXPECT_EQ(i, handle.Value());
57 } 58 }
58 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount()); 59 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount());
59 // Create lots of scoped handles in a loop with a nested scope. 60 // Create lots of scoped handles in a loop with a nested scope.
60 for (int loop = 0; loop < 1000; loop++) { 61 for (int loop = 0; loop < 1000; loop++) {
61 HANDLESCOPE(); 62 HANDLESCOPE(isolate);
62 for (int i = 0; i < 2; i++) { 63 for (int i = 0; i < 2; i++) {
63 const Smi& handle = Smi::Handle(Smi::New(i + loop)); 64 const Smi& handle = Smi::Handle(Smi::New(i + loop));
64 EXPECT(handle.IsSmi()); 65 EXPECT(handle.IsSmi());
65 EXPECT_EQ(i + loop, handle.Value()); 66 EXPECT_EQ(i + loop, handle.Value());
66 } 67 }
67 EXPECT_EQ((handle_count + kNumHandles + 2), 68 EXPECT_EQ((handle_count + kNumHandles + 2),
68 VMHandles::ScopedHandleCount()); 69 VMHandles::ScopedHandleCount());
69 } 70 }
70 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount()); 71 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount());
71 for (int i = 0; i < kNumHandles; i++) { 72 for (int i = 0; i < kNumHandles; i++) {
72 const Smi& handle = Smi::Handle(Smi::New(i)); 73 const Smi& handle = Smi::Handle(Smi::New(i));
73 EXPECT(handle.IsSmi()); 74 EXPECT(handle.IsSmi());
74 EXPECT_EQ(i, handle.Value()); 75 EXPECT_EQ(i, handle.Value());
75 } 76 }
76 EXPECT_EQ((handle_count + (2 * kNumHandles)), 77 EXPECT_EQ((handle_count + (2 * kNumHandles)),
77 VMHandles::ScopedHandleCount()); 78 VMHandles::ScopedHandleCount());
78 } 79 }
79 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount()); 80 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount());
80 } 81 }
81 82
82 } // namespace dart 83 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/handles.cc ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698