Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 inline void* OSAllocator::reserveAndCommit(size_t reserveSize, size_t commitSize , Usage usage, bool writable, bool executable) | 76 inline void* OSAllocator::reserveAndCommit(size_t reserveSize, size_t commitSize , Usage usage, bool writable, bool executable) |
| 77 { | 77 { |
| 78 void* base = reserveUncommitted(reserveSize, usage, writable, executable); | 78 void* base = reserveUncommitted(reserveSize, usage, writable, executable); |
| 79 commit(base, commitSize, writable, executable); | 79 commit(base, commitSize, writable, executable); |
| 80 return base; | 80 return base; |
| 81 } | 81 } |
| 82 | 82 |
| 83 inline void OSAllocator::decommitAndRelease(void* releaseBase, size_t releaseSiz e, void* decommitBase, size_t decommitSize) | 83 inline void OSAllocator::decommitAndRelease(void* releaseBase, size_t releaseSiz e, void* decommitBase, size_t decommitSize) |
| 84 { | 84 { |
| 85 ASSERT(decommitBase >= releaseBase && (static_cast<char*>(decommitBase) + de commitSize) <= (static_cast<char*>(releaseBase) + releaseSize)); | 85 ASSERT(decommitBase >= releaseBase && (static_cast<char*>(decommitBase) + de commitSize) <= (static_cast<char*>(releaseBase) + releaseSize)); |
| 86 #if OS(WINCE) | |
| 87 // On most platforms we can actually skip this final decommit; releasing the VM will | |
| 88 // implicitly decommit any physical memory in the region. This is not true o n WINCE. | |
| 89 decommit(decommitBase, decommitSize); | |
|
jamesr
2013/04/20 01:37:01
as a followup, could we remove these parameters co
| |
| 90 #else | |
| 91 UNUSED_PARAM(decommitBase); | 86 UNUSED_PARAM(decommitBase); |
| 92 UNUSED_PARAM(decommitSize); | 87 UNUSED_PARAM(decommitSize); |
| 93 #endif | 88 |
| 94 releaseDecommitted(releaseBase, releaseSize); | 89 releaseDecommitted(releaseBase, releaseSize); |
| 95 } | 90 } |
| 96 | 91 |
| 97 inline void OSAllocator::decommitAndRelease(void* base, size_t size) | 92 inline void OSAllocator::decommitAndRelease(void* base, size_t size) |
| 98 { | 93 { |
| 99 decommitAndRelease(base, size, base, size); | 94 decommitAndRelease(base, size, base, size); |
| 100 } | 95 } |
| 101 | 96 |
| 102 template<typename T> | 97 template<typename T> |
| 103 inline T* OSAllocator::reallocateCommitted(T* oldBase, size_t oldSize, size_t ne wSize, Usage usage, bool writable, bool executable) | 98 inline T* OSAllocator::reallocateCommitted(T* oldBase, size_t oldSize, size_t ne wSize, Usage usage, bool writable, bool executable) |
| 104 { | 99 { |
| 105 void* newBase = reserveAndCommit(newSize, usage, writable, executable); | 100 void* newBase = reserveAndCommit(newSize, usage, writable, executable); |
| 106 memcpy(newBase, oldBase, std::min(oldSize, newSize)); | 101 memcpy(newBase, oldBase, std::min(oldSize, newSize)); |
| 107 decommitAndRelease(oldBase, oldSize); | 102 decommitAndRelease(oldBase, oldSize); |
| 108 return static_cast<T*>(newBase); | 103 return static_cast<T*>(newBase); |
| 109 } | 104 } |
| 110 | 105 |
| 111 } // namespace WTF | 106 } // namespace WTF |
| 112 | 107 |
| 113 using WTF::OSAllocator; | 108 using WTF::OSAllocator; |
| 114 | 109 |
| 115 #endif // OSAllocator_h | 110 #endif // OSAllocator_h |
| OLD | NEW |