Ignore:
Timestamp:
Oct 5, 2008, 7:48:08 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-05 Maciej Stachowiak <[email protected]>

Reviewed by Oliver Hunt.



The problem is that dynamicGlobalObject had become O(N) in number
of call frames, but unwinding the stack for an exception called it
for every call frame, resulting in O(N2) behavior for an
exception thrown from inside deep recursion.

Instead of doing it that way, stash the dynamic global object in JSGlobalData.


  • JavaScriptCore.exp:
  • VM/Machine.cpp: (JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Helper class to temporarily store and later restore a dynamicGlobalObject in JSGlobalData. (JSC::DynamicGlobalObjectScope::~DynamicGlobalObjectScope): (JSC::Machine::execute): In each version, establish a DynamicGlobalObjectScope. For ProgramNode, always establish set new dynamicGlobalObject, for FunctionBody and Eval, only if none is currently set.
  • VM/Machine.h:
  • kjs/ExecState.h:
  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): Ininitalize new dynamicGlobalObject field to 0.
  • kjs/JSGlobalData.h:
  • kjs/JSGlobalObject.h: (JSC::ExecState::dynamicGlobalObject): Moved here from ExecState for benefit of inlining. Return lexical global object if this is a globalExec(), otherwise look in JSGlobalData for the one stashed there.
File:
1 edited

Legend:

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

    r37297 r37323  
    4444
    4545        // Global object in which execution began.
    46         JSGlobalObject* dynamicGlobalObject()
    47         {
    48             return Machine::scopeChain(Machine::firstCallFrame(this))->globalObject();
    49         }
     46        JSGlobalObject* dynamicGlobalObject();
    5047
    5148        // Global object in which the currently executing code was defined.
Note: See TracChangeset for help on using the changeset viewer.