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

Side by Side Diff: src/spaces.cc

Issue 7121009: Multi-page newspace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 // that it works (it depends on the invariants we are checking). 1042 // that it works (it depends on the invariants we are checking).
1043 void NewSpace::Verify() { 1043 void NewSpace::Verify() {
1044 // The allocation pointer should be in the space or at the very end. 1044 // The allocation pointer should be in the space or at the very end.
1045 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 1045 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
1046 1046
1047 // There should be objects packed in from the low address up to the 1047 // There should be objects packed in from the low address up to the
1048 // allocation pointer. 1048 // allocation pointer.
1049 NewSpacePage* page = to_space_.first_page(); 1049 NewSpacePage* page = to_space_.first_page();
1050 Address current = page->body(); 1050 Address current = page->body();
1051 CHECK_EQ(current, to_space_.space_low()); 1051 CHECK_EQ(current, to_space_.space_low());
1052 CHECK(end_page->ContainsLimit(top()));
1053 1052
1054 while (current != top()) { 1053 while (current != top()) {
1055 if (current == page->body_limit()) { 1054 if (current == page->body_limit()) {
1056 // At end of page, switch to next page. 1055 // At end of page, switch to next page.
1057 page = page->next_page(); 1056 page = page->next_page();
1058 // Next page should be valid. 1057 // Next page should be valid.
1059 CHECK(!page->is_anchor()); 1058 CHECK(!page->is_anchor());
1060 current = page->body(); 1059 current = page->body();
1061 } 1060 }
1062 // The allocation pointer should not be in the middle of an object. 1061 // The allocation pointer should not be in the middle of an object.
(...skipping 26 matching lines...) Expand all
1089 ASSERT_EQ(from_space_.id(), kFromSpace); 1088 ASSERT_EQ(from_space_.id(), kFromSpace);
1090 ASSERT_EQ(to_space_.id(), kToSpace); 1089 ASSERT_EQ(to_space_.id(), kToSpace);
1091 from_space_.Verify(); 1090 from_space_.Verify();
1092 to_space_.Verify(); 1091 to_space_.Verify();
1093 } 1092 }
1094 #endif 1093 #endif
1095 1094
1096 1095
1097 bool SemiSpace::Commit() { 1096 bool SemiSpace::Commit() {
1098 ASSERT(!is_committed()); 1097 ASSERT(!is_committed());
1099 // TODO(gc): Rewrite completely when switching to n-page new-space. 1098 int pages = capacity_ / Page::kPageSize;
1100 // Create one page. 1099 if (!heap()->isolate()->memory_allocator()->CommitBlock(start_,
1101 int pagesize = Page::kPageSize; 1100 capacity_,
1102 if (!heap()->isolate()->memory_allocator()->CommitBlock( 1101 executable())) {
1103 start_, pagesize, executable())) {
1104 return false; 1102 return false;
1105 } 1103 }
1106 NewSpacePage* page = NewSpacePage::Initialize(heap(), start_, this);
1107 page->InsertAfter(&anchor_);
1108 1104
1109 // Maybe create a second. 1105 NewSpacePage* page = anchor();
1110 if (capacity_ >= 2 * pagesize) { 1106 for (int i = 0; i < pages; i++) {
1111 Address last_page_address = 1107 NewSpacePage* new_page =
1112 start_ + ((capacity_ - pagesize) & ~Page::kPageAlignmentMask); 1108 NewSpacePage::Initialize(heap(), start_ + i * Page::kPageSize, this);
1113 if (heap()->isolate()->memory_allocator()->CommitBlock( 1109 new_page->InsertAfter(page);
1114 last_page_address, pagesize, executable())) { 1110 page = new_page;
1115 NewSpacePage* last_page = NewSpacePage::Initialize(heap(),
1116 last_page_address,
1117 this);
1118 last_page->InsertAfter(page);
1119 } else {
1120 UNREACHABLE(); // TODO(gc): Don't rely on this. Splitting the commit
1121 // is only temporary.
1122 }
1123 } 1111 }
1124 1112
1125 committed_ = true; 1113 committed_ = true;
1126 Reset(); 1114 Reset();
1127 return true; 1115 return true;
1128 } 1116 }
1129 1117
1130 1118
1131 bool SemiSpace::Uncommit() { 1119 bool SemiSpace::Uncommit() {
1132 ASSERT(is_committed()); 1120 ASSERT(is_committed());
1133 // TODO(gc): Rewrite completely when switching to n-page new-space. 1121 if (!heap()->isolate()->memory_allocator()->UncommitBlock(start_,
1134 NewSpacePage* last_page = anchor()->prev_page(); 1122 capacity_)) {
1135 while (last_page != anchor()) { 1123 return false;
1136 NewSpacePage* temp_page = last_page->prev_page();
1137 last_page->Unlink();
1138 if (!heap()->isolate()->memory_allocator()->UncommitBlock(
1139 last_page->address(), Page::kPageSize)) {
1140 return false;
1141 }
1142 last_page = temp_page;
1143 } 1124 }
1125 anchor()->set_next_page(anchor());
1126 anchor()->set_prev_page(anchor());
1144 1127
1145 committed_ = false; 1128 committed_ = false;
1146 return true; 1129 return true;
1147 } 1130 }
1148 1131
1149 1132
1150 void SemiSpace::Reset() { 1133 void SemiSpace::Reset() {
1151 ASSERT(anchor_.next_page() != &anchor_); 1134 ASSERT(anchor_.next_page() != &anchor_);
1152 current_page_ = anchor_.next_page(); 1135 current_page_ = anchor_.next_page();
1153 } 1136 }
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { 2427 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) {
2445 if (obj->IsCode()) { 2428 if (obj->IsCode()) {
2446 Code* code = Code::cast(obj); 2429 Code* code = Code::cast(obj);
2447 isolate->code_kind_statistics()[code->kind()] += code->Size(); 2430 isolate->code_kind_statistics()[code->kind()] += code->Size();
2448 } 2431 }
2449 } 2432 }
2450 } 2433 }
2451 #endif // DEBUG 2434 #endif // DEBUG
2452 2435
2453 } } // namespace v8::internal 2436 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698