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

Side by Side Diff: src/spaces.cc

Issue 9117035: Initially unmap one of the semispaces to reduce memory use at boot time. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 11 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 | « src/spaces.h ('k') | test/cctest/test-mark-compact.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 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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 #define SET_NAME(name) allocated_histogram_[name].set_name(#name); \ 915 #define SET_NAME(name) allocated_histogram_[name].set_name(#name); \
916 promoted_histogram_[name].set_name(#name); 916 promoted_histogram_[name].set_name(#name);
917 INSTANCE_TYPE_LIST(SET_NAME) 917 INSTANCE_TYPE_LIST(SET_NAME)
918 #undef SET_NAME 918 #undef SET_NAME
919 919
920 ASSERT(reserved_semispace_capacity == heap()->ReservedSemiSpaceSize()); 920 ASSERT(reserved_semispace_capacity == heap()->ReservedSemiSpaceSize());
921 ASSERT(static_cast<intptr_t>(chunk_size_) >= 921 ASSERT(static_cast<intptr_t>(chunk_size_) >=
922 2 * heap()->ReservedSemiSpaceSize()); 922 2 * heap()->ReservedSemiSpaceSize());
923 ASSERT(IsAddressAligned(chunk_base_, 2 * reserved_semispace_capacity, 0)); 923 ASSERT(IsAddressAligned(chunk_base_, 2 * reserved_semispace_capacity, 0));
924 924
925 if (!to_space_.SetUp(chunk_base_, 925 to_space_.SetUp(chunk_base_,
926 initial_semispace_capacity, 926 initial_semispace_capacity,
927 maximum_semispace_capacity)) { 927 maximum_semispace_capacity);
928 return false; 928 from_space_.SetUp(chunk_base_ + reserved_semispace_capacity,
929 } 929 initial_semispace_capacity,
930 if (!from_space_.SetUp(chunk_base_ + reserved_semispace_capacity, 930 maximum_semispace_capacity);
931 initial_semispace_capacity, 931 if (!to_space_.Commit()) {
932 maximum_semispace_capacity)) {
933 return false; 932 return false;
934 } 933 }
935 934
936 start_ = chunk_base_; 935 start_ = chunk_base_;
937 address_mask_ = ~(2 * reserved_semispace_capacity - 1); 936 address_mask_ = ~(2 * reserved_semispace_capacity - 1);
938 object_mask_ = address_mask_ | kHeapObjectTagMask; 937 object_mask_ = address_mask_ | kHeapObjectTagMask;
939 object_expected_ = reinterpret_cast<uintptr_t>(start_) | kHeapObjectTag; 938 object_expected_ = reinterpret_cast<uintptr_t>(start_) | kHeapObjectTag;
940 939
941 ResetAllocationInfo(); 940 ResetAllocationInfo();
942 941
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 ASSERT_EQ(from_space_.id(), kFromSpace); 1154 ASSERT_EQ(from_space_.id(), kFromSpace);
1156 ASSERT_EQ(to_space_.id(), kToSpace); 1155 ASSERT_EQ(to_space_.id(), kToSpace);
1157 from_space_.Verify(); 1156 from_space_.Verify();
1158 to_space_.Verify(); 1157 to_space_.Verify();
1159 } 1158 }
1160 #endif 1159 #endif
1161 1160
1162 // ----------------------------------------------------------------------------- 1161 // -----------------------------------------------------------------------------
1163 // SemiSpace implementation 1162 // SemiSpace implementation
1164 1163
1165 bool SemiSpace::SetUp(Address start, 1164 void SemiSpace::SetUp(Address start,
1166 int initial_capacity, 1165 int initial_capacity,
1167 int maximum_capacity) { 1166 int maximum_capacity) {
1168 // Creates a space in the young generation. The constructor does not 1167 // Creates a space in the young generation. The constructor does not
1169 // allocate memory from the OS. A SemiSpace is given a contiguous chunk of 1168 // allocate memory from the OS. A SemiSpace is given a contiguous chunk of
1170 // memory of size 'capacity' when set up, and does not grow or shrink 1169 // memory of size 'capacity' when set up, and does not grow or shrink
1171 // otherwise. In the mark-compact collector, the memory region of the from 1170 // otherwise. In the mark-compact collector, the memory region of the from
1172 // space is used as the marking stack. It requires contiguous memory 1171 // space is used as the marking stack. It requires contiguous memory
1173 // addresses. 1172 // addresses.
1174 ASSERT(maximum_capacity >= Page::kPageSize); 1173 ASSERT(maximum_capacity >= Page::kPageSize);
1175 initial_capacity_ = RoundDown(initial_capacity, Page::kPageSize); 1174 initial_capacity_ = RoundDown(initial_capacity, Page::kPageSize);
1176 capacity_ = initial_capacity; 1175 capacity_ = initial_capacity;
1177 maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize); 1176 maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize);
1178 committed_ = false; 1177 committed_ = false;
1179 start_ = start; 1178 start_ = start;
1180 address_mask_ = ~(maximum_capacity - 1); 1179 address_mask_ = ~(maximum_capacity - 1);
1181 object_mask_ = address_mask_ | kHeapObjectTagMask; 1180 object_mask_ = address_mask_ | kHeapObjectTagMask;
1182 object_expected_ = reinterpret_cast<uintptr_t>(start) | kHeapObjectTag; 1181 object_expected_ = reinterpret_cast<uintptr_t>(start) | kHeapObjectTag;
1183 age_mark_ = start_; 1182 age_mark_ = start_;
1184
1185 return Commit();
1186 } 1183 }
1187 1184
1188 1185
1189 void SemiSpace::TearDown() { 1186 void SemiSpace::TearDown() {
1190 start_ = NULL; 1187 start_ = NULL;
1191 capacity_ = 0; 1188 capacity_ = 0;
1192 } 1189 }
1193 1190
1194 1191
1195 bool SemiSpace::Commit() { 1192 bool SemiSpace::Commit() {
(...skipping 29 matching lines...) Expand all
1225 } 1222 }
1226 anchor()->set_next_page(anchor()); 1223 anchor()->set_next_page(anchor());
1227 anchor()->set_prev_page(anchor()); 1224 anchor()->set_prev_page(anchor());
1228 1225
1229 committed_ = false; 1226 committed_ = false;
1230 return true; 1227 return true;
1231 } 1228 }
1232 1229
1233 1230
1234 bool SemiSpace::GrowTo(int new_capacity) { 1231 bool SemiSpace::GrowTo(int new_capacity) {
1232 if (!is_committed()) {
1233 bool ok = Commit();
1234 if (!ok) return false;
Vyacheslav Egorov (Chromium) 2012/01/24 15:57:37 if (!Commit()) return false;
1235 }
1235 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); 1236 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0);
1236 ASSERT(new_capacity <= maximum_capacity_); 1237 ASSERT(new_capacity <= maximum_capacity_);
1237 ASSERT(new_capacity > capacity_); 1238 ASSERT(new_capacity > capacity_);
1238 int pages_before = capacity_ / Page::kPageSize; 1239 int pages_before = capacity_ / Page::kPageSize;
1239 int pages_after = new_capacity / Page::kPageSize; 1240 int pages_after = new_capacity / Page::kPageSize;
1240 1241
1241 Address end = start_ + maximum_capacity_; 1242 Address end = start_ + maximum_capacity_;
1242 Address start = end - new_capacity; 1243 Address start = end - new_capacity;
1243 size_t delta = new_capacity - capacity_; 1244 size_t delta = new_capacity - capacity_;
1244 1245
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 object->ShortPrint(); 2675 object->ShortPrint();
2675 PrintF("\n"); 2676 PrintF("\n");
2676 } 2677 }
2677 printf(" --------------------------------------\n"); 2678 printf(" --------------------------------------\n");
2678 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 2679 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
2679 } 2680 }
2680 2681
2681 #endif // DEBUG 2682 #endif // DEBUG
2682 2683
2683 } } // namespace v8::internal 2684 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698