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

Side by Side Diff: src/spaces.h

Issue 174219: Shrink new space on compacting collections. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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/heap.cc ('k') | src/spaces.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1003
1004 // True if the space has been set up but not torn down. 1004 // True if the space has been set up but not torn down.
1005 bool HasBeenSetup() { return start_ != NULL; } 1005 bool HasBeenSetup() { return start_ != NULL; }
1006 1006
1007 // Grow the size of the semispace by committing extra virtual memory. 1007 // Grow the size of the semispace by committing extra virtual memory.
1008 // Assumes that the caller has checked that the semispace has not reached 1008 // Assumes that the caller has checked that the semispace has not reached
1009 // its maximum capacity (and thus there is space available in the reserved 1009 // its maximum capacity (and thus there is space available in the reserved
1010 // address range to grow). 1010 // address range to grow).
1011 bool Grow(); 1011 bool Grow();
1012 1012
1013 // Grow the semispace to the new capacity. The new capacity
1014 // requested must be larger than the current capacity.
1015 bool GrowTo(int new_capacity);
1016
1017 // Shrinks the semispace to the new capacity. The new capacity
1018 // requested must be more than the amount of used memory in the
1019 // semispace and less than the current capacity.
1020 bool ShrinkTo(int new_capacity);
1021
1013 // Returns the start address of the space. 1022 // Returns the start address of the space.
1014 Address low() { return start_; } 1023 Address low() { return start_; }
1015 // Returns one past the end address of the space. 1024 // Returns one past the end address of the space.
1016 Address high() { return low() + capacity_; } 1025 Address high() { return low() + capacity_; }
1017 1026
1018 // Age mark accessors. 1027 // Age mark accessors.
1019 Address age_mark() { return age_mark_; } 1028 Address age_mark() { return age_mark_; }
1020 void set_age_mark(Address mark) { age_mark_ = mark; } 1029 void set_age_mark(Address mark) { age_mark_ = mark; }
1021 1030
1022 // True if the address is in the address range of this semispace (not 1031 // True if the address is in the address range of this semispace (not
(...skipping 27 matching lines...) Expand all
1050 virtual void Print(); 1059 virtual void Print();
1051 virtual void Verify(); 1060 virtual void Verify();
1052 #endif 1061 #endif
1053 1062
1054 // Returns the current capacity of the semi space. 1063 // Returns the current capacity of the semi space.
1055 int Capacity() { return capacity_; } 1064 int Capacity() { return capacity_; }
1056 1065
1057 // Returns the maximum capacity of the semi space. 1066 // Returns the maximum capacity of the semi space.
1058 int MaximumCapacity() { return maximum_capacity_; } 1067 int MaximumCapacity() { return maximum_capacity_; }
1059 1068
1069 // Returns the initial capacity of the semi space.
1070 int InitialCapacity() { return initial_capacity_; }
1060 1071
1061 private: 1072 private:
1062 // The current and maximum capacity of the space. 1073 // The current and maximum capacity of the space.
1063 int capacity_; 1074 int capacity_;
1064 int maximum_capacity_; 1075 int maximum_capacity_;
1076 int initial_capacity_;
1065 1077
1066 // The start address of the space. 1078 // The start address of the space.
1067 Address start_; 1079 Address start_;
1068 // Used to govern object promotion during mark-compact collection. 1080 // Used to govern object promotion during mark-compact collection.
1069 Address age_mark_; 1081 Address age_mark_;
1070 1082
1071 // Masks and comparison values to test for containment in this semispace. 1083 // Masks and comparison values to test for containment in this semispace.
1072 uintptr_t address_mask_; 1084 uintptr_t address_mask_;
1073 uintptr_t object_mask_; 1085 uintptr_t object_mask_;
1074 uintptr_t object_expected_; 1086 uintptr_t object_expected_;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1157
1146 // True if the space has been set up but not torn down. 1158 // True if the space has been set up but not torn down.
1147 bool HasBeenSetup() { 1159 bool HasBeenSetup() {
1148 return to_space_.HasBeenSetup() && from_space_.HasBeenSetup(); 1160 return to_space_.HasBeenSetup() && from_space_.HasBeenSetup();
1149 } 1161 }
1150 1162
1151 // Flip the pair of spaces. 1163 // Flip the pair of spaces.
1152 void Flip(); 1164 void Flip();
1153 1165
1154 // Grow the capacity of the semispaces. Assumes that they are not at 1166 // Grow the capacity of the semispaces. Assumes that they are not at
1155 // their maximum capacity. Returns a flag indicating success or failure. 1167 // their maximum capacity.
1156 bool Grow(); 1168 void Grow();
1169
1170 // Shrink the capacity of the semispaces.
1171 void Shrink();
1157 1172
1158 // True if the address or object lies in the address range of either 1173 // True if the address or object lies in the address range of either
1159 // semispace (not necessarily below the allocation pointer). 1174 // semispace (not necessarily below the allocation pointer).
1160 bool Contains(Address a) { 1175 bool Contains(Address a) {
1161 return (reinterpret_cast<uintptr_t>(a) & address_mask_) 1176 return (reinterpret_cast<uintptr_t>(a) & address_mask_)
1162 == reinterpret_cast<uintptr_t>(start_); 1177 == reinterpret_cast<uintptr_t>(start_);
1163 } 1178 }
1164 bool Contains(Object* o) { 1179 bool Contains(Object* o) {
1165 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; 1180 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
1166 } 1181 }
1167 1182
1168 // Return the allocated bytes in the active semispace. 1183 // Return the allocated bytes in the active semispace.
1169 virtual int Size() { return top() - bottom(); } 1184 virtual int Size() { return top() - bottom(); }
1170 // Return the current capacity of a semispace. 1185 // Return the current capacity of a semispace.
1171 int Capacity() { 1186 int Capacity() {
1172 ASSERT(to_space_.Capacity() == from_space_.Capacity()); 1187 ASSERT(to_space_.Capacity() == from_space_.Capacity());
1173 return to_space_.Capacity(); 1188 return to_space_.Capacity();
1174 } 1189 }
1175 // Return the available bytes without growing in the active semispace. 1190 // Return the available bytes without growing in the active semispace.
1176 int Available() { return Capacity() - Size(); } 1191 int Available() { return Capacity() - Size(); }
1177 1192
1178 // Return the maximum capacity of a semispace. 1193 // Return the maximum capacity of a semispace.
1179 int MaximumCapacity() { 1194 int MaximumCapacity() {
1180 ASSERT(to_space_.MaximumCapacity() == from_space_.MaximumCapacity()); 1195 ASSERT(to_space_.MaximumCapacity() == from_space_.MaximumCapacity());
1181 return to_space_.MaximumCapacity(); 1196 return to_space_.MaximumCapacity();
1182 } 1197 }
1183 1198
1199 // Returns the initial capacity of a semispace.
1200 int InitialCapacity() {
1201 ASSERT(to_space_.InitialCapacity() == from_space_.InitialCapacity());
1202 return to_space_.InitialCapacity();
1203 }
1204
1184 // Return the address of the allocation pointer in the active semispace. 1205 // Return the address of the allocation pointer in the active semispace.
1185 Address top() { return allocation_info_.top; } 1206 Address top() { return allocation_info_.top; }
1186 // Return the address of the first object in the active semispace. 1207 // Return the address of the first object in the active semispace.
1187 Address bottom() { return to_space_.low(); } 1208 Address bottom() { return to_space_.low(); }
1188 1209
1189 // Get the age mark of the inactive semispace. 1210 // Get the age mark of the inactive semispace.
1190 Address age_mark() { return from_space_.age_mark(); } 1211 Address age_mark() { return from_space_.age_mark(); }
1191 // Set the age mark in the active semispace. 1212 // Set the age mark in the active semispace.
1192 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); } 1213 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); }
1193 1214
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 1863
1843 private: 1864 private:
1844 LargeObjectChunk* current_; 1865 LargeObjectChunk* current_;
1845 HeapObjectCallback size_func_; 1866 HeapObjectCallback size_func_;
1846 }; 1867 };
1847 1868
1848 1869
1849 } } // namespace v8::internal 1870 } } // namespace v8::internal
1850 1871
1851 #endif // V8_SPACES_H_ 1872 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698