Chromium Code Reviews| 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 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1405 return false; | 1405 return false; |
| 1406 } | 1406 } |
| 1407 | 1407 |
| 1408 UpdateAllocatedSpaceLimits(address, static_cast<int>(size)); | 1408 UpdateAllocatedSpaceLimits(address, static_cast<int>(size)); |
| 1409 return true; | 1409 return true; |
| 1410 } | 1410 } |
| 1411 | 1411 |
| 1412 | 1412 |
| 1413 bool VirtualMemory::Uncommit(void* address, size_t size) { | 1413 bool VirtualMemory::Uncommit(void* address, size_t size) { |
| 1414 ASSERT(IsReserved()); | 1414 ASSERT(IsReserved()); |
| 1415 return VirtualFree(address, size, MEM_DECOMMIT) != false; | 1415 return VirtualFree(address, size, MEM_DECOMMIT) != false; |
|
Vyacheslav Egorov (Chromium)
2011/06/28 12:28:37
I think on Linux these methods are expressed via *
Lasse Reichstein
2011/06/29 10:54:58
Doesn't seem any shorter, but perhaps a little cle
| |
| 1416 } | 1416 } |
| 1417 | 1417 |
| 1418 | 1418 |
| 1419 void* VirtualMemory::ReserveRegion(size_t size) { | |
| 1420 return VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS); | |
| 1421 } | |
| 1422 | |
| 1423 | |
| 1424 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { | |
| 1425 int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; | |
| 1426 if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) { | |
| 1427 return false; | |
| 1428 } | |
| 1429 | |
| 1430 UpdateAllocatedSpaceLimits(base, static_cast<int>(size)); | |
| 1431 return true; | |
| 1432 } | |
| 1433 | |
| 1434 | |
| 1435 bool VirtualMemory::UncommitRegion(void* base, size_t size) { | |
| 1436 return VirtualFree(base, size, MEM_DECOMMIT) != false; | |
| 1437 } | |
| 1438 | |
| 1439 | |
| 1440 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { | |
| 1441 return VirtualFree(base, size, MEM_DECOMMIT) != false; | |
| 1442 } | |
| 1443 | |
| 1444 | |
| 1445 | |
| 1419 // ---------------------------------------------------------------------------- | 1446 // ---------------------------------------------------------------------------- |
| 1420 // Win32 thread support. | 1447 // Win32 thread support. |
| 1421 | 1448 |
| 1422 // Definition of invalid thread handle and id. | 1449 // Definition of invalid thread handle and id. |
| 1423 static const HANDLE kNoThread = INVALID_HANDLE_VALUE; | 1450 static const HANDLE kNoThread = INVALID_HANDLE_VALUE; |
| 1424 static const DWORD kNoThreadId = 0; | 1451 static const DWORD kNoThreadId = 0; |
| 1425 | 1452 |
| 1426 | 1453 |
| 1427 class ThreadHandle::PlatformData : public Malloced { | 1454 class ThreadHandle::PlatformData : public Malloced { |
| 1428 public: | 1455 public: |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 | 1992 |
| 1966 // Release the thread handles | 1993 // Release the thread handles |
| 1967 CloseHandle(data_->sampler_thread_); | 1994 CloseHandle(data_->sampler_thread_); |
| 1968 CloseHandle(data_->profiled_thread_); | 1995 CloseHandle(data_->profiled_thread_); |
| 1969 } | 1996 } |
| 1970 | 1997 |
| 1971 | 1998 |
| 1972 #endif // ENABLE_LOGGING_AND_PROFILING | 1999 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1973 | 2000 |
| 1974 } } // namespace v8::internal | 2001 } } // namespace v8::internal |
| OLD | NEW |