Ignore:
Timestamp:
Feb 23, 2010, 12:37:34 AM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: JavaScriptCore: Added support for the OS/2 platform (untested).

Location:
trunk/src/3rdparty/javascriptcore/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.cpp

    r561 r592  
    3737    munmap(reinterpret_cast<char*>(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register));
    3838#elif HAVE(VIRTUALALLOC)
     39
     40
     41
    3942#if PLATFORM(WINCE)
    4043    VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT);
    4144#endif
    4245    VirtualFree(m_buffer, 0, MEM_RELEASE);
     46
    4347#else
    4448    fastFree(m_buffer);
     
    5155    while (madvise(m_start, (m_max - m_start) * sizeof(Register), MADV_FREE) == -1 && errno == EAGAIN) { }
    5256#elif HAVE(VIRTUALALLOC)
     57
     58
     59
     60
    5361    VirtualFree(m_start, (m_max - m_start) * sizeof(Register), MEM_DECOMMIT);
    5462    m_commitEnd = m_start;
     63
    5564#endif
    5665    m_maxUsed = m_start;
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.h

    r561 r592  
    4242#endif
    4343
     44
     45
     46
     47
     48
    4449namespace JSC {
    4550
     
    130135        bool grow(Register* newEnd);
    131136        void shrink(Register* newEnd);
    132        
     137
    133138        void setNumGlobals(size_t numGlobals) { m_numGlobals = numGlobals; }
    134139        int numGlobals() const { return m_numGlobals; }
     
    136141
    137142        Register* lastGlobal() const { return m_start - m_numGlobals; }
    138        
     143
    139144        void markGlobals(MarkStack& markStack, Heap* heap) { heap->markConservatively(markStack, lastGlobal(), m_start); }
    140145        void markCallFrames(MarkStack& markStack, Heap* heap) { heap->markConservatively(markStack, m_start, m_end); }
     
    185190        }
    186191    #elif HAVE(VIRTUALALLOC)
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
    187206        m_buffer = static_cast<Register*>(VirtualAlloc(0, roundUpAllocationSize(bufferLength, commitSize), MEM_RESERVE, PAGE_READWRITE));
    188207        if (!m_buffer) {
     
    205224        }
    206225        m_commitEnd = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_buffer) + committedSize);
    207     #else
    208         /*
     226#endif
     227    #else
     228        /*
    209229         * If neither MMAP nor VIRTUALALLOC are available - use fastMalloc instead.
    210230         *
     
    240260
    241261#if !HAVE(MMAP) && HAVE(VIRTUALALLOC)
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
    242273        if (newEnd > m_commitEnd) {
    243274            size_t size = roundUpAllocationSize(reinterpret_cast<char*>(newEnd) - reinterpret_cast<char*>(m_commitEnd), commitSize);
     
    253284        }
    254285#endif
     286
    255287
    256288        if (newEnd > m_maxUsed)
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp

    r561 r592  
    6868namespace JSC {
    6969
    70 #if PLATFORM(DARWIN) || PLATFORM(WIN_OS)
     70#if PLATFORM(DARWIN) || PLATFORM(WIN_OS)
    7171#define SYMBOL_STRING(name) "_" #name
    7272#else
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp

    r561 r592  
    128128class Heap::Thread {
    129129public:
    130     Thread(pthread_t pthread, const PlatformThread& platThread, void* base) 
     130    Thread(pthread_t pthread, const PlatformThread& platThread, void* base)
    131131        : posixThread(pthread)
    132132        , platformThread(platThread)
     
    172172    }
    173173#endif // PLATFORM(SYMBIAN)
    174    
     174
    175175    memset(&primaryHeap, 0, sizeof(CollectorHeap));
    176176    memset(&numberHeap, 0, sizeof(CollectorHeap));
     
    239239
    240240    memset(reinterpret_cast<void*>(address), 0, BLOCK_SIZE);
     241
     242
     243
    241244#elif PLATFORM(WINCE)
    242245    void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
     
    312315
    313316    if (heap.numBlocks > MIN_ARRAY_SIZE && heap.usedBlocks < heap.numBlocks / LOW_WATER_FACTOR) {
    314         heap.numBlocks = heap.numBlocks / GROWTH_FACTOR; 
     317        heap.numBlocks = heap.numBlocks / GROWTH_FACTOR;
    315318        heap.blocks = static_cast<CollectorBlock**>(fastRealloc(heap.blocks, heap.numBlocks * sizeof(CollectorBlock*)));
    316319    }
     
    325328#elif PLATFORM(SYMBIAN)
    326329    userChunk->Free(reinterpret_cast<TAny*>(block));
     330
     331
    327332#elif PLATFORM(WINCE)
    328333    VirtualFree(block, 0, MEM_RELEASE);
     
    361366    // if a large value survives one garbage collection, there is not much point to
    362367    // collecting more frequently as long as it stays alive.
    363     // NOTE: we target the primaryHeap unconditionally as JSNumber doesn't modify cost 
     368    // NOTE: we target the primaryHeap unconditionally as JSNumber doesn't modify cost
    364369
    365370    primaryHeap.extraCost += cost;
     
    629634        );
    630635    return static_cast<void*>(pTib->StackBase);
     636
     637
     638
     639
    631640#elif PLATFORM(QNX)
    632641    return currentThreadStackBaseQNX();
     
    819828                }
    820829            }
    821          
     830
    822831            // Mark the primary heap
    823832            for (size_t block = 0; block < usedPrimaryBlocks; block++) {
     
    924933    unsigned user_count = x86_THREAD_STATE64_COUNT;
    925934    thread_state_flavor_t flavor = x86_THREAD_STATE64;
    926 #elif PLATFORM(PPC) 
     935#elif PLATFORM(PPC)
    927936    unsigned user_count = PPC_THREAD_STATE_COUNT;
    928937    thread_state_flavor_t flavor = PPC_THREAD_STATE;
     
    939948    kern_return_t result = thread_get_state(platformThread, flavor, (thread_state_t)&regs, &user_count);
    940949    if (result != KERN_SUCCESS) {
    941         WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 
     950        WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION,
    942951                            "JavaScript garbage collection failed because thread_get_state returned an error (%d). This is probably the result of running inside Rosetta, which is not supported.", result);
    943952        CRASH();
     
    10241033
    10251034#ifndef NDEBUG
    1026         // Forbid malloc during the mark phase. Marking a thread suspends it, so 
    1027         // a malloc inside markChildren() would risk a deadlock with a thread that had been 
     1035        // Forbid malloc during the mark phase. Marking a thread suspends it, so
     1036        // a malloc inside markChildren() would risk a deadlock with a thread that had been
    10281037        // suspended while holding the malloc lock.
    10291038        fastMallocForbid();
     
    11081117    // SWEEP: delete everything with a zero refcount (garbage) and unmark everything else
    11091118    CollectorHeap& heap = heapType == PrimaryHeap ? primaryHeap : numberHeap;
    1110    
     1119
    11111120    size_t emptyBlocks = 0;
    11121121    size_t numLiveObjects = heap.numLiveObjects;
    1113    
     1122
    11141123    for (size_t block = 0; block < heap.usedBlocks; block++) {
    11151124        Block* curBlock = reinterpret_cast<Block*>(heap.blocks[block]);
    1116        
     1125
    11171126        size_t usedCells = curBlock->usedCells;
    11181127        Cell* freeList = curBlock->freeList;
    1119        
     1128
    11201129        if (usedCells == HeapConstants<heapType>::cellsPerBlock) {
    11211130            // special case with a block where all cells are used -- testing indicates this happens often
     
    11231132                if (!curBlock->marked.get(i >> HeapConstants<heapType>::bitmapShift)) {
    11241133                    Cell* cell = curBlock->cells + i;
    1125                    
     1134
    11261135                    if (heapType != NumberHeap) {
    11271136                        JSCell* imp = reinterpret_cast<JSCell*>(cell);
    11281137                        // special case for allocated but uninitialized object
    1129                         // (We don't need this check earlier because nothing prior this point 
     1138                        // (We don't need this check earlier because nothing prior this point
    11301139                        // assumes the object has a valid vptr.)
    11311140                        if (cell->u.freeCell.zeroIfFree == 0)
    11321141                            continue;
    1133                        
     1142
    11341143                        imp->~JSCell();
    11351144                    }
    1136                    
     1145
    11371146                    --usedCells;
    11381147                    --numLiveObjects;
    1139                    
     1148
    11401149                    // put cell on the free list
    11411150                    cell->u.freeCell.zeroIfFree = 0;
     
    11581167                        --usedCells;
    11591168                        --numLiveObjects;
    1160                        
     1169
    11611170                        // put cell on the free list
    11621171                        cell->u.freeCell.zeroIfFree = 0;
    1163                         cell->u.freeCell.next = freeList - (cell + 1); 
     1172                        cell->u.freeCell.next = freeList - (cell + 1);
    11641173                        freeList = cell;
    11651174                    }
     
    11671176            }
    11681177        }
    1169        
     1178
    11701179        curBlock->usedCells = static_cast<uint32_t>(usedCells);
    11711180        curBlock->freeList = freeList;
    11721181        curBlock->marked.clearAll();
    1173        
     1182
    11741183        if (!usedCells)
    11751184            ++emptyBlocks;
    11761185    }
    1177    
     1186
    11781187    if (heap.numLiveObjects != numLiveObjects)
    11791188        heap.firstBlockWithPossibleSpace = 0;
    1180    
     1189
    11811190    heap.numLiveObjects = numLiveObjects;
    11821191    heap.numLiveObjectsAtLastCollect = numLiveObjects;
    11831192    heap.extraCost = 0;
    1184    
     1193
    11851194    if (!emptyBlocks)
    11861195        return numLiveObjects;
     
    12541263}
    12551264
    1256 size_t Heap::objectCount() 
    1257 {
    1258     return primaryHeap.numLiveObjects + numberHeap.numLiveObjects - m_globalData->smallStrings.count(); 
    1259 }
    1260 
    1261 template <HeapType heapType> 
     1265size_t Heap::objectCount()
     1266{
     1267    return primaryHeap.numLiveObjects + numberHeap.numLiveObjects - m_globalData->smallStrings.count();
     1268}
     1269
     1270template <HeapType heapType>
    12621271static void addToStatistics(Heap::Statistics& statistics, const CollectorHeap& heap)
    12631272{
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h

    r561 r592  
    120120        JSGlobalData* globalData() const { return m_globalData; }
    121121        static bool isNumber(JSCell*);
    122        
     122
    123123        // Iterators for the object heap.
    124124        iterator primaryHeapBegin();
     
    182182    template<> struct CellSize<sizeof(uint64_t)> { static const size_t m_value = 64; };
    183183
    184 #if PLATFORM(WINCE) || PLATFORM(SYMBIAN)
     184#if PLATFORM(WINCE) || PLATFORM(SYMBIAN)
    185185    const size_t BLOCK_SIZE = 64 * 1024; // 64k
    186186#else
     
    201201    const size_t BITMAP_SIZE = (CELLS_PER_BLOCK + 7) / 8;
    202202    const size_t BITMAP_WORDS = (BITMAP_SIZE + 3) / sizeof(uint32_t);
    203  
     203
    204204    struct CollectorBitmap {
    205205        uint32_t bits[BITMAP_WORDS];
    206         bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); } 
    207         void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } 
    208         void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } 
     206        bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); }
     207        void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); }
     208        void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); }
    209209        void clearAll() { memset(bits, 0, sizeof(bits)); }
    210210    };
    211  
     211
    212212    struct CollectorCell {
    213213        union {
     
    249249        HeapType type;
    250250    };
    251    
     251
    252252    template <HeapType heapType> struct HeapConstants;
    253253
     
    295295    inline void Heap::reportExtraMemoryCost(size_t cost)
    296296    {
    297         if (cost > minExtraCostSize) 
    298             recordExtraCost(cost / (CELL_SIZE * 2)); 
     297        if (cost > minExtraCostSize)
     298            recordExtraCost(cost / (CELL_SIZE * 2));
    299299    }
    300300
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStackPosix.cpp

    r561 r592  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (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. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
     
    5555void* MarkStack::allocateStack(size_t size)
    5656{
    57 #if defined (__SYMBIAN32__)
     57#if defined (__SYMBIAN32__)
    5858    return fastMalloc(size);
    5959#else
     
    6363void MarkStack::releaseStack(void* addr, size_t size)
    6464{
    65 #if defined (__SYMBIAN32__)
     65#if defined (__SYMBIAN32__)
    6666    fastFree(addr);
    6767#else
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp

    r561 r592  
    22// All rights reserved.
    33// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
    4 // 
     4//
    55// Redistribution and use in source and binary forms, with or without
    66// modification, are permitted provided that the following conditions are
    77// met:
    8 // 
     8//
    99//     * Redistributions of source code must retain the above copyright
    1010// notice, this list of conditions and the following disclaimer.
     
    1616// contributors may be used to endorse or promote products derived from
    1717// this software without specific prior written permission.
    18 // 
     18//
    1919// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    2020// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    177177#endif
    178178
    179 void* fastZeroedMalloc(size_t n) 
     179void* fastZeroedMalloc(size_t n)
    180180{
    181181    void* result = fastMalloc(n);
     
    183183    return result;
    184184}
    185    
    186 TryMallocReturnValue tryFastZeroedMalloc(size_t n) 
     185
     186TryMallocReturnValue tryFastZeroedMalloc(size_t n)
    187187{
    188188    void* result;
     
    198198
    199199#include <stdlib.h>
    200 #if !PLATFORM(WIN_OS)
     200#if PLATFORM(WIN_OS)
     201    #include "windows.h"
     202#elif PLATFORM(OS2)
     203    #define INCL_BASE
     204    #include <os2.h>
     205#else
    201206    #include <pthread.h>
    202 #else
    203     #include "windows.h"
    204207#endif
    205208
    206209namespace WTF {
    207210
    208 TryMallocReturnValue tryFastMalloc(size_t n) 
     211TryMallocReturnValue tryFastMalloc(size_t n)
    209212{
    210213    ASSERT(!isForbidden());
     
    227230}
    228231
    229 void* fastMalloc(size_t n) 
     232void* fastMalloc(size_t n)
    230233{
    231234    ASSERT(!isForbidden());
     
    346349
    347350void releaseFastMallocFreeMemory() { }
    348    
     351
    349352FastMallocStatistics fastMallocStatistics()
    350353{
     
    422425  }                                                                           \
    423426  using FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead::FLAGS_##name
    424  
     427
    425428#define DEFINE_int64(name, value, meaning) \
    426429  DEFINE_VARIABLE(int64_t, name, value, meaning)
    427  
     430
    428431#define DEFINE_double(name, value, meaning) \
    429432  DEFINE_VARIABLE(double, name, value, meaning)
     
    11791182#if defined(WTF_CHANGES)
    11801183#if PLATFORM(X86_64)
    1181 // On all known X86-64 platforms, the upper 16 bits are always unused and therefore 
     1184// On all known X86-64 platforms, the upper 16 bits are always unused and therefore
    11821185// can be excluded from the PageMap key.
    11831186// See http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details
     
    12761279      return GetDescriptor(p);
    12771280  }
    1278    
     1281
    12791282  size_t ReturnedBytes() const;
    12801283#endif
     
    13611364    }
    13621365  }
    1363  
     1366
    13641367    // Allocate a large span of length == n.  If successful, returns a
    13651368  // span of exactly the specified length.  Else, returns NULL.
     
    13771380  // Index of last free list we scavenged
    13781381  size_t scavenge_index_;
    1379  
     1382
    13801383#if defined(WTF_CHANGES) && PLATFORM(DARWIN)
    13811384  friend class FastMallocZone;
     
    14431446}
    14441447
    1445 void TCMalloc_PageHeap::scavenge() 
     1448void TCMalloc_PageHeap::scavenge()
    14461449{
    14471450    // If we have to commit memory in the last 5 seconds, it means we don't have enough free committed pages
     
    14561459        if (!DLL_IsEmpty(&slist->normal)) {
    14571460            // Release the last span on the normal portion of this list
    1458             Span* s = slist->normal.prev; 
     1461            Span* s = slist->normal.prev;
    14591462            // Only decommit up to a fraction of the free committed pages if pages_allocated_since_last_scavenge_ > 0.
    14601463            if ((pagesDecommitted + s->length) * kMaxScavengeAmountFactor > free_committed_pages_)
     
    14781481}
    14791482
    1480 inline bool TCMalloc_PageHeap::shouldContinueScavenging() const 
    1481 {
    1482     return free_committed_pages_ > kMinimumFreeCommittedPageCount; 
     1483inline bool TCMalloc_PageHeap::shouldContinueScavenging() const
     1484{
     1485    return free_committed_pages_ > kMinimumFreeCommittedPageCount;
    14831486}
    14841487
     
    18001803  }
    18011804}
    1802    
     1805
    18031806#ifdef WTF_CHANGES
    18041807size_t TCMalloc_PageHeap::ReturnedBytes() const {
     
    18091812        result += r_pages << kPageShift;
    18101813    }
    1811    
     1814
    18121815    for (Span* s = large_.returned.next; s != &large_.returned; s = s->next)
    18131816        result += s->length << kPageShift;
     
    22892292    ::Sleep(seconds * 1000);
    22902293}
     2294
     2295
     2296
     2297
     2298
    22912299#endif
    22922300
     
    28802888#endif
    28812889  tsd_inited = true;
    2882    
     2890
    28832891#if !COMPILER(MSVC)
    28842892  // We may have used a fake pthread_t for the main thread.  Fix it.
     
    35843592
    35853593#ifndef WTF_CHANGES
    3586 extern "C" 
     3594extern "C"
    35873595#else
    35883596#define do_malloc do_malloc<crashOnFailure>
     
    36263634
    36273635#ifndef WTF_CHANGES
    3628 extern "C" 
     3636extern "C"
    36293637#endif
    36303638void free(void* ptr) {
     
    36473655
    36483656#ifndef WTF_CHANGES
    3649 extern "C" 
     3657extern "C"
    36503658#else
    36513659template <bool crashOnFailure>
     
    36673675void* calloc(size_t n, size_t elem_size) {
    36683676  size_t totalBytes = n * elem_size;
    3669    
     3677
    36703678  // Protect against overflow
    36713679  if (n > 1 && elem_size && (totalBytes / elem_size) != n)
     
    37003708#ifndef WTF_CHANGES
    37013709#ifndef WTF_CHANGES
    3702 extern "C" 
     3710extern "C"
    37033711#endif
    37043712void cfree(void* ptr) {
     
    37113719
    37123720#ifndef WTF_CHANGES
    3713 extern "C" 
     3721extern "C"
    37143722#else
    37153723template <bool crashOnFailure>
     
    43534361    pageheap->ReleaseFreePages();
    43544362}
    4355    
     4363
    43564364FastMallocStatistics fastMallocStatistics()
    43574365{
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h

    r561 r592  
    5858#endif
    5959
     60
     61
     62
     63
     64
     65
     66
    6067/* PLATFORM(WINCE) */
    6168/* Operating system level dependencies for Windows CE that should be used */
     
    224231/* Makes PLATFORM(WIN) default to PLATFORM(CAIRO) */
    225232/* FIXME: This should be changed from a blacklist to a whitelist */
    226 #if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(CHROMIUM) && !PLATFORM(WINCE) && !PLATFORM(HAIKU)
     233#if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(CHROMIUM) && !PLATFORM(WINCE) && !PLATFORM(HAIKU)
    227234#define WTF_PLATFORM_CAIRO 1
    228235#endif
     
    562569#if !PLATFORM(WIN_OS) && !PLATFORM(SOLARIS) && !PLATFORM(QNX) \
    563570    && !PLATFORM(SYMBIAN) && !PLATFORM(HAIKU) && !COMPILER(RVCT) && !PLATFORM(AIX) \
    564     && !PLATFORM(HPUX)
     571    && !PLATFORM(HPUX)
    565572#define HAVE_TM_GMTOFF 1
    566573#define HAVE_TM_ZONE 1
    567574#define HAVE_TIMEGM 1
    568 #endif     
     575#endif
    569576
    570577#if PLATFORM(DARWIN)
     
    599606#endif
    600607#define HAVE_VIRTUALALLOC 1
     608
     609
     610
     611
     612
     613
     614
     615
     616
    601617
    602618#elif PLATFORM(SYMBIAN)
  • trunk/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSystemAlloc.cpp

    r561 r592  
    11// Copyright (c) 2005, 2007, Google Inc.
    22// All rights reserved.
    3 // 
     3//
    44// Redistribution and use in source and binary forms, with or without
    55// modification, are permitted provided that the following conditions are
    66// met:
    7 // 
     7//
    88//     * Redistributions of source code must retain the above copyright
    99// notice, this list of conditions and the following disclaimer.
     
    1515// contributors may be used to endorse or promote products derived from
    1616// this software without specific prior written permission.
    17 // 
     17//
    1818// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    5050#if PLATFORM(WIN_OS)
    5151#include "windows.h"
     52
     53
     54
    5255#else
    5356#include <errno.h>
     
    9093#if HAVE(MMAP)
    9194static bool use_mmap = true;
    92 #endif 
     95#endif
    9396
    9497#if HAVE(VIRTUALALLOC)
     
    118121static void* TrySbrk(size_t size, size_t *actual_size, size_t alignment) {
    119122  size = ((size + alignment - 1) / alignment) * alignment;
    120  
     123
    121124  // could theoretically return the "extra" bytes here, but this
    122125  // is simple and correct.
    123   if (actual_size) 
     126  if (actual_size)
    124127    *actual_size = size;
    125    
     128
    126129  void* result = sbrk(size);
    127130  if (result == reinterpret_cast<void*>(-1)) {
     
    165168  if (alignment < pagesize) alignment = pagesize;
    166169  size = ((size + alignment - 1) / alignment) * alignment;
    167  
     170
    168171  // could theoretically return the "extra" bytes here, but this
    169172  // is simple and correct.
    170   if (actual_size) 
     173  if (actual_size)
    171174    *actual_size = size;
    172    
     175
    173176  // Ask for extra memory if alignment > pagesize
    174177  size_t extra = 0;
     
    211214  // Enforce page alignment
    212215  if (pagesize == 0) {
     216
     217
     218
    213219    SYSTEM_INFO system_info;
    214220    GetSystemInfo(&system_info);
    215221    pagesize = system_info.dwPageSize;
     222
    216223  }
    217224
     
    221228  // could theoretically return the "extra" bytes here, but this
    222229  // is simple and correct.
    223   if (actual_size) 
     230  if (actual_size)
    224231    *actual_size = size;
    225    
     232
    226233  // Ask for extra memory if alignment > pagesize
    227234  size_t extra = 0;
     
    229236    extra = alignment - pagesize;
    230237  }
     238
     239
     240
     241
    231242  void* result = VirtualAlloc(NULL, size + extra,
    232                               MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, 
     243                              MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN,
    233244                              PAGE_READWRITE);
     245
    234246
    235247  if (result == NULL) {
     
    248260  // is decommit, since Windows only lets you free the whole allocation.
    249261  if (adjust > 0) {
     262
     263
     264
    250265    VirtualFree(reinterpret_cast<void*>(ptr), adjust, MEM_DECOMMIT);
     266
    251267  }
    252268  if (adjust < extra) {
     269
     270
     271
    253272    VirtualFree(reinterpret_cast<void*>(ptr + adjust + size), extra-adjust, MEM_DECOMMIT);
     273
    254274  }
    255275
     
    258278}
    259279
    260 #endif /* HAVE(MMAP) */
     280#endif /* HAVE() */
    261281
    262282#ifndef WTF_CHANGES
     
    266286  static off_t physmem_limit; // maximum physical address allowed
    267287  static int physmem_fd;      // file descriptor for /dev/mem
    268  
     288
    269289  // Check if we should use /dev/mem allocation.  Note that it may take
    270290  // a while to get this flag initialized, so meanwhile we fall back to
     
    276296    return NULL;
    277297  }
    278  
     298
    279299  if (!initialized) {
    280300    physmem_fd = open("/dev/mem", O_RDWR);
     
    287307    initialized = true;
    288308  }
    289  
     309
    290310  // Enforce page alignment
    291311  if (pagesize == 0) pagesize = getpagesize();
    292312  if (alignment < pagesize) alignment = pagesize;
    293313  size = ((size + alignment - 1) / alignment) * alignment;
    294    
     314
    295315  // could theoretically return the "extra" bytes here, but this
    296316  // is simple and correct.
    297317  if (actual_size)
    298318    *actual_size = size;
    299    
     319
    300320  // Ask for extra memory if alignment > pagesize
    301321  size_t extra = 0;
     
    303323    extra = alignment - pagesize;
    304324  }
    305  
     325
    306326  // check to see if we have any memory left
    307327  if (physmem_limit != 0 && physmem_base + size + extra > physmem_limit) {
     
    316336  }
    317337  uintptr_t ptr = reinterpret_cast<uintptr_t>(result);
    318  
     338
    319339  // Adjust the return memory so it is aligned
    320340  size_t adjust = 0;
     
    322342    adjust = alignment - (ptr & (alignment - 1));
    323343  }
    324  
     344
    325345  // Return the unused virtual memory to the system
    326346  if (adjust > 0) {
     
    330350    munmap(reinterpret_cast<char*>(ptr + adjust + size), extra - adjust);
    331351  }
    332  
     352
    333353  ptr += adjust;
    334354  physmem_base += adjust + size;
    335  
     355
    336356  return reinterpret_cast<void*>(ptr);
    337357}
     
    341361  // Discard requests that overflow
    342362  if (size + alignment < size) return NULL;
    343    
     363
    344364  SpinLockHolder lock_holder(&spinlock);
    345365
     
    357377    }
    358378#endif
    359    
     379
    360380#if HAVE(SBRK)
    361381    if (use_sbrk && !sbrk_failure) {
     
    365385#endif
    366386
    367 #if HAVE(MMAP)   
     387#if HAVE(MMAP)
    368388    if (use_mmap && !mmap_failure) {
    369389      void* result = TryMmap(size, actual_size, alignment);
     
    452472void TCMalloc_SystemRelease(void* start, size_t length)
    453473{
     474
     475
     476
     477
    454478    if (VirtualFree(start, length, MEM_DECOMMIT))
    455479        return;
     480
    456481
    457482    // The decommit may fail if the memory region consists of allocations
     
    492517void TCMalloc_SystemCommit(void* start, size_t length)
    493518{
     519
     520
     521
     522
    494523    if (VirtualAlloc(start, length, MEM_COMMIT, PAGE_READWRITE) == start)
    495524        return;
     525
    496526
    497527    // The commit may fail if the memory region consists of allocations
Note: See TracChangeset for help on using the changeset viewer.