Changeset 37323 in webkit for trunk/JavaScriptCore/VM/Machine.h


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/VM/Machine.h

    r37297 r37323  
    104104        void retrieveLastCaller(ExecState* exec, int& lineNumber, intptr_t& sourceID, UString& sourceURL, JSValue*& function) const;
    105105       
    106         static const Register* firstCallFrame(const Register* callFrame);
    107106        static ScopeChainNode* scopeChain(const Register* r) { return r[RegisterFile::ScopeChain].scopeChain(); }
    108107        static CodeBlock* codeBlock(const Register* r) { return r[RegisterFile::CodeBlock].codeBlock(); }
Note: See TracChangeset for help on using the changeset viewer.