Chromium Code Reviews

Side by Side Diff: src/base/platform/platform.h

Issue 2032393002: [heap] Uncommit unused large object page memory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | src/base/platform/platform-linux.cc » ('j') | src/base/platform/platform-macos.cc » ('J')
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 // This module contains the platform-specific code. This make the rest of the 5 // This module contains the platform-specific code. This make the rest of the
6 // code less dependent on operating system, compilers and runtime libraries. 6 // code less dependent on operating system, compilers and runtime libraries.
7 // This module does specifically not deal with differences between different 7 // This module does specifically not deal with differences between different
8 // processor architecture. 8 // processor architecture.
9 // The platform classes have the same definition for all platforms. The 9 // The platform classes have the same definition for all platforms. The
10 // implementation for a particular platform is put in platform_<os>.cc. 10 // implementation for a particular platform is put in platform_<os>.cc.
(...skipping 319 matching lines...)
330 330
331 // Commits real memory. Returns whether the operation succeeded. 331 // Commits real memory. Returns whether the operation succeeded.
332 bool Commit(void* address, size_t size, bool is_executable); 332 bool Commit(void* address, size_t size, bool is_executable);
333 333
334 // Uncommit real memory. Returns whether the operation succeeded. 334 // Uncommit real memory. Returns whether the operation succeeded.
335 bool Uncommit(void* address, size_t size); 335 bool Uncommit(void* address, size_t size);
336 336
337 // Creates a single guard page at the given address. 337 // Creates a single guard page at the given address.
338 bool Guard(void* address); 338 bool Guard(void* address);
339 339
340 // Releases the tail [free_start, free_start + size] of a previously allocated
341 // chunk of memory.
342 void ReleasePartial(void* free_start, size_t size) {
ulan 2016/06/06 13:44:22 As discussed, we can make a stricter version of th
Hannes Payer (out of office) 2016/06/06 14:42:44 Done.
343 DCHECK(IsReserved());
344 // Notice: Order is important here. The VirtualMemory object might live
345 // inside the allocated region.
346 CHECK(InVM(free_start, size));
347 DCHECK(free_start != address_);
348 DCHECK(size < size_);
349 bool result = ReleasePartialRegion(address_, size_, free_start, size);
350 USE(result);
351 DCHECK(result);
352 size_ -= size;
353 }
354
340 void Release() { 355 void Release() {
341 DCHECK(IsReserved()); 356 DCHECK(IsReserved());
342 // Notice: Order is important here. The VirtualMemory object might live 357 // Notice: Order is important here. The VirtualMemory object might live
343 // inside the allocated region. 358 // inside the allocated region.
344 void* address = address_; 359 void* address = address_;
345 size_t size = size_; 360 size_t size = size_;
346 CHECK(InVM(address, size)); 361 CHECK(InVM(address, size));
347 Reset(); 362 Reset();
348 bool result = ReleaseRegion(address, size); 363 bool result = ReleaseRegion(address, size);
349 USE(result); 364 USE(result);
(...skipping 12 matching lines...)
362 static void* ReserveRegion(size_t size); 377 static void* ReserveRegion(size_t size);
363 378
364 static bool CommitRegion(void* base, size_t size, bool is_executable); 379 static bool CommitRegion(void* base, size_t size, bool is_executable);
365 380
366 static bool UncommitRegion(void* base, size_t size); 381 static bool UncommitRegion(void* base, size_t size);
367 382
368 // Must be called with a base pointer that has been returned by ReserveRegion 383 // Must be called with a base pointer that has been returned by ReserveRegion
369 // and the same size it was reserved with. 384 // and the same size it was reserved with.
370 static bool ReleaseRegion(void* base, size_t size); 385 static bool ReleaseRegion(void* base, size_t size);
371 386
387 // Must be called with a base pointer that has been returned by ReserveRegion
388 // and the same size it was reserved with.
389 // [free_start, free_start + free_size] is the memory that will be released.
390 static bool ReleasePartialRegion(void* base, size_t size, void* free_start,
391 size_t free_size);
392
372 // Returns true if OS performs lazy commits, i.e. the memory allocation call 393 // Returns true if OS performs lazy commits, i.e. the memory allocation call
373 // defers actual physical memory allocation till the first memory access. 394 // defers actual physical memory allocation till the first memory access.
374 // Otherwise returns false. 395 // Otherwise returns false.
375 static bool HasLazyCommits(); 396 static bool HasLazyCommits();
376 397
377 private: 398 private:
378 bool InVM(void* address, size_t size) { 399 bool InVM(void* address, size_t size) {
379 return (reinterpret_cast<uintptr_t>(address_) <= 400 return (reinterpret_cast<uintptr_t>(address_) <=
380 reinterpret_cast<uintptr_t>(address)) && 401 reinterpret_cast<uintptr_t>(address)) &&
381 ((reinterpret_cast<uintptr_t>(address_) + size_) >= 402 ((reinterpret_cast<uintptr_t>(address_) + size_) >=
(...skipping 107 matching lines...)
489 int stack_size_; 510 int stack_size_;
490 Semaphore* start_semaphore_; 511 Semaphore* start_semaphore_;
491 512
492 DISALLOW_COPY_AND_ASSIGN(Thread); 513 DISALLOW_COPY_AND_ASSIGN(Thread);
493 }; 514 };
494 515
495 } // namespace base 516 } // namespace base
496 } // namespace v8 517 } // namespace v8
497 518
498 #endif // V8_BASE_PLATFORM_PLATFORM_H_ 519 #endif // V8_BASE_PLATFORM_PLATFORM_H_
OLDNEW
« no previous file with comments | « no previous file | src/base/platform/platform-linux.cc » ('j') | src/base/platform/platform-macos.cc » ('J')

Powered by Google App Engine