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

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

Issue 1310463005: - Ensure that HandleScope is initialized with a thread. (Remove (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments Created 5 years, 3 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/handles.cc ('k') | runtime/vm/isolate.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) 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"
(...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 = 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 Thread* thread = Thread::Current();
53 HANDLESCOPE(isolate); 53 HANDLESCOPE(thread);
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());
57 EXPECT_EQ(i, handle.Value()); 57 EXPECT_EQ(i, handle.Value());
58 } 58 }
59 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount()); 59 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount());
60 // 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.
61 for (int loop = 0; loop < 1000; loop++) { 61 for (int loop = 0; loop < 1000; loop++) {
62 HANDLESCOPE(isolate); 62 HANDLESCOPE(thread);
63 for (int i = 0; i < 2; i++) { 63 for (int i = 0; i < 2; i++) {
64 const Smi& handle = Smi::Handle(Smi::New(i + loop)); 64 const Smi& handle = Smi::Handle(Smi::New(i + loop));
65 EXPECT(handle.IsSmi()); 65 EXPECT(handle.IsSmi());
66 EXPECT_EQ(i + loop, handle.Value()); 66 EXPECT_EQ(i + loop, handle.Value());
67 } 67 }
68 EXPECT_EQ((handle_count + kNumHandles + 2), 68 EXPECT_EQ((handle_count + kNumHandles + 2),
69 VMHandles::ScopedHandleCount()); 69 VMHandles::ScopedHandleCount());
70 } 70 }
71 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount()); 71 EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount());
72 for (int i = 0; i < kNumHandles; i++) { 72 for (int i = 0; i < kNumHandles; i++) {
73 const Smi& handle = Smi::Handle(Smi::New(i)); 73 const Smi& handle = Smi::Handle(Smi::New(i));
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 | « runtime/vm/handles.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698