Changeset 34977 in webkit for trunk/JavaScriptCore/API/JSBase.cpp


Ignore:
Timestamp:
Jul 3, 2008, 12:44:43 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoff.

Don't create unnecessary JSGlobalData instances.

  • kjs/JSGlobalData.h:
  • kjs/JSGlobalData.cpp: (KJS::JSGlobalData::threadInstanceExists): (KJS::JSGlobalData::sharedInstanceExists): (KJS::JSGlobalData::threadInstance): (KJS::JSGlobalData::sharedInstance): (KJS::JSGlobalData::threadInstanceInternal): (KJS::JSGlobalData::sharedInstanceInternal): Added methods to query instance existence.
  • kjs/InitializeThreading.cpp: (KJS::initializeThreadingOnce): Initialize thread instance static in a new way.
  • API/JSBase.cpp: (JSGarbageCollect):
  • kjs/collector.cpp: (KJS::Heap::collect): Check for instance existence before accessing it.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSBase.cpp

    r34947 r34977  
    8989    // and it may actually be garbage for some clients (most likely, because of JSGarbageCollect being called after releasing the context).
    9090
    91     // FIXME: It would be good to avoid creating a JSGlobalData instance if it didn't exist for this thread yet.
    92     Heap* heap = JSGlobalData::threadInstance().heap;
    93     if (!heap->isBusy())
    94         heap->collect();
     91    if (JSGlobalData::threadInstanceExists()) {
     92        Heap* heap = JSGlobalData::threadInstance().heap;
     93        if (!heap->isBusy())
     94            heap->collect();
     95    }
    9596
    9697    JSLock lock(true);
    9798
    98     // FIXME: Similarly, we shouldn't create a shared instance here.
    99     heap = JSGlobalData::sharedInstance().heap;
    100     if (!heap->isBusy())
    101         heap->collect();
     99    if (JSGlobalData::sharedInstanceExists()) {
     100        Heap* heap = JSGlobalData::sharedInstance().heap;
     101        if (!heap->isBusy())
     102            heap->collect();
     103    }
    102104
    103105    // FIXME: Perhaps we should trigger a second mark and sweep
Note: See TracChangeset for help on using the changeset viewer.