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

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

Issue 581223004: Support large objects in the serializer/deserializer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments 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/heap/spaces.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 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 return result; 916 return result;
917 } 917 }
918 918
919 919
920 void Heap::ReserveSpace(int* sizes, Address* locations_out) { 920 void Heap::ReserveSpace(int* sizes, Address* locations_out) {
921 bool gc_performed = true; 921 bool gc_performed = true;
922 int counter = 0; 922 int counter = 0;
923 static const int kThreshold = 20; 923 static const int kThreshold = 20;
924 while (gc_performed && counter++ < kThreshold) { 924 while (gc_performed && counter++ < kThreshold) {
925 gc_performed = false; 925 gc_performed = false;
926 DCHECK(NEW_SPACE == FIRST_PAGED_SPACE - 1); 926 for (int space = NEW_SPACE; space < Serializer::kNumberOfSpaces; space++) {
927 for (int space = NEW_SPACE; space <= LAST_PAGED_SPACE; space++) { 927 if (sizes[space] == 0) continue;
928 if (sizes[space] != 0) { 928 bool perform_gc = false;
929 if (space == LO_SPACE) {
930 perform_gc = !lo_space()->CanAllocateSize(sizes[space]);
931 } else {
929 AllocationResult allocation; 932 AllocationResult allocation;
930 if (space == NEW_SPACE) { 933 if (space == NEW_SPACE) {
931 allocation = new_space()->AllocateRaw(sizes[space]); 934 allocation = new_space()->AllocateRaw(sizes[space]);
932 } else { 935 } else {
933 allocation = paged_space(space)->AllocateRaw(sizes[space]); 936 allocation = paged_space(space)->AllocateRaw(sizes[space]);
934 } 937 }
935 FreeListNode* node; 938 FreeListNode* node;
936 if (!allocation.To(&node)) { 939 if (allocation.To(&node)) {
937 if (space == NEW_SPACE) {
938 Heap::CollectGarbage(NEW_SPACE,
939 "failed to reserve space in the new space");
940 } else {
941 AbortIncrementalMarkingAndCollectGarbage(
942 this, static_cast<AllocationSpace>(space),
943 "failed to reserve space in paged space");
944 }
945 gc_performed = true;
946 break;
947 } else {
948 // Mark with a free list node, in case we have a GC before 940 // Mark with a free list node, in case we have a GC before
949 // deserializing. 941 // deserializing.
950 node->set_size(this, sizes[space]); 942 node->set_size(this, sizes[space]);
943 DCHECK(space < Serializer::kNumberOfPreallocatedSpaces);
951 locations_out[space] = node->address(); 944 locations_out[space] = node->address();
945 } else {
946 perform_gc = true;
952 } 947 }
953 } 948 }
949 if (perform_gc) {
950 if (space == NEW_SPACE) {
951 Heap::CollectGarbage(NEW_SPACE,
952 "failed to reserve space in the new space");
953 } else {
954 AbortIncrementalMarkingAndCollectGarbage(
955 this, static_cast<AllocationSpace>(space),
956 "failed to reserve space in paged or large object space");
957 }
958 gc_performed = true;
959 break; // Abort for-loop over spaces and retry.
960 }
954 } 961 }
955 } 962 }
956 963
957 if (gc_performed) { 964 if (gc_performed) {
958 // Failed to reserve the space after several attempts. 965 // Failed to reserve the space after several attempts.
959 V8::FatalProcessOutOfMemory("Heap::ReserveSpace"); 966 V8::FatalProcessOutOfMemory("Heap::ReserveSpace");
960 } 967 }
961 } 968 }
962 969
963 970
(...skipping 5179 matching lines...) Expand 10 before | Expand all | Expand 10 after
6143 static_cast<int>(object_sizes_last_time_[index])); 6150 static_cast<int>(object_sizes_last_time_[index]));
6144 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6151 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6145 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6152 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6146 6153
6147 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6154 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6148 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6155 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6149 ClearObjectStats(); 6156 ClearObjectStats();
6150 } 6157 }
6151 } 6158 }
6152 } // namespace v8::internal 6159 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698