Chromium Code Reviews| 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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1202 inline bool OldGenerationPromotionLimitReached() { | 1202 inline bool OldGenerationPromotionLimitReached() { |
| 1203 return (PromotedSpaceSize() + PromotedExternalMemorySize()) | 1203 return (PromotedSpaceSize() + PromotedExternalMemorySize()) |
| 1204 > old_gen_promotion_limit_; | 1204 > old_gen_promotion_limit_; |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 inline intptr_t OldGenerationSpaceAvailable() { | 1207 inline intptr_t OldGenerationSpaceAvailable() { |
| 1208 return old_gen_allocation_limit_ - | 1208 return old_gen_allocation_limit_ - |
| 1209 (PromotedSpaceSize() + PromotedExternalMemorySize()); | 1209 (PromotedSpaceSize() + PromotedExternalMemorySize()); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 inline void LowerOldGenLimits(intptr_t bytes) { | 1212 static const intptr_t kMinimumPromotionLimit = |
| 1213 old_gen_promotion_limit_ -= bytes; | 1213 2 * (Page::kPageSize > MB ? Page::kPageSize : MB); |
| 1214 old_gen_allocation_limit_ -= bytes; | 1214 static const intptr_t kMinimumAllocationLimit = |
| 1215 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); | |
| 1216 | |
| 1217 // When we sweep lazily we initially guess that there is no garbage on the | |
| 1218 // heap and set the limits for the next GC accordingly. As we sweep we find | |
| 1219 // out that some of the pages contained garbage and we have to adjust | |
| 1220 // downwards the size of the heap. This means the limits that control the | |
| 1221 // timing of the next GC also need to be adjusted downwards. | |
| 1222 void LowerOldGenLimits(intptr_t adjustment) { | |
| 1223 size_of_old_gen_at_last_old_space_gc_ -= adjustment; | |
| 1224 old_gen_promotion_limit_ = | |
| 1225 OldGenPromotionLimit(size_of_old_gen_at_last_old_space_gc_); | |
| 1226 old_gen_allocation_limit_ = | |
| 1227 OldGenAllocationLimit(size_of_old_gen_at_last_old_space_gc_); | |
| 1228 } | |
| 1229 | |
| 1230 intptr_t OldGenPromotionLimit(intptr_t old_gen_size) { | |
| 1231 intptr_t limit = | |
| 1232 Max(old_gen_size + old_gen_size / 3, kMinimumPromotionLimit); | |
| 1233 limit += new_space_.Capacity(); | |
|
Vyacheslav Egorov (Chromium)
2011/08/12 09:11:51
new_space_.Capacity can change while lazy sweeping
Erik Corry
2011/08/12 09:21:48
No, but I don't think it matters.
| |
| 1234 limit *= old_gen_limit_factor_; | |
| 1235 return limit; | |
| 1236 } | |
| 1237 | |
| 1238 intptr_t OldGenAllocationLimit(intptr_t old_gen_size) { | |
| 1239 intptr_t limit = | |
| 1240 Max(old_gen_size + old_gen_size / 2, kMinimumAllocationLimit); | |
| 1241 limit += new_space_.Capacity(); | |
| 1242 limit *= old_gen_limit_factor_; | |
| 1243 return limit; | |
| 1215 } | 1244 } |
| 1216 | 1245 |
| 1217 // Can be called when the embedding application is idle. | 1246 // Can be called when the embedding application is idle. |
| 1218 bool IdleNotification(); | 1247 bool IdleNotification(); |
| 1219 | 1248 |
| 1220 // Declare all the root indices. | 1249 // Declare all the root indices. |
| 1221 enum RootListIndex { | 1250 enum RootListIndex { |
| 1222 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, | 1251 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
| 1223 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) | 1252 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
| 1224 #undef ROOT_INDEX_DECLARATION | 1253 #undef ROOT_INDEX_DECLARATION |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1451 // Limit that triggers a global GC on the next (normally caused) GC. This | 1480 // Limit that triggers a global GC on the next (normally caused) GC. This |
| 1452 // is checked when we have already decided to do a GC to help determine | 1481 // is checked when we have already decided to do a GC to help determine |
| 1453 // which collector to invoke. | 1482 // which collector to invoke. |
| 1454 intptr_t old_gen_promotion_limit_; | 1483 intptr_t old_gen_promotion_limit_; |
| 1455 | 1484 |
| 1456 // Limit that triggers a global GC as soon as is reasonable. This is | 1485 // Limit that triggers a global GC as soon as is reasonable. This is |
| 1457 // checked before expanding a paged space in the old generation and on | 1486 // checked before expanding a paged space in the old generation and on |
| 1458 // every allocation in large object space. | 1487 // every allocation in large object space. |
| 1459 intptr_t old_gen_allocation_limit_; | 1488 intptr_t old_gen_allocation_limit_; |
| 1460 | 1489 |
| 1490 // Sometimes the heuristics dictate that those limits are increased. This | |
| 1491 // variable records that fact. | |
| 1492 int old_gen_limit_factor_; | |
| 1493 | |
| 1494 // Used to adjust the limits that control the timing of the next GC. | |
| 1495 intptr_t size_of_old_gen_at_last_old_space_gc_; | |
| 1496 | |
| 1461 // Limit on the amount of externally allocated memory allowed | 1497 // Limit on the amount of externally allocated memory allowed |
| 1462 // between global GCs. If reached a global GC is forced. | 1498 // between global GCs. If reached a global GC is forced. |
| 1463 intptr_t external_allocation_limit_; | 1499 intptr_t external_allocation_limit_; |
| 1464 | 1500 |
| 1465 // The amount of external memory registered through the API kept alive | 1501 // The amount of external memory registered through the API kept alive |
| 1466 // by global handles | 1502 // by global handles |
| 1467 int amount_of_external_allocated_memory_; | 1503 int amount_of_external_allocated_memory_; |
| 1468 | 1504 |
| 1469 // Caches the amount of external memory registered at the last global gc. | 1505 // Caches the amount of external memory registered at the last global gc. |
| 1470 int amount_of_external_allocated_memory_at_last_global_gc_; | 1506 int amount_of_external_allocated_memory_at_last_global_gc_; |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2387 | 2423 |
| 2388 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2424 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2389 }; | 2425 }; |
| 2390 #endif // DEBUG || LIVE_OBJECT_LIST | 2426 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2391 | 2427 |
| 2392 } } // namespace v8::internal | 2428 } } // namespace v8::internal |
| 2393 | 2429 |
| 2394 #undef HEAP | 2430 #undef HEAP |
| 2395 | 2431 |
| 2396 #endif // V8_HEAP_H_ | 2432 #endif // V8_HEAP_H_ |
| OLD | NEW |