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

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

Issue 876613002: Only use FreeSpace objects in the free list. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update multiplier for mips64 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
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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 Code* code = Code::cast(object); 488 Code* code = Code::cast(object);
489 Code::Kind current_kind = code->kind(); 489 Code::Kind current_kind = code->kind();
490 if (current_kind == Code::FUNCTION || 490 if (current_kind == Code::FUNCTION ||
491 current_kind == Code::OPTIMIZED_FUNCTION) { 491 current_kind == Code::OPTIMIZED_FUNCTION) {
492 code->ClearInlineCaches(kind); 492 code->ClearInlineCaches(kind);
493 } 493 }
494 } 494 }
495 } 495 }
496 496
497 497
498 void Heap::RepairFreeListsAfterBoot() { 498 void Heap::RepairFreeListsAfterDeserialization() {
499 PagedSpaces spaces(this); 499 PagedSpaces spaces(this);
500 for (PagedSpace* space = spaces.next(); space != NULL; 500 for (PagedSpace* space = spaces.next(); space != NULL;
501 space = spaces.next()) { 501 space = spaces.next()) {
502 space->RepairFreeListsAfterBoot(); 502 space->RepairFreeListsAfterDeserialization();
503 } 503 }
504 } 504 }
505 505
506 506
507 void Heap::ProcessPretenuringFeedback() { 507 void Heap::ProcessPretenuringFeedback() {
508 if (FLAG_allocation_site_pretenuring) { 508 if (FLAG_allocation_site_pretenuring) {
509 int tenure_decisions = 0; 509 int tenure_decisions = 0;
510 int dont_tenure_decisions = 0; 510 int dont_tenure_decisions = 0;
511 int allocation_mementos_found = 0; 511 int allocation_mementos_found = 0;
512 int allocation_sites = 0; 512 int allocation_sites = 0;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 for (auto& chunk : *reservation) { 944 for (auto& chunk : *reservation) {
945 AllocationResult allocation; 945 AllocationResult allocation;
946 int size = chunk.size; 946 int size = chunk.size;
947 DCHECK_LE(size, MemoryAllocator::PageAreaSize( 947 DCHECK_LE(size, MemoryAllocator::PageAreaSize(
948 static_cast<AllocationSpace>(space))); 948 static_cast<AllocationSpace>(space)));
949 if (space == NEW_SPACE) { 949 if (space == NEW_SPACE) {
950 allocation = new_space()->AllocateRaw(size); 950 allocation = new_space()->AllocateRaw(size);
951 } else { 951 } else {
952 allocation = paged_space(space)->AllocateRaw(size); 952 allocation = paged_space(space)->AllocateRaw(size);
953 } 953 }
954 FreeListNode* node; 954 HeapObject* free_space;
955 if (allocation.To(&node)) { 955 if (allocation.To(&free_space)) {
956 // Mark with a free list node, in case we have a GC before 956 // Mark with a free list node, in case we have a GC before
957 // deserializing. 957 // deserializing.
958 node->set_size(this, size); 958 Address free_space_address = free_space->address();
959 CreateFillerObjectAt(free_space_address, size);
959 DCHECK(space < Serializer::kNumberOfPreallocatedSpaces); 960 DCHECK(space < Serializer::kNumberOfPreallocatedSpaces);
960 chunk.start = node->address(); 961 chunk.start = free_space_address;
961 chunk.end = node->address() + size; 962 chunk.end = free_space_address + size;
962 } else { 963 } else {
963 perform_gc = true; 964 perform_gc = true;
964 break; 965 break;
965 } 966 }
966 } 967 }
967 } 968 }
968 if (perform_gc) { 969 if (perform_gc) {
969 if (space == NEW_SPACE) { 970 if (space == NEW_SPACE) {
970 CollectGarbage(NEW_SPACE, "failed to reserve space in the new space"); 971 CollectGarbage(NEW_SPACE, "failed to reserve space in the new space");
971 } else { 972 } else {
(...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 3385
3385 result->set_map_no_write_barrier(byte_array_map()); 3386 result->set_map_no_write_barrier(byte_array_map());
3386 ByteArray::cast(result)->set_length(length); 3387 ByteArray::cast(result)->set_length(length);
3387 return result; 3388 return result;
3388 } 3389 }
3389 3390
3390 3391
3391 void Heap::CreateFillerObjectAt(Address addr, int size) { 3392 void Heap::CreateFillerObjectAt(Address addr, int size) {
3392 if (size == 0) return; 3393 if (size == 0) return;
3393 HeapObject* filler = HeapObject::FromAddress(addr); 3394 HeapObject* filler = HeapObject::FromAddress(addr);
3395 // At this point, we may be deserializing the heap from a snapshot, and
3396 // none of the maps have been created yet and are NULL.
3394 if (size == kPointerSize) { 3397 if (size == kPointerSize) {
3395 filler->set_map_no_write_barrier(one_pointer_filler_map()); 3398 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map());
3399 DCHECK(filler->map() == NULL || filler->map() == one_pointer_filler_map());
3396 } else if (size == 2 * kPointerSize) { 3400 } else if (size == 2 * kPointerSize) {
3397 filler->set_map_no_write_barrier(two_pointer_filler_map()); 3401 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map());
3402 DCHECK(filler->map() == NULL || filler->map() == two_pointer_filler_map());
3398 } else { 3403 } else {
3399 filler->set_map_no_write_barrier(free_space_map()); 3404 filler->set_map_no_write_barrier(raw_unchecked_free_space_map());
3405 DCHECK(filler->map() == NULL || filler->map() == free_space_map());
3400 FreeSpace::cast(filler)->set_size(size); 3406 FreeSpace::cast(filler)->set_size(size);
3401 } 3407 }
3402 } 3408 }
3403 3409
3404 3410
3405 bool Heap::CanMoveObjectStart(HeapObject* object) { 3411 bool Heap::CanMoveObjectStart(HeapObject* object) {
3406 Address address = object->address(); 3412 Address address = object->address();
3407 bool is_in_old_pointer_space = InOldPointerSpace(address); 3413 bool is_in_old_pointer_space = InOldPointerSpace(address);
3408 bool is_in_old_data_space = InOldDataSpace(address); 3414 bool is_in_old_data_space = InOldDataSpace(address);
3409 3415
(...skipping 3028 matching lines...) Expand 10 before | Expand all | Expand 10 after
6438 static_cast<int>(object_sizes_last_time_[index])); 6444 static_cast<int>(object_sizes_last_time_[index]));
6439 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6445 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6440 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6446 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6441 6447
6442 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6448 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6443 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6449 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6444 ClearObjectStats(); 6450 ClearObjectStats();
6445 } 6451 }
6446 } 6452 }
6447 } // namespace v8::internal 6453 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698