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

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

Issue 1016503005: Rename NoGCScope -> NoSafepointScope. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | « runtime/vm/heap.cc ('k') | runtime/vm/object.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/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_LE(expected_size, after - before); 206 EXPECT_LE(expected_size, after - before);
207 EXPECT_GT(expected_size + kTolerance, after - before); 207 EXPECT_GT(expected_size + kTolerance, after - before);
208 Dart_ExitScope(); 208 Dart_ExitScope();
209 } 209 }
210 210
211 211
212 class FindOnly : public FindObjectVisitor { 212 class FindOnly : public FindObjectVisitor {
213 public: 213 public:
214 FindOnly(Isolate* isolate, RawObject* target) 214 FindOnly(Isolate* isolate, RawObject* target)
215 : FindObjectVisitor(isolate), target_(target) { 215 : FindObjectVisitor(isolate), target_(target) {
216 ASSERT(isolate->no_gc_scope_depth() != 0); 216 ASSERT(isolate->no_safepoint_scope_depth() != 0);
217 } 217 }
218 virtual ~FindOnly() { } 218 virtual ~FindOnly() { }
219 219
220 virtual bool FindObject(RawObject* obj) const { 220 virtual bool FindObject(RawObject* obj) const {
221 return obj == target_; 221 return obj == target_;
222 } 222 }
223 private: 223 private:
224 RawObject* target_; 224 RawObject* target_;
225 }; 225 };
226 226
227 227
228 class FindNothing : public FindObjectVisitor { 228 class FindNothing : public FindObjectVisitor {
229 public: 229 public:
230 FindNothing() : FindObjectVisitor(Isolate::Current()) { } 230 FindNothing() : FindObjectVisitor(Isolate::Current()) { }
231 virtual ~FindNothing() { } 231 virtual ~FindNothing() { }
232 virtual bool FindObject(RawObject* obj) const { return false; } 232 virtual bool FindObject(RawObject* obj) const { return false; }
233 }; 233 };
234 234
235 235
236 TEST_CASE(FindObject) { 236 TEST_CASE(FindObject) {
237 Isolate* isolate = Isolate::Current(); 237 Isolate* isolate = Isolate::Current();
238 Heap* heap = isolate->heap(); 238 Heap* heap = isolate->heap();
239 Heap::Space spaces[2] = {Heap::kOld, Heap::kNew}; 239 Heap::Space spaces[2] = {Heap::kOld, Heap::kNew};
240 for (size_t space = 0; space < ARRAY_SIZE(spaces); ++space) { 240 for (size_t space = 0; space < ARRAY_SIZE(spaces); ++space) {
241 const String& obj = String::Handle(String::New("x", spaces[space])); 241 const String& obj = String::Handle(String::New("x", spaces[space]));
242 { 242 {
243 NoGCScope no_gc; 243 NoSafepointScope no_safepoint;
244 FindOnly find_only(isolate, obj.raw()); 244 FindOnly find_only(isolate, obj.raw());
245 EXPECT(obj.raw() == heap->FindObject(&find_only)); 245 EXPECT(obj.raw() == heap->FindObject(&find_only));
246 } 246 }
247 } 247 }
248 { 248 {
249 NoGCScope no_gc; 249 NoSafepointScope no_safepoint;
250 FindNothing find_nothing; 250 FindNothing find_nothing;
251 EXPECT(Object::null() == heap->FindObject(&find_nothing)); 251 EXPECT(Object::null() == heap->FindObject(&find_nothing));
252 } 252 }
253 } 253 }
254 254
255 } // namespace dart. 255 } // namespace dart.
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698