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 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1902 return sum; | 1902 return sum; |
1903 } | 1903 } |
1904 #endif | 1904 #endif |
1905 | 1905 |
1906 | 1906 |
1907 // ----------------------------------------------------------------------------- | 1907 // ----------------------------------------------------------------------------- |
1908 // OldSpace implementation | 1908 // OldSpace implementation |
1909 | 1909 |
1910 bool NewSpace::ReserveSpace(int bytes) { | 1910 bool NewSpace::ReserveSpace(int bytes) { |
1911 // We can't reliably unpack a partial snapshot that needs more new space | 1911 // We can't reliably unpack a partial snapshot that needs more new space |
1912 // space than the minimum NewSpace size. | 1912 // space than the minimum NewSpace size. The limit can be set lower than |
1913 // the end of new space either because there is more space on the next page | |
1914 // or because we have lowered the limit in order to get periodic incremental | |
1915 // marking. The most reliable way to ensure that there is linear space is | |
1916 // to do the allocation, then rewind the limit. | |
1913 ASSERT(bytes <= InitialCapacity()); | 1917 ASSERT(bytes <= InitialCapacity()); |
1914 Address limit = allocation_info_.limit; | 1918 MaybeObject* maybe = AllocateRawInternal(bytes); |
1919 Object* object = NULL; | |
1920 if (!maybe->ToObject(&object)) return false; | |
1921 HeapObject* allocation = HeapObject::cast(object); | |
1915 Address top = allocation_info_.top; | 1922 Address top = allocation_info_.top; |
1916 return limit - top >= bytes; | 1923 if (top - bytes == allocation->address()) { |
Vyacheslav Egorov (Chromium)
2011/10/14 10:47:39
I like to have parens around top - bytes.
| |
1924 allocation_info_.top = allocation->address(); | |
1925 return true; | |
1926 } | |
1927 // There may be a borderline case here where the allocation succeeded, but | |
1928 // the limit and top have moved on to a new page. In that case we try again. | |
1929 return ReserveSpace(bytes); | |
1917 } | 1930 } |
1918 | 1931 |
1919 | 1932 |
1920 void PagedSpace::PrepareForMarkCompact() { | 1933 void PagedSpace::PrepareForMarkCompact() { |
1921 // We don't have a linear allocation area while sweeping. It will be restored | 1934 // We don't have a linear allocation area while sweeping. It will be restored |
1922 // on the first allocation after the sweep. | 1935 // on the first allocation after the sweep. |
1923 // Mark the old linear allocation area with a free space map so it can be | 1936 // Mark the old linear allocation area with a free space map so it can be |
1924 // skipped when scanning the heap. | 1937 // skipped when scanning the heap. |
1925 int old_linear_size = static_cast<int>(limit() - top()); | 1938 int old_linear_size = static_cast<int>(limit() - top()); |
1926 Free(top(), old_linear_size); | 1939 Free(top(), old_linear_size); |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2523 object->ShortPrint(); | 2536 object->ShortPrint(); |
2524 PrintF("\n"); | 2537 PrintF("\n"); |
2525 } | 2538 } |
2526 printf(" --------------------------------------\n"); | 2539 printf(" --------------------------------------\n"); |
2527 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 2540 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
2528 } | 2541 } |
2529 | 2542 |
2530 #endif // DEBUG | 2543 #endif // DEBUG |
2531 | 2544 |
2532 } } // namespace v8::internal | 2545 } } // namespace v8::internal |
OLD | NEW |