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

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

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
9 #include "vm/globals.h" 10 #include "vm/globals.h"
10 #include "vm/heap.h" 11 #include "vm/heap.h"
11 #include "vm/unit_test.h" 12 #include "vm/unit_test.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 DECLARE_FLAG(int, marker_tasks); 16 DECLARE_FLAG(int, marker_tasks);
16 17
17 TEST_CASE(OldGC) { 18 TEST_CASE(OldGC) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 TEST_CASE(IterateReadOnly) { 283 TEST_CASE(IterateReadOnly) {
283 const String& obj = String::Handle(String::New("x", Heap::kOld)); 284 const String& obj = String::Handle(String::New("x", Heap::kOld));
284 Heap* heap = Thread::Current()->isolate()->heap(); 285 Heap* heap = Thread::Current()->isolate()->heap();
285 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); 286 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw())));
286 heap->WriteProtect(true); 287 heap->WriteProtect(true);
287 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); 288 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw())));
288 heap->WriteProtect(false); 289 heap->WriteProtect(false);
289 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw()))); 290 EXPECT(heap->Contains(RawObject::ToAddr(obj.raw())));
290 } 291 }
291 292
292 } // namespace dart. 293
294 void TestBecomeForward(Heap::Space before_space, Heap::Space after_space) {
295 Isolate* isolate = Isolate::Current();
296 Heap* heap = isolate->heap();
297
298 const String& before_obj = String::Handle(String::New("old", before_space));
299 const String& after_obj = String::Handle(String::New("new", after_space));
300
301 EXPECT(before_obj.raw() != after_obj.raw());
302
303 // Allocate the arrays in old space to test the remembered set.
304 const Array& before = Array::Handle(Array::New(1, Heap::kOld));
305 before.SetAt(0, before_obj);
306 const Array& after = Array::Handle(Array::New(1, Heap::kOld));
307 after.SetAt(0, after_obj);
308
309 Become::ElementsForwardIdentity(before, after);
310
311 EXPECT(before_obj.raw() == after_obj.raw());
312
313 heap->CollectAllGarbage();
314
315 EXPECT(before_obj.raw() == after_obj.raw());
316 }
317
318
319 VM_TEST_CASE(BecomeFowardOldToOld) {
320 TestBecomeForward(Heap::kOld, Heap::kOld);
321 }
322
323
324 VM_TEST_CASE(BecomeFowardNewToNew) {
325 TestBecomeForward(Heap::kNew, Heap::kNew);
326 }
327
328
329 VM_TEST_CASE(BecomeFowardOldToNew) {
330 TestBecomeForward(Heap::kOld, Heap::kNew);
331 }
332
333
334 VM_TEST_CASE(BecomeFowardNewToOld) {
335 TestBecomeForward(Heap::kNew, Heap::kOld);
336 }
337
338
339 VM_TEST_CASE(BecomeForwardRememberedObject) {
340 Isolate* isolate = Isolate::Current();
341 Heap* heap = isolate->heap();
342
343 const String& new_element = String::Handle(String::New("new", Heap::kNew));
344 const String& old_element = String::Handle(String::New("old", Heap::kOld));
345 const Array& before_obj = Array::Handle(Array::New(1, Heap::kOld));
346 const Array& after_obj = Array::Handle(Array::New(1, Heap::kOld));
347 before_obj.SetAt(0, new_element);
348 after_obj.SetAt(0, old_element);
349 EXPECT(before_obj.raw()->IsRemembered());
350 EXPECT(!after_obj.raw()->IsRemembered());
351
352 EXPECT(before_obj.raw() != after_obj.raw());
353
354 const Array& before = Array::Handle(Array::New(1, Heap::kOld));
355 before.SetAt(0, before_obj);
356 const Array& after = Array::Handle(Array::New(1, Heap::kOld));
357 after.SetAt(0, after_obj);
358
359 Become::ElementsForwardIdentity(before, after);
360
361 EXPECT(before_obj.raw() == after_obj.raw());
362 EXPECT(!after_obj.raw()->IsRemembered());
363
364 heap->CollectAllGarbage();
365
366 EXPECT(before_obj.raw() == after_obj.raw());
367 }
368
369 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698