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 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 // The bytes in the linear allocation area are not included in this total | 1462 // The bytes in the linear allocation area are not included in this total |
1463 // because updating the stats would slow down allocation. New pages are | 1463 // because updating the stats would slow down allocation. New pages are |
1464 // immediately added to the free list so they show up here. | 1464 // immediately added to the free list so they show up here. |
1465 intptr_t Available() { return free_list_.available(); } | 1465 intptr_t Available() { return free_list_.available(); } |
1466 | 1466 |
1467 // Allocated bytes in this space. Garbage bytes that were not found due to | 1467 // Allocated bytes in this space. Garbage bytes that were not found due to |
1468 // lazy sweeping are counted as being allocated! The bytes in the current | 1468 // lazy sweeping are counted as being allocated! The bytes in the current |
1469 // linear allocation area (between top and limit) are also counted here. | 1469 // linear allocation area (between top and limit) are also counted here. |
1470 virtual intptr_t Size() { return accounting_stats_.Size(); } | 1470 virtual intptr_t Size() { return accounting_stats_.Size(); } |
1471 | 1471 |
1472 // As size, but the bytes in the current linear allocation area are not | 1472 // As size, but the bytes in lazily swept pages are estimated and the bytes |
1473 // included. | 1473 // in the current linear allocation area are not included. |
1474 virtual intptr_t SizeOfObjects() { return Size() - (limit() - top()); } | 1474 intptr_t SizeOfObjectsSlow(); |
| 1475 virtual intptr_t SizeOfObjects() { |
| 1476 if (IsSweepingComplete()) { |
| 1477 return Size() - (limit() - top()); |
| 1478 } else { |
| 1479 return SizeOfObjectsSlow(); |
| 1480 } |
| 1481 } |
1475 | 1482 |
1476 // Wasted bytes in this space. These are just the bytes that were thrown away | 1483 // Wasted bytes in this space. These are just the bytes that were thrown away |
1477 // due to being too small to use for allocation. They do not include the | 1484 // due to being too small to use for allocation. They do not include the |
1478 // free bytes that were not found at all due to lazy sweeping. | 1485 // free bytes that were not found at all due to lazy sweeping. |
1479 virtual intptr_t Waste() { return accounting_stats_.Waste(); } | 1486 virtual intptr_t Waste() { return accounting_stats_.Waste(); } |
1480 | 1487 |
1481 // Returns the allocation pointer in this space. | 1488 // Returns the allocation pointer in this space. |
1482 Address top() { | 1489 Address top() { return allocation_info_.top; } |
1483 return allocation_info_.top; | |
1484 } | |
1485 Address limit() { return allocation_info_.limit; } | 1490 Address limit() { return allocation_info_.limit; } |
1486 | 1491 |
1487 // Allocate the requested number of bytes in the space if possible, return a | 1492 // Allocate the requested number of bytes in the space if possible, return a |
1488 // failure object if not. | 1493 // failure object if not. |
1489 MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes); | 1494 MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes); |
1490 | 1495 |
1491 virtual bool ReserveSpace(int bytes); | 1496 virtual bool ReserveSpace(int bytes); |
1492 | 1497 |
1493 // Give a block of memory to the space's free list. It might be added to | 1498 // Give a block of memory to the space's free list. It might be added to |
1494 // the free list or accounted as waste. | 1499 // the free list or accounted as waste. |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2630 } | 2635 } |
2631 // Must be small, since an iteration is used for lookup. | 2636 // Must be small, since an iteration is used for lookup. |
2632 static const int kMaxComments = 64; | 2637 static const int kMaxComments = 64; |
2633 }; | 2638 }; |
2634 #endif | 2639 #endif |
2635 | 2640 |
2636 | 2641 |
2637 } } // namespace v8::internal | 2642 } } // namespace v8::internal |
2638 | 2643 |
2639 #endif // V8_SPACES_H_ | 2644 #endif // V8_SPACES_H_ |
OLD | NEW |