source: webkit/trunk/JavaScriptCore/wtf/FastMalloc.h@ 38146

Last change on this file since 38146 was 37804, checked in by [email protected], 17 years ago

Really "fix" CTI mode on windows 2k3.

Reviewed my Maciej Stachowiak

This adds new methods fastMallocExecutable and fastFreeExecutable
to wrap allocation for cti code. This still just makes fastMalloc
return executable memory all the time, which will be fixed in a
later patch.

However in windows debug builds all executable allocations will be
allocated on separate executable pages, which should resolve any
remaining 2k3 issues. Conveniently the 2k3 bot will now also fail
if there are any fastFree vs. fastFreeExecutable errors.

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1/*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef WTF_FastMalloc_h
22#define WTF_FastMalloc_h
23
24#include "Platform.h"
25#include <stdlib.h>
26#include <new>
27
28namespace WTF {
29
30 // These functions call abort() if an allocation fails.
31 void* fastMalloc(size_t n);
32 void* fastZeroedMalloc(size_t n);
33 void* fastCalloc(size_t n_elements, size_t element_size);
34 void* fastRealloc(void* p, size_t n);
35
36 // These functions return NULL if an allocation fails.
37 void* tryFastMalloc(size_t n);
38 void* tryFastZeroedMalloc(size_t n);
39 void* tryFastCalloc(size_t n_elements, size_t element_size);
40 void* tryFastRealloc(void* p, size_t n);
41
42 void fastFree(void* p);
43
44 void* fastMallocExecutable(size_t n);
45 void fastFreeExecutable(void* p);
46
47#ifndef NDEBUG
48 void fastMallocForbid();
49 void fastMallocAllow();
50#endif
51
52 void releaseFastMallocFreeMemory();
53
54} // namespace WTF
55
56using WTF::fastMalloc;
57using WTF::fastZeroedMalloc;
58using WTF::fastCalloc;
59using WTF::fastRealloc;
60using WTF::tryFastMalloc;
61using WTF::tryFastZeroedMalloc;
62using WTF::tryFastCalloc;
63using WTF::tryFastRealloc;
64using WTF::fastFree;
65
66#ifndef NDEBUG
67using WTF::fastMallocForbid;
68using WTF::fastMallocAllow;
69#endif
70
71#if COMPILER(GCC) && PLATFORM(DARWIN)
72#define WTF_PRIVATE_INLINE __private_extern__ inline __attribute__((always_inline))
73#elif COMPILER(GCC)
74#define WTF_PRIVATE_INLINE inline __attribute__((always_inline))
75#elif COMPILER(MSVC)
76#define WTF_PRIVATE_INLINE __forceinline
77#else
78#define WTF_PRIVATE_INLINE inline
79#endif
80
81#ifndef _CRTDBG_MAP_ALLOC
82
83#if !defined(USE_SYSTEM_MALLOC) || !(USE_SYSTEM_MALLOC)
84WTF_PRIVATE_INLINE void* operator new(size_t s) { return fastMalloc(s); }
85WTF_PRIVATE_INLINE void operator delete(void* p) { fastFree(p); }
86WTF_PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); }
87WTF_PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); }
88#endif
89
90#endif // _CRTDBG_MAP_ALLOC
91
92#endif /* WTF_FastMalloc_h */
Note: See TracBrowser for help on using the repository browser.