extern "C" {
#endif
-int JSLockDropAllLocks(void)
+static JSLock::DropAllLocks* sLockDropper = NULL;
+
+void JSLockDropAllLocks(void)
{
- KJS::JSLock::lock();
- int lockCount = KJS::JSLock::lockCount();
- for (int i = 0; i < lockCount; i++)
- KJS::JSLock::unlock();
- return lockCount - 1;
+ ASSERT(sLockDropper == NULL);
+ sLockDropper = new JSLock::DropAllLocks();
}
-void JSLockRecoverAllLocks(int lockCount)
+void JSLockRecoverAllLocks(void)
{
- ASSERT(KJS::JSLock::lockCount() == 0);
- for (int i = 0; i < lockCount; i++)
- KJS::JSLock::lock();
+ ASSERT(sLockDropper != NULL);
+ delete sLockDropper;
+ sLockDropper = NULL;
}
static pthread_t javaScriptCollectionThread = 0;
extern "C" {
#endif
-int JSLockDropAllLocks(void);
-void JSLockRecoverAllLocks(int lockCount);
+void JSLockDropAllLocks(void);
+void JSLockRecoverAllLocks(void);
void JSSetJavaScriptCollectionThread (pthread_t thread);
pthread_t JSJavaScriptCollectionThread (void);
// -*- c-basic-offset: 2 -*-
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2006, 2007 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All Rights Reserved.
* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
*
* This library is free software; you can redistribute it and/or
void Lexer::setCode(int startingLineNumber, const KJS::UChar *c, unsigned int len)
{
- yylineno = 1 + startingLineNumber;
- restrKeyword = false;
- delimited = false;
- eatNextIdentifier = false;
- stackToken = -1;
- lastToken = -1;
- pos = 0;
- code = c;
- length = len;
- skipLF = false;
- skipCR = false;
- error = false;
- atLineStart = true;
-
- // read first characters
- current = (length > 0) ? code[0].uc : -1;
- next1 = (length > 1) ? code[1].uc : -1;
- next2 = (length > 2) ? code[2].uc : -1;
- next3 = (length > 3) ? code[3].uc : -1;
+ yylineno = 1 + startingLineNumber;
+ restrKeyword = false;
+ delimited = false;
+ eatNextIdentifier = false;
+ stackToken = -1;
+ lastToken = -1;
+ pos = 0;
+ code = c;
+ length = len;
+ skipLF = false;
+ skipCR = false;
+ error = false;
+ atLineStart = true;
+
+ // read first characters
+ shift(4);
}
-void Lexer::shift(unsigned int p)
+void Lexer::shift(unsigned p)
{
- // Here would be a good place to strip Cf characters, but that has caused compatibility problems:
- // <http://bugs.webkit.org/show_bug.cgi?id=10183>.
- while (p--) {
- pos++;
- current = next1;
- next1 = next2;
- next2 = next3;
- next3 = (pos + 3 < length) ? code[pos + 3].uc : -1;
- }
+ // ECMA-262 calls for stripping Cf characters here, but we only do this for BOM,
+ // see <https://bugs.webkit.org/show_bug.cgi?id=4931>.
+
+ while (p--) {
+ current = next1;
+ next1 = next2;
+ next2 = next3;
+ do {
+ if (pos >= length) {
+ next3 = -1;
+ break;
+ }
+ next3 = code[pos++].uc;
+ } while (next3 == 0xFEFF);
+ }
}
// called on each new line
scavenge_counter_ -= n;
if (scavenge_counter_ >= 0) return; // Not yet time to scavenge
- // If there is nothing to release, wait for so many pages before
- // scavenging again. With 4K pages, this comes to 16MB of memory.
- static const size_t kDefaultReleaseDelay = 1 << 8;
+ static const size_t kDefaultReleaseDelay = 64;
// Find index of free list to scavenge
size_t index = scavenge_index_ + 1;
static_cast<size_t>(s->length << kPageShift));
DLL_Prepend(&slist->returned, s);
- scavenge_counter_ = std::max<size_t>(64UL, std::min<size_t>(kDefaultReleaseDelay, kDefaultReleaseDelay - (free_pages_ / kDefaultReleaseDelay)));
+ scavenge_counter_ = std::max<size_t>(16UL, std::min<size_t>(kDefaultReleaseDelay, kDefaultReleaseDelay - (free_pages_ / kDefaultReleaseDelay)));
if (index == kMaxPages && !DLL_IsEmpty(&slist->normal))
scavenge_index_ = index - 1;