[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
mjs
mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:30:37 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 439e9051b40226291f0c7d335acc198c0a256d93
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Aug 9 23:24:41 2002 +0000
- fixed 2948835 - JavaScriptCore locking is too fine grained, makes it too slow
* kjs/collector.cpp:
(Collector::allocate):
(Collector::collect):
(Collector::finalCheck):
(Collector::numInterpreters):
(Collector::numGCNotAllowedObjects):
(Collector::numReferencedObjects):
* kjs/collector.h:
* kjs/internal.cpp:
(initializeInterpreterLock):
(lockInterpreter):
(unlockInterpreter):
(Parser::parse):
(InterpreterImp::InterpreterImp):
(InterpreterImp::clear):
(InterpreterImp::evaluate):
* kjs/value.cpp:
(ValueImp::ValueImp):
(ValueImp::setGcAllowed):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1789 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 000864c..bf03487 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,27 @@
+2002-08-09 Maciej Stachowiak <mjs at apple.com>
+
+ - fixed 2948835 - JavaScriptCore locking is too fine grained, makes it too slow
+
+ * kjs/collector.cpp:
+ (Collector::allocate):
+ (Collector::collect):
+ (Collector::finalCheck):
+ (Collector::numInterpreters):
+ (Collector::numGCNotAllowedObjects):
+ (Collector::numReferencedObjects):
+ * kjs/collector.h:
+ * kjs/internal.cpp:
+ (initializeInterpreterLock):
+ (lockInterpreter):
+ (unlockInterpreter):
+ (Parser::parse):
+ (InterpreterImp::InterpreterImp):
+ (InterpreterImp::clear):
+ (InterpreterImp::evaluate):
+ * kjs/value.cpp:
+ (ValueImp::ValueImp):
+ (ValueImp::setGcAllowed):
+
=== milestone 0.5 ===
=== Alexander-16 ===
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 000864c..bf03487 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,3 +1,27 @@
+2002-08-09 Maciej Stachowiak <mjs at apple.com>
+
+ - fixed 2948835 - JavaScriptCore locking is too fine grained, makes it too slow
+
+ * kjs/collector.cpp:
+ (Collector::allocate):
+ (Collector::collect):
+ (Collector::finalCheck):
+ (Collector::numInterpreters):
+ (Collector::numGCNotAllowedObjects):
+ (Collector::numReferencedObjects):
+ * kjs/collector.h:
+ * kjs/internal.cpp:
+ (initializeInterpreterLock):
+ (lockInterpreter):
+ (unlockInterpreter):
+ (Parser::parse):
+ (InterpreterImp::InterpreterImp):
+ (InterpreterImp::clear):
+ (InterpreterImp::evaluate):
+ * kjs/value.cpp:
+ (ValueImp::ValueImp):
+ (ValueImp::setGcAllowed):
+
=== milestone 0.5 ===
=== Alexander-16 ===
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 000864c..bf03487 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,27 @@
+2002-08-09 Maciej Stachowiak <mjs at apple.com>
+
+ - fixed 2948835 - JavaScriptCore locking is too fine grained, makes it too slow
+
+ * kjs/collector.cpp:
+ (Collector::allocate):
+ (Collector::collect):
+ (Collector::finalCheck):
+ (Collector::numInterpreters):
+ (Collector::numGCNotAllowedObjects):
+ (Collector::numReferencedObjects):
+ * kjs/collector.h:
+ * kjs/internal.cpp:
+ (initializeInterpreterLock):
+ (lockInterpreter):
+ (unlockInterpreter):
+ (Parser::parse):
+ (InterpreterImp::InterpreterImp):
+ (InterpreterImp::clear):
+ (InterpreterImp::evaluate):
+ * kjs/value.cpp:
+ (ValueImp::ValueImp):
+ (ValueImp::setGcAllowed):
+
=== milestone 0.5 ===
=== Alexander-16 ===
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index f5f5653..ee1df03 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -66,12 +66,6 @@ CollectorBlock::~CollectorBlock()
mem = 0L;
}
-#ifdef APPLE_CHANGES
-static pthread_mutex_t collectorLock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t collectorCondition = PTHREAD_COND_INITIALIZER;
-static unsigned collectorLockCount = 0;
-static pthread_t collectorLockThread;
-#endif
CollectorBlock* Collector::root = 0L;
CollectorBlock* Collector::currentBlock = 0L;
unsigned long Collector::filled = 0;
@@ -91,10 +85,6 @@ void* Collector::allocate(size_t s)
if (s == 0)
return 0L;
-#ifdef APPLE_CHANGES
- lock();
-#endif
-
// Try and deal with memory requirements in a scalable way. Simple scripts
// should only require small amounts of memory, but for complex scripts we don't
// want to end up running the garbage collector hundreds of times a second.
@@ -161,10 +151,6 @@ void* Collector::allocate(size_t s)
fprintf(stderr,"Out of memory");
}
-#ifdef APPLE_CHANGES
- unlock();
-#endif
-
return m;
}
@@ -173,9 +159,6 @@ void* Collector::allocate(size_t s)
*/
bool Collector::collect()
{
-#ifdef APPLE_CHANGES
- lock();
-#endif
#ifdef KJS_DEBUG_MEM
fprintf(stderr,"Collector::collect()\n");
#endif
@@ -286,18 +269,12 @@ bool Collector::collect()
if (s_count++ % 50 == 2)
finalCheck();
#endif
-#ifdef APPLE_CHANGES
- unlock();
-#endif
return deleted;
}
#ifdef KJS_DEBUG_MEM
void Collector::finalCheck()
{
-#ifdef APPLE_CHANGES
- lock();
-#endif
CollectorBlock *block = root;
while (block) {
ValueImp **r = (ValueImp**)block->mem;
@@ -313,16 +290,12 @@ void Collector::finalCheck()
}
block = block->next;
}
-#ifdef APPLE_CHANGES
- unlock();
-#endif
}
#endif
#ifdef APPLE_CHANGES
int Collector::numInterpreters()
{
- lock();
int count = 0;
if (InterpreterImp::s_hook) {
InterpreterImp *scr = InterpreterImp::s_hook;
@@ -331,13 +304,11 @@ int Collector::numInterpreters()
scr = scr->next;
} while (scr != InterpreterImp::s_hook);
}
- unlock();
return count;
}
int Collector::numGCNotAllowedObjects()
{
- lock();
int count = 0;
CollectorBlock *block = root;
while (block) {
@@ -352,13 +323,11 @@ int Collector::numGCNotAllowedObjects()
}
block = block->next;
}
- unlock();
return count;
}
int Collector::numReferencedObjects()
{
- lock();
int count = 0;
CollectorBlock *block = root;
while (block) {
@@ -373,30 +342,7 @@ int Collector::numReferencedObjects()
}
block = block->next;
}
- unlock();
return count;
}
-void Collector::lock()
-{
- pthread_mutex_lock(&collectorLock);
- while (collectorLockCount > 0 &&
- !pthread_equal(pthread_self(), collectorLockThread)) {
- pthread_cond_wait(&collectorCondition, &collectorLock);
- }
- collectorLockThread = pthread_self();
- collectorLockCount++;
- pthread_mutex_unlock(&collectorLock);
-}
-
-void Collector::unlock()
-{
- pthread_mutex_lock(&collectorLock);
- collectorLockCount--;
- if (collectorLockCount == 0) {
- pthread_cond_signal(&collectorCondition);
- }
- pthread_mutex_unlock(&collectorLock);
-}
-
#endif
diff --git a/JavaScriptCore/kjs/collector.h b/JavaScriptCore/kjs/collector.h
index 61b08b2..d0649e0 100644
--- a/JavaScriptCore/kjs/collector.h
+++ b/JavaScriptCore/kjs/collector.h
@@ -92,8 +92,6 @@ namespace KJS {
static int numInterpreters();
static int numGCNotAllowedObjects();
static int numReferencedObjects();
- static void lock();
- static void unlock();
#endif
private:
static CollectorBlock* root;
diff --git a/JavaScriptCore/kjs/internal.cpp b/JavaScriptCore/kjs/internal.cpp
index 8ddecf6..ed40fa9 100644
--- a/JavaScriptCore/kjs/internal.cpp
+++ b/JavaScriptCore/kjs/internal.cpp
@@ -68,6 +68,34 @@ namespace KJS {
const double Inf = *(const double*) Inf_Bytes;
};
+#ifdef APPLE_CHANGES
+static pthread_once_t interpreterLockOnce = PTHREAD_ONCE_INIT;
+static pthread_mutex_t interpreterLock;
+
+static void initializeInterpreterLock()
+{
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+
+ pthread_mutex_init(&interpreterLock, &attr);
+}
+
+static inline void lockInterpreter()
+{
+ pthread_once(&interpreterLockOnce, initializeInterpreterLock);
+ pthread_mutex_lock(&interpreterLock);
+}
+
+static inline void unlockInterpreter()
+{
+ pthread_mutex_unlock(&interpreterLock);
+}
+
+#endif
+
+
// ------------------------------ UndefinedImp ---------------------------------
UndefinedImp *UndefinedImp::staticUndefined = 0;
@@ -688,16 +716,10 @@ void ContextImp::popScope()
ProgramNode *Parser::progNode = 0;
int Parser::sid = 0;
-#ifdef APPLE_CHANGES
-static pthread_mutex_t parserLock = PTHREAD_MUTEX_INITIALIZER;
-#endif
ProgramNode *Parser::parse(const UChar *code, unsigned int length, int *sourceId,
int *errLine, UString *errMsg)
{
-#ifdef APPLE_CHANGES
- pthread_mutex_lock(&parserLock);
-#endif
if (errLine)
*errLine = -1;
if (errMsg)
@@ -726,15 +748,9 @@ ProgramNode *Parser::parse(const UChar *code, unsigned int length, int *sourceId
fprintf(stderr, "KJS: JavaScript parse error at line %d.\n", eline);
#endif
delete prog;
-#ifdef APPLE_CHANGES
- pthread_mutex_unlock(&parserLock);
-#endif
return 0;
}
-#ifdef APPLE_CHANGES
- pthread_mutex_unlock(&parserLock);
-#endif
return prog;
}
@@ -777,7 +793,7 @@ InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob)
// add this interpreter to the global chain
// as a root set for garbage collection
#ifdef APPLE_CHANGES
- Collector::lock();
+ pthread_mutex_lock(&interpreterLock);
m_interpreter = interp;
#endif
if (s_hook) {
@@ -791,7 +807,7 @@ InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob)
globalInit();
}
#ifdef APPLE_CHANGES
- Collector::unlock();
+ pthread_mutex_unlock(&interpreterLock);
#endif
#ifndef APPLE_CHANGES
@@ -938,7 +954,7 @@ void InterpreterImp::clear()
//fprintf(stderr,"InterpreterImp::clear\n");
// remove from global chain (see init())
#ifdef APPLE_CHANGES
- Collector::lock();
+ pthread_mutex_lock(&interpreterLock);
#endif
next->prev = prev;
prev->next = next;
@@ -950,7 +966,7 @@ void InterpreterImp::clear()
globalClear();
}
#ifdef APPLE_CHANGES
- Collector::unlock();
+ pthread_mutex_unlock(&interpreterLock);
#endif
}
@@ -988,9 +1004,18 @@ bool InterpreterImp::checkSyntax(const UString &code)
Completion InterpreterImp::evaluate(const UString &code, const Value &thisV)
{
+#ifdef APPLE_CHANGES
+ pthread_mutex_lock(&interpreterLock);
+#endif
// prevent against infinite recursion
if (recursion >= 20) {
+#ifdef APPLE_CHANGES
+ Completion result = Completion(Throw,Error::create(globExec,GeneralError,"Recursion too deep"));
+ pthread_mutex_unlock(&interpreterLock);
+ return result;
+#else
return Completion(Throw,Error::create(globExec,GeneralError,"Recursion too deep"));
+#endif
}
// parse the source code
@@ -1003,13 +1028,23 @@ Completion InterpreterImp::evaluate(const UString &code, const Value &thisV)
if (dbg) {
bool cont = dbg->sourceParsed(globExec,sid,code,errLine);
if (!cont)
+#ifdef APPLE_CHANGES
+ {
+ pthread_mutex_unlock(&interpreterLock);
+ return Completion(Break);
+ }
+#else
return Completion(Break);
+#endif
}
// no program node means a syntax error occurred
if (!progNode) {
Object err = Error::create(globExec,SyntaxError,errMsg.ascii(),errLine);
err.put(globExec,"sid",Number(sid));
+#ifdef APPLE_CHANGES
+ pthread_mutex_unlock(&interpreterLock);
+#endif
return Completion(Throw,err);
}
@@ -1052,6 +1087,9 @@ Completion InterpreterImp::evaluate(const UString &code, const Value &thisV)
delete progNode;
recursion--;
+#ifdef APPLE_CHANGES
+ pthread_mutex_unlock(&interpreterLock);
+#endif
return res;
}
diff --git a/JavaScriptCore/kjs/value.cpp b/JavaScriptCore/kjs/value.cpp
index f7bfc8b..e15f423 100644
--- a/JavaScriptCore/kjs/value.cpp
+++ b/JavaScriptCore/kjs/value.cpp
@@ -41,17 +41,6 @@ using namespace KJS;
// ----------------------------- ValueImp -------------------------------------
-#if APPLE_CHANGES
-ValueImp::ValueImp() :
- refcount(0)
-{
- // Tell the garbage collector that this memory block corresponds to a real object now
- Collector::lock();
- _flags = VI_CREATED;
- //fprintf(stderr,"ValueImp::ValueImp %p\n",(void*)this);
- Collector::unlock();
-}
-#else
ValueImp::ValueImp() :
refcount(0),
// Tell the garbage collector that this memory block corresponds to a real object now
@@ -59,7 +48,6 @@ ValueImp::ValueImp() :
{
//fprintf(stderr,"ValueImp::ValueImp %p\n",(void*)this);
}
-#endif
ValueImp::~ValueImp()
{
@@ -80,14 +68,8 @@ bool ValueImp::marked() const
void ValueImp::setGcAllowed()
{
-#ifdef APPLE_CHANGES
- Collector::lock();
-#endif
//fprintf(stderr,"ValueImp::setGcAllowed %p\n",(void*)this);
_flags |= VI_GCALLOWED;
-#ifdef APPLE_CHANGES
- Collector::unlock();
-#endif
}
void* ValueImp::operator new(size_t s)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list