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

Side by Side Diff: runtime/vm/pages.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/object_graph_test.cc ('k') | runtime/vm/profiler_service.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/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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 441 }
442 HeapPage* page() const { return page_; } 442 HeapPage* page() const { return page_; }
443 bool Done() const { return page_ == NULL; } 443 bool Done() const { return page_ == NULL; }
444 void Advance() { 444 void Advance() {
445 ASSERT(!Done()); 445 ASSERT(!Done());
446 page_ = space_->NextPageAnySize(page_); 446 page_ = space_->NextPageAnySize(page_);
447 } 447 }
448 private: 448 private:
449 const PageSpace* space_; 449 const PageSpace* space_;
450 MutexLocker ml_; 450 MutexLocker ml_;
451 NoGCScope no_gc; 451 NoSafepointScope no_safepoint;
452 HeapPage* page_; 452 HeapPage* page_;
453 }; 453 };
454 454
455 455
456 // Provides exclusive access to code pages, and ensures they are walkable. 456 // Provides exclusive access to code pages, and ensures they are walkable.
457 // NOTE: This does not iterate over large pages which can contain code. 457 // NOTE: This does not iterate over large pages which can contain code.
458 class ExclusiveCodePageIterator : ValueObject { 458 class ExclusiveCodePageIterator : ValueObject {
459 public: 459 public:
460 explicit ExclusiveCodePageIterator(const PageSpace* space) 460 explicit ExclusiveCodePageIterator(const PageSpace* space)
461 : space_(space), ml_(space->pages_lock_) { 461 : space_(space), ml_(space->pages_lock_) {
462 space_->MakeIterable(); 462 space_->MakeIterable();
463 page_ = space_->exec_pages_; 463 page_ = space_->exec_pages_;
464 } 464 }
465 HeapPage* page() const { return page_; } 465 HeapPage* page() const { return page_; }
466 bool Done() const { return page_ == NULL; } 466 bool Done() const { return page_ == NULL; }
467 void Advance() { 467 void Advance() {
468 ASSERT(!Done()); 468 ASSERT(!Done());
469 page_ = page_->next(); 469 page_ = page_->next();
470 } 470 }
471 private: 471 private:
472 const PageSpace* space_; 472 const PageSpace* space_;
473 MutexLocker ml_; 473 MutexLocker ml_;
474 NoGCScope no_gc; 474 NoSafepointScope no_safepoint;
475 HeapPage* page_; 475 HeapPage* page_;
476 }; 476 };
477 477
478 478
479 // Provides exclusive access to large pages, and ensures they are walkable. 479 // Provides exclusive access to large pages, and ensures they are walkable.
480 class ExclusiveLargePageIterator : ValueObject { 480 class ExclusiveLargePageIterator : ValueObject {
481 public: 481 public:
482 explicit ExclusiveLargePageIterator(const PageSpace* space) 482 explicit ExclusiveLargePageIterator(const PageSpace* space)
483 : space_(space), ml_(space->pages_lock_) { 483 : space_(space), ml_(space->pages_lock_) {
484 space_->MakeIterable(); 484 space_->MakeIterable();
485 page_ = space_->large_pages_; 485 page_ = space_->large_pages_;
486 } 486 }
487 HeapPage* page() const { return page_; } 487 HeapPage* page() const { return page_; }
488 bool Done() const { return page_ == NULL; } 488 bool Done() const { return page_ == NULL; }
489 void Advance() { 489 void Advance() {
490 ASSERT(!Done()); 490 ASSERT(!Done());
491 page_ = page_->next(); 491 page_ = page_->next();
492 } 492 }
493 private: 493 private:
494 const PageSpace* space_; 494 const PageSpace* space_;
495 MutexLocker ml_; 495 MutexLocker ml_;
496 NoGCScope no_gc; 496 NoSafepointScope no_safepoint;
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_);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 { 663 {
664 JSONObject class_list(&heap_map, "class_list"); 664 JSONObject class_list(&heap_map, "class_list");
665 isolate->class_table()->PrintToJSONObject(&class_list); 665 isolate->class_table()->PrintToJSONObject(&class_list);
666 } 666 }
667 { 667 {
668 // "pages" is an array [page0, page1, ..., pageN], each page of the form 668 // "pages" is an array [page0, page1, ..., pageN], each page of the form
669 // {"object_start": "0x...", "objects": [size, class id, size, ...]} 669 // {"object_start": "0x...", "objects": [size, class id, size, ...]}
670 // TODO(19445): Use ExclusivePageIterator once HeapMap supports large pages. 670 // TODO(19445): Use ExclusivePageIterator once HeapMap supports large pages.
671 MutexLocker ml(pages_lock_); 671 MutexLocker ml(pages_lock_);
672 MakeIterable(); 672 MakeIterable();
673 NoGCScope no_gc; 673 NoSafepointScope no_safepoint;
674 JSONArray all_pages(&heap_map, "pages"); 674 JSONArray all_pages(&heap_map, "pages");
675 for (HeapPage* page = pages_; page != NULL; page = page->next()) { 675 for (HeapPage* page = pages_; page != NULL; page = page->next()) {
676 JSONObject page_container(&all_pages); 676 JSONObject page_container(&all_pages);
677 page_container.AddPropertyF("object_start", 677 page_container.AddPropertyF("object_start",
678 "0x%" Px "", page->object_start()); 678 "0x%" Px "", page->object_start());
679 JSONArray page_map(&page_container, "objects"); 679 JSONArray page_map(&page_container, "objects");
680 HeapMapAsJSONVisitor printer(&page_map); 680 HeapMapAsJSONVisitor printer(&page_map);
681 page->VisitObjects(&printer); 681 page->VisitObjects(&printer);
682 } 682 }
683 for (HeapPage* page = exec_pages_; page != NULL; page = page->next()) { 683 for (HeapPage* page = exec_pages_; page != NULL; page = page->next()) {
(...skipping 22 matching lines...) Expand all
706 page_space_controller_.set_last_code_collection_in_us(start); 706 page_space_controller_.set_last_code_collection_in_us(start);
707 return true; 707 return true;
708 } 708 }
709 return false; 709 return false;
710 } 710 }
711 711
712 712
713 void PageSpace::WriteProtectCode(bool read_only) { 713 void PageSpace::WriteProtectCode(bool read_only) {
714 if (FLAG_write_protect_code) { 714 if (FLAG_write_protect_code) {
715 MutexLocker ml(pages_lock_); 715 MutexLocker ml(pages_lock_);
716 NoGCScope no_gc; 716 NoSafepointScope no_safepoint;
717 // No need to go through all of the data pages first. 717 // No need to go through all of the data pages first.
718 HeapPage* page = exec_pages_; 718 HeapPage* page = exec_pages_;
719 while (page != NULL) { 719 while (page != NULL) {
720 ASSERT(page->type() == HeapPage::kExecutable); 720 ASSERT(page->type() == HeapPage::kExecutable);
721 page->WriteProtect(read_only); 721 page->WriteProtect(read_only);
722 page = page->next(); 722 page = page->next();
723 } 723 }
724 page = large_pages_; 724 page = large_pages_;
725 while (page != NULL) { 725 while (page != NULL) {
726 if (page->type() == HeapPage::kExecutable) { 726 if (page->type() == HeapPage::kExecutable) {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 return 0; 1117 return 0;
1118 } else { 1118 } else {
1119 ASSERT(total_time >= gc_time); 1119 ASSERT(total_time >= gc_time);
1120 int result = static_cast<int>((static_cast<double>(gc_time) / 1120 int result = static_cast<int>((static_cast<double>(gc_time) /
1121 static_cast<double>(total_time)) * 100); 1121 static_cast<double>(total_time)) * 100);
1122 return result; 1122 return result;
1123 } 1123 }
1124 } 1124 }
1125 1125
1126 } // namespace dart 1126 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_graph_test.cc ('k') | runtime/vm/profiler_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698