Changeset 636


Ignore:
Timestamp:
Mar 5, 2010, 7:50:20 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

webkit: Appliied r592 to a local javaScriptCore.

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

Legend:

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

    r561 r636  
    3737    munmap(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/webkit/JavaScriptCore/interpreter/RegisterFile.h

    r561 r636  
    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/webkit/JavaScriptCore/jit/JITStubs.cpp

    r561 r636  
    6464namespace JSC {
    6565
    66 #if PLATFORM(DARWIN) || PLATFORM(WIN_OS)
     66#if PLATFORM(DARWIN) || PLATFORM(WIN_OS)
    6767#define SYMBOL_STRING(name) "_" #name
    6868#else
     
    143143    "ret" "\n"
    144144);
    145    
     145
    146146asm volatile (
    147147".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     
    155155    "ret" "\n"
    156156);
    157    
     157
    158158#elif COMPILER(GCC) && PLATFORM(X86_64)
    159159
     
    405405    "ret" "\n"
    406406);
    407    
     407
    408408asm volatile (
    409409".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     
    417417    "ret" "\n"
    418418);
    419    
     419
    420420#elif COMPILER(GCC) && PLATFORM(X86_64)
    421421
     
    648648        }
    649649    }
    650      
     650
    651651     __declspec(naked) void ctiOpThrowNotCaught()
    652652     {
     
    709709        return;
    710710    }
    711    
     711
    712712    JSCell* baseCell = asCell(baseValue);
    713713    Structure* structure = baseCell->structure();
     
    741741        return;
    742742    }
    743    
     743
    744744    stubInfo->initPutByIdReplace(structure);
    745745
     
    757757        return;
    758758    }
    759    
     759
    760760    JSGlobalData* globalData = &callFrame->globalData();
    761761
     
    764764        return;
    765765    }
    766    
     766
    767767    if (isJSString(globalData, baseValue) && propertyName == callFrame->propertyNames().length) {
    768768        // The tradeoff of compiling an patched inline string length access routine does not seem
     
    810810        if (slotBaseObject->structure()->isDictionary())
    811811            slotBaseObject->setStructure(Structure::fromDictionaryTransition(slotBaseObject->structure()));
    812        
     812
    813813        stubInfo->initGetByIdProto(structure, slotBaseObject->structure());
    814814
     
    840840extern "C" {
    841841
    842 static void jscGeneratedNativeCode() 
     842static void jscGeneratedNativeCode()
    843843{
    844844    // When executing a JIT stub function (which might do an allocation), we hack the return address
     
    850850
    851851struct StackHack {
    852     ALWAYS_INLINE StackHack(JITStackFrame& stackFrame) 
     852    ALWAYS_INLINE StackHack(JITStackFrame& stackFrame)
    853853        : stackFrame(stackFrame)
    854854        , savedReturnAddress(*stackFrame.returnAddressSlot())
     
    857857    }
    858858
    859     ALWAYS_INLINE ~StackHack() 
    860     { 
     859    ALWAYS_INLINE ~StackHack()
     860    {
    861861        *stackFrame.returnAddressSlot() = savedReturnAddress;
    862862    }
     
    996996    if (rightIsNumber && v1.getNumber(left))
    997997        return JSValue::encode(jsNumber(stackFrame.globalData, left + right));
    998    
     998
    999999    CallFrame* callFrame = stackFrame.callFrame;
    10001000
     
    10431043{
    10441044    STUB_INIT_STACK_FRAME(stackFrame);
    1045    
     1045
    10461046    JSGlobalData* globalData = stackFrame.globalData;
    10471047    TimeoutChecker& timeoutChecker = globalData->timeoutChecker;
     
    10511051        VM_THROW_EXCEPTION_AT_END();
    10521052    }
    1053    
     1053
    10541054    return timeoutChecker.ticksUntilNextCheck();
    10551055}
     
    13381338        ASSERT_NOT_REACHED();
    13391339    }
    1340    
     1340
    13411341    ASSERT(listIndex < POLYMORPHIC_LIST_CACHE_SIZE);
    13421342    return prototypeStructureList;
     
    14581458    // At least one of these checks must have failed to get to the slow case.
    14591459    ASSERT(!value.isCell() || !baseVal.isCell() || !proto.isCell()
    1460            || !value.isObject() || !baseVal.isObject() || !proto.isObject() 
     1460           || !value.isObject() || !baseVal.isObject() || !proto.isObject()
    14611461           || (asObject(baseVal)->structure()->typeInfo().flags() & (ImplementsHasInstance | OverridesHasInstance)) != ImplementsHasInstance);
    14621462
     
    14951495
    14961496    CallFrame* callFrame = stackFrame.callFrame;
    1497    
     1497
    14981498    JSObject* baseObj = stackFrame.args[0].jsValue().toObject(callFrame);
    14991499
     
    16001600    ExecutableBase* executable = callee->executable();
    16011601    JITCode& jitCode = executable->generatedJITCode();
    1602    
     1602
    16031603    CodeBlock* codeBlock = 0;
    16041604    if (!executable->isHostFunction())
     
    18661866    return JSValue::encode(result);
    18671867}
    1868    
     1868
    18691869DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_string)
    18701870{
    18711871    STUB_INIT_STACK_FRAME(stackFrame);
    1872    
     1872
    18731873    CallFrame* callFrame = stackFrame.callFrame;
    18741874    JSGlobalData* globalData = stackFrame.globalData;
    1875    
     1875
    18761876    JSValue baseValue = stackFrame.args[0].jsValue();
    18771877    JSValue subscript = stackFrame.args[1].jsValue();
    1878    
     1878
    18791879    JSValue result;
    1880    
     1880
    18811881    if (LIKELY(subscript.isUInt32())) {
    18821882        uint32_t i = subscript.asUInt32();
     
    18921892        result = baseValue.get(callFrame, property);
    18931893    }
    1894    
    1895     CHECK_FOR_EXCEPTION_AT_END();
    1896     return JSValue::encode(result);
    1897 }
    1898    
     1894
     1895    CHECK_FOR_EXCEPTION_AT_END();
     1896    return JSValue::encode(result);
     1897}
     1898
    18991899DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_byte_array)
    19001900{
    19011901    STUB_INIT_STACK_FRAME(stackFrame);
    1902    
     1902
    19031903    CallFrame* callFrame = stackFrame.callFrame;
    19041904    JSGlobalData* globalData = stackFrame.globalData;
    1905    
     1905
    19061906    JSValue baseValue = stackFrame.args[0].jsValue();
    19071907    JSValue subscript = stackFrame.args[1].jsValue();
    1908    
     1908
    19091909    JSValue result;
    19101910
     
    19231923        result = baseValue.get(callFrame, property);
    19241924    }
    1925    
     1925
    19261926    CHECK_FOR_EXCEPTION_AT_END();
    19271927    return JSValue::encode(result);
     
    19971997{
    19981998    STUB_INIT_STACK_FRAME(stackFrame);
    1999    
     1999
    20002000    CallFrame* callFrame = stackFrame.callFrame;
    20012001    JSGlobalData* globalData = stackFrame.globalData;
    2002    
     2002
    20032003    JSValue baseValue = stackFrame.args[0].jsValue();
    20042004    JSValue subscript = stackFrame.args[1].jsValue();
    20052005    JSValue value = stackFrame.args[2].jsValue();
    2006    
     2006
    20072007    if (LIKELY(subscript.isUInt32())) {
    20082008        uint32_t i = subscript.asUInt32();
    20092009        if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    20102010            JSByteArray* jsByteArray = asByteArray(baseValue);
    2011            
     2011
    20122012            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    20132013            if (value.isInt32()) {
     
    20152015                return;
    20162016            } else {
    2017                 double dValue = 0;               
     2017                double dValue = 0;
    20182018                if (value.getNumber(dValue)) {
    20192019                    jsByteArray->setIndex(i, dValue);
     
    20332033        }
    20342034    }
    2035    
     2035
    20362036    CHECK_FOR_EXCEPTION_AT_END();
    20372037}
     
    20592059    return result;
    20602060}
    2061    
     2061
    20622062DEFINE_STUB_FUNCTION(int, op_load_varargs)
    20632063{
     
    20802080        int32_t expectedParams = callFrame->callee()->jsExecutable()->parameterCount();
    20812081        int32_t inplaceArgs = min(providedParams, expectedParams);
    2082        
     2082
    20832083        Register* inplaceArgsDst = callFrame->registers() + argsOffset;
    20842084
     
    20882088        Register* inplaceArgsSrc = callFrame->registers() - RegisterFile::CallFrameHeaderSize - expectedParams;
    20892089        Register* inplaceArgsSrc2 = inplaceArgsSrc - providedParams - 1 + inplaceArgs;
    2090  
     2090
    20912091        // First step is to copy the "expected" parameters from their normal location relative to the callframe
    20922092        while (inplaceArgsDst < inplaceArgsEnd)
     
    23452345    start:
    23462346    if (src2.isUndefined()) {
    2347         return src1.isNull() || 
     2347        return src1.isNull() ||
    23482348               (src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) ||
    23492349               src1.isUndefined();
    23502350    }
    2351    
     2351
    23522352    if (src2.isNull()) {
    2353         return src1.isUndefined() || 
     2353        return src1.isUndefined() ||
    23542354               (src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) ||
    23552355               src1.isNull();
     
    23872387        return d == 0.0;
    23882388    }
    2389    
     2389
    23902390    if (src1.isUndefined())
    23912391        return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined();
    2392    
     2392
    23932393    if (src1.isNull())
    23942394        return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined();
     
    23992399        if (src2.isInt32())
    24002400            return static_cast<JSString*>(cell1)->value().toDouble() == src2.asInt32();
    2401            
     2401
    24022402        if (src2.isDouble())
    24032403            return static_cast<JSString*>(cell1)->value().toDouble() == src2.asDouble();
     
    25532553    JSFunction* func = function->make(callFrame, callFrame->scopeChain());
    25542554
    2555     /* 
     2555    /*
    25562556        The Identifier in a FunctionExpression can be referenced from inside
    25572557        the FunctionExpression's FunctionBody to allow the function to call
     
    26632663
    26642664    Interpreter* interpreter = stackFrame.globalData->interpreter;
    2665    
     2665
    26662666    JSValue funcVal = stackFrame.args[0].jsValue();
    26672667    int registerOffset = stackFrame.args[1].int32();
  • trunk/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp

    r561 r636  
    144144class Heap::Thread {
    145145public:
    146     Thread(pthread_t pthread, const PlatformThread& platThread, void* base) 
     146    Thread(pthread_t pthread, const PlatformThread& platThread, void* base)
    147147        : posixThread(pthread)
    148148        , platformThread(platThread)
     
    188188    }
    189189#endif // PLATFORM(SYMBIAN)
    190    
     190
    191191    memset(&primaryHeap, 0, sizeof(CollectorHeap));
    192192    memset(&numberHeap, 0, sizeof(CollectorHeap));
     
    255255
    256256    memset(reinterpret_cast<void*>(address), 0, BLOCK_SIZE);
     257
     258
     259
    257260#elif PLATFORM(WINCE)
    258261    void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
     
    328331
    329332    if (heap.numBlocks > MIN_ARRAY_SIZE && heap.usedBlocks < heap.numBlocks / LOW_WATER_FACTOR) {
    330         heap.numBlocks = heap.numBlocks / GROWTH_FACTOR; 
     333        heap.numBlocks = heap.numBlocks / GROWTH_FACTOR;
    331334        heap.blocks = static_cast<CollectorBlock**>(fastRealloc(heap.blocks, heap.numBlocks * sizeof(CollectorBlock*)));
    332335    }
     
    341344#elif PLATFORM(SYMBIAN)
    342345    userChunk->Free(reinterpret_cast<TAny*>(block));
     346
     347
    343348#elif PLATFORM(WINCE)
    344349    VirtualFree(block, 0, MEM_RELEASE);
     
    377382    // if a large value survives one garbage collection, there is not much point to
    378383    // collecting more frequently as long as it stays alive.
    379     // NOTE: we target the primaryHeap unconditionally as JSNumber doesn't modify cost 
     384    // NOTE: we target the primaryHeap unconditionally as JSNumber doesn't modify cost
    380385
    381386    primaryHeap.extraCost += cost;
     
    602607        );
    603608    return static_cast<void*>(pTib->StackBase);
     609
     610
     611
     612
    604613#elif PLATFORM(QNX)
    605614    return currentThreadStackBaseQNX();
     
    821830                }
    822831            }
    823          
     832
    824833            // Mark the primary heap
    825834            for (size_t block = 0; block < usedPrimaryBlocks; block++) {
     
    926935    unsigned user_count = x86_THREAD_STATE64_COUNT;
    927936    thread_state_flavor_t flavor = x86_THREAD_STATE64;
    928 #elif PLATFORM(PPC) 
     937#elif PLATFORM(PPC)
    929938    unsigned user_count = PPC_THREAD_STATE_COUNT;
    930939    thread_state_flavor_t flavor = PPC_THREAD_STATE;
     
    941950    kern_return_t result = thread_get_state(platformThread, flavor, (thread_state_t)&regs, &user_count);
    942951    if (result != KERN_SUCCESS) {
    943         WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 
     952        WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION,
    944953                            "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);
    945954        CRASH();
     
    10261035
    10271036#ifndef NDEBUG
    1028         // Forbid malloc during the mark phase. Marking a thread suspends it, so 
    1029         // a malloc inside markChildren() would risk a deadlock with a thread that had been 
     1037        // Forbid malloc during the mark phase. Marking a thread suspends it, so
     1038        // a malloc inside markChildren() would risk a deadlock with a thread that had been
    10301039        // suspended while holding the malloc lock.
    10311040        fastMallocForbid();
     
    10821091    // SWEEP: delete everything with a zero refcount (garbage) and unmark everything else
    10831092    CollectorHeap& heap = heapType == PrimaryHeap ? primaryHeap : numberHeap;
    1084    
     1093
    10851094    size_t emptyBlocks = 0;
    10861095    size_t numLiveObjects = heap.numLiveObjects;
    1087    
     1096
    10881097    for (size_t block = 0; block < heap.usedBlocks; block++) {
    10891098        Block* curBlock = reinterpret_cast<Block*>(heap.blocks[block]);
    1090        
     1099
    10911100        size_t usedCells = curBlock->usedCells;
    10921101        Cell* freeList = curBlock->freeList;
    1093        
     1102
    10941103        if (usedCells == HeapConstants<heapType>::cellsPerBlock) {
    10951104            // special case with a block where all cells are used -- testing indicates this happens often
     
    10971106                if (!curBlock->marked.get(i >> HeapConstants<heapType>::bitmapShift)) {
    10981107                    Cell* cell = curBlock->cells + i;
    1099                    
     1108
    11001109                    if (heapType != NumberHeap) {
    11011110                        JSCell* imp = reinterpret_cast<JSCell*>(cell);
    11021111                        // special case for allocated but uninitialized object
    1103                         // (We don't need this check earlier because nothing prior this point 
     1112                        // (We don't need this check earlier because nothing prior this point
    11041113                        // assumes the object has a valid vptr.)
    11051114                        if (cell->u.freeCell.zeroIfFree == 0)
    11061115                            continue;
    1107                        
     1116
    11081117                        imp->~JSCell();
    11091118                    }
    1110                    
     1119
    11111120                    --usedCells;
    11121121                    --numLiveObjects;
    1113                    
     1122
    11141123                    // put cell on the free list
    11151124                    cell->u.freeCell.zeroIfFree = 0;
     
    11321141                        --usedCells;
    11331142                        --numLiveObjects;
    1134                        
     1143
    11351144                        // put cell on the free list
    11361145                        cell->u.freeCell.zeroIfFree = 0;
    1137                         cell->u.freeCell.next = freeList - (cell + 1); 
     1146                        cell->u.freeCell.next = freeList - (cell + 1);
    11381147                        freeList = cell;
    11391148                    }
     
    11411150            }
    11421151        }
    1143        
     1152
    11441153        curBlock->usedCells = static_cast<uint32_t>(usedCells);
    11451154        curBlock->freeList = freeList;
    11461155        curBlock->marked.clearAll();
    1147        
     1156
    11481157        if (!usedCells)
    11491158            ++emptyBlocks;
    11501159    }
    1151    
     1160
    11521161    if (heap.numLiveObjects != numLiveObjects)
    11531162        heap.firstBlockWithPossibleSpace = 0;
    1154    
     1163
    11551164    heap.numLiveObjects = numLiveObjects;
    11561165    heap.numLiveObjectsAtLastCollect = numLiveObjects;
    11571166    heap.extraCost = 0;
    1158    
     1167
    11591168    if (!emptyBlocks)
    11601169        return numLiveObjects;
     
    12241233}
    12251234
    1226 size_t Heap::objectCount() 
    1227 {
    1228     return primaryHeap.numLiveObjects + numberHeap.numLiveObjects - m_globalData->smallStrings.count(); 
    1229 }
    1230 
    1231 template <HeapType heapType> 
     1235size_t Heap::objectCount()
     1236{
     1237    return primaryHeap.numLiveObjects + numberHeap.numLiveObjects - m_globalData->smallStrings.count();
     1238}
     1239
     1240template <HeapType heapType>
    12321241static void addToStatistics(Heap::Statistics& statistics, const CollectorHeap& heap)
    12331242{
  • trunk/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.h

    r561 r636  
    111111        JSGlobalData* globalData() const { return m_globalData; }
    112112        static bool isNumber(JSCell*);
    113        
     113
    114114        // Iterators for the object heap.
    115115        iterator primaryHeapBegin();
     
    172172    template<> struct CellSize<sizeof(uint64_t)> { static const size_t m_value = 64; };
    173173
    174 #if PLATFORM(WINCE) || PLATFORM(SYMBIAN)
     174#if PLATFORM(WINCE) || PLATFORM(SYMBIAN)
    175175    const size_t BLOCK_SIZE = 64 * 1024; // 64k
    176176#else
     
    191191    const size_t BITMAP_SIZE = (CELLS_PER_BLOCK + 7) / 8;
    192192    const size_t BITMAP_WORDS = (BITMAP_SIZE + 3) / sizeof(uint32_t);
    193  
     193
    194194    struct CollectorBitmap {
    195195        uint32_t bits[BITMAP_WORDS];
    196         bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); } 
    197         void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); } 
    198         void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); } 
     196        bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); }
     197        void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); }
     198        void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); }
    199199        void clearAll() { memset(bits, 0, sizeof(bits)); }
    200200    };
    201  
     201
    202202    struct CollectorCell {
    203203        union {
     
    239239        HeapType type;
    240240    };
    241    
     241
    242242    template <HeapType heapType> struct HeapConstants;
    243243
     
    285285    inline void Heap::reportExtraMemoryCost(size_t cost)
    286286    {
    287         if (cost > minExtraCostSize) 
    288             recordExtraCost(cost / (CELL_SIZE * 2)); 
     287        if (cost > minExtraCostSize)
     288            recordExtraCost(cost / (CELL_SIZE * 2));
    289289    }
    290290
  • trunk/src/3rdparty/webkit/JavaScriptCore/runtime/MarkStackPosix.cpp

    r561 r636  
    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
     
    4141void* MarkStack::allocateStack(size_t size)
    4242{
     43
     44
     45
    4346    return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
     47
    4448}
    4549void MarkStack::releaseStack(void* addr, size_t size)
    4650{
     51
     52
     53
    4754    munmap(addr, size);
     55
    4856}
    4957
  • trunk/src/3rdparty/webkit/JavaScriptCore/wtf/FastMalloc.cpp

    r561 r636  
    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
     
    172172#endif
    173173
    174 void* fastZeroedMalloc(size_t n) 
     174void* fastZeroedMalloc(size_t n)
    175175{
    176176    void* result = fastMalloc(n);
     
    178178    return result;
    179179}
    180    
    181 TryMallocReturnValue tryFastZeroedMalloc(size_t n) 
     180
     181TryMallocReturnValue tryFastZeroedMalloc(size_t n)
    182182{
    183183    void* result;
     
    193193
    194194#include <stdlib.h>
    195 #if !PLATFORM(WIN_OS)
     195#if PLATFORM(WIN_OS)
     196    #include "windows.h"
     197#elif PLATFORM(OS2)
     198    #define INCL_BASE
     199    #include <os2.h>
     200#else
    196201    #include <pthread.h>
    197 #else
    198     #include "windows.h"
    199202#endif
    200203
    201204namespace WTF {
    202205
    203 TryMallocReturnValue tryFastMalloc(size_t n) 
     206TryMallocReturnValue tryFastMalloc(size_t n)
    204207{
    205208    ASSERT(!isForbidden());
     
    222225}
    223226
    224 void* fastMalloc(size_t n) 
     227void* fastMalloc(size_t n)
    225228{
    226229    ASSERT(!isForbidden());
     
    341344
    342345void releaseFastMallocFreeMemory() { }
    343    
     346
    344347FastMallocStatistics fastMallocStatistics()
    345348{
     
    417420  }                                                                           \
    418421  using FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead::FLAGS_##name
    419  
     422
    420423#define DEFINE_int64(name, value, meaning) \
    421424  DEFINE_VARIABLE(int64_t, name, value, meaning)
    422  
     425
    423426#define DEFINE_double(name, value, meaning) \
    424427  DEFINE_VARIABLE(double, name, value, meaning)
     
    11741177#if defined(WTF_CHANGES)
    11751178#if PLATFORM(X86_64)
    1176 // On all known X86-64 platforms, the upper 16 bits are always unused and therefore 
     1179// On all known X86-64 platforms, the upper 16 bits are always unused and therefore
    11771180// can be excluded from the PageMap key.
    11781181// See http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details
     
    12711274      return GetDescriptor(p);
    12721275  }
    1273    
     1276
    12741277  size_t ReturnedBytes() const;
    12751278#endif
     
    13561359    }
    13571360  }
    1358  
     1361
    13591362    // Allocate a large span of length == n.  If successful, returns a
    13601363  // span of exactly the specified length.  Else, returns NULL.
     
    13721375  // Index of last free list we scavenged
    13731376  size_t scavenge_index_;
    1374  
     1377
    13751378#if defined(WTF_CHANGES) && PLATFORM(DARWIN)
    13761379  friend class FastMallocZone;
     
    14381441}
    14391442
    1440 void TCMalloc_PageHeap::scavenge() 
     1443void TCMalloc_PageHeap::scavenge()
    14411444{
    14421445    // If we have to commit memory in the last 5 seconds, it means we don't have enough free committed pages
     
    14511454        if (!DLL_IsEmpty(&slist->normal)) {
    14521455            // Release the last span on the normal portion of this list
    1453             Span* s = slist->normal.prev; 
     1456            Span* s = slist->normal.prev;
    14541457            // Only decommit up to a fraction of the free committed pages if pages_allocated_since_last_scavenge_ > 0.
    14551458            if ((pagesDecommitted + s->length) * kMaxScavengeAmountFactor > free_committed_pages_)
     
    14731476}
    14741477
    1475 inline bool TCMalloc_PageHeap::shouldContinueScavenging() const 
    1476 {
    1477     return free_committed_pages_ > kMinimumFreeCommittedPageCount; 
     1478inline bool TCMalloc_PageHeap::shouldContinueScavenging() const
     1479{
     1480    return free_committed_pages_ > kMinimumFreeCommittedPageCount;
    14781481}
    14791482
     
    17951798  }
    17961799}
    1797    
     1800
    17981801#ifdef WTF_CHANGES
    17991802size_t TCMalloc_PageHeap::ReturnedBytes() const {
     
    18041807        result += r_pages << kPageShift;
    18051808    }
    1806    
     1809
    18071810    for (Span* s = large_.returned.next; s != &large_.returned; s = s->next)
    18081811        result += s->length << kPageShift;
     
    22842287    ::Sleep(seconds * 1000);
    22852288}
     2289
     2290
     2291
     2292
     2293
    22862294#endif
    22872295
     
    28752883#endif
    28762884  tsd_inited = true;
    2877    
     2885
    28782886#if !COMPILER(MSVC)
    28792887  // We may have used a fake pthread_t for the main thread.  Fix it.
     
    35793587
    35803588#ifndef WTF_CHANGES
    3581 extern "C" 
     3589extern "C"
    35823590#else
    35833591#define do_malloc do_malloc<crashOnFailure>
     
    36213629
    36223630#ifndef WTF_CHANGES
    3623 extern "C" 
     3631extern "C"
    36243632#endif
    36253633void free(void* ptr) {
     
    36423650
    36433651#ifndef WTF_CHANGES
    3644 extern "C" 
     3652extern "C"
    36453653#else
    36463654template <bool crashOnFailure>
     
    36623670void* calloc(size_t n, size_t elem_size) {
    36633671  size_t totalBytes = n * elem_size;
    3664    
     3672
    36653673  // Protect against overflow
    36663674  if (n > 1 && elem_size && (totalBytes / elem_size) != n)
     
    36953703#ifndef WTF_CHANGES
    36963704#ifndef WTF_CHANGES
    3697 extern "C" 
     3705extern "C"
    36983706#endif
    36993707void cfree(void* ptr) {
     
    37063714
    37073715#ifndef WTF_CHANGES
    3708 extern "C" 
     3716extern "C"
    37093717#else
    37103718template <bool crashOnFailure>
     
    43484356    pageheap->ReleaseFreePages();
    43494357}
    4350    
     4358
    43514359FastMallocStatistics fastMallocStatistics()
    43524360{
  • trunk/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h

    r561 r636  
    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 */
     
    201208/* Makes PLATFORM(WIN) default to PLATFORM(CAIRO) */
    202209/* FIXME: This should be changed from a blacklist to a whitelist */
    203 #if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(CHROMIUM) && !PLATFORM(WINCE) && !PLATFORM(HAIKU)
     210#if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(CHROMIUM) && !PLATFORM(WINCE) && !PLATFORM(HAIKU)
    204211#define WTF_PLATFORM_CAIRO 1
    205212#endif
     
    565572
    566573#if !PLATFORM(WIN_OS) && !PLATFORM(SOLARIS) && !PLATFORM(QNX) \
    567     && !PLATFORM(SYMBIAN) && !PLATFORM(HAIKU) && !COMPILER(RVCT)
     574    && !PLATFORM(SYMBIAN) && !PLATFORM(HAIKU) && !COMPILER(RVCT) \
     575    && !PLATFORM(OS2)
    568576#define HAVE_TM_GMTOFF 1
    569577#define HAVE_TM_ZONE 1
    570578#define HAVE_TIMEGM 1
    571 #endif     
     579#endif
    572580
    573581#if PLATFORM(DARWIN)
     
    602610#endif
    603611#define HAVE_VIRTUALALLOC 1
     612
     613
     614
     615
     616
     617
     618
     619
     620
    604621
    605622#elif PLATFORM(SYMBIAN)
  • trunk/src/3rdparty/webkit/JavaScriptCore/wtf/TCSystemAlloc.cpp

    r561 r636  
    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) {
     
    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.