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

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

Issue 2951333002: Moves the top_ and end_ words of the Scavenger into mutator thread. (Closed)
Patch Set: Removes the ZeroSizeScavenger test. Proper testing requires a second vm isolate. Created 3 years, 5 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/heap.h ('k') | runtime/vm/intrinsifier_arm.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 "vm/heap.h" 5 #include "vm/heap.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 delete new_weak_tables_[sel]; 56 delete new_weak_tables_[sel];
57 delete old_weak_tables_[sel]; 57 delete old_weak_tables_[sel];
58 } 58 }
59 } 59 }
60 60
61 61
62 uword Heap::AllocateNew(intptr_t size) { 62 uword Heap::AllocateNew(intptr_t size) {
63 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0); 63 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
64 // Currently, only the Dart thread may allocate in new space. 64 // Currently, only the Dart thread may allocate in new space.
65 isolate()->AssertCurrentThreadIsMutator(); 65 isolate()->AssertCurrentThreadIsMutator();
66 uword addr = new_space_.TryAllocate(size); 66 Thread* thread = Thread::Current();
67 uword addr = new_space_.TryAllocateInTLAB(thread, size);
67 if (addr == 0) { 68 if (addr == 0) {
68 // This call to CollectGarbage might end up "reusing" a collection spawned 69 // This call to CollectGarbage might end up "reusing" a collection spawned
69 // from a different thread and will be racing to allocate the requested 70 // from a different thread and will be racing to allocate the requested
70 // memory with other threads being released after the collection. 71 // memory with other threads being released after the collection.
71 CollectGarbage(kNew); 72 CollectGarbage(kNew);
72 addr = new_space_.TryAllocate(size); 73 addr = new_space_.TryAllocateInTLAB(thread, size);
73 if (addr == 0) { 74 if (addr == 0) {
74 return AllocateOld(size, HeapPage::kData); 75 return AllocateOld(size, HeapPage::kData);
75 } 76 }
76 } 77 }
77 return addr; 78 return addr;
78 } 79 }
79 80
80 81
81 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) { 82 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
82 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0); 83 ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 503 }
503 504
504 505
505 void Heap::WriteProtect(bool read_only) { 506 void Heap::WriteProtect(bool read_only) {
506 read_only_ = read_only; 507 read_only_ = read_only;
507 new_space_.WriteProtect(read_only); 508 new_space_.WriteProtect(read_only);
508 old_space_.WriteProtect(read_only); 509 old_space_.WriteProtect(read_only);
509 } 510 }
510 511
511 512
512 intptr_t Heap::TopOffset(Heap::Space space) {
513 if (space == kNew) {
514 return OFFSET_OF(Heap, new_space_) + Scavenger::top_offset();
515 } else {
516 ASSERT(space == kOld);
517 return OFFSET_OF(Heap, old_space_) + PageSpace::top_offset();
518 }
519 }
520
521
522 intptr_t Heap::EndOffset(Heap::Space space) {
523 if (space == kNew) {
524 return OFFSET_OF(Heap, new_space_) + Scavenger::end_offset();
525 } else {
526 ASSERT(space == kOld);
527 return OFFSET_OF(Heap, old_space_) + PageSpace::end_offset();
528 }
529 }
530
531
532 void Heap::Init(Isolate* isolate, 513 void Heap::Init(Isolate* isolate,
533 intptr_t max_new_gen_words, 514 intptr_t max_new_gen_words,
534 intptr_t max_old_gen_words, 515 intptr_t max_old_gen_words,
535 intptr_t max_external_words) { 516 intptr_t max_external_words) {
536 ASSERT(isolate->heap() == NULL); 517 ASSERT(isolate->heap() == NULL);
537 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words, 518 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words,
538 max_external_words); 519 max_external_words);
539 isolate->set_heap(heap); 520 isolate->set_heap(heap);
540 } 521 }
541 522
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 581
601 582
602 bool Heap::Verify(MarkExpectation mark_expectation) const { 583 bool Heap::Verify(MarkExpectation mark_expectation) const {
603 HeapIterationScope heap_iteration_scope; 584 HeapIterationScope heap_iteration_scope;
604 return VerifyGC(mark_expectation); 585 return VerifyGC(mark_expectation);
605 } 586 }
606 587
607 588
608 bool Heap::VerifyGC(MarkExpectation mark_expectation) const { 589 bool Heap::VerifyGC(MarkExpectation mark_expectation) const {
609 StackZone stack_zone(Thread::Current()); 590 StackZone stack_zone(Thread::Current());
591
592 // Change the new space's top_ with the more up-to-date thread's view of top_
593 new_space_.FlushTLS();
594
610 ObjectSet* allocated_set = 595 ObjectSet* allocated_set =
611 CreateAllocatedObjectSet(stack_zone.GetZone(), mark_expectation); 596 CreateAllocatedObjectSet(stack_zone.GetZone(), mark_expectation);
612 VerifyPointersVisitor visitor(isolate(), allocated_set); 597 VerifyPointersVisitor visitor(isolate(), allocated_set);
613 VisitObjectPointers(&visitor); 598 VisitObjectPointers(&visitor);
614 599
615 // Only returning a value so that Heap::Validate can be called from an ASSERT. 600 // Only returning a value so that Heap::Validate can be called from an ASSERT.
616 return true; 601 return true;
617 } 602 }
618 603
619 604
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 Dart::vm_isolate()->heap()->WriteProtect(false); 883 Dart::vm_isolate()->heap()->WriteProtect(false);
899 } 884 }
900 885
901 886
902 WritableVMIsolateScope::~WritableVMIsolateScope() { 887 WritableVMIsolateScope::~WritableVMIsolateScope() {
903 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); 888 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
904 Dart::vm_isolate()->heap()->WriteProtect(true); 889 Dart::vm_isolate()->heap()->WriteProtect(true);
905 } 890 }
906 891
907 } // namespace dart 892 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/intrinsifier_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698