OLD | NEW |
---|---|
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/pages.h" | 5 #include "vm/pages.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/compiler_stats.h" | 8 #include "vm/compiler_stats.h" |
9 #include "vm/gc_marker.h" | 9 #include "vm/gc_marker.h" |
10 #include "vm/gc_sweeper.h" | 10 #include "vm/gc_sweeper.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 HeapPage* page_; | 497 HeapPage* page_; |
498 }; | 498 }; |
499 | 499 |
500 | 500 |
501 void PageSpace::MakeIterable() const { | 501 void PageSpace::MakeIterable() const { |
502 // Assert not called from concurrent sweeper task. | 502 // Assert not called from concurrent sweeper task. |
503 // TODO(koda): Use thread/task identity when implemented. | 503 // TODO(koda): Use thread/task identity when implemented. |
504 ASSERT(Isolate::Current()->heap() != NULL); | 504 ASSERT(Isolate::Current()->heap() != NULL); |
505 if (bump_top_ < bump_end_) { | 505 if (bump_top_ < bump_end_) { |
506 FreeListElement::AsElement(bump_top_, bump_end_ - bump_top_); | 506 FreeListElement::AsElement(bump_top_, bump_end_ - bump_top_); |
507 } | 507 } |
siva
2015/04/15 16:11:56
Is it ok to still have bump_top_ and bump_end_ poi
koda
2015/04/15 16:24:06
The call only writes a header to the block, but do
| |
508 } | 508 } |
509 | 509 |
510 | 510 |
511 void PageSpace::AbandonBumpAllocation() { | |
512 if (bump_top_ < bump_end_) { | |
513 freelist_[HeapPage::kData].Free(bump_top_, bump_end_ - bump_top_); | |
514 bump_top_ = 0; | |
515 bump_end_ = 0; | |
516 } | |
517 } | |
518 | |
519 | |
511 bool PageSpace::Contains(uword addr) const { | 520 bool PageSpace::Contains(uword addr) const { |
512 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { | 521 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { |
513 if (it.page()->Contains(addr)) { | 522 if (it.page()->Contains(addr)) { |
514 return true; | 523 return true; |
515 } | 524 } |
516 } | 525 } |
517 return false; | 526 return false; |
518 } | 527 } |
519 | 528 |
520 | 529 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 if (obj != Object::null()) { | 607 if (obj != Object::null()) { |
599 return obj; | 608 return obj; |
600 } | 609 } |
601 } | 610 } |
602 } | 611 } |
603 return Object::null(); | 612 return Object::null(); |
604 } | 613 } |
605 | 614 |
606 | 615 |
607 void PageSpace::WriteProtect(bool read_only) { | 616 void PageSpace::WriteProtect(bool read_only) { |
617 if (read_only) { | |
618 // Avoid MakeIterable trying to write to the heap. | |
619 AbandonBumpAllocation(); | |
620 } | |
608 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { | 621 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { |
609 it.page()->WriteProtect(read_only); | 622 it.page()->WriteProtect(read_only); |
610 } | 623 } |
611 } | 624 } |
612 | 625 |
613 | 626 |
614 void PageSpace::PrintToJSONObject(JSONObject* object) { | 627 void PageSpace::PrintToJSONObject(JSONObject* object) { |
615 Isolate* isolate = Isolate::Current(); | 628 Isolate* isolate = Isolate::Current(); |
616 ASSERT(isolate != NULL); | 629 ASSERT(isolate != NULL); |
617 JSONObject space(object, "old"); | 630 JSONObject space(object, "old"); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 | 786 |
774 // Mark all reachable old-gen objects. | 787 // Mark all reachable old-gen objects. |
775 bool collect_code = FLAG_collect_code && ShouldCollectCode(); | 788 bool collect_code = FLAG_collect_code && ShouldCollectCode(); |
776 GCMarker marker(heap_); | 789 GCMarker marker(heap_); |
777 marker.MarkObjects(isolate, this, invoke_api_callbacks, collect_code); | 790 marker.MarkObjects(isolate, this, invoke_api_callbacks, collect_code); |
778 usage_.used_in_words = marker.marked_words(); | 791 usage_.used_in_words = marker.marked_words(); |
779 | 792 |
780 int64_t mid1 = OS::GetCurrentTimeMicros(); | 793 int64_t mid1 = OS::GetCurrentTimeMicros(); |
781 | 794 |
782 // Abandon the remainder of the bump allocation block. | 795 // Abandon the remainder of the bump allocation block. |
783 MakeIterable(); | 796 AbandonBumpAllocation(); |
784 bump_top_ = 0; | |
785 bump_end_ = 0; | |
786 // Reset the freelists and setup sweeping. | 797 // Reset the freelists and setup sweeping. |
787 freelist_[HeapPage::kData].Reset(); | 798 freelist_[HeapPage::kData].Reset(); |
788 freelist_[HeapPage::kExecutable].Reset(); | 799 freelist_[HeapPage::kExecutable].Reset(); |
789 | 800 |
790 int64_t mid2 = OS::GetCurrentTimeMicros(); | 801 int64_t mid2 = OS::GetCurrentTimeMicros(); |
791 int64_t mid3 = 0; | 802 int64_t mid3 = 0; |
792 | 803 |
793 { | 804 { |
794 if (FLAG_verify_before_gc) { | 805 if (FLAG_verify_before_gc) { |
795 OS::PrintErr("Verifying before sweeping..."); | 806 OS::PrintErr("Verifying before sweeping..."); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 return 0; | 1128 return 0; |
1118 } else { | 1129 } else { |
1119 ASSERT(total_time >= gc_time); | 1130 ASSERT(total_time >= gc_time); |
1120 int result = static_cast<int>((static_cast<double>(gc_time) / | 1131 int result = static_cast<int>((static_cast<double>(gc_time) / |
1121 static_cast<double>(total_time)) * 100); | 1132 static_cast<double>(total_time)) * 100); |
1122 return result; | 1133 return result; |
1123 } | 1134 } |
1124 } | 1135 } |
1125 | 1136 |
1126 } // namespace dart | 1137 } // namespace dart |
OLD | NEW |