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

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

Issue 2418733002: [heap] Fix MemoryAllocator::AllocateAlignedMemory. (Closed)
Patch Set: Created 4 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
« 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/heap/spaces.h" 5 #include "src/heap/spaces.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 controller->TakeControl(&reservation); 452 controller->TakeControl(&reservation);
453 return base; 453 return base;
454 } 454 }
455 455
456 Address MemoryAllocator::AllocateAlignedMemory( 456 Address MemoryAllocator::AllocateAlignedMemory(
457 size_t reserve_size, size_t commit_size, size_t alignment, 457 size_t reserve_size, size_t commit_size, size_t alignment,
458 Executability executable, base::VirtualMemory* controller) { 458 Executability executable, base::VirtualMemory* controller) {
459 DCHECK(commit_size <= reserve_size); 459 DCHECK(commit_size <= reserve_size);
460 base::VirtualMemory reservation; 460 base::VirtualMemory reservation;
461 Address base = ReserveAlignedMemory(reserve_size, alignment, &reservation); 461 Address base = ReserveAlignedMemory(reserve_size, alignment, &reservation);
462 if (base == NULL) return NULL; 462 if (base == NULL) {
463 size_.Decrement(reserve_size);
Michael Lippautz 2016/10/13 08:24:36 IIUC ReserveAlignedMemory only increments if it su
Ilija.Pavlovic1 2016/10/13 12:29:58 This Decrement will be removed. Done.
464 return NULL;
465 }
463 466
464 if (executable == EXECUTABLE) { 467 if (executable == EXECUTABLE) {
465 if (!CommitExecutableMemory(&reservation, base, commit_size, 468 if (!CommitExecutableMemory(&reservation, base, commit_size,
466 reserve_size)) { 469 reserve_size)) {
467 base = NULL; 470 base = NULL;
468 } 471 }
469 } else { 472 } else {
470 if (reservation.Commit(base, commit_size, false)) { 473 if (reservation.Commit(base, commit_size, false)) {
471 UpdateAllocatedSpaceLimits(base, base + commit_size); 474 UpdateAllocatedSpaceLimits(base, base + commit_size);
472 } else { 475 } else {
473 base = NULL; 476 base = NULL;
474 } 477 }
475 } 478 }
476 479
477 if (base == NULL) { 480 if (base == NULL) {
478 // Failed to commit the body. Release the mapping and any partially 481 // Failed to commit the body. Release the mapping and any partially
479 // commited regions inside it. 482 // commited regions inside it.
480 reservation.Release(); 483 reservation.Release();
484 size_.Decrement(reserve_size);
481 return NULL; 485 return NULL;
482 } 486 }
483 487
484 controller->TakeControl(&reservation); 488 controller->TakeControl(&reservation);
485 return base; 489 return base;
486 } 490 }
487 491
488 void Page::InitializeAsAnchor(Space* space) { 492 void Page::InitializeAsAnchor(Space* space) {
489 set_owner(space); 493 set_owner(space);
490 set_next_chunk(this); 494 set_next_chunk(this);
(...skipping 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 object->ShortPrint(); 3234 object->ShortPrint();
3231 PrintF("\n"); 3235 PrintF("\n");
3232 } 3236 }
3233 printf(" --------------------------------------\n"); 3237 printf(" --------------------------------------\n");
3234 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3238 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3235 } 3239 }
3236 3240
3237 #endif // DEBUG 3241 #endif // DEBUG
3238 } // namespace internal 3242 } // namespace internal
3239 } // namespace v8 3243 } // namespace v8
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