Changeset 37215 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 2, 2008, 4:48:47 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-02 Darin Adler <Darin Adler>

Reviewed by Geoff Garen.

1.019x as fast on SunSpider.

  • API/JSBase.cpp: (JSEvaluateScript): Use heap. instead of heap-> to work with the heap. (JSCheckScriptSyntax): Ditto. (JSGarbageCollect): Ditto. (JSReportExtraMemoryCost): Ditto.
  • API/JSContextRef.cpp: (JSGlobalContextRetain): Ditto. (JSGlobalContextRelease): Destroy the heap with the destroy function instead of the delete operator. (JSContextGetGlobalObject): Use heap. instead of heap-> to work with the heap.
  • API/JSObjectRef.cpp: (JSObjectMake): Use heap. instead of heap-> to work with the heap. (JSObjectMakeFunctionWithCallback): Ditto. (JSObjectMakeConstructor): Ditto. (JSObjectMakeFunction): Ditto. (JSObjectMakeArray): Ditto. (JSObjectMakeDate): Ditto. (JSObjectMakeError): Ditto. (JSObjectMakeRegExp): Ditto. (JSObjectHasProperty): Ditto. (JSObjectGetProperty): Ditto. (JSObjectSetProperty): Ditto. (JSObjectGetPropertyAtIndex): Ditto. (JSObjectSetPropertyAtIndex): Ditto. (JSObjectDeleteProperty): Ditto. (JSObjectCallAsFunction): Ditto. (JSObjectCallAsConstructor): Ditto. (JSObjectCopyPropertyNames): Ditto. (JSPropertyNameAccumulatorAddName): Ditto.
  • API/JSValueRef.cpp: (JSValueIsEqual): Ditto. (JSValueIsInstanceOfConstructor): Ditto. (JSValueMakeNumber): Ditto. (JSValueMakeString): Ditto. (JSValueToNumber): Ditto. (JSValueToStringCopy): Ditto. (JSValueToObject): Ditto. (JSValueProtect): Ditto. (JSValueUnprotect): Ditto.
  • kjs/ExecState.h: (JSC::ExecState::heap): Update to use the & operator.
  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): Update to initialize a heap member instead of calling new to make a heap. (JSC::JSGlobalData::~JSGlobalData): Destroy the heap with the destroy function instead of the delete operator.
  • kjs/JSGlobalData.h: Change from Heap* to a Heap.
  • kjs/JSGlobalObject.cpp: (JSC::JSGlobalObject::mark): Use the & operator here. (JSC::JSGlobalObject::operator new): Use heap. instead of heap-> to work with the heap.

WebCore:

2008-10-02 Darin Adler <Darin Adler>

Reviewed by Geoff Garen.

  • bindings/js/GCController.cpp: (WebCore::collect): Use heap. instead of heap-> to work with the heap. (WebCore::GCController::gcTimerFired): Ditto. (WebCore::GCController::garbageCollectNow): Ditto.
  • bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::operator new): Ditto.
  • storage/Database.cpp: (WebCore::Database::Database): Ditto.

WebKit/mac:

2008-10-02 Darin Adler <Darin Adler>

Reviewed by Geoff Garen.

  • Misc/WebCoreStatistics.mm: (+[WebCoreStatistics javaScriptObjectsCount]): Use heap. instead of heap-> to work with the heap. (+[WebCoreStatistics javaScriptGlobalObjectsCount]): Ditto. (+[WebCoreStatistics javaScriptProtectedObjectsCount]): Ditto. (+[WebCoreStatistics javaScriptProtectedGlobalObjectsCount]): Ditto. (+[WebCoreStatistics javaScriptProtectedObjectTypeCounts]): Ditto. (+[WebCoreStatistics javaScriptReferencedObjectsCount]): Ditto.

WebKit/win:

2008-10-02 Darin Adler <Darin Adler>

  • WebCoreStatistics.cpp: (WebCoreStatistics::javaScriptObjectsCount): Use heap. instead of heap-> to work with the heap. (WebCoreStatistics::javaScriptGlobalObjectsCount): Ditto. (WebCoreStatistics::javaScriptProtectedObjectsCount): Ditto. (WebCoreStatistics::javaScriptProtectedGlobalObjectsCount): Ditto. (WebCoreStatistics::javaScriptProtectedObjectTypeCounts): Ditto.
  • WebJavaScriptCollector.cpp: (WebJavaScriptCollector::objectCount): Ditto.
Location:
trunk/JavaScriptCore/kjs
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ExecState.h

    r37125 r37215  
    8383        static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; }
    8484
    85         Heap* heap() const { return m_globalData->heap; }
     85        Heap* heap() const { return &m_globalData->heap; }
    8686
    8787    private:
  • trunk/JavaScriptCore/kjs/JSGlobalData.cpp

    r37190 r37215  
    5959JSGlobalData::JSGlobalData(bool isShared)
    6060    : machine(new Machine)
    61     , heap(new Heap(this))
    6261#if ENABLE(JSC_MULTIPLE_THREADS)
    6362    , arrayTable(new HashTable(JSC::arrayTable))
     
    9089    , isSharedInstance(isShared)
    9190    , clientData(0)
     91    , heap(this)
    9292{
    9393}
     
    9595JSGlobalData::~JSGlobalData()
    9696{
    97     delete heap;
     97    heap.destroy();
    9898    delete machine;
    9999#ifndef NDEBUG
    100100    // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.
    101     heap = 0;
    102101    machine = 0;
    103102#endif
  • trunk/JavaScriptCore/kjs/JSGlobalData.h

    r37190 r37215  
    3131
    3232#include <wtf/Forward.h>
    33 #include <wtf/HashCountedSet.h>
    3433#include <wtf/HashMap.h>
    35 #include <wtf/HashSet.h>
    3634#include <wtf/RefCounted.h>
     35#include "collector.h"
    3736#include "SmallStrings.h"
    3837
     
    6564
    6665        Machine* machine;
    67         Heap* heap;
    6866
    6967        const HashTable* arrayTable;
     
    105103        HashSet<JSObject*> arrayVisitedElements;
    106104
     105        Heap heap;
     106
    107107    private:
    108108        JSGlobalData(bool isShared = false);
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r37213 r37215  
    360360    RegisterFile& registerFile = globalData()->machine->registerFile();
    361361    if (registerFile.globalObject() == this)
    362         registerFile.markGlobals(globalData()->heap);
     362        registerFile.markGlobals(&globalData()->heap);
    363363
    364364    markIfNeeded(d()->globalExec->exception());
     
    449449{
    450450#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
    451     return globalData->heap->inlineAllocate(size);
     451    return globalData->heap.inlineAllocate(size);
    452452#else
    453     return globalData->heap->allocate(size);
     453    return globalData->heap.allocate(size);
    454454#endif
    455455}
  • trunk/JavaScriptCore/kjs/collector.cpp

    r36263 r37215  
    124124    , m_globalData(globalData)
    125125{
     126    ASSERT(globalData);
     127
    126128#if ENABLE(JSC_MULTIPLE_THREADS)
    127129    int error = pthread_key_create(&m_currentThreadRegistrar, unregisterThread);
     
    136138Heap::~Heap()
    137139{
     140    // The destroy function must already have been called, so assert this.
     141    ASSERT(!m_globalData);
     142}
     143
     144void Heap::destroy()
     145{
    138146    JSLock lock(false);
    139147
    140     // The global object is not GC protected at this point, so sweeping may delete it (and thus the global data)
    141     // before other objects that may use the global data.
     148    if (!m_globalData)
     149        return;
     150
     151    // The global object is not GC protected at this point, so sweeping may delete it
     152    // (and thus the global data) before other objects that may use the global data.
    142153    RefPtr<JSGlobalData> protect(m_globalData);
    143154
     
    167178    }
    168179#endif
     180
     181    m_globalData = 0;
    169182}
    170183
  • trunk/JavaScriptCore/kjs/collector.h

    r36263 r37215  
    6464        class Thread;
    6565        enum HeapType { PrimaryHeap, NumberHeap };
     66
     67        void destroy();
    6668
    6769#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
     
    7981        bool isBusy(); // true if an allocation or collection is in progress
    8082
    81         ~Heap();
    82 
    8383        static const size_t minExtraCostSize = 256;
    8484
     
    119119        friend class JSGlobalData;
    120120        Heap(JSGlobalData*);
     121        ~Heap();
    121122
    122123        void recordExtraCost(size_t);
Note: See TracChangeset for help on using the changeset viewer.