| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 | 226 |
| 227 size_t OS::AllocateAlignment() { | 227 size_t OS::AllocateAlignment() { |
| 228 return getpagesize(); | 228 return getpagesize(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 void* OS::Allocate(const size_t requested, | 232 void* OS::Allocate(const size_t requested, |
| 233 size_t* allocated, | 233 size_t* allocated, |
| 234 bool executable) { | 234 bool is_executable) { |
| 235 const size_t msize = RoundUp(requested, getpagesize()); | 235 const size_t msize = RoundUp(requested, getpagesize()); |
| 236 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); | 236 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 237 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); | 237 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); |
| 238 if (mbase == MAP_FAILED) { | 238 if (mbase == MAP_FAILED) { |
| 239 LOG(StringEvent("OS::Allocate", "mmap failed")); | 239 LOG(StringEvent("OS::Allocate", "mmap failed")); |
| 240 return NULL; | 240 return NULL; |
| 241 } | 241 } |
| 242 *allocated = msize; | 242 *allocated = msize; |
| 243 UpdateAllocatedSpaceLimits(mbase, msize); | 243 UpdateAllocatedSpaceLimits(mbase, msize); |
| 244 return mbase; | 244 return mbase; |
| 245 } | 245 } |
| 246 | 246 |
| 247 | 247 |
| 248 void OS::Free(void* buf, const size_t length) { | 248 void OS::Free(void* address, const size_t size) { |
| 249 // TODO(1240712): munmap has a return value which is ignored here. | 249 // TODO(1240712): munmap has a return value which is ignored here. |
| 250 munmap(buf, length); | 250 munmap(address, size); |
| 251 } | 251 } |
| 252 | 252 |
| 253 | 253 |
| 254 #ifdef ENABLE_HEAP_PROTECTION |
| 255 |
| 256 void OS::Protect(void* address, size_t size) { |
| 257 UNIMPLEMENTED(); |
| 258 } |
| 259 |
| 260 |
| 261 void OS::Unprotect(void* address, size_t size, bool is_executable) { |
| 262 UNIMPLEMENTED(); |
| 263 } |
| 264 |
| 265 #endif |
| 266 |
| 267 |
| 254 void OS::Sleep(int milliseconds) { | 268 void OS::Sleep(int milliseconds) { |
| 255 usleep(1000 * milliseconds); | 269 usleep(1000 * milliseconds); |
| 256 } | 270 } |
| 257 | 271 |
| 258 | 272 |
| 259 void OS::Abort() { | 273 void OS::Abort() { |
| 260 // Redirect to std abort to signal abnormal program termination | 274 // Redirect to std abort to signal abnormal program termination |
| 261 abort(); | 275 abort(); |
| 262 } | 276 } |
| 263 | 277 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 if (0 == munmap(address(), size())) address_ = MAP_FAILED; | 380 if (0 == munmap(address(), size())) address_ = MAP_FAILED; |
| 367 } | 381 } |
| 368 } | 382 } |
| 369 | 383 |
| 370 | 384 |
| 371 bool VirtualMemory::IsReserved() { | 385 bool VirtualMemory::IsReserved() { |
| 372 return address_ != MAP_FAILED; | 386 return address_ != MAP_FAILED; |
| 373 } | 387 } |
| 374 | 388 |
| 375 | 389 |
| 376 bool VirtualMemory::Commit(void* address, size_t size, bool executable) { | 390 bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { |
| 377 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); | 391 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 378 if (MAP_FAILED == mmap(address, size, prot, | 392 if (MAP_FAILED == mmap(address, size, prot, |
| 379 MAP_PRIVATE | MAP_ANON | MAP_FIXED, | 393 MAP_PRIVATE | MAP_ANON | MAP_FIXED, |
| 380 kMmapFd, kMmapFdOffset)) { | 394 kMmapFd, kMmapFdOffset)) { |
| 381 return false; | 395 return false; |
| 382 } | 396 } |
| 383 | 397 |
| 384 UpdateAllocatedSpaceLimits(address, size); | 398 UpdateAllocatedSpaceLimits(address, size); |
| 385 return true; | 399 return true; |
| 386 } | 400 } |
| 387 | 401 |
| 388 | 402 |
| 389 bool VirtualMemory::Uncommit(void* address, size_t size) { | 403 bool VirtualMemory::Uncommit(void* address, size_t size) { |
| 390 return mmap(address, size, PROT_NONE, | 404 return mmap(address, size, PROT_NONE, |
| 391 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, | 405 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, |
| 392 kMmapFd, kMmapFdOffset) != MAP_FAILED; | 406 kMmapFd, kMmapFdOffset) != MAP_FAILED; |
| 393 } | 407 } |
| 394 | 408 |
| 409 |
| 395 class ThreadHandle::PlatformData : public Malloced { | 410 class ThreadHandle::PlatformData : public Malloced { |
| 396 public: | 411 public: |
| 397 explicit PlatformData(ThreadHandle::Kind kind) { | 412 explicit PlatformData(ThreadHandle::Kind kind) { |
| 398 Initialize(kind); | 413 Initialize(kind); |
| 399 } | 414 } |
| 400 | 415 |
| 401 void Initialize(ThreadHandle::Kind kind) { | 416 void Initialize(ThreadHandle::Kind kind) { |
| 402 switch (kind) { | 417 switch (kind) { |
| 403 case ThreadHandle::SELF: thread_ = pthread_self(); break; | 418 case ThreadHandle::SELF: thread_ = pthread_self(); break; |
| 404 case ThreadHandle::INVALID: thread_ = kNoThread; break; | 419 case ThreadHandle::INVALID: thread_ = kNoThread; break; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 } | 848 } |
| 834 | 849 |
| 835 // This sampler is no longer the active sampler. | 850 // This sampler is no longer the active sampler. |
| 836 active_sampler_ = NULL; | 851 active_sampler_ = NULL; |
| 837 active_ = false; | 852 active_ = false; |
| 838 } | 853 } |
| 839 | 854 |
| 840 #endif // ENABLE_LOGGING_AND_PROFILING | 855 #endif // ENABLE_LOGGING_AND_PROFILING |
| 841 | 856 |
| 842 } } // namespace v8::internal | 857 } } // namespace v8::internal |
| OLD | NEW |