1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef VMTags_h 27 #define VMTags_h 28 29 // On Mac OS X, the VM subsystem allows tagging memory requested from mmap and vm_map 30 // in order to aid tools that inspect system memory use. 31 #if OS(DARWIN) 32 33 #include <mach/vm_statistics.h> 34 35 #if !defined(TARGETING_TIGER) 36 37 #if defined(VM_MEMORY_TCMALLOC) 38 #define VM_TAG_FOR_TCMALLOC_MEMORY VM_MAKE_TAG(VM_MEMORY_TCMALLOC) 39 #else 40 #define VM_TAG_FOR_TCMALLOC_MEMORY VM_MAKE_TAG(53) 41 #endif // defined(VM_MEMORY_TCMALLOC) 42 43 #if defined(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR) 44 #define VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR) 45 #else 46 #define VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY VM_MAKE_TAG(64) 47 #endif // defined(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR) 48 49 #if defined(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE) 50 #define VM_TAG_FOR_REGISTERFILE_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE) 51 #else 52 #define VM_TAG_FOR_REGISTERFILE_MEMORY VM_MAKE_TAG(65) 53 #endif // defined(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE) 54 55 #else // !defined(TARGETING_TIGER) 56 57 // mmap on Tiger fails with tags that work on Leopard, so fall 58 // back to Tiger-compatible tags (that also work on Leopard) 59 // when targeting Tiger. 60 #define VM_TAG_FOR_TCMALLOC_MEMORY -1 61 #define VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY -1 62 #define VM_TAG_FOR_REGISTERFILE_MEMORY -1 63 64 #endif // !defined(TARGETING_TIGER) 65 66 // Tags for vm_map and vm_allocate work on both Tiger and Leopard. 67 68 #if defined(VM_MEMORY_JAVASCRIPT_CORE) 69 #define VM_TAG_FOR_COLLECTOR_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_CORE) 70 #else 71 #define VM_TAG_FOR_COLLECTOR_MEMORY VM_MAKE_TAG(63) 72 #endif // defined(VM_MEMORY_JAVASCRIPT_CORE) 73 74 #if defined(VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS) 75 #define VM_TAG_FOR_WEBCORE_PURGEABLE_MEMORY VM_MAKE_TAG(VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS) 76 #else 77 #define VM_TAG_FOR_WEBCORE_PURGEABLE_MEMORY VM_MAKE_TAG(69) 78 #endif // defined(VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS) 79 80 #else // OS(DARWIN) 81 82 #define VM_TAG_FOR_TCMALLOC_MEMORY -1 83 #define VM_TAG_FOR_COLLECTOR_MEMORY -1 84 #define VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY -1 85 #define VM_TAG_FOR_REGISTERFILE_MEMORY -1 86 #define VM_TAG_FOR_WEBCORE_PURGEABLE_MEMORY -1 87 88 #endif // OS(DARWIN) 89 90 #endif // VMTags_h 91