Changeset 32819 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
May 2, 2008, 11:10:33 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

Move call stack depth counter to global object.

  • kjs/ExecState.h: (KJS::ExecState::functionCallDepth): Added a recursion depth counter to per-thread data.
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::init): Initialize PerThreadData.functionCallDepth.
  • kjs/JSGlobalObject.h: (KJS::JSGlobalObject::perThreadData): Made the result non-const.
  • kjs/object.cpp: (KJS::throwStackSizeExceededError): Moved throwError to a separate function, since it is now the only thing in JSObject::call that needs a PIC branch. (KJS::JSObject::call): Use a per-thread variable instead of local static for recursion depth tracking.
Location:
trunk/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r32808 r32819  
     12008-05-02  Alexey Proskuryakov  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        Move call stack depth counter to global object.
     6
     7        * kjs/ExecState.h: (KJS::ExecState::functionCallDepth): Added a recursion depth counter to
     8        per-thread data.
     9        * kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::init): Initialize PerThreadData.functionCallDepth.
     10        * kjs/JSGlobalObject.h: (KJS::JSGlobalObject::perThreadData): Made the result non-const.
     11
     12        * kjs/object.cpp:
     13        (KJS::throwStackSizeExceededError): Moved throwError to a separate function, since it is now
     14        the only thing in JSObject::call that needs a PIC branch.
     15        (KJS::JSObject::call): Use a per-thread variable instead of local static for recursion depth
     16        tracking.
     17
    1182008-05-02  Alexey Proskuryakov  <[email protected]>
    219
  • trunk/JavaScriptCore/kjs/ExecState.h

    r32807 r32819  
    6161       
    6262        Heap* heap;
     63
     64        unsigned functionCallDepth;
    6365    };
    6466
     
    125127        Heap* heap() const { return m_perThreadData->heap; }
    126128
     129        unsigned& functionCallDepth() { return m_perThreadData->functionCallDepth; }
     130
    127131        LocalStorage& localStorage() { return *m_localStorage; }
    128132        void setLocalStorage(LocalStorage* s) { m_localStorage = s; }
     
    205209        ExecState* m_callingExec;
    206210
    207         const PerThreadData* m_perThreadData;
     211        PerThreadData* m_perThreadData;
    208212
    209213        ScopeNode* m_scopeNode;
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r32807 r32819  
    231231    d()->perThreadData.propertyNames = CommonIdentifiers::shared();
    232232    d()->perThreadData.heap = Heap::threadHeap();
     233    d()->perThreadData.functionCallDepth = 0;
    233234
    234235    d()->globalExec.set(new GlobalExecState(this, thisValue));
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r32807 r32819  
    251251
    252252        // Per-thread hash tables, cached on the global object for faster access.
    253         const PerThreadData* perThreadData() const { return &d()->perThreadData; }
     253        PerThreadData* perThreadData() { return &d()->perThreadData; }
    254254
    255255        // Initialize and/or retrieve per-thread hash tables - use perThreadData() for faster access instead.
  • trunk/JavaScriptCore/kjs/object.cpp

    r32807 r32819  
    6464// ------------------------------ Object ---------------------------------------
    6565
     66JSValue* NEVER_INLINE throwStackSizeExceededError(ExecState* exec)
     67{
     68    // This function takes a PIC branch to access a string literal, so moving it out of JSObject::call() improves performance.
     69    return throwError(exec, RangeError, "Maximum call stack size exceeded.");
     70}
     71
    6672JSValue *JSObject::call(ExecState *exec, JSObject *thisObj, const List &args)
    6773{
     
    6975
    7076#if KJS_MAX_STACK > 0
    71   static int depth = 0; // sum of all extant function calls
    72 
    7377#if JAVASCRIPT_CALL_TRACING
    7478    static bool tracing = false;
     
    8791#endif
    8892
     93  unsigned& depth = exec->functionCallDepth();
    8994  if (++depth > KJS_MAX_STACK) {
     95    // FIXME: secondary threads probably need a different limit than main thread.
     96    // Ideally, the limit should be calculated from available stack space, and not just hardcoded.
    9097    --depth;
    91     return throwError(exec, RangeError, "Maximum call stack size exceeded.");
     98    return throwStackSizeExceededError(exec);
    9299  }
    93100#endif
Note: See TracChangeset for help on using the changeset viewer.