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

Side by Side Diff: src/heap/heap.cc

Issue 831893003: Try to reduce memory footprint when we run out of memory in Deserializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 }; 915 };
916 916
917 917
918 static void VerifyStringTable(Heap* heap) { 918 static void VerifyStringTable(Heap* heap) {
919 StringTableVerifier verifier; 919 StringTableVerifier verifier;
920 heap->string_table()->IterateElements(&verifier); 920 heap->string_table()->IterateElements(&verifier);
921 } 921 }
922 #endif // VERIFY_HEAP 922 #endif // VERIFY_HEAP
923 923
924 924
925 static bool AbortIncrementalMarkingAndCollectGarbage(
926 Heap* heap, AllocationSpace space, const char* gc_reason = NULL) {
927 heap->mark_compact_collector()->SetFlags(Heap::kAbortIncrementalMarkingMask);
928 bool result = heap->CollectGarbage(space, gc_reason);
929 heap->mark_compact_collector()->SetFlags(Heap::kNoGCFlags);
930 return result;
931 }
932
933
934 bool Heap::ReserveSpace(Reservation* reservations) { 925 bool Heap::ReserveSpace(Reservation* reservations) {
935 bool gc_performed = true; 926 bool gc_performed = true;
936 int counter = 0; 927 int counter = 0;
937 static const int kThreshold = 20; 928 static const int kThreshold = 20;
938 while (gc_performed && counter++ < kThreshold) { 929 while (gc_performed && counter++ < kThreshold) {
939 gc_performed = false; 930 gc_performed = false;
940 for (int space = NEW_SPACE; space < Serializer::kNumberOfSpaces; space++) { 931 for (int space = NEW_SPACE; space < Serializer::kNumberOfSpaces; space++) {
941 Reservation* reservation = &reservations[space]; 932 Reservation* reservation = &reservations[space];
942 DCHECK_LE(1, reservation->length()); 933 DCHECK_LE(1, reservation->length());
943 if (reservation->at(0).size == 0) continue; 934 if (reservation->at(0).size == 0) continue;
(...skipping 21 matching lines...) Expand all
965 chunk.start = node->address(); 956 chunk.start = node->address();
966 chunk.end = node->address() + size; 957 chunk.end = node->address() + size;
967 } else { 958 } else {
968 perform_gc = true; 959 perform_gc = true;
969 break; 960 break;
970 } 961 }
971 } 962 }
972 } 963 }
973 if (perform_gc) { 964 if (perform_gc) {
974 if (space == NEW_SPACE) { 965 if (space == NEW_SPACE) {
975 Heap::CollectGarbage(NEW_SPACE, 966 CollectGarbage(NEW_SPACE, "failed to reserve space in the new space");
976 "failed to reserve space in the new space");
977 } else { 967 } else {
978 AbortIncrementalMarkingAndCollectGarbage( 968 if (counter > 1) {
979 this, static_cast<AllocationSpace>(space), 969 CollectAllGarbage(
980 "failed to reserve space in paged or large object space"); 970 kReduceMemoryFootprintMask,
971 "failed to reserve space in paged or large "
972 "object space, trying to reduce memory footprint");
973 } else {
974 CollectAllGarbage(
975 kAbortIncrementalMarkingMask,
976 "failed to reserve space in paged or large object space");
977 }
981 } 978 }
982 gc_performed = true; 979 gc_performed = true;
983 break; // Abort for-loop over spaces and retry. 980 break; // Abort for-loop over spaces and retry.
984 } 981 }
985 } 982 }
986 } 983 }
987 984
988 return !gc_performed; 985 return !gc_performed;
989 } 986 }
990 987
(...skipping 5446 matching lines...) Expand 10 before | Expand all | Expand 10 after
6437 static_cast<int>(object_sizes_last_time_[index])); 6434 static_cast<int>(object_sizes_last_time_[index]));
6438 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6435 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6439 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6436 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6440 6437
6441 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6438 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6442 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6439 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6443 ClearObjectStats(); 6440 ClearObjectStats();
6444 } 6441 }
6445 } 6442 }
6446 } // namespace v8::internal 6443 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698