summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime')
-rw-r--r--Source/JavaScriptCore/runtime/CommonIdentifiers.cpp8
-rw-r--r--Source/JavaScriptCore/runtime/DateConstructor.cpp6
-rw-r--r--Source/JavaScriptCore/runtime/DateConversion.cpp170
-rw-r--r--Source/JavaScriptCore/runtime/DateConversion.h73
-rw-r--r--Source/JavaScriptCore/runtime/DatePrototype.cpp93
-rw-r--r--Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp4
-rw-r--r--Source/JavaScriptCore/runtime/Identifier.cpp24
-rw-r--r--Source/JavaScriptCore/runtime/Identifier.h21
-rw-r--r--Source/JavaScriptCore/runtime/JSCell.h5
-rw-r--r--Source/JavaScriptCore/runtime/JSGlobalData.cpp4
-rw-r--r--Source/JavaScriptCore/runtime/Options.h1
-rw-r--r--Source/JavaScriptCore/runtime/Structure.h9
-rw-r--r--Source/JavaScriptCore/runtime/TimeoutChecker.cpp5
13 files changed, 200 insertions, 223 deletions
diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp b/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
index 82beda336..e929d7a49 100644
--- a/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
+++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2007, 2009, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,14 +23,12 @@
namespace JSC {
-static const char* const nullCString = 0;
-
#define INITIALIZE_PROPERTY_NAME(name) , name(globalData, #name)
#define INITIALIZE_KEYWORD(name) , name##Keyword(globalData, #name)
CommonIdentifiers::CommonIdentifiers(JSGlobalData* globalData)
- : nullIdentifier(globalData, nullCString)
- , emptyIdentifier(globalData, "")
+ : nullIdentifier()
+ , emptyIdentifier(Identifier::EmptyIdentifier)
, underscoreProto(globalData, "__proto__")
, thisIdentifier(globalData, "this")
, useStrictIdentifier(globalData, "use strict")
diff --git a/Source/JavaScriptCore/runtime/DateConstructor.cpp b/Source/JavaScriptCore/runtime/DateConstructor.cpp
index 5984bbf97..e4f89dd37 100644
--- a/Source/JavaScriptCore/runtime/DateConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/DateConstructor.cpp
@@ -168,11 +168,7 @@ static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec)
{
GregorianDateTime ts;
msToGregorianDateTime(exec, currentTimeMS(), false, ts);
- DateConversionBuffer date;
- DateConversionBuffer time;
- formatDate(ts, date);
- formatTime(ts, time);
- return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
+ return JSValue::encode(jsNontrivialString(exec, formatDateTime(ts, DateTimeFormatDateAndTime, false)));
}
CallType DateConstructor::getCallData(JSCell*, CallData& callData)
diff --git a/Source/JavaScriptCore/runtime/DateConversion.cpp b/Source/JavaScriptCore/runtime/DateConversion.cpp
index 706ffe9a2..47839817f 100644
--- a/Source/JavaScriptCore/runtime/DateConversion.cpp
+++ b/Source/JavaScriptCore/runtime/DateConversion.cpp
@@ -1,95 +1,127 @@
/*
- * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com>
*
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Alternatively, the contents of this file may be used under the terms
- * of either the Mozilla Public License Version 1.1, found at
- * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
- * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
- * (the "GPL"), in which case the provisions of the MPL or the GPL are
- * applicable instead of those above. If you wish to allow use of your
- * version of this file only under the terms of one of those two
- * licenses (the MPL or the GPL) and not to allow others to use your
- * version of this file under the LGPL, indicate your decision by
- * deletingthe provisions above and replace them with the notice and
- * other provisions required by the MPL or the GPL, as the case may be.
- * If you do not delete the provisions above, a recipient may use your
- * version of this file under any of the LGPL, the MPL or the GPL.
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "DateConversion.h"
-#include "CallFrame.h"
-#include "JSDateMath.h"
-#include "JSObject.h"
-#include "ScopeChain.h"
#include "UString.h"
-#include <wtf/StringExtras.h>
-#include <wtf/text/CString.h>
+#include <wtf/Assertions.h>
+#include <wtf/DateMath.h>
+#include <wtf/text/StringBuilder.h>
+
+#if OS(WINDOWS)
+#include <windows.h>
+#endif
using namespace WTF;
namespace JSC {
-void formatDate(const GregorianDateTime &t, DateConversionBuffer& buffer)
+template<int width>
+static inline void appendNumber(StringBuilder& builder, int value)
{
- snprintf(buffer, DateConversionBufferSize, "%s %s %02d %04d",
- weekdayName[(t.weekDay() + 6) % 7],
- monthName[t.month()], t.monthDay(), t.year());
+ int fillingZerosCount = width;
+ if (value < 0) {
+ builder.append('-');
+ value = -value;
+ --fillingZerosCount;
+ }
+ String valueString = String::number(value);
+ fillingZerosCount -= valueString.length();
+ for (int i = 0; i < fillingZerosCount; ++i)
+ builder.append('0');
+ builder.append(valueString);
}
-void formatDateUTCVariant(const GregorianDateTime &t, DateConversionBuffer& buffer)
+template<>
+void appendNumber<2>(StringBuilder& builder, int value)
{
- snprintf(buffer, DateConversionBufferSize, "%s, %02d %s %04d",
- weekdayName[(t.weekDay() + 6) % 7],
- t.monthDay(), monthName[t.month()], t.year());
+ ASSERT(0 <= value && value <= 99);
+ builder.append(static_cast<char>('0' + value / 10));
+ builder.append(static_cast<char>('0' + value % 10));
}
-void formatTime(const GregorianDateTime &t, DateConversionBuffer& buffer)
+UString formatDateTime(const GregorianDateTime& t, DateTimeFormat format, bool asUTCVariant)
{
- int offset = abs(t.utcOffset());
- char timeZoneName[70];
- struct tm gtm = t;
- strftime(timeZoneName, sizeof(timeZoneName), "%Z", &gtm);
-
- if (timeZoneName[0]) {
- snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d (%s)",
- t.hour(), t.minute(), t.second(),
- t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60, timeZoneName);
- } else {
- snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT%c%02d%02d",
- t.hour(), t.minute(), t.second(),
- t.utcOffset() < 0 ? '-' : '+', offset / (60*60), (offset / 60) % 60);
+ bool appendDate = format & DateTimeFormatDate;
+ bool appendTime = format & DateTimeFormatTime;
+
+ StringBuilder builder;
+
+ if (appendDate) {
+ builder.append(weekdayName[(t.weekDay() + 6) % 7]);
+
+ if (asUTCVariant) {
+ builder.append(", ");
+ appendNumber<2>(builder, t.monthDay());
+ builder.append(' ');
+ builder.append(monthName[t.month()]);
+ } else {
+ builder.append(' ');
+ builder.append(monthName[t.month()]);
+ builder.append(' ');
+ appendNumber<2>(builder, t.monthDay());
+ }
+ builder.append(' ');
+ appendNumber<4>(builder, t.year());
}
-}
-void formatTimeUTC(const GregorianDateTime &t, DateConversionBuffer& buffer)
-{
- snprintf(buffer, DateConversionBufferSize, "%02d:%02d:%02d GMT", t.hour(), t.minute(), t.second());
+ if (appendDate && appendTime)
+ builder.append(' ');
+
+ if (appendTime) {
+ appendNumber<2>(builder, t.hour());
+ builder.append(':');
+ appendNumber<2>(builder, t.minute());
+ builder.append(':');
+ appendNumber<2>(builder, t.second());
+ builder.append(" GMT");
+
+ if (!asUTCVariant) {
+ int offset = abs(t.utcOffset()) / 60;
+ builder.append(t.utcOffset() < 0 ? '-' : '+');
+ appendNumber<2>(builder, offset / 60);
+ appendNumber<2>(builder, offset % 60);
+
+#if OS(WINDOWS)
+ TIME_ZONE_INFORMATION timeZoneInformation;
+ GetTimeZoneInformation(&timeZoneInformation);
+ const WCHAR* timeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
+#else
+ struct tm gtm = t;
+ char timeZoneName[70];
+ strftime(timeZoneName, sizeof(timeZoneName), "%Z", &gtm);
+#endif
+ if (timeZoneName[0]) {
+ builder.append(" (");
+ builder.append(timeZoneName);
+ builder.append(')');
+ }
+ }
+ }
+
+ return builder.toString().impl();
}
} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/DateConversion.h b/Source/JavaScriptCore/runtime/DateConversion.h
index 0b078cd34..fd1a7eb35 100644
--- a/Source/JavaScriptCore/runtime/DateConversion.h
+++ b/Source/JavaScriptCore/runtime/DateConversion.h
@@ -1,42 +1,25 @@
/*
- * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
+ * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DateConversion_h
@@ -46,15 +29,15 @@
namespace JSC {
-class ExecState;
+class UString;
-static const unsigned DateConversionBufferSize = 100;
-typedef char DateConversionBuffer[DateConversionBufferSize];
+enum DateTimeFormat {
+ DateTimeFormatDate = 1,
+ DateTimeFormatTime = 2,
+ DateTimeFormatDateAndTime = DateTimeFormatDate | DateTimeFormatTime
+};
-void formatDate(const GregorianDateTime&, DateConversionBuffer&);
-void formatDateUTCVariant(const GregorianDateTime&, DateConversionBuffer&);
-void formatTime(const GregorianDateTime&, DateConversionBuffer&);
-void formatTimeUTC(const GregorianDateTime&, DateConversionBuffer&);
+UString formatDateTime(const GregorianDateTime&, DateTimeFormat, bool asUTCVariant);
} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/DatePrototype.cpp b/Source/JavaScriptCore/runtime/DatePrototype.cpp
index 7cbab0497..363eec03a 100644
--- a/Source/JavaScriptCore/runtime/DatePrototype.cpp
+++ b/Source/JavaScriptCore/runtime/DatePrototype.cpp
@@ -340,6 +340,23 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, doubl
#endif // !PLATFORM(MAC) && !PLATFORM(IOS)
+static EncodedJSValue formateDateInstance(ExecState* exec, DateTimeFormat format, bool asUTCVariant)
+{
+ JSValue thisValue = exec->hostThisValue();
+ if (!thisValue.inherits(&DateInstance::s_info))
+ return throwVMTypeError(exec);
+
+ DateInstance* thisDateObj = asDateInstance(thisValue);
+
+ const GregorianDateTime* gregorianDateTime = asUTCVariant
+ ? thisDateObj->gregorianDateTimeUTC(exec)
+ : thisDateObj->gregorianDateTime(exec);
+ if (!gregorianDateTime)
+ return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
+
+ return JSValue::encode(jsNontrivialString(exec, formatDateTime(*gregorianDateTime, format, asUTCVariant)));
+}
+
// Converts a list of arguments sent to a Date member function into milliseconds, updating
// ms (representing milliseconds) and t (representing the rest of the date structure) appropriately.
//
@@ -513,38 +530,14 @@ bool DatePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec,
EncodedJSValue JSC_HOST_CALL dateProtoFuncToString(ExecState* exec)
{
- JSValue thisValue = exec->hostThisValue();
- if (!thisValue.inherits(&DateInstance::s_info))
- return throwVMTypeError(exec);
-
- DateInstance* thisDateObj = asDateInstance(thisValue);
-
- const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
- if (!gregorianDateTime)
- return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
- DateConversionBuffer date;
- DateConversionBuffer time;
- formatDate(*gregorianDateTime, date);
- formatTime(*gregorianDateTime, time);
- return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
+ const bool asUTCVariant = false;
+ return formateDateInstance(exec, DateTimeFormatDateAndTime, asUTCVariant);
}
EncodedJSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState* exec)
{
- JSValue thisValue = exec->hostThisValue();
- if (!thisValue.inherits(&DateInstance::s_info))
- return throwVMTypeError(exec);
-
- DateInstance* thisDateObj = asDateInstance(thisValue);
-
- const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
- if (!gregorianDateTime)
- return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
- DateConversionBuffer date;
- DateConversionBuffer time;
- formatDateUTCVariant(*gregorianDateTime, date);
- formatTimeUTC(*gregorianDateTime, time);
- return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
+ const bool asUTCVariant = true;
+ return formateDateInstance(exec, DateTimeFormatDateAndTime, asUTCVariant);
}
EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec)
@@ -577,34 +570,14 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec)
EncodedJSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec)
{
- JSValue thisValue = exec->hostThisValue();
- if (!thisValue.inherits(&DateInstance::s_info))
- return throwVMTypeError(exec);
-
- DateInstance* thisDateObj = asDateInstance(thisValue);
-
- const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
- if (!gregorianDateTime)
- return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
- DateConversionBuffer date;
- formatDate(*gregorianDateTime, date);
- return JSValue::encode(jsNontrivialString(exec, date));
+ const bool asUTCVariant = false;
+ return formateDateInstance(exec, DateTimeFormatDate, asUTCVariant);
}
EncodedJSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState* exec)
{
- JSValue thisValue = exec->hostThisValue();
- if (!thisValue.inherits(&DateInstance::s_info))
- return throwVMTypeError(exec);
-
- DateInstance* thisDateObj = asDateInstance(thisValue);
-
- const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTime(exec);
- if (!gregorianDateTime)
- return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
- DateConversionBuffer time;
- formatTime(*gregorianDateTime, time);
- return JSValue::encode(jsNontrivialString(exec, time));
+ const bool asUTCVariant = false;
+ return formateDateInstance(exec, DateTimeFormatTime, asUTCVariant);
}
EncodedJSValue JSC_HOST_CALL dateProtoFuncToLocaleString(ExecState* exec)
@@ -676,20 +649,8 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec)
EncodedJSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec)
{
- JSValue thisValue = exec->hostThisValue();
- if (!thisValue.inherits(&DateInstance::s_info))
- return throwVMTypeError(exec);
-
- DateInstance* thisDateObj = asDateInstance(thisValue);
-
- const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
- if (!gregorianDateTime)
- return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
- DateConversionBuffer date;
- DateConversionBuffer time;
- formatDateUTCVariant(*gregorianDateTime, date);
- formatTimeUTC(*gregorianDateTime, time);
- return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
+ const bool asUTCVariant = true;
+ return formateDateInstance(exec, DateTimeFormatDateAndTime, asUTCVariant);
}
EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMonth(ExecState* exec)
diff --git a/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp b/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp
index c052c61ba..35b992567 100644
--- a/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp
+++ b/Source/JavaScriptCore/runtime/GCActivityCallbackBlackBerry.cpp
@@ -25,8 +25,6 @@
namespace JSC {
-static const size_t bytesWorthGC = 4 * 1024 * 1024;
-
DefaultGCActivityCallback::DefaultGCActivityCallback(Heap* heap)
: GCActivityCallback(heap->globalData())
{
@@ -40,7 +38,7 @@ void DefaultGCActivityCallback::doWork()
void DefaultGCActivityCallback::didAllocate(size_t bytesAllocated)
{
- if (bytesAllocated < bytesWorthGC || m_timer.started())
+ if (m_timer.started())
return;
// Try using ~5% CPU time.
diff --git a/Source/JavaScriptCore/runtime/Identifier.cpp b/Source/JavaScriptCore/runtime/Identifier.cpp
index 20770928c..0fc54f3c6 100644
--- a/Source/JavaScriptCore/runtime/Identifier.cpp
+++ b/Source/JavaScriptCore/runtime/Identifier.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -46,10 +46,10 @@ void deleteIdentifierTable(IdentifierTable* table)
delete table;
}
-struct IdentifierCStringTranslator {
+struct IdentifierASCIIStringTranslator {
static unsigned hash(const LChar* c)
{
- return StringHasher::computeHash<LChar>(c);
+ return StringHasher::computeHashAndMaskTop8Bits<LChar>(c);
}
static bool equal(StringImpl* r, const LChar* s)
@@ -60,19 +60,15 @@ struct IdentifierCStringTranslator {
static void translate(StringImpl*& location, const LChar* c, unsigned hash)
{
size_t length = strlen(reinterpret_cast<const char*>(c));
- LChar* d;
- StringImpl* r = StringImpl::createUninitialized(length, d).leakRef();
- for (size_t i = 0; i != length; i++)
- d[i] = c[i];
- r->setHash(hash);
- location = r;
+ location = StringImpl::createFromLiteral(reinterpret_cast<const char*>(c), length).leakRef();
+ location->setHash(hash);
}
};
struct IdentifierLCharFromUCharTranslator {
static unsigned hash(const CharBuffer<UChar>& buf)
{
- return StringHasher::computeHash<UChar>(buf.s, buf.length);
+ return StringHasher::computeHashAndMaskTop8Bits<UChar>(buf.s, buf.length);
}
static bool equal(StringImpl* str, const CharBuffer<UChar>& buf)
@@ -96,10 +92,8 @@ struct IdentifierLCharFromUCharTranslator {
PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const char* c)
{
- if (!c)
- return 0;
- if (!c[0])
- return StringImpl::empty();
+ ASSERT(c);
+ ASSERT(c[0]);
if (!c[1])
return add(globalData, globalData->smallStrings.singleCharacterStringRep(c[0]));
@@ -110,7 +104,7 @@ PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const char* c)
if (iter != literalIdentifierTable.end())
return iter->second;
- HashSet<StringImpl*>::AddResult addResult = identifierTable.add<const LChar*, IdentifierCStringTranslator>(reinterpret_cast<const LChar*>(c));
+ HashSet<StringImpl*>::AddResult addResult = identifierTable.add<const LChar*, IdentifierASCIIStringTranslator>(reinterpret_cast<const LChar*>(c));
// If the string is newly-translated, then we need to adopt it.
// The boolean in the pair tells us if that is so.
diff --git a/Source/JavaScriptCore/runtime/Identifier.h b/Source/JavaScriptCore/runtime/Identifier.h
index 7b7907983..196fdca23 100644
--- a/Source/JavaScriptCore/runtime/Identifier.h
+++ b/Source/JavaScriptCore/runtime/Identifier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -35,12 +35,18 @@ namespace JSC {
friend class Structure;
public:
Identifier() { }
+ enum EmptyIdentifierFlag { EmptyIdentifier };
+ Identifier(EmptyIdentifierFlag) : m_string(StringImpl::empty()) { }
- Identifier(ExecState* exec, const char* s) : m_string(add(exec, s)) { } // Only to be used with string literals.
- Identifier(ExecState* exec, StringImpl* rep) : m_string(add(exec, rep)) { }
+ // Only to be used with string literals.
+ template<unsigned charactersCount>
+ Identifier(ExecState* exec, const char (&characters)[charactersCount]) : m_string(add(exec, characters)) { }
+ template<unsigned charactersCount>
+ Identifier(JSGlobalData* globalData, const char (&characters)[charactersCount]) : m_string(add(globalData, characters)) { }
+
+ Identifier(ExecState* exec, StringImpl* rep) : m_string(add(exec, rep)) { }
Identifier(ExecState* exec, const UString& s) : m_string(add(exec, s.impl())) { }
- Identifier(JSGlobalData* globalData, const char* s) : m_string(add(globalData, s)) { } // Only to be used with string literals.
Identifier(JSGlobalData* globalData, const LChar* s, int length) : m_string(add(globalData, s, length)) { }
Identifier(JSGlobalData* globalData, const UChar* s, int length) : m_string(add(globalData, s, length)) { }
Identifier(JSGlobalData* globalData, StringImpl* rep) : m_string(add(globalData, rep)) { }
@@ -80,8 +86,9 @@ namespace JSC {
static bool equal(const StringImpl*, const UChar*, unsigned length);
static bool equal(const StringImpl* a, const StringImpl* b) { return ::equal(a, b); }
- JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(ExecState*, const char*); // Only to be used with string literals.
- static PassRefPtr<StringImpl> add(JSGlobalData*, const char*); // Only to be used with string literals.
+ // Only to be used with string literals.
+ static PassRefPtr<StringImpl> add(JSGlobalData*, const char*);
+ JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(ExecState*, const char*);
private:
UString m_string;
@@ -143,7 +150,7 @@ namespace JSC {
struct IdentifierCharBufferTranslator {
static unsigned hash(const CharBuffer<T>& buf)
{
- return StringHasher::computeHash<T>(buf.s, buf.length);
+ return StringHasher::computeHashAndMaskTop8Bits<T>(buf.s, buf.length);
}
static bool equal(StringImpl* str, const CharBuffer<T>& buf)
diff --git a/Source/JavaScriptCore/runtime/JSCell.h b/Source/JavaScriptCore/runtime/JSCell.h
index cdd409706..90e531cec 100644
--- a/Source/JavaScriptCore/runtime/JSCell.h
+++ b/Source/JavaScriptCore/runtime/JSCell.h
@@ -192,11 +192,6 @@ namespace JSC {
return m_structure.get();
}
- inline const ClassInfo* JSCell::classInfo() const
- {
- return m_classInfo;
- }
-
inline void JSCell::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
MARK_LOG_PARENT(visitor, cell);
diff --git a/Source/JavaScriptCore/runtime/JSGlobalData.cpp b/Source/JavaScriptCore/runtime/JSGlobalData.cpp
index dd05005c7..2d6d1e54f 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalData.cpp
+++ b/Source/JavaScriptCore/runtime/JSGlobalData.cpp
@@ -223,9 +223,7 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
JSGlobalData::~JSGlobalData()
{
ASSERT(!m_apiLock.currentThreadIsHoldingLock());
- heap.activityCallback()->didStartVMShutdown();
- heap.sweeper()->didStartVMShutdown();
- heap.lastChanceToFinalize();
+ heap.didStartVMShutdown();
delete interpreter;
#ifndef NDEBUG
diff --git a/Source/JavaScriptCore/runtime/Options.h b/Source/JavaScriptCore/runtime/Options.h
index 0a55bda6b..ab3f34bb6 100644
--- a/Source/JavaScriptCore/runtime/Options.h
+++ b/Source/JavaScriptCore/runtime/Options.h
@@ -109,6 +109,7 @@ namespace JSC {
v(double, desiredProfileFullnessRate, 0.35) \
\
v(double, doubleVoteRatioForDoubleFormat, 2) \
+ v(double, structureCheckVoteRatioForHoisting, 1) \
\
v(unsigned, minimumNumberOfScansBetweenRebalance, 100) \
v(unsigned, gcMarkStackSegmentSize, pageSize()) \
diff --git a/Source/JavaScriptCore/runtime/Structure.h b/Source/JavaScriptCore/runtime/Structure.h
index 8e41781e2..ee0b573d9 100644
--- a/Source/JavaScriptCore/runtime/Structure.h
+++ b/Source/JavaScriptCore/runtime/Structure.h
@@ -602,6 +602,15 @@ namespace JSC {
ASSERT(m_structure || !globalData.structureStructure);
}
+ inline const ClassInfo* JSCell::classInfo() const
+ {
+#if ENABLE(GC_VALIDATION)
+ return m_structure.unvalidatedGet()->classInfo();
+#else
+ return m_structure->classInfo();
+#endif
+ }
+
} // namespace JSC
#endif // Structure_h
diff --git a/Source/JavaScriptCore/runtime/TimeoutChecker.cpp b/Source/JavaScriptCore/runtime/TimeoutChecker.cpp
index 8f3d1a578..56d6d4b71 100644
--- a/Source/JavaScriptCore/runtime/TimeoutChecker.cpp
+++ b/Source/JavaScriptCore/runtime/TimeoutChecker.cpp
@@ -80,6 +80,11 @@ static inline unsigned getCPUTime()
GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime.fileTime, &userTime.fileTime);
return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000;
+#elif OS(QNX)
+ struct timespec time;
+ if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time))
+ CRASH();
+ return time.tv_sec * 1000.0 + time.tv_nsec / 1.0e6;
#else
// FIXME: We should return the time the current thread has spent executing.