Ignore:
Timestamp:
Sep 7, 2008, 1:39:38 AM (17 years ago)
Author:
[email protected]
Message:

2008-09-07 Cameron Zwarich <[email protected]>

Reviewed by Sam Weinig.

Remove C-style casts from kjs/collector.cpp.

  • kjs/collector.cpp: (KJS::Heap::heapAllocate): (KJS::currentThreadStackBase): (KJS::Heap::markConservatively): (KJS::otherThreadStackPointer): (KJS::Heap::markOtherThreadConservatively): (KJS::Heap::sweep):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/collector.cpp

    r36006 r36251  
    317317    size_t targetBlockUsedCells;
    318318    if (i != usedBlocks) {
    319         targetBlock = (Block*)heap.blocks[i];
     319        targetBlock = reinterpret_cast<Block*>(heap.blocks[i]);
    320320        targetBlockUsedCells = targetBlock->usedCells;
    321321        ASSERT(targetBlockUsedCells <= HeapConstants<heapType>::cellsPerBlock);
     
    323323            if (++i == usedBlocks)
    324324                goto collect;
    325             targetBlock = (Block*)heap.blocks[i];
     325            targetBlock = reinterpret_cast<Block*>(heap.blocks[i]);
    326326            targetBlockUsedCells = targetBlock->usedCells;
    327327            ASSERT(targetBlockUsedCells <= HeapConstants<heapType>::cellsPerBlock);
     
    359359        }
    360360
    361         targetBlock = (Block*)allocateBlock<heapType>();
     361        targetBlock = reinterpret_cast<Block*>(allocateBlock<heapType>());
    362362        targetBlock->freeList = targetBlock->cells;
    363363        targetBlock->heap = this;
    364364        targetBlockUsedCells = 0;
    365         heap.blocks[usedBlocks] = (CollectorBlock*)targetBlock;
     365        heap.blocks[usedBlocks] = reinterpret_cast<CollectorBlock*>(targetBlock);
    366366        heap.usedBlocks = usedBlocks + 1;
    367367        heap.firstBlockWithPossibleSpace = usedBlocks;
     
    408408        MOV pTib, EAX
    409409    }
    410     return (void*)pTib->StackBase;
     410    return static_cast<void*>(pTib->StackBase);
    411411#elif PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC)
    412412    PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb());
    413     return (void*)pTib->StackBase;
     413    return static_cast<void*>(pTib->StackBase);
    414414#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(GCC)
    415415    // offset 0x18 from the FS segment register gives a pointer to
     
    419419          : "=r" (pTib)
    420420        );
    421     return (void*)pTib->StackBase;
     421    return static_cast<void*>(pTib->StackBase);
    422422#elif PLATFORM(SOLARIS)
    423423    stack_t s;
     
    534534    }
    535535
    536     ASSERT(((char*)end - (char*)start) < 0x1000000);
     536    ASSERT((static_cast<char*>(end) - static_cast<char*>(start)) < 0x1000000);
    537537    ASSERT(IS_POINTER_ALIGNED(start));
    538538    ASSERT(IS_POINTER_ALIGNED(end));
    539539
    540     char** p = (char**)start;
    541     char** e = (char**)end;
     540    char** p = static_cast<char**>(start);
     541    char** e = static_cast<char**>(end);
    542542
    543543    size_t usedPrimaryBlocks = primaryHeap.usedBlocks;
     
    566566            for (size_t block = 0; block < usedPrimaryBlocks; block++) {
    567567                if ((primaryBlocks[block] == blockAddr) & (offset <= lastCellOffset)) {
    568                     if (((CollectorCell*)xAsBits)->u.freeCell.zeroIfFree != 0) {
     568                    if (reinterpret_cast<CollectorCell*>(xAsBits)->u.freeCell.zeroIfFree != 0) {
    569569                        JSCell* imp = reinterpret_cast<JSCell*>(xAsBits);
    570570                        if (!imp->marked())
     
    700700
    701701#if PLATFORM(X86)
    702     return (void*)regs.__esp;
     702    return reinterpret_cast<void*>(regs.__esp);
    703703#elif PLATFORM(X86_64)
    704     return (void*)regs.__rsp;
     704    return reinterpret_cast<void*>(regs.__rsp);
    705705#elif PLATFORM(PPC) || PLATFORM(PPC64)
    706     return (void*)regs.__r1;
     706    return reinterpret_cast<void*>(regs.__r1);
    707707#elif PLATFORM(ARM)
    708     return (void*)regs.__sp;
     708    return reinterpret_cast<void*>(regs.__sp);
    709709#else
    710710#error Unknown Architecture
     
    714714
    715715#if PLATFORM(X86)
    716     return (void*)regs.esp;
     716    return reinterpret_cast<void*>(regs.esp);
    717717#elif PLATFORM(X86_64)
    718     return (void*)regs.rsp;
     718    return reinterpret_cast<void*>(regs.rsp);
    719719#elif (PLATFORM(PPC) || PLATFORM(PPC64))
    720     return (void*)regs.r1;
     720    return reinterpret_cast<void*>(regs.r1);
    721721#else
    722722#error Unknown Architecture
     
    727727// end PLATFORM(DARWIN)
    728728#elif PLATFORM(X86) && PLATFORM(WIN_OS)
    729     return (void*)(uintptr_t)regs.Esp;
     729    return reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(regs.Esp));
    730730#else
    731731#error Need a way to get the stack pointer for another thread on this platform
     
    741741
    742742    // mark the thread's registers
    743     markConservatively((void*)&regs, (void*)((char*)&regs + regSize));
     743    markConservatively(static_cast<void*>(&regs), static_cast<void*>(reinterpret_cast<char*>(&regs) + regSize));
    744744
    745745    void* stackPointer = otherThreadStackPointer(regs);
     
    859859   
    860860    for (size_t block = 0; block < heap.usedBlocks; block++) {
    861         Block* curBlock = (Block*)heap.blocks[block];
     861        Block* curBlock = reinterpret_cast<Block*>(heap.blocks[block]);
    862862       
    863863        size_t usedCells = curBlock->usedCells;
     
    922922            if (emptyBlocks > SPARE_EMPTY_BLOCKS) {
    923923#if !DEBUG_COLLECTOR
    924                 freeBlock((CollectorBlock*)curBlock);
     924                freeBlock(reinterpret_cast<CollectorBlock*>(curBlock));
    925925#endif
    926926                // swap with the last block so we compact as we go
     
    931931                if (heap.numBlocks > MIN_ARRAY_SIZE && heap.usedBlocks < heap.numBlocks / LOW_WATER_FACTOR) {
    932932                    heap.numBlocks = heap.numBlocks / GROWTH_FACTOR;
    933                     heap.blocks = (CollectorBlock**)fastRealloc(heap.blocks, heap.numBlocks * sizeof(CollectorBlock*));
     933                    heap.blocks = static_cast<CollectorBlock**>(fastRealloc(heap.blocks, heap.numBlocks * sizeof(CollectorBlock*)));
    934934                }
    935935            }
Note: See TracChangeset for help on using the changeset viewer.