OLD | NEW |
---|---|
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...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | |
ulan
2016/06/06 15:53:15
Should be [free_start, size_]
Hannes Payer (out of office)
2016/06/06 15:56:38
Done.
| |
341 // chunk of memory. | |
342 void ReleasePartial(void* free_start) { | |
343 DCHECK(IsReserved()); | |
344 // Notice: Order is important here. The VirtualMemory object might live | |
345 // inside the allocated region. | |
346 size_t size = size_ - (reinterpret_cast<size_t>(free_start) - | |
347 reinterpret_cast<size_t>(address_)); | |
348 CHECK(InVM(free_start, size)); | |
349 DCHECK(free_start != address_); | |
ulan
2016/06/06 15:53:15
DCHECK_LT(address_, free_start);
DCHECK_LT(free_st
Hannes Payer (out of office)
2016/06/06 15:56:38
Done.
| |
350 bool result = ReleasePartialRegion(address_, size_, free_start, size); | |
351 USE(result); | |
352 DCHECK(result); | |
353 size_ -= size; | |
354 } | |
355 | |
340 void Release() { | 356 void Release() { |
341 DCHECK(IsReserved()); | 357 DCHECK(IsReserved()); |
342 // Notice: Order is important here. The VirtualMemory object might live | 358 // Notice: Order is important here. The VirtualMemory object might live |
343 // inside the allocated region. | 359 // inside the allocated region. |
344 void* address = address_; | 360 void* address = address_; |
345 size_t size = size_; | 361 size_t size = size_; |
346 CHECK(InVM(address, size)); | 362 CHECK(InVM(address, size)); |
347 Reset(); | 363 Reset(); |
348 bool result = ReleaseRegion(address, size); | 364 bool result = ReleaseRegion(address, size); |
349 USE(result); | 365 USE(result); |
(...skipping 12 matching lines...) Expand all Loading... | |
362 static void* ReserveRegion(size_t size); | 378 static void* ReserveRegion(size_t size); |
363 | 379 |
364 static bool CommitRegion(void* base, size_t size, bool is_executable); | 380 static bool CommitRegion(void* base, size_t size, bool is_executable); |
365 | 381 |
366 static bool UncommitRegion(void* base, size_t size); | 382 static bool UncommitRegion(void* base, size_t size); |
367 | 383 |
368 // Must be called with a base pointer that has been returned by ReserveRegion | 384 // Must be called with a base pointer that has been returned by ReserveRegion |
369 // and the same size it was reserved with. | 385 // and the same size it was reserved with. |
370 static bool ReleaseRegion(void* base, size_t size); | 386 static bool ReleaseRegion(void* base, size_t size); |
371 | 387 |
388 // Must be called with a base pointer that has been returned by ReserveRegion | |
389 // and the same size it was reserved with. | |
390 // [free_start, free_start + free_size] is the memory that will be released. | |
391 static bool ReleasePartialRegion(void* base, size_t size, void* free_start, | |
392 size_t free_size); | |
393 | |
372 // Returns true if OS performs lazy commits, i.e. the memory allocation call | 394 // Returns true if OS performs lazy commits, i.e. the memory allocation call |
373 // defers actual physical memory allocation till the first memory access. | 395 // defers actual physical memory allocation till the first memory access. |
374 // Otherwise returns false. | 396 // Otherwise returns false. |
375 static bool HasLazyCommits(); | 397 static bool HasLazyCommits(); |
376 | 398 |
377 private: | 399 private: |
378 bool InVM(void* address, size_t size) { | 400 bool InVM(void* address, size_t size) { |
379 return (reinterpret_cast<uintptr_t>(address_) <= | 401 return (reinterpret_cast<uintptr_t>(address_) <= |
380 reinterpret_cast<uintptr_t>(address)) && | 402 reinterpret_cast<uintptr_t>(address)) && |
381 ((reinterpret_cast<uintptr_t>(address_) + size_) >= | 403 ((reinterpret_cast<uintptr_t>(address_) + size_) >= |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 int stack_size_; | 511 int stack_size_; |
490 Semaphore* start_semaphore_; | 512 Semaphore* start_semaphore_; |
491 | 513 |
492 DISALLOW_COPY_AND_ASSIGN(Thread); | 514 DISALLOW_COPY_AND_ASSIGN(Thread); |
493 }; | 515 }; |
494 | 516 |
495 } // namespace base | 517 } // namespace base |
496 } // namespace v8 | 518 } // namespace v8 |
497 | 519 |
498 #endif // V8_BASE_PLATFORM_PLATFORM_H_ | 520 #endif // V8_BASE_PLATFORM_PLATFORM_H_ |
OLD | NEW |