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

Side by Side Diff: src/spaces.cc

Issue 8477030: Ensure that promotion queue does not overlap with objects relocated to ToSpace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove wrong assertion Created 9 years, 1 month 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/spaces.h ('k') | src/spaces-inl.h » ('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 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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 // We should only get here if someone asks to allocate more 1005 // We should only get here if someone asks to allocate more
1006 // than what can be stored in a single page. 1006 // than what can be stored in a single page.
1007 // TODO(gc): Change the limit on new-space allocation to prevent this 1007 // TODO(gc): Change the limit on new-space allocation to prevent this
1008 // from happening (all such allocations should go directly to LOSpace). 1008 // from happening (all such allocations should go directly to LOSpace).
1009 return false; 1009 return false;
1010 } 1010 }
1011 if (!to_space_.AdvancePage()) { 1011 if (!to_space_.AdvancePage()) {
1012 // Failed to get a new page in to-space. 1012 // Failed to get a new page in to-space.
1013 return false; 1013 return false;
1014 } 1014 }
1015
1015 // Clear remainder of current page. 1016 // Clear remainder of current page.
1016 int remaining_in_page = 1017 Address limit = NewSpacePage::FromLimit(top)->body_limit();
1017 static_cast<int>(NewSpacePage::FromLimit(top)->body_limit() - top); 1018 if (heap()->gc_state() == Heap::SCAVENGE) {
1019 heap()->promotion_queue()->SetNewLimit(limit);
1020 heap()->promotion_queue()->ActivateGuardIfOnTheSamePage();
1021 }
1022
1023 int remaining_in_page = static_cast<int>(limit - top);
1018 heap()->CreateFillerObjectAt(top, remaining_in_page); 1024 heap()->CreateFillerObjectAt(top, remaining_in_page);
1019 pages_used_++; 1025 pages_used_++;
1020 UpdateAllocationInfo(); 1026 UpdateAllocationInfo();
1027
1021 return true; 1028 return true;
1022 } 1029 }
1023 1030
1024 1031
1032 MaybeObject* NewSpace::SlowAllocateRaw(int size_in_bytes) {
1033 Address old_top = allocation_info_.top;
1034 Address new_top = old_top + size_in_bytes;
1035 Address high = to_space_.page_high();
1036 if (allocation_info_.limit < high) {
1037 // Incremental marking has lowered the limit to get a
1038 // chance to do a step.
1039 allocation_info_.limit = Min(
1040 allocation_info_.limit + inline_allocation_limit_step_,
1041 high);
1042 int bytes_allocated = static_cast<int>(new_top - top_on_previous_step_);
1043 heap()->incremental_marking()->Step(bytes_allocated);
1044 top_on_previous_step_ = new_top;
1045 return AllocateRaw(size_in_bytes);
1046 } else if (AddFreshPage()) {
1047 // Switched to new page. Try allocating again.
1048 int bytes_allocated = static_cast<int>(old_top - top_on_previous_step_);
1049 heap()->incremental_marking()->Step(bytes_allocated);
1050 top_on_previous_step_ = to_space_.page_low();
1051 return AllocateRaw(size_in_bytes);
1052 } else {
1053 return Failure::RetryAfterGC();
1054 }
1055 }
1056
1057
1025 #ifdef DEBUG 1058 #ifdef DEBUG
1026 // We do not use the SemiSpaceIterator because verification doesn't assume 1059 // We do not use the SemiSpaceIterator because verification doesn't assume
1027 // that it works (it depends on the invariants we are checking). 1060 // that it works (it depends on the invariants we are checking).
1028 void NewSpace::Verify() { 1061 void NewSpace::Verify() {
1029 // The allocation pointer should be in the space or at the very end. 1062 // The allocation pointer should be in the space or at the very end.
1030 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); 1063 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
1031 1064
1032 // There should be objects packed in from the low address up to the 1065 // There should be objects packed in from the low address up to the
1033 // allocation pointer. 1066 // allocation pointer.
1034 Address current = to_space_.first_page()->body(); 1067 Address current = to_space_.first_page()->body();
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 // OldSpace implementation 1930 // OldSpace implementation
1898 1931
1899 bool NewSpace::ReserveSpace(int bytes) { 1932 bool NewSpace::ReserveSpace(int bytes) {
1900 // We can't reliably unpack a partial snapshot that needs more new space 1933 // We can't reliably unpack a partial snapshot that needs more new space
1901 // space than the minimum NewSpace size. The limit can be set lower than 1934 // space than the minimum NewSpace size. The limit can be set lower than
1902 // the end of new space either because there is more space on the next page 1935 // the end of new space either because there is more space on the next page
1903 // or because we have lowered the limit in order to get periodic incremental 1936 // or because we have lowered the limit in order to get periodic incremental
1904 // marking. The most reliable way to ensure that there is linear space is 1937 // marking. The most reliable way to ensure that there is linear space is
1905 // to do the allocation, then rewind the limit. 1938 // to do the allocation, then rewind the limit.
1906 ASSERT(bytes <= InitialCapacity()); 1939 ASSERT(bytes <= InitialCapacity());
1907 MaybeObject* maybe = AllocateRawInternal(bytes); 1940 MaybeObject* maybe = AllocateRaw(bytes);
1908 Object* object = NULL; 1941 Object* object = NULL;
1909 if (!maybe->ToObject(&object)) return false; 1942 if (!maybe->ToObject(&object)) return false;
1910 HeapObject* allocation = HeapObject::cast(object); 1943 HeapObject* allocation = HeapObject::cast(object);
1911 Address top = allocation_info_.top; 1944 Address top = allocation_info_.top;
1912 if ((top - bytes) == allocation->address()) { 1945 if ((top - bytes) == allocation->address()) {
1913 allocation_info_.top = allocation->address(); 1946 allocation_info_.top = allocation->address();
1914 return true; 1947 return true;
1915 } 1948 }
1916 // There may be a borderline case here where the allocation succeeded, but 1949 // There may be a borderline case here where the allocation succeeded, but
1917 // the limit and top have moved on to a new page. In that case we try again. 1950 // the limit and top have moved on to a new page. In that case we try again.
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 object->ShortPrint(); 2565 object->ShortPrint();
2533 PrintF("\n"); 2566 PrintF("\n");
2534 } 2567 }
2535 printf(" --------------------------------------\n"); 2568 printf(" --------------------------------------\n");
2536 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 2569 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
2537 } 2570 }
2538 2571
2539 #endif // DEBUG 2572 #endif // DEBUG
2540 2573
2541 } } // namespace v8::internal 2574 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698