Ignore:
Timestamp:
Feb 9, 2007, 11:28:02 AM (18 years ago)
Author:
andersca
Message:

JavaScriptCore:

Reviewed by Geoff.

<rdar://problem/4930614>
Safari complains about "Slow Script" if GMail is left open and machine is busy


<rdar://problem/4649516>
Turn off slow script dialog or crank up time that makes it come up


<rdar://problem/4963589>
Slow script warning is displayed after closing of PROMPT or PRINT dialog


Re-do the way script timeouts are handled. No longer use a unix timer that sends signals. Instead, add a
tick count and increment it in loop bodies. If the tick count reaches a threshold, do a timeout check. If the total time executing
is higher than the timeout value, (possibly) interrupt the script. The timeout checker also adjusts the threshold dynamically
to prevent doing the timeout check too often.



  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add winmm.lib.
  • kjs/interpreter.cpp: (KJS::Interpreter::init): (KJS::Interpreter::~Interpreter): (KJS::Interpreter::startTimeoutCheck): (KJS::Interpreter::stopTimeoutCheck): (KJS::Interpreter::resetTimeoutCheck): (KJS::getCurrentTime): (KJS::Interpreter::checkTimeout):
  • kjs/interpreter.h: (KJS::Interpreter::timedOut):
  • kjs/nodes.cpp: (DoWhileNode::execute): (WhileNode::execute): (ForNode::execute):

WebCore:

Reviewed by Geoff.

No need to pause timeout checks anymore.


  • bindings/js/kjs_window.cpp: (KJS::WindowFunc::callAsFunction):
File:
1 edited

Legend:

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

    r18461 r19534  
    3737  class SavedBuiltins;
    3838  class ScopeChain;
    39   class TimeoutChecker;
    4039 
    4140  /**
     
    4746  class Interpreter {
    4847      friend class Collector;
    49       friend class TimeoutChecker;
    5048  public:
    5149    /**
     
    315313    void startTimeoutCheck();
    316314    void stopTimeoutCheck();
    317 
    318     void pauseTimeoutCheck();
    319     void resumeTimeoutCheck();
    320    
    321     bool checkTimeout();
     315   
     316    bool timedOut();
    322317   
    323318    void ref() { ++m_refCount; }
     
    329324    virtual bool shouldInterruptScript() const { return true; }
    330325
    331     long m_timeoutTime;
     326    unsigned m_timeoutTime;
    332327
    333328private:
    334     bool handleTimeout();
     329    bool checkTimeout();
    335330    void init();
    336    
     331    void resetTimeoutCheck();
     332
    337333    /**
    338334     * This constructor is not implemented, in order to prevent
     
    367363    CompatMode m_compatMode;
    368364
    369     TimeoutChecker* m_timeoutChecker;
    370     bool m_timedOut;
    371 
    372     unsigned m_startTimeoutCheckCount;
    373     unsigned m_pauseTimeoutCheckCount;
     365    unsigned m_timeAtLastCheckTimeout;
     366    unsigned m_timeExecuting;
     367    unsigned m_timeoutCheckCount;
     368   
     369    unsigned m_tickCount;
     370    unsigned m_ticksUntilNextTimeoutCheck;
    374371
    375372    ProtectedPtr<JSObject> m_Object;
     
    408405  };
    409406
    410   inline bool Interpreter::checkTimeout()
     407  inline bool Interpreter::timedOut()
    411408  {
    412     if (!m_timedOut)
    413       return false;
    414 
    415     return handleTimeout();
     409      m_tickCount++;
     410     
     411      if (m_tickCount != m_ticksUntilNextTimeoutCheck)
     412          return false;
     413     
     414      return checkTimeout();
    416415  }
    417416 
Note: See TracChangeset for help on using the changeset viewer.