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

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

Issue 654243003: Revert "Break deserializer reservations into chunks that fit onto a page." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/heap.h ('k') | src/list.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 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 10 matching lines...) Expand all
21 #include "src/heap/incremental-marking.h" 21 #include "src/heap/incremental-marking.h"
22 #include "src/heap/mark-compact.h" 22 #include "src/heap/mark-compact.h"
23 #include "src/heap/objects-visiting-inl.h" 23 #include "src/heap/objects-visiting-inl.h"
24 #include "src/heap/objects-visiting.h" 24 #include "src/heap/objects-visiting.h"
25 #include "src/heap/store-buffer.h" 25 #include "src/heap/store-buffer.h"
26 #include "src/heap-profiler.h" 26 #include "src/heap-profiler.h"
27 #include "src/isolate-inl.h" 27 #include "src/isolate-inl.h"
28 #include "src/natives.h" 28 #include "src/natives.h"
29 #include "src/runtime-profiler.h" 29 #include "src/runtime-profiler.h"
30 #include "src/scopeinfo.h" 30 #include "src/scopeinfo.h"
31 #include "src/serialize.h"
32 #include "src/snapshot.h" 31 #include "src/snapshot.h"
33 #include "src/utils.h" 32 #include "src/utils.h"
34 #include "src/v8threads.h" 33 #include "src/v8threads.h"
35 #include "src/vm-state-inl.h" 34 #include "src/vm-state-inl.h"
36 35
37 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP 36 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
38 #include "src/regexp-macro-assembler.h" // NOLINT 37 #include "src/regexp-macro-assembler.h" // NOLINT
39 #include "src/arm/regexp-macro-assembler-arm.h" // NOLINT 38 #include "src/arm/regexp-macro-assembler-arm.h" // NOLINT
40 #endif 39 #endif
41 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP 40 #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 912
914 static bool AbortIncrementalMarkingAndCollectGarbage( 913 static bool AbortIncrementalMarkingAndCollectGarbage(
915 Heap* heap, AllocationSpace space, const char* gc_reason = NULL) { 914 Heap* heap, AllocationSpace space, const char* gc_reason = NULL) {
916 heap->mark_compact_collector()->SetFlags(Heap::kAbortIncrementalMarkingMask); 915 heap->mark_compact_collector()->SetFlags(Heap::kAbortIncrementalMarkingMask);
917 bool result = heap->CollectGarbage(space, gc_reason); 916 bool result = heap->CollectGarbage(space, gc_reason);
918 heap->mark_compact_collector()->SetFlags(Heap::kNoGCFlags); 917 heap->mark_compact_collector()->SetFlags(Heap::kNoGCFlags);
919 return result; 918 return result;
920 } 919 }
921 920
922 921
923 bool Heap::ReserveSpace(Reservation* reservations) { 922 void Heap::ReserveSpace(int* sizes, Address* locations_out) {
924 bool gc_performed = true; 923 bool gc_performed = true;
925 int counter = 0; 924 int counter = 0;
926 static const int kThreshold = 20; 925 static const int kThreshold = 20;
927 while (gc_performed && counter++ < kThreshold) { 926 while (gc_performed && counter++ < kThreshold) {
928 gc_performed = false; 927 gc_performed = false;
929 for (int space = NEW_SPACE; space < Serializer::kNumberOfSpaces; space++) { 928 for (int space = NEW_SPACE; space < Serializer::kNumberOfSpaces; space++) {
930 Reservation* reservation = &reservations[space]; 929 if (sizes[space] == 0) continue;
931 DCHECK_LE(1, reservation->length());
932 if (reservation->at(0).size == 0) continue;
933 bool perform_gc = false; 930 bool perform_gc = false;
934 if (space == LO_SPACE) { 931 if (space == LO_SPACE) {
935 DCHECK_EQ(1, reservation->length()); 932 perform_gc = !lo_space()->CanAllocateSize(sizes[space]);
936 perform_gc = !lo_space()->CanAllocateSize(reservation->at(0).size);
937 } else { 933 } else {
938 for (auto& chunk : *reservation) { 934 AllocationResult allocation;
939 AllocationResult allocation; 935 if (space == NEW_SPACE) {
940 int size = chunk.size; 936 allocation = new_space()->AllocateRaw(sizes[space]);
941 if (space == NEW_SPACE) { 937 } else {
942 allocation = new_space()->AllocateRaw(size); 938 allocation = paged_space(space)->AllocateRaw(sizes[space]);
943 } else { 939 }
944 allocation = paged_space(space)->AllocateRaw(size); 940 FreeListNode* node;
945 } 941 if (allocation.To(&node)) {
946 FreeListNode* node; 942 // Mark with a free list node, in case we have a GC before
947 if (allocation.To(&node)) { 943 // deserializing.
948 // Mark with a free list node, in case we have a GC before 944 node->set_size(this, sizes[space]);
949 // deserializing. 945 DCHECK(space < Serializer::kNumberOfPreallocatedSpaces);
950 node->set_size(this, size); 946 locations_out[space] = node->address();
951 DCHECK(space < Serializer::kNumberOfPreallocatedSpaces); 947 } else {
952 chunk.start = node->address(); 948 perform_gc = true;
953 chunk.end = node->address() + size;
954 } else {
955 perform_gc = true;
956 break;
957 }
958 } 949 }
959 } 950 }
960 if (perform_gc) { 951 if (perform_gc) {
961 if (space == NEW_SPACE) { 952 if (space == NEW_SPACE) {
962 Heap::CollectGarbage(NEW_SPACE, 953 Heap::CollectGarbage(NEW_SPACE,
963 "failed to reserve space in the new space"); 954 "failed to reserve space in the new space");
964 } else { 955 } else {
965 AbortIncrementalMarkingAndCollectGarbage( 956 AbortIncrementalMarkingAndCollectGarbage(
966 this, static_cast<AllocationSpace>(space), 957 this, static_cast<AllocationSpace>(space),
967 "failed to reserve space in paged or large object space"); 958 "failed to reserve space in paged or large object space");
968 } 959 }
969 gc_performed = true; 960 gc_performed = true;
970 break; // Abort for-loop over spaces and retry. 961 break; // Abort for-loop over spaces and retry.
971 } 962 }
972 } 963 }
973 } 964 }
974 965
975 return !gc_performed; 966 if (gc_performed) {
967 // Failed to reserve the space after several attempts.
968 V8::FatalProcessOutOfMemory("Heap::ReserveSpace");
969 }
976 } 970 }
977 971
978 972
979 void Heap::EnsureFromSpaceIsCommitted() { 973 void Heap::EnsureFromSpaceIsCommitted() {
980 if (new_space_.CommitFromSpaceIfNeeded()) return; 974 if (new_space_.CommitFromSpaceIfNeeded()) return;
981 975
982 // Committing memory to from space failed. 976 // Committing memory to from space failed.
983 // Memory is exhausted and we will die. 977 // Memory is exhausted and we will die.
984 V8::FatalProcessOutOfMemory("Committing semi space failed."); 978 V8::FatalProcessOutOfMemory("Committing semi space failed.");
985 } 979 }
(...skipping 5212 matching lines...) Expand 10 before | Expand all | Expand 10 after
6198 static_cast<int>(object_sizes_last_time_[index])); 6192 static_cast<int>(object_sizes_last_time_[index]));
6199 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6193 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6200 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6194 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6201 6195
6202 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6196 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6203 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6197 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6204 ClearObjectStats(); 6198 ClearObjectStats();
6205 } 6199 }
6206 } 6200 }
6207 } // namespace v8::internal 6201 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698