| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 // from the original object. | 288 // from the original object. |
| 289 class VirtualMemory { | 289 class VirtualMemory { |
| 290 public: | 290 public: |
| 291 // Empty VirtualMemory object, controlling no reserved memory. | 291 // Empty VirtualMemory object, controlling no reserved memory. |
| 292 VirtualMemory(); | 292 VirtualMemory(); |
| 293 | 293 |
| 294 // Reserves virtual memory with size. | 294 // Reserves virtual memory with size. |
| 295 explicit VirtualMemory(size_t size); | 295 explicit VirtualMemory(size_t size); |
| 296 | 296 |
| 297 // Reserves virtual memory containing an area of the given size that | 297 // Reserves virtual memory containing an area of the given size that |
| 298 // is aligned per alignment. This may not be at the position returned | 298 // is aligned per alignment. |
| 299 // by address(). | |
| 300 VirtualMemory(size_t size, size_t alignment); | 299 VirtualMemory(size_t size, size_t alignment); |
| 301 | 300 |
| 302 // Construct a virtual memory by assigning it some already mapped address | 301 // Construct a virtual memory by assigning it some already mapped address |
| 303 // and size. | 302 // and size. |
| 304 VirtualMemory(void* address, size_t size) : address_(address), size_(size) {} | 303 VirtualMemory(void* address, size_t size) : address_(address), size_(size) {} |
| 305 | 304 |
| 306 // Releases the reserved memory, if any, controlled by this VirtualMemory | 305 // Releases the reserved memory, if any, controlled by this VirtualMemory |
| 307 // object. | 306 // object. |
| 308 ~VirtualMemory(); | 307 ~VirtualMemory(); |
| 309 | 308 |
| 310 // Returns whether the memory has been reserved. | 309 // Returns whether the memory has been reserved. |
| 311 bool IsReserved(); | 310 bool IsReserved() const; |
| 312 | 311 |
| 313 // Initialize or resets an embedded VirtualMemory object. | 312 // Initialize or resets an embedded VirtualMemory object. |
| 314 void Reset(); | 313 void Reset(); |
| 315 | 314 |
| 316 // Returns the start address of the reserved memory. | 315 // Returns the start address of the reserved memory. |
| 317 // If the memory was reserved with an alignment, this address is not | 316 void* address() const { |
| 318 // necessarily aligned. The user might need to round it up to a multiple of | |
| 319 // the alignment to get the start of the aligned block. | |
| 320 void* address() { | |
| 321 DCHECK(IsReserved()); | 317 DCHECK(IsReserved()); |
| 322 return address_; | 318 return address_; |
| 323 } | 319 } |
| 324 | 320 |
| 325 // Returns the size of the reserved memory. The returned value is only | 321 // Returns the size of the reserved memory. The returned value is only |
| 326 // meaningful when IsReserved() returns true. | 322 // meaningful when IsReserved() returns true. |
| 327 // If the memory was reserved with an alignment, this size may be larger | 323 size_t size() const { return size_; } |
| 328 // than the requested size. | |
| 329 size_t size() { return size_; } | |
| 330 | 324 |
| 331 // Commits real memory. Returns whether the operation succeeded. | 325 // Commits real memory. Returns whether the operation succeeded. |
| 332 bool Commit(void* address, size_t size, bool is_executable); | 326 bool Commit(void* address, size_t size, bool is_executable); |
| 333 | 327 |
| 334 // Uncommit real memory. Returns whether the operation succeeded. | 328 // Uncommit real memory. Returns whether the operation succeeded. |
| 335 bool Uncommit(void* address, size_t size); | 329 bool Uncommit(void* address, size_t size); |
| 336 | 330 |
| 337 // Creates a single guard page at the given address. | 331 // Creates a single guard page at the given address. |
| 338 bool Guard(void* address); | 332 bool Guard(void* address); |
| 339 | 333 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 int stack_size_; | 506 int stack_size_; |
| 513 Semaphore* start_semaphore_; | 507 Semaphore* start_semaphore_; |
| 514 | 508 |
| 515 DISALLOW_COPY_AND_ASSIGN(Thread); | 509 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 516 }; | 510 }; |
| 517 | 511 |
| 518 } // namespace base | 512 } // namespace base |
| 519 } // namespace v8 | 513 } // namespace v8 |
| 520 | 514 |
| 521 #endif // V8_BASE_PLATFORM_PLATFORM_H_ | 515 #endif // V8_BASE_PLATFORM_PLATFORM_H_ |
| OLD | NEW |