| OLD | NEW |
| 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 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 last_page = new_page; | 1215 last_page = new_page; |
| 1216 } | 1216 } |
| 1217 return true; | 1217 return true; |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 | 1220 |
| 1221 bool SemiSpace::ShrinkTo(int new_capacity) { | 1221 bool SemiSpace::ShrinkTo(int new_capacity) { |
| 1222 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); | 1222 ASSERT((new_capacity & Page::kPageAlignmentMask) == 0); |
| 1223 ASSERT(new_capacity >= initial_capacity_); | 1223 ASSERT(new_capacity >= initial_capacity_); |
| 1224 ASSERT(new_capacity < capacity_); | 1224 ASSERT(new_capacity < capacity_); |
| 1225 Address end = start_ + maximum_capacity_; | 1225 // Semispaces grow backwards from the end of their allocated capacity, |
| 1226 Address start = end - new_capacity; | 1226 // so we find the before and after start addresses relative to the |
| 1227 // end of the space. |
| 1228 Address space_end = start_ + maximum_capacity_; |
| 1229 Address old_start = space_end - capacity_; |
| 1227 size_t delta = capacity_ - new_capacity; | 1230 size_t delta = capacity_ - new_capacity; |
| 1228 ASSERT(IsAligned(delta, OS::AllocateAlignment())); | 1231 ASSERT(IsAligned(delta, OS::AllocateAlignment())); |
| 1229 if (!heap()->isolate()->memory_allocator()->UncommitBlock(start, delta)) { | 1232 if (!heap()->isolate()->memory_allocator()->UncommitBlock(old_start, delta)) { |
| 1230 return false; | 1233 return false; |
| 1231 } | 1234 } |
| 1232 capacity_ = new_capacity; | 1235 capacity_ = new_capacity; |
| 1233 | 1236 |
| 1234 int pages_after = capacity_ / Page::kPageSize; | 1237 int pages_after = capacity_ / Page::kPageSize; |
| 1235 NewSpacePage* new_last_page = | 1238 NewSpacePage* new_last_page = |
| 1236 NewSpacePage::FromAddress(end - pages_after * Page::kPageSize); | 1239 NewSpacePage::FromAddress(space_end - pages_after * Page::kPageSize); |
| 1237 new_last_page->set_next_page(anchor()); | 1240 new_last_page->set_next_page(anchor()); |
| 1238 anchor()->set_prev_page(new_last_page); | 1241 anchor()->set_prev_page(new_last_page); |
| 1239 ASSERT(current_page_ == first_page()); | 1242 ASSERT(current_page_ == first_page()); |
| 1240 | 1243 |
| 1241 return true; | 1244 return true; |
| 1242 } | 1245 } |
| 1243 | 1246 |
| 1244 | 1247 |
| 1245 void SemiSpace::FlipPages(intptr_t flags, intptr_t mask) { | 1248 void SemiSpace::FlipPages(intptr_t flags, intptr_t mask) { |
| 1246 anchor_.set_owner(this); | 1249 anchor_.set_owner(this); |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 2509 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
| 2507 if (obj->IsCode()) { | 2510 if (obj->IsCode()) { |
| 2508 Code* code = Code::cast(obj); | 2511 Code* code = Code::cast(obj); |
| 2509 isolate->code_kind_statistics()[code->kind()] += code->Size(); | 2512 isolate->code_kind_statistics()[code->kind()] += code->Size(); |
| 2510 } | 2513 } |
| 2511 } | 2514 } |
| 2512 } | 2515 } |
| 2513 #endif // DEBUG | 2516 #endif // DEBUG |
| 2514 | 2517 |
| 2515 } } // namespace v8::internal | 2518 } } // namespace v8::internal |
| OLD | NEW |