Changeset 11284 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Nov 22, 2005, 9:41:23 PM (20 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Geoff.

<rdar://problem/4139620> Seed: WebKit: hang when sending XMLHttpRequest if automatic proxy config is used

Also factored locking code completely into a separate class, and
added a convenient packaged way to temporarily drop locks.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/JSLock.cpp: Added. (KJS::initializeInterpreterLock): (KJS::InterpreterLock::lock): (KJS::InterpreterLock::unlock): (KJS::InterpreterLock::lockCount): (KJS::InterpreterLock::DropAllLocks::DropAllLocks): (KJS::InterpreterLock::DropAllLocks::~DropAllLocks):
  • kjs/JSLock.h: Added. (KJS::InterpreterLock::InterpreterLock): (KJS::InterpreterLock::~InterpreterLock):
  • kjs/internal.cpp:
  • kjs/internal.h:
  • kjs/interpreter.cpp:
  • kjs/interpreter.h:
  • kjs/protect.h:
  • kjs/testkjs.cpp: (TestFunctionImp::callAsFunction):

WebCore:

Reviewed by Geoff.

<rdar://problem/4139620> Seed: WebKit: hang when sending XMLHttpRequest if automatic proxy config is used

  • khtml/ecma/kjs_events.cpp: (KJS::JSLazyEventListener::parseCode):
  • khtml/ecma/xmlhttprequest.cpp: (KJS::XMLHttpRequest::send):
  • kwq/WebCoreJavaScript.mm:
Location:
trunk/JavaScriptCore/kjs
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/collector.cpp

    r11213 r11284  
    107107void* Collector::allocate(size_t s)
    108108{
    109   assert(Interpreter::lockCount() > 0);
     109  assert(InterpreterLock::lockCount() > 0);
    110110
    111111  // collect if needed
     
    394394bool Collector::collect()
    395395{
    396   assert(Interpreter::lockCount() > 0);
     396  assert(InterpreterLock::lockCount() > 0);
    397397
    398398  if (InterpreterImp::s_hook) {
  • trunk/JavaScriptCore/kjs/config.h

    r10801 r11284  
    1010#define HAVE_SYS_TIME_H 1
    1111#define HAVE_SYS_TIMEB_H 1
     12
     13#define KJS_MULTIPLE_THREADS 1
    1214
    1315#elif WIN32
  • trunk/JavaScriptCore/kjs/internal.cpp

    r11213 r11284  
    7474 
    7575#endif // APPLE_CHANGES
    76 
    77 #if defined(KJS_MULTIPLE_THREADS) && KJS_MULTIPLE_THREADS
    78 
    79 static pthread_once_t interpreterLockOnce = PTHREAD_ONCE_INIT;
    80 static pthread_mutex_t interpreterLock;
    81 static int interpreterLockCount = 0;
    82 
    83 static void initializeInterpreterLock()
    84 {
    85   pthread_mutexattr_t attr;
    86 
    87   pthread_mutexattr_init(&attr);
    88   pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
    89 
    90   pthread_mutex_init(&interpreterLock, &attr);
    91 }
    92 
    93 static inline void lockInterpreter()
    94 {
    95   pthread_once(&interpreterLockOnce, initializeInterpreterLock);
    96   pthread_mutex_lock(&interpreterLock);
    97   interpreterLockCount++;
    98   Collector::registerThread();
    99 }
    100 
    101 static inline void unlockInterpreter()
    102 {
    103   interpreterLockCount--;
    104   pthread_mutex_unlock(&interpreterLock);
    105 }
    106 
    107 #else
    108 
    109 static inline void initializeInterpreterLock() { }
    110 static inline void lockInterpreter() { }
    111 static inline void unlockInterpreter() { }
    112 
    113 const int interpreterLockCount = 1;
    114 
    115 #endif
    11676
    11777// ------------------------------ UndefinedImp ---------------------------------
     
    472432
    473433  recursion = 0;
    474 }
    475 
    476 void InterpreterImp::lock()
    477 {
    478   lockInterpreter();
    479 
    480   // FIXME: Hack-o-rama. To prevent construction of a global object with a null prototype (4342216),
    481   // we need to intialize our constants before the first object is constructed. InterpreterImp::lock()
    482   // is a good place to do this because you have to call it before doing any allocations. Once we change our
    483   // implementation to use immediate values, we should remove this code.
    484   ConstantValues::initIfNeeded();
    485 }
    486 
    487 int InterpreterImp::lockCount()
    488 {
    489   return interpreterLockCount;
    490 }
    491 
    492 void InterpreterImp::unlock()
    493 {
    494   unlockInterpreter();
    495434}
    496435
  • trunk/JavaScriptCore/kjs/internal.h

    r11213 r11284  
    3434#include <kxmlcore/SharedPtr.h>
    3535
    36 #if __APPLE__
    37 #define KJS_MULTIPLE_THREADS 1
    38 #endif
    39 
    4036#define I18N_NOOP(s) s
    4137
     
    254250
    255251    void initGlobalObject();
    256     static void lock();
    257     static void unlock();
    258     static int lockCount();
    259252
    260253    void mark();
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r10701 r11284  
    100100}
    101101
    102 void Interpreter::lock()
    103 {
    104   InterpreterImp::lock();
    105 }
    106 
    107 void Interpreter::unlock()
    108 {
    109   InterpreterImp::unlock();
    110 }
    111 
    112 int Interpreter::lockCount()
    113 {
    114   return InterpreterImp::lockCount();
    115 }
    116 
    117102ExecState *Interpreter::globalExec()
    118103{
  • trunk/JavaScriptCore/kjs/interpreter.h

    r10563 r11284  
    168168    void initGlobalObject();
    169169
    170     static void lock();
    171     static void unlock();
    172     static int lockCount();
    173 
    174170    /**
    175171     * Returns the execution state object which can be used to execute
     
    483479  };
    484480
    485     class InterpreterLock
    486     {
    487     public:
    488         InterpreterLock() { Interpreter::lock(); }
    489         ~InterpreterLock() { Interpreter::unlock(); }
    490     private:
    491         InterpreterLock(const InterpreterLock &);
    492         InterpreterLock &operator =(const InterpreterLock &);
    493     };
    494 
    495481} // namespace
    496482
  • trunk/JavaScriptCore/kjs/protect.h

    r10857 r11284  
    2828#include "value.h"
    2929#include "protected_values.h"
    30 #include "interpreter.h"
     30#include "JSLock.h"
    3131
    3232namespace KJS {
  • trunk/JavaScriptCore/kjs/protected_values.cpp

    r10713 r11284  
    4343{
    4444    assert(k);
    45     assert(InterpreterImp::lockCount() > 0);
     45    assert(InterpreterLock::lockCount() > 0);
    4646
    4747    if (!_table)
     
    7272{
    7373    assert(k);
    74     assert(InterpreterImp::lockCount() > 0);
     74    assert(InterpreterLock::lockCount() > 0);
    7575
    7676    if (SimpleNumber::is(k))
     
    122122{
    123123    assert(k);
    124     assert(InterpreterImp::lockCount() > 0);
     124    assert(InterpreterLock::lockCount() > 0);
    125125
    126126    if (SimpleNumber::is(k))
  • trunk/JavaScriptCore/kjs/testkjs.cpp

    r10701 r11284  
    3232#include "interpreter.h"
    3333#include "collector.h"
     34#include "JSLock.h"
    3435
    3536using namespace KJS;
     
    6364    return Undefined();
    6465  case GC:
    65     Interpreter::lock();
     66  {
     67    InterpreterLock lock;
    6668    Collector::collect();
    67     Interpreter::unlock();
     69  }
    6870    break;
    6971  default:
Note: See TracChangeset for help on using the changeset viewer.