Changeset 127505 in webkit


Ignore:
Timestamp:
Sep 4, 2012 2:19:25 PM (12 years ago)
Author:
benjamin@webkit.org
Message:

Improve JSC use of Strings after the UString->String change
https://bugs.webkit.org/show_bug.cgi?id=95633

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-09-04
Reviewed by Geoffrey Garen.

This patch improve the use of strings in the JSC runtime.

The initialization of Identifier is left for future patches.

The improvements are the following:
-5% faster to raise one of the modified exception.
-3 times faster to execute Boolean::toString()

Most of the changes are just about using the new methods
for string literals.

With the changes, the binary on x86_64 gets 176 bytes smaller.

  • API/JSCallbackObjectFunctions.h:

(JSC::::staticFunctionGetter):
(JSC::::callbackGetter):

  • API/JSContextRef.cpp:

(JSContextCreateBacktrace):

  • API/JSObjectRef.cpp:

(JSObjectMakeFunctionWithCallback):

  • bytecode/CodeBlock.cpp:

(JSC::valueToSourceString):
(JSC::CodeBlock::nameForRegister):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::addStackTraceIfNecessary):

  • runtime/ArrayConstructor.cpp:

(JSC::constructArrayWithSizeQuirk):

  • runtime/ArrayPrototype.cpp:

(JSC::shift):
(JSC::unshift):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncReverse):

  • runtime/BooleanPrototype.cpp:

(JSC::booleanProtoFuncToString): Instead of instanciating new strings, reuse the
keywords available in SmallStrings. Avoiding the creation of the JSString and StringImpl
makes the method significantly faster.

  • runtime/DateConversion.cpp:

(JSC::formatDateTime):

  • runtime/DatePrototype.cpp:

(JSC::formatLocaleDate):
(JSC::formateDateInstance):
(JSC::dateProtoFuncToISOString):
Change the way we use snprintf() for clarity and performance.

Instead of allocating one extra byte to put a zero "just in case", we use the size returned
by snprintf().
To prevent any overflow from a programming mistake, we explicitely test for overflow and
return an empty string.

(JSC::dateProtoFuncToJSON):

  • runtime/Error.cpp:

(JSC::createNotEnoughArgumentsError):
(JSC::throwTypeError):
(JSC::throwSyntaxError):

  • runtime/Error.h:

(JSC::StrictModeTypeErrorFunction::create):

  • runtime/ErrorPrototype.cpp:

(JSC::ErrorPrototype::finishCreation):
(JSC::errorProtoFuncToString):
Using a null String is correct because (8) uses jsString(), (9) tests for a length of 0.

  • runtime/ExceptionHelpers.cpp:

(JSC::InterruptedExecutionError::defaultValue):
(JSC::TerminatedExecutionError::defaultValue):
(JSC::createStackOverflowError):
(JSC::createOutOfMemoryError):

  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileInternal):
(JSC::FunctionExecutable::paramString):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):
(JSC::constructFunctionSkippingEvalEnabledCheck):

  • runtime/FunctionPrototype.h:

(JSC::FunctionPrototype::create):
Using a null String for the name is correct because InternalFunction uses jsString()
to create the name value.

  • runtime/InternalFunction.cpp:

(JSC::InternalFunction::finishCreation):
There is no need to create an empty string for a null string, jsString() handle both
cases as empty JSString.

  • runtime/JSArray.cpp:

(JSC::reject):
(JSC::SparseArrayValueMap::put):
(JSC::JSArray::put):
(JSC::JSArray::putByIndexBeyondVectorLength):
(JSC::JSArray::putDirectIndexBeyondVectorLength):
(JSC::JSArray::setLength):
(JSC::JSArray::pop):
(JSC::JSArray::push):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::finishCreation): Same issue as InternalFunction::finishCreation.

(JSC::JSFunction::callerGetter):
(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGlobalData.cpp:

(JSC::enableAssembler): Use CFSTR() instead of CFStringCreateWithCString().
CFStringCreateWithCString() copy the content and may choose to decode the data.
CFSTR() is much more efficient.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):
JSFunction uses jsString() to create the name, we can use null strings instead
of creating empty strings.

(JSC::JSGlobalObject::createThrowTypeError): ditto.

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::encode):
(JSC::decode):
(JSC::globalFuncEval):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::appendStringifiedValue):
(JSC::Stringifier::Holder::appendNextProperty):
(JSC::JSONProtoFuncParse):
(JSC::JSONProtoFuncStringify):

  • runtime/JSObject.cpp:

(JSC::JSObject::put):
(JSC::JSObject::defaultValue):
(JSC::JSObject::hasInstance):
(JSC::JSObject::defineOwnProperty):

  • runtime/JSString.cpp:

Return an empty JSString to avoid the creation of a temporary empty String.

(JSC::JSRopeString::getIndexSlowCase):

  • runtime/JSString.h:

(JSC): Remove the versions of jsNontrivialString() taking a char*. All the callers
have been replaced by calls using ASCIILiteral.

  • runtime/JSValue.cpp:

(JSC::JSValue::putToPrimitive):

  • runtime/LiteralParser.cpp:

(JSC::::Lexer::lex):
(JSC::::Lexer::lexString):
(JSC::::Lexer::lexNumber):
(JSC::::parse):

  • runtime/LiteralParser.h:

(JSC::LiteralParser::getErrorMessage):

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncToExponential):
(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToPrecision):
(JSC::numberProtoFuncToString):

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorGetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorKeys):
(JSC::toPropertyDescriptor):
(JSC::objectConstructorDefineProperty):
(JSC::objectConstructorDefineProperties):
(JSC::objectConstructorCreate):
(JSC::objectConstructorSeal):
(JSC::objectConstructorFreeze):
(JSC::objectConstructorPreventExtensions):
(JSC::objectConstructorIsSealed):
(JSC::objectConstructorIsFrozen):
(JSC::objectConstructorIsExtensible):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncToString):

  • runtime/RegExpConstructor.cpp:

(JSC::constructRegExp):

  • runtime/RegExpObject.cpp:

(JSC::reject):
(JSC::regExpObjectSource):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncCompile):

  • runtime/StringObject.cpp:

(JSC::StringObject::defineOwnProperty):

  • runtime/StringPrototype.cpp:

(JSC::jsSpliceSubstrings):
(JSC::jsSpliceSubstringsWithSeparators):

Location:
trunk/Source/JavaScriptCore
Files:
39 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r127191 r127505  
    569569    }
    570570
    571     return throwError(exec, createReferenceError(exec, "Static function property defined with NULL callAsFunction callback."));
     571    return throwError(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback.")));
    572572}
    573573
     
    601601    }
    602602
    603     return throwError(exec, createReferenceError(exec, "hasProperty callback returned true for a property that doesn't exist."));
     603    return throwError(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist.")));
    604604}
    605605
  • trunk/Source/JavaScriptCore/API/JSContextRef.cpp

    r127191 r127505  
    174174        if (asObject(exec->callee())->inherits(&InternalFunction::s_info)) {
    175175            functionName = asInternalFunction(exec->callee())->name(exec);
    176             builder.append("#0 ");
     176            builder.appendLiteral("#0 ");
    177177            builder.append(functionName);
    178             builder.append("() ");
     178            builder.appendLiteral("() ");
    179179            count++;
    180180        }
  • trunk/Source/JavaScriptCore/API/JSObjectRef.cpp

    r121924 r127505  
    9393    ExecState* exec = toJS(ctx);
    9494    APIEntryShim entryShim(exec);
    95     return toRef(JSCallbackFunction::create(exec, exec->lexicalGlobalObject(), callAsFunction, name ? name->ustring() : "anonymous"));
     95    return toRef(JSCallbackFunction::create(exec, exec->lexicalGlobalObject(), callAsFunction, name ? name->ustring() : ASCIILiteral("anonymous")));
    9696}
    9797
  • trunk/Source/JavaScriptCore/ChangeLog

    r127503 r127505  
     12012-09-04  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        Improve JSC use of Strings after the UString->String change
     4        https://bugs.webkit.org/show_bug.cgi?id=95633
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        This patch improve the use of strings in the JSC runtime.
     9
     10        The initialization of Identifier is left for future patches.
     11
     12        The improvements are the following:
     13        -5% faster to raise one of the modified exception.
     14        -3 times faster to execute Boolean::toString()
     15
     16        Most of the changes are just about using the new methods
     17        for string literals.
     18
     19        With the changes, the binary on x86_64 gets 176 bytes smaller.
     20
     21        * API/JSCallbackObjectFunctions.h:
     22        (JSC::::staticFunctionGetter):
     23        (JSC::::callbackGetter):
     24        * API/JSContextRef.cpp:
     25        (JSContextCreateBacktrace):
     26        * API/JSObjectRef.cpp:
     27        (JSObjectMakeFunctionWithCallback):
     28        * bytecode/CodeBlock.cpp:
     29        (JSC::valueToSourceString):
     30        (JSC::CodeBlock::nameForRegister):
     31        * interpreter/Interpreter.cpp:
     32        (JSC::Interpreter::addStackTraceIfNecessary):
     33        * runtime/ArrayConstructor.cpp:
     34        (JSC::constructArrayWithSizeQuirk):
     35        * runtime/ArrayPrototype.cpp:
     36        (JSC::shift):
     37        (JSC::unshift):
     38        (JSC::arrayProtoFuncPop):
     39        (JSC::arrayProtoFuncReverse):
     40        * runtime/BooleanPrototype.cpp:
     41        (JSC::booleanProtoFuncToString): Instead of instanciating new strings, reuse the
     42        keywords available in SmallStrings. Avoiding the creation of the JSString and StringImpl
     43        makes the method significantly faster.
     44
     45        * runtime/DateConversion.cpp:
     46        (JSC::formatDateTime):
     47        * runtime/DatePrototype.cpp:
     48        (JSC::formatLocaleDate):
     49        (JSC::formateDateInstance):
     50        (JSC::dateProtoFuncToISOString):
     51        Change the way we use snprintf() for clarity and performance.
     52
     53        Instead of allocating one extra byte to put a zero "just in case", we use the size returned
     54        by snprintf().
     55        To prevent any overflow from a programming mistake, we explicitely test for overflow and
     56        return an empty string.
     57
     58        (JSC::dateProtoFuncToJSON):
     59        * runtime/Error.cpp:
     60        (JSC::createNotEnoughArgumentsError):
     61        (JSC::throwTypeError):
     62        (JSC::throwSyntaxError):
     63        * runtime/Error.h:
     64        (JSC::StrictModeTypeErrorFunction::create):
     65        * runtime/ErrorPrototype.cpp:
     66        (JSC::ErrorPrototype::finishCreation):
     67        (JSC::errorProtoFuncToString):
     68        Using a null String is correct because (8) uses jsString(), (9) tests for a length of 0.
     69
     70        * runtime/ExceptionHelpers.cpp:
     71        (JSC::InterruptedExecutionError::defaultValue):
     72        (JSC::TerminatedExecutionError::defaultValue):
     73        (JSC::createStackOverflowError):
     74        (JSC::createOutOfMemoryError):
     75        * runtime/Executable.cpp:
     76        (JSC::EvalExecutable::compileInternal):
     77        (JSC::FunctionExecutable::paramString):
     78        * runtime/FunctionConstructor.cpp:
     79        (JSC::constructFunction):
     80        (JSC::constructFunctionSkippingEvalEnabledCheck):
     81        * runtime/FunctionPrototype.h:
     82        (JSC::FunctionPrototype::create):
     83        Using a null String for the name is correct because InternalFunction uses jsString()
     84        to create the name value.
     85
     86        * runtime/InternalFunction.cpp:
     87        (JSC::InternalFunction::finishCreation):
     88        There is no need to create an empty string for a null string, jsString() handle both
     89        cases as empty JSString.
     90
     91        * runtime/JSArray.cpp:
     92        (JSC::reject):
     93        (JSC::SparseArrayValueMap::put):
     94        (JSC::JSArray::put):
     95        (JSC::JSArray::putByIndexBeyondVectorLength):
     96        (JSC::JSArray::putDirectIndexBeyondVectorLength):
     97        (JSC::JSArray::setLength):
     98        (JSC::JSArray::pop):
     99        (JSC::JSArray::push):
     100        * runtime/JSFunction.cpp:
     101        (JSC::JSFunction::finishCreation): Same issue as InternalFunction::finishCreation.
     102
     103        (JSC::JSFunction::callerGetter):
     104        (JSC::JSFunction::defineOwnProperty):
     105        * runtime/JSGlobalData.cpp:
     106        (JSC::enableAssembler): Use CFSTR() instead of CFStringCreateWithCString().
     107        CFStringCreateWithCString() copy the content and may choose to decode the data.
     108        CFSTR() is much more efficient.
     109
     110        * runtime/JSGlobalObject.cpp:
     111        (JSC::JSGlobalObject::reset):
     112        JSFunction uses jsString() to create the name, we can use null strings instead
     113        of creating empty strings.
     114
     115        (JSC::JSGlobalObject::createThrowTypeError): ditto.
     116        * runtime/JSGlobalObjectFunctions.cpp:
     117        (JSC::encode):
     118        (JSC::decode):
     119        (JSC::globalFuncEval):
     120        * runtime/JSONObject.cpp:
     121        (JSC::Stringifier::appendStringifiedValue):
     122        (JSC::Stringifier::Holder::appendNextProperty):
     123        (JSC::JSONProtoFuncParse):
     124        (JSC::JSONProtoFuncStringify):
     125        * runtime/JSObject.cpp:
     126        (JSC::JSObject::put):
     127        (JSC::JSObject::defaultValue):
     128        (JSC::JSObject::hasInstance):
     129        (JSC::JSObject::defineOwnProperty):
     130        * runtime/JSString.cpp:
     131        Return an empty JSString to avoid the creation of a temporary empty String.
     132
     133        (JSC::JSRopeString::getIndexSlowCase):
     134        * runtime/JSString.h:
     135        (JSC): Remove the versions of jsNontrivialString() taking a char*. All the callers
     136        have been replaced by calls using ASCIILiteral.
     137
     138        * runtime/JSValue.cpp:
     139        (JSC::JSValue::putToPrimitive):
     140        * runtime/LiteralParser.cpp:
     141        (JSC::::Lexer::lex):
     142        (JSC::::Lexer::lexString):
     143        (JSC::::Lexer::lexNumber):
     144        (JSC::::parse):
     145        * runtime/LiteralParser.h:
     146        (JSC::LiteralParser::getErrorMessage):
     147        * runtime/NumberPrototype.cpp:
     148        (JSC::numberProtoFuncToExponential):
     149        (JSC::numberProtoFuncToFixed):
     150        (JSC::numberProtoFuncToPrecision):
     151        (JSC::numberProtoFuncToString):
     152        * runtime/ObjectConstructor.cpp:
     153        (JSC::objectConstructorGetPrototypeOf):
     154        (JSC::objectConstructorGetOwnPropertyDescriptor):
     155        (JSC::objectConstructorGetOwnPropertyNames):
     156        (JSC::objectConstructorKeys):
     157        (JSC::toPropertyDescriptor):
     158        (JSC::objectConstructorDefineProperty):
     159        (JSC::objectConstructorDefineProperties):
     160        (JSC::objectConstructorCreate):
     161        (JSC::objectConstructorSeal):
     162        (JSC::objectConstructorFreeze):
     163        (JSC::objectConstructorPreventExtensions):
     164        (JSC::objectConstructorIsSealed):
     165        (JSC::objectConstructorIsFrozen):
     166        (JSC::objectConstructorIsExtensible):
     167        * runtime/ObjectPrototype.cpp:
     168        (JSC::objectProtoFuncDefineGetter):
     169        (JSC::objectProtoFuncDefineSetter):
     170        (JSC::objectProtoFuncToString):
     171        * runtime/RegExpConstructor.cpp:
     172        (JSC::constructRegExp):
     173        * runtime/RegExpObject.cpp:
     174        (JSC::reject):
     175        (JSC::regExpObjectSource):
     176        * runtime/RegExpPrototype.cpp:
     177        (JSC::regExpProtoFuncCompile):
     178        * runtime/StringObject.cpp:
     179        (JSC::StringObject::defineOwnProperty):
     180        * runtime/StringPrototype.cpp:
     181        (JSC::jsSpliceSubstrings):
     182        (JSC::jsSpliceSubstringsWithSeparators):
     183
    11842012-09-04  Filip Pizlo  <fpizlo@apple.com>
    2185
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r127393 r127505  
    7676{
    7777    if (!val)
    78         return "0";
     78        return ASCIILiteral("0");
    7979
    8080    if (val.isString())
     
    30333033    }
    30343034    if (needsActivation() && registerNumber == activationRegister())
    3035         return "activation";
     3035        return ASCIILiteral("activation");
    30363036    if (registerNumber == thisRegister())
    3037         return "this";
     3037        return ASCIILiteral("this");
    30383038    if (usesArguments()) {
    30393039        if (registerNumber == argumentsRegister())
    3040             return "arguments";
     3040            return ASCIILiteral("arguments");
    30413041        if (unmodifiedArgumentsRegister(argumentsRegister()) == registerNumber)
    3042             return "real arguments";
     3042            return ASCIILiteral("real arguments");
    30433043    }
    30443044    if (registerNumber < 0) {
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r127393 r127505  
    743743    else
    744744        globalObject = error->globalObject();
     745
     746    // FIXME: JSStringJoiner could be more efficient than StringBuilder here.
    745747    StringBuilder builder;
    746748    for (unsigned i = 0; i < stackTrace.size(); i++) {
  • trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp

    r116828 r127505  
    8686        uint32_t n = args.at(0).toUInt32(exec);
    8787        if (n != args.at(0).toNumber(exec))
    88             return throwError(exec, createRangeError(exec, "Array size is not a small enough positive integer."));
     88            return throwError(exec, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer.")));
    8989        return constructEmptyArray(exec, globalObject, n);
    9090    }
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r127202 r127505  
    206206                return;
    207207        } else if (!thisObj->methodTable()->deletePropertyByIndex(thisObj, exec, to)) {
    208             throwTypeError(exec, "Unable to delete property.");
     208            throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    209209            return;
    210210        }
     
    212212    for (unsigned k = length; k > length - count; --k) {
    213213        if (!thisObj->methodTable()->deletePropertyByIndex(thisObj, exec, k - 1)) {
    214             throwTypeError(exec, "Unable to delete property.");
     214            throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    215215            return;
    216216        }
     
    244244            thisObj->methodTable()->putByIndex(thisObj, exec, to, value, true);
    245245        } else if (!thisObj->methodTable()->deletePropertyByIndex(thisObj, exec, to)) {
    246             throwTypeError(exec, "Unable to delete property.");
     246            throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    247247            return;
    248248        }
     
    492492            return JSValue::encode(jsUndefined());
    493493        if (!thisObj->methodTable()->deletePropertyByIndex(thisObj, exec, length - 1)) {
    494             throwTypeError(exec, "Unable to delete property.");
     494            throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    495495            return JSValue::encode(jsUndefined());
    496496        }
     
    554554                return JSValue::encode(jsUndefined());
    555555        } else if (!thisObj->methodTable()->deletePropertyByIndex(thisObj, exec, k)) {
    556             throwTypeError(exec, "Unable to delete property.");
     556            throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    557557            return JSValue::encode(jsUndefined());
    558558        }
     
    563563                return JSValue::encode(jsUndefined());
    564564        } else if (!thisObj->methodTable()->deletePropertyByIndex(thisObj, exec, lk1)) {
    565             throwTypeError(exec, "Unable to delete property.");
     565            throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    566566            return JSValue::encode(jsUndefined());
    567567        }
  • trunk/Source/JavaScriptCore/runtime/BooleanPrototype.cpp

    r116828 r127505  
    7878EncodedJSValue JSC_HOST_CALL booleanProtoFuncToString(ExecState* exec)
    7979{
     80    JSGlobalData* globalData = &exec->globalData();
    8081    JSValue thisValue = exec->hostThisValue();
    8182    if (thisValue == jsBoolean(false))
    82         return JSValue::encode(jsNontrivialString(exec, "false"));
     83        return JSValue::encode(globalData->smallStrings.falseString(globalData));
    8384
    8485    if (thisValue == jsBoolean(true))
    85         return JSValue::encode(jsNontrivialString(exec, "true"));
     86        return JSValue::encode(globalData->smallStrings.trueString(globalData));
    8687
    8788    if (!thisValue.inherits(&BooleanObject::s_info))
     
    8990
    9091    if (asBooleanObject(thisValue)->internalValue() == jsBoolean(false))
    91         return JSValue::encode(jsNontrivialString(exec, "false"));
     92        return JSValue::encode(globalData->smallStrings.falseString(globalData));
    9293
    9394    ASSERT(asBooleanObject(thisValue)->internalValue() == jsBoolean(true));
    94     return JSValue::encode(jsNontrivialString(exec, "true"));
     95    return JSValue::encode(globalData->smallStrings.trueString(globalData));
    9596}
    9697
  • trunk/Source/JavaScriptCore/runtime/DateConversion.cpp

    r127191 r127505  
    7474
    7575        if (asUTCVariant) {
    76             builder.append(", ");
     76            builder.appendLiteral(", ");
    7777            appendNumber<2>(builder, t.monthDay());
    7878            builder.append(' ');
     
    9797        builder.append(':');
    9898        appendNumber<2>(builder, t.second());
    99         builder.append(" GMT");
     99        builder.appendLiteral(" GMT");
    100100
    101101        if (!asUTCVariant) {
     
    115115#endif
    116116            if (timeZoneName[0]) {
    117                 builder.append(" (");
     117                builder.appendLiteral(" (");
    118118                builder.append(timeZoneName);
    119119                builder.append(')');
  • trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp

    r127191 r127505  
    335335    const GregorianDateTime* gregorianDateTime = dateObject->gregorianDateTime(exec);
    336336    if (!gregorianDateTime)
    337         return jsNontrivialString(exec, "Invalid Date");
     337        return jsNontrivialString(exec, ASCIILiteral("Invalid Date"));
    338338    return formatLocaleDate(exec, *gregorianDateTime, format);
    339339}
     
    353353        : thisDateObj->gregorianDateTime(exec);
    354354    if (!gregorianDateTime)
    355         return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
     355        return JSValue::encode(jsNontrivialString(exec, String(ASCIILiteral("Invalid Date"))));
    356356
    357357    return JSValue::encode(jsNontrivialString(exec, formatDateTime(*gregorianDateTime, format, asUTCVariant)));
     
    549549    DateInstance* thisDateObj = asDateInstance(thisValue);
    550550    if (!isfinite(thisDateObj->internalNumber()))
    551         return throwVMError(exec, createRangeError(exec, "Invalid Date"));
     551        return throwVMError(exec, createRangeError(exec, ASCIILiteral("Invalid Date")));
    552552
    553553    const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(exec);
    554554    if (!gregorianDateTime)
    555         return JSValue::encode(jsNontrivialString(exec, "Invalid Date"));
     555        return JSValue::encode(jsNontrivialString(exec, String(ASCIILiteral("Invalid Date"))));
    556556    // Maximum amount of space we need in buffer: 7 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) + 4 (. + 3 digits for milliseconds)
    557557    // 6 for formatting and one for null termination = 28. We add one extra character to allow us to force null termination.
    558     char buffer[29];
     558    char buffer[28];
    559559    // If the year is outside the bounds of 0 and 9999 inclusive we want to use the extended year format (ES 15.9.1.15.1).
    560560    int ms = static_cast<int>(fmod(thisDateObj->internalNumber(), msPerSecond));
    561561    if (ms < 0)
    562562        ms += msPerSecond;
     563
     564    int charactersWritten;
    563565    if (gregorianDateTime->year() > 9999 || gregorianDateTime->year() < 0)
    564         snprintf(buffer, sizeof(buffer) - 1, "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
     566        charactersWritten = snprintf(buffer, sizeof(buffer), "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
    565567    else
    566         snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
    567     buffer[sizeof(buffer) - 1] = 0;
    568     return JSValue::encode(jsNontrivialString(exec, buffer));
     568        charactersWritten = snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
     569
     570    ASSERT(charactersWritten > 0 && static_cast<unsigned>(charactersWritten) < sizeof(buffer));
     571    if (static_cast<unsigned>(charactersWritten) >= sizeof(buffer))
     572        return JSValue::encode(jsEmptyString(exec));
     573
     574    return JSValue::encode(jsNontrivialString(exec, String(buffer, charactersWritten)));
    569575}
    570576
     
    11141120    CallType callType = getCallData(toISOValue, callData);
    11151121    if (callType == CallTypeNone)
    1116         return throwVMError(exec, createTypeError(exec, "toISOString is not a function"));
     1122        return throwVMError(exec, createTypeError(exec, ASCIILiteral("toISOString is not a function")));
    11171123
    11181124    JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
     
    11201126        return JSValue::encode(jsNull());
    11211127    if (result.isObject())
    1122         return throwVMError(exec, createTypeError(exec, "toISOString did not return a primitive value"));
     1128        return throwVMError(exec, createTypeError(exec, ASCIILiteral("toISOString did not return a primitive value")));
    11231129    return JSValue::encode(result);
    11241130}
  • trunk/Source/JavaScriptCore/runtime/Error.cpp

    r127191 r127505  
    8282JSObject* createNotEnoughArgumentsError(JSGlobalObject* globalObject)
    8383{
    84     return createTypeError(globalObject, "Not enough arguments");
     84    return createTypeError(globalObject, ASCIILiteral("Not enough arguments"));
    8585}
    8686
     
    170170JSObject* throwTypeError(ExecState* exec)
    171171{
    172     return throwError(exec, createTypeError(exec, "Type error"));
     172    return throwError(exec, createTypeError(exec, ASCIILiteral("Type error")));
    173173}
    174174
    175175JSObject* throwSyntaxError(ExecState* exec)
    176176{
    177     return throwError(exec, createSyntaxError(exec, "Syntax error"));
     177    return throwError(exec, createSyntaxError(exec, ASCIILiteral("Syntax error")));
    178178}
    179179
  • trunk/Source/JavaScriptCore/runtime/Error.h

    r127191 r127505  
    9090        {
    9191            StrictModeTypeErrorFunction* function = new (NotNull, allocateCell<StrictModeTypeErrorFunction>(*exec->heap())) StrictModeTypeErrorFunction(globalObject, structure, message);
    92             function->finishCreation(exec->globalData(), "");
     92            function->finishCreation(exec->globalData(), String());
    9393            return function;
    9494        }
  • trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp

    r127191 r127505  
    6060    Base::finishCreation(exec->globalData(), "");
    6161    ASSERT(inherits(&s_info));
    62     putDirect(exec->globalData(), exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum);
     62    putDirect(exec->globalData(), exec->propertyNames().name, jsNontrivialString(exec, String(ASCIILiteral("Error"))), DontEnum);
    6363}
    6464
     
    9999    String nameString;
    100100    if (name.isUndefined())
    101         nameString = "Error";
     101        nameString = ASCIILiteral("Error");
    102102    else {
    103103        nameString = name.toString(exec)->value(exec);
     
    116116    String messageString;
    117117    if (message.isUndefined())
    118         messageString = "";
     118        messageString = String();
    119119    else {
    120120        messageString = message.toString(exec)->value(exec);
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r127191 r127505  
    4848{
    4949    if (hint == PreferString)
    50         return jsNontrivialString(exec, "JavaScript execution exceeded timeout.");
     50        return jsNontrivialString(exec, String(ASCIILiteral("JavaScript execution exceeded timeout.")));
    5151    return JSValue(std::numeric_limits<double>::quiet_NaN());
    5252}
     
    7575{
    7676    if (hint == PreferString)
    77         return jsNontrivialString(exec, "JavaScript execution terminated.");
     77        return jsNontrivialString(exec, String(ASCIILiteral("JavaScript execution terminated.")));
    7878    return JSValue(std::numeric_limits<double>::quiet_NaN());
    7979}
     
    9797JSObject* createStackOverflowError(ExecState* exec)
    9898{
    99     return createRangeError(exec, "Maximum call stack size exceeded.");
     99    return createRangeError(exec, ASCIILiteral("Maximum call stack size exceeded."));
    100100}
    101101
    102102JSObject* createStackOverflowError(JSGlobalObject* globalObject)
    103103{
    104     return createRangeError(globalObject, "Maximum call stack size exceeded.");
     104    return createRangeError(globalObject, ASCIILiteral("Maximum call stack size exceeded."));
    105105}
    106106
     
    154154JSObject* createOutOfMemoryError(JSGlobalObject* globalObject)
    155155{
    156     return createError(globalObject, "Out of memory");
     156    return createError(globalObject, ASCIILiteral("Out of memory"));
    157157}
    158158
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r127202 r127505  
    210210    } else {
    211211        if (!lexicalGlobalObject->evalEnabled())
    212             return throwError(exec, createEvalError(exec, "Eval is disabled"));
     212            return throwError(exec, createEvalError(exec, ASCIILiteral("Eval is disabled")));
    213213        RefPtr<EvalNode> evalNode = parse<EvalNode>(globalData, lexicalGlobalObject, m_source, 0, isStrictMode() ? JSParseStrict : JSParseNormal, EvalNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);
    214214        if (!evalNode) {
     
    676676    for (size_t pos = 0; pos < parameters.size(); ++pos) {
    677677        if (!builder.isEmpty())
    678             builder.append(", ");
     678            builder.appendLiteral(", ");
    679679        builder.append(parameters[pos].ustring());
    680680    }
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r127202 r127505  
    8383{
    8484    if (!globalObject->evalEnabled())
    85         return throwError(exec, createEvalError(exec, "Function constructor is disabled"));
     85        return throwError(exec, createEvalError(exec, ASCIILiteral("Function constructor is disabled")));
    8686    return constructFunctionSkippingEvalEnabledCheck(exec, globalObject, args, functionName, sourceURL, position);
    8787}
     
    9494    String program;
    9595    if (args.isEmpty())
    96         program = "(function() { \n})";
     96        program = ASCIILiteral("(function() { \n})");
    9797    else if (args.size() == 1)
    9898        program = makeString("(function() { ", args.at(0).toString(exec)->value(exec), "\n})");
    9999    else {
    100100        StringBuilder builder;
    101         builder.append("(function(");
     101        builder.appendLiteral("(function(");
    102102        builder.append(args.at(0).toString(exec)->value(exec));
    103103        for (size_t i = 1; i < args.size() - 1; i++) {
    104             builder.append(",");
     104            builder.append(',');
    105105            builder.append(args.at(i).toString(exec)->value(exec));
    106106        }
    107         builder.append(") { ");
     107        builder.appendLiteral(") { ");
    108108        builder.append(args.at(args.size() - 1).toString(exec)->value(exec));
    109         builder.append("\n})");
     109        builder.appendLiteral("\n})");
    110110        program = builder.toString();
    111111    }
  • trunk/Source/JavaScriptCore/runtime/FunctionPrototype.h

    r127191 r127505  
    3333        {
    3434            FunctionPrototype* prototype = new (NotNull, allocateCell<FunctionPrototype>(*exec->heap())) FunctionPrototype(globalObject, structure);
    35             prototype->finishCreation(exec, "");
     35            prototype->finishCreation(exec, String());
    3636            return prototype;
    3737        }
  • trunk/Source/JavaScriptCore/runtime/InternalFunction.cpp

    r127191 r127505  
    4545    ASSERT(inherits(&s_info));
    4646    ASSERT(methodTable()->getCallData != InternalFunction::s_info.methodTable.getCallData);
    47     putDirect(globalData, globalData.propertyNames->name, jsString(&globalData, name.isNull() ? "" : name), DontDelete | ReadOnly | DontEnum);
     47    putDirect(globalData, globalData.propertyNames->name, jsString(&globalData, name), DontDelete | ReadOnly | DontEnum);
    4848}
    4949
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r127349 r127505  
    114114{
    115115    if (throwException)
    116         throwTypeError(exec, message);
     116        throwTypeError(exec, ASCIILiteral(message));
    117117    return false;
    118118}
     
    213213        remove(result.iterator);
    214214        if (shouldThrow)
    215             throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     215            throwTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError));
    216216        return;
    217217    }
     
    220220        if (entry.attributes & ReadOnly) {
    221221            if (shouldThrow)
    222                 throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     222                throwTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError));
    223223            return;
    224224        }
     
    234234    if (!setter) {
    235235        if (shouldThrow)
    236             throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     236            throwTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError));
    237237        return;
    238238    }
     
    724724        unsigned newLength = value.toUInt32(exec);
    725725        if (value.toNumber(exec) != static_cast<double>(newLength)) {
    726             throwError(exec, createRangeError(exec, "Invalid array length"));
     726            throwError(exec, createRangeError(exec, ASCIILiteral("Invalid array length")));
    727727            return;
    728728        }
     
    812812        if (map->lengthIsReadOnly() || !isExtensible()) {
    813813            if (shouldThrow)
    814                 throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     814                throwTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError));
    815815            return;
    816816        }
     
    12371237    if (!length) {
    12381238        if (!isLengthWritable())
    1239             throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     1239            throwTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError));
    12401240        return jsUndefined();
    12411241    }
     
    12621262    // Call the [[Delete]] internal method of O with arguments indx and true.
    12631263    if (!deletePropertyByIndex(this, exec, index)) {
    1264         throwTypeError(exec, "Unable to delete property.");
     1264        throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    12651265        return jsUndefined();
    12661266    }
     
    12951295        // Per ES5.1 15.4.4.7 step 6 & 15.4.5.1 step 3.d.
    12961296        if (!exec->hadException())
    1297             throwError(exec, createRangeError(exec, "Invalid array length"));
     1297            throwError(exec, createRangeError(exec, ASCIILiteral("Invalid array length")));
    12981298        return;
    12991299    }
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r127202 r127505  
    9797    ASSERT(inherits(&s_info));
    9898    m_executable.set(exec->globalData(), this, executable);
    99     putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name), DontDelete | ReadOnly | DontEnum);
     99    putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name), DontDelete | ReadOnly | DontEnum);
    100100    putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum);
    101101}
     
    204204    if (function->isHostFunction() || !function->jsExecutable()->isStrictMode())
    205205        return caller;
    206     return throwTypeError(exec, "Function.caller used to retrieve strict caller");
     206    return throwTypeError(exec, ASCIILiteral("Function.caller used to retrieve strict caller"));
    207207}
    208208
     
    415415    if (descriptor.configurablePresent() && descriptor.configurable()) {
    416416        if (throwException)
    417             throwError(exec, createTypeError(exec, "Attempting to configurable attribute of unconfigurable property."));
     417            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
    418418        return false;
    419419    }
    420420    if (descriptor.enumerablePresent() && descriptor.enumerable()) {
    421421        if (throwException)
    422             throwError(exec, createTypeError(exec, "Attempting to change enumerable attribute of unconfigurable property."));
     422            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
    423423        return false;
    424424    }
    425425    if (descriptor.isAccessorDescriptor()) {
    426426        if (throwException)
    427             throwError(exec, createTypeError(exec, "Attempting to change access mechanism for an unconfigurable property."));
     427            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
    428428        return false;
    429429    }
    430430    if (descriptor.writablePresent() && descriptor.writable()) {
    431431        if (throwException)
    432             throwError(exec, createTypeError(exec, "Attempting to change writable attribute of unconfigurable property."));
     432            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
    433433        return false;
    434434    }
    435435    if (!valueCheck) {
    436436        if (throwException)
    437             throwError(exec, createTypeError(exec, "Attempting to change value of a readonly property."));
     437            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
    438438        return false;
    439439    }
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r127348 r127505  
    105105
    106106#if USE(CF)
    107     RetainPtr<CFStringRef> canUseJITKey(AdoptCF, CFStringCreateWithCString(0 , "JavaScriptCoreUseJIT", kCFStringEncodingMacRoman));
    108     RetainPtr<CFBooleanRef> canUseJIT(AdoptCF, (CFBooleanRef)CFPreferencesCopyAppValue(canUseJITKey.get(), kCFPreferencesCurrentApplication));
     107#if COMPILER(GCC) && !COMPILER(CLANG)
     108    // FIXME: remove this once the EWS have been upgraded to LLVM.
     109    // Work around a bug of GCC with strict-aliasing.
     110    RetainPtr<CFStringRef> canUseJITKeyRetain(AdoptCF, CFStringCreateWithCString(0 , "JavaScriptCoreUseJIT", kCFStringEncodingMacRoman));
     111    CFStringRef canUseJITKey = canUseJITKeyRetain.get();
     112#else
     113    CFStringRef canUseJITKey = CFSTR("JavaScriptCoreUseJIT");
     114#endif // COMPILER(GCC) && !COMPILER(CLANG)
     115    RetainPtr<CFBooleanRef> canUseJIT(AdoptCF, (CFBooleanRef)CFPreferencesCopyAppValue(canUseJITKey, kCFPreferencesCurrentApplication));
    109116    if (canUseJIT)
    110117        return kCFBooleanTrue == canUseJIT.get();
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r127363 r127505  
    212212    m_objectPrototype.set(exec->globalData(), this, ObjectPrototype::create(exec, this, ObjectPrototype::createStructure(exec->globalData(), this, jsNull())));
    213213    GetterSetter* protoAccessor = GetterSetter::create(exec);
    214     protoAccessor->setGetter(exec->globalData(), JSFunction::create(exec, this, 0, "", globalFuncProtoGetter));
    215     protoAccessor->setSetter(exec->globalData(), JSFunction::create(exec, this, 0, "", globalFuncProtoSetter));
     214    protoAccessor->setGetter(exec->globalData(), JSFunction::create(exec, this, 0, String(), globalFuncProtoGetter));
     215    protoAccessor->setSetter(exec->globalData(), JSFunction::create(exec, this, 0, String(), globalFuncProtoSetter));
    216216    m_objectPrototype->putDirectAccessor(exec->globalData(), exec->propertyNames().underscoreProto, protoAccessor, Accessor | DontEnum);
    217217    m_functionPrototype->structure()->setPrototypeWithoutTransition(exec->globalData(), m_objectPrototype.get());
     
    272272    Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), this, m_errorPrototype.get());
    273273    Structure* nativeErrorStructure = NativeErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get());
    274     m_evalErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "EvalError"));
    275     m_rangeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "RangeError"));
    276     m_referenceErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "ReferenceError"));
    277     m_syntaxErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "SyntaxError"));
    278     m_typeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "TypeError"));
    279     m_URIErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "URIError"));
     274    m_evalErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("EvalError")));
     275    m_rangeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("RangeError")));
     276    m_referenceErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("ReferenceError")));
     277    m_syntaxErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("SyntaxError")));
     278    m_typeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("TypeError")));
     279    m_URIErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("URIError")));
    280280
    281281    m_objectPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, objectConstructor, DontEnum);
     
    332332void JSGlobalObject::createThrowTypeError(ExecState* exec)
    333333{
    334     JSFunction* thrower = JSFunction::create(exec, this, 0, "", globalFuncThrowTypeError);
     334    JSFunction* thrower = JSFunction::create(exec, this, 0, String(), globalFuncThrowTypeError);
    335335    GetterSetter* getterSetter = GetterSetter::create(exec);
    336336    getterSetter->setGetter(exec->globalData(), thrower);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r127202 r127505  
    5454    CString cstr = exec->argument(0).toString(exec)->value(exec).utf8(true);
    5555    if (!cstr.data())
    56         return throwError(exec, createURIError(exec, "String contained an illegal UTF-16 sequence."));
     56        return throwError(exec, createURIError(exec, ASCIILiteral("String contained an illegal UTF-16 sequence.")));
    5757
    5858    JSStringBuilder builder;
     
    115115            if (charLen == 0) {
    116116                if (strict)
    117                     return throwError(exec, createURIError(exec, "URI error"));
     117                    return throwError(exec, createURIError(exec, ASCIILiteral("URI error")));
    118118                // The only case where we don't use "strict" mode is the "unescape" function.
    119119                // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE.
     
    500500    JSObject* unwrappedObject = thisObject->unwrappedObject();
    501501    if (!unwrappedObject->isGlobalObject() || jsCast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee())
    502         return throwVMError(exec, createEvalError(exec, "The \"this\" value passed to eval must be the global object from which eval originated"));
     502        return throwVMError(exec, createEvalError(exec, ASCIILiteral("The \"this\" value passed to eval must be the global object from which eval originated")));
    503503
    504504    JSValue x = exec->argument(0);
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r127349 r127505  
    362362
    363363    if (value.isNull()) {
    364         builder.append("null");
     364        builder.appendLiteral("null");
    365365        return StringifySucceeded;
    366366    }
     
    372372
    373373    if (value.isBoolean()) {
    374         builder.append(value.isTrue() ? "true" : "false");
     374        if (value.isTrue())
     375            builder.appendLiteral("true");
     376        else
     377            builder.appendLiteral("false");
    375378        return StringifySucceeded;
    376379    }
     
    385388        double number = value.asNumber();
    386389        if (!isfinite(number))
    387             builder.append("null");
     390            builder.appendLiteral("null");
    388391        else
    389392            builder.append(String::numberToStringECMAScript(number));
     
    399402    if (object->methodTable()->getCallData(object, callData) != CallTypeNone) {
    400403        if (holder->inherits(&JSArray::s_info)) {
    401             builder.append("null");
     404            builder.appendLiteral("null");
    402405            return StringifySucceeded;
    403406        }
     
    408411    for (unsigned i = 0; i < m_holderStack.size(); i++) {
    409412        if (m_holderStack[i].object() == object) {
    410             throwError(m_exec, createTypeError(m_exec, "JSON.stringify cannot serialize cyclic structures."));
     413            throwError(m_exec, createTypeError(m_exec, ASCIILiteral("JSON.stringify cannot serialize cyclic structures.")));
    411414            return StringifyFailed;
    412415        }
     
    570573    switch (stringifyResult) {
    571574        case StringifyFailed:
    572             builder.append("null");
     575            builder.appendLiteral("null");
    573576            break;
    574577        case StringifySucceeded:
     
    810813{
    811814    if (!exec->argumentCount())
    812         return throwVMError(exec, createError(exec, "JSON.parse requires at least one parameter"));
     815        return throwVMError(exec, createError(exec, ASCIILiteral("JSON.parse requires at least one parameter")));
    813816    String source = exec->argument(0).toString(exec)->value(exec);
    814817    if (exec->hadException())
     
    844847{
    845848    if (!exec->argumentCount())
    846         return throwVMError(exec, createError(exec, "No input to stringify"));
     849        return throwVMError(exec, createError(exec, ASCIILiteral("No input to stringify")));
    847850    LocalScope scope(exec->globalData());
    848851    Local<Unknown> value(exec->globalData(), exec->argument(0));
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r127191 r127505  
    183183            if (prototype.isNull()) {
    184184                if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getCallableObject(value)) && slot.isStrictMode())
    185                     throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     185                    throwTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError));
    186186                return;
    187187            }
     
    196196            if (attributes & ReadOnly) {
    197197                if (slot.isStrictMode())
    198                     throwError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
     198                    throwError(exec, createTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError)));
    199199                return;
    200200            }
     
    205205                if (!setterFunc) {
    206206                    if (slot.isStrictMode())
    207                         throwError(exec, createTypeError(exec, "setting a property that has only a getter"));
     207                        throwError(exec, createTypeError(exec, ASCIILiteral("setting a property that has only a getter")));
    208208                    return;
    209209                }
     
    230230   
    231231    if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getCallableObject(value)) && slot.isStrictMode())
    232         throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     232        throwTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError));
    233233    return;
    234234}
     
    390390    ASSERT(!exec->hadException());
    391391
    392     return throwError(exec, createTypeError(exec, "No default value"));
     392    return throwError(exec, createTypeError(exec, ASCIILiteral("No default value")));
    393393}
    394394
     
    410410
    411411    if (!proto.isObject()) {
    412         throwError(exec, createTypeError(exec, "instanceof called on an object with an invalid prototype property."));
     412        throwError(exec, createTypeError(exec, ASCIILiteral("instanceof called on an object with an invalid prototype property.")));
    413413        return false;
    414414    }
     
    719719        if (!object->isExtensible()) {
    720720            if (throwException)
    721                 throwError(exec, createTypeError(exec, "Attempting to define property on object that is not extensible."));
     721                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
    722722            return false;
    723723        }
     
    737737        if (descriptor.configurable()) {
    738738            if (throwException)
    739                 throwError(exec, createTypeError(exec, "Attempting to configurable attribute of unconfigurable property."));
     739                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
    740740            return false;
    741741        }
    742742        if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) {
    743743            if (throwException)
    744                 throwError(exec, createTypeError(exec, "Attempting to change enumerable attribute of unconfigurable property."));
     744                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
    745745            return false;
    746746        }
     
    760760        if (!current.configurable()) {
    761761            if (throwException)
    762                 throwError(exec, createTypeError(exec, "Attempting to change access mechanism for an unconfigurable property."));
     762                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
    763763            return false;
    764764        }
     
    772772            if (!current.writable() && descriptor.writable()) {
    773773                if (throwException)
    774                     throwError(exec, createTypeError(exec, "Attempting to change writable attribute of unconfigurable property."));
     774                    throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
    775775                return false;
    776776            }
     
    778778                if (descriptor.value() && !sameValue(exec, current.value(), descriptor.value())) {
    779779                    if (throwException)
    780                         throwError(exec, createTypeError(exec, "Attempting to change value of a readonly property."));
     780                        throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
    781781                    return false;
    782782                }
     
    794794        if (descriptor.setterPresent() && !(current.setterPresent() && JSValue::strictEqual(exec, current.setter(), descriptor.setter()))) {
    795795            if (throwException)
    796                 throwError(exec, createTypeError(exec, "Attempting to change the setter of an unconfigurable property."));
     796                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change the setter of an unconfigurable property.")));
    797797            return false;
    798798        }
    799799        if (descriptor.getterPresent() && !(current.getterPresent() && JSValue::strictEqual(exec, current.getter(), descriptor.getter()))) {
    800800            if (throwException)
    801                 throwError(exec, createTypeError(exec, "Attempting to change the getter of an unconfigurable property."));
     801                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change the getter of an unconfigurable property.")));
    802802            return false;
    803803        }
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r127191 r127505  
    226226    // Return a safe no-value result, this should never be used, since the excetion will be thrown.
    227227    if (exec->exception())
    228         return jsString(exec, "");
     228        return jsEmptyString(exec);
    229229    ASSERT(!isRope());
    230230    ASSERT(i < m_value.length());
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r127212 r127505  
    5151    JSString* jsNontrivialString(JSGlobalData*, const String&);
    5252    JSString* jsNontrivialString(ExecState*, const String&);
    53     JSString* jsNontrivialString(JSGlobalData*, const char*);
    54     JSString* jsNontrivialString(ExecState*, const char*);
    5553
    5654    // Should be used for strings that are owned by an object that will
     
    354352    }
    355353
    356     inline JSString* jsNontrivialString(JSGlobalData* globalData, const char* s)
    357     {
    358         ASSERT(s);
    359         ASSERT(s[0]);
    360         ASSERT(s[1]);
    361         return JSString::create(*globalData, String(s).impl());
    362     }
    363 
    364354    inline JSString* jsNontrivialString(JSGlobalData* globalData, const String& s)
    365355    {
     
    469459    inline JSString* jsSubstring(ExecState* exec, const String& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); }
    470460    inline JSString* jsNontrivialString(ExecState* exec, const String& s) { return jsNontrivialString(&exec->globalData(), s); }
    471     inline JSString* jsNontrivialString(ExecState* exec, const char* s) { return jsNontrivialString(&exec->globalData(), s); }
    472461    inline JSString* jsOwnedString(ExecState* exec, const String& s) { return jsOwnedString(&exec->globalData(), s); }
    473462
  • trunk/Source/JavaScriptCore/runtime/JSValue.cpp

    r127191 r127505  
    144144                if (!setterFunc) {
    145145                    if (slot.isStrictMode())
    146                         throwError(exec, createTypeError(exec, "setting a property that has only a getter"));
     146                        throwError(exec, createTypeError(exec, ASCIILiteral("setting a property that has only a getter")));
    147147                    return;
    148148                }
  • trunk/Source/JavaScriptCore/runtime/LiteralParser.cpp

    r127191 r127505  
    270270        if (*m_ptr == '\'') {
    271271            if (mode == StrictJSON) {
    272                 m_lexErrorMessage = "Single quotes (\') are not allowed in JSON";
     272                m_lexErrorMessage = ASCIILiteral("Single quotes (\') are not allowed in JSON");
    273273                return TokError;
    274274            }
     
    357357            ++m_ptr;
    358358            if (m_ptr >= m_end) {
    359                 m_lexErrorMessage = "Unterminated string";
     359                m_lexErrorMessage = ASCIILiteral("Unterminated string");
    360360                return TokError;
    361361            }
     
    396396                case 'u':
    397397                    if ((m_end - m_ptr) < 5) {
    398                         m_lexErrorMessage = "\\u must be followed by 4 hex digits";
     398                        m_lexErrorMessage = ASCIILiteral("\\u must be followed by 4 hex digits");
    399399                        return TokError;
    400400                    } // uNNNN == 5 characters
     
    422422
    423423    if (m_ptr >= m_end || *m_ptr != terminator) {
    424         m_lexErrorMessage = "Unterminated string";
     424        m_lexErrorMessage = ASCIILiteral("Unterminated string");
    425425        return TokError;
    426426    }
     
    475475            ++m_ptr;
    476476    } else {
    477         m_lexErrorMessage = "Invalid number";
     477        m_lexErrorMessage = ASCIILiteral("Invalid number");
    478478        return TokError;
    479479    }
     
    484484        // [0-9]+
    485485        if (m_ptr >= m_end || !isASCIIDigit(*m_ptr)) {
    486             m_lexErrorMessage = "Invalid digits after decimal point";
     486            m_lexErrorMessage = ASCIILiteral("Invalid digits after decimal point");
    487487            return TokError;
    488488        }
     
    519519        // [0-9]+
    520520        if (m_ptr >= m_end || !isASCIIDigit(*m_ptr)) {
    521             m_lexErrorMessage = "Exponent symbols should be followed by an optional '+' or '-' and then by at least one number";
     521            m_lexErrorMessage = ASCIILiteral("Exponent symbols should be followed by an optional '+' or '-' and then by at least one number");
    522522            return TokError;
    523523        }
     
    556556                if (m_lexer.next() == TokRBracket) {
    557557                    if (lastToken == TokComma) {
    558                         m_parseErrorMessage = "Unexpected comma at the end of array expression";
     558                        m_parseErrorMessage = ASCIILiteral("Unexpected comma at the end of array expression");
    559559                        return JSValue();
    560560                    }
     
    575575
    576576                if (m_lexer.currentToken().type != TokRBracket) {
    577                     m_parseErrorMessage = "Expected ']'";
     577                    m_parseErrorMessage = ASCIILiteral("Expected ']'");
    578578                    return JSValue();
    579579                }
     
    595595                    // Check for colon
    596596                    if (m_lexer.next() != TokColon) {
    597                         m_parseErrorMessage = "Expected ':' before value in object property definition";
     597                        m_parseErrorMessage = ASCIILiteral("Expected ':' before value in object property definition");
    598598                        return JSValue();
    599599                    }
     
    608608                }
    609609                if (type != TokRBrace)  {
    610                     m_parseErrorMessage = "Expected '}'";
     610                    m_parseErrorMessage = ASCIILiteral("Expected '}'");
    611611                    return JSValue();
    612612                }
     
    620620                TokenType type = m_lexer.next();
    621621                if (type != TokString && (m_mode == StrictJSON || type != TokIdentifier)) {
    622                     m_parseErrorMessage = "Property name must be a string literal";
     622                    m_parseErrorMessage = ASCIILiteral("Property name must be a string literal");
    623623                    return JSValue();
    624624                }
     
    627627                // Check for colon
    628628                if (m_lexer.next() != TokColon) {
    629                     m_parseErrorMessage = "Expected ':'";
     629                    m_parseErrorMessage = ASCIILiteral("Expected ':'");
    630630                    return JSValue();
    631631                }
     
    646646                    goto doParseObjectStartExpression;
    647647                if (m_lexer.currentToken().type != TokRBrace) {
    648                     m_parseErrorMessage = "Expected '}'";
     648                    m_parseErrorMessage = ASCIILiteral("Expected '}'");
    649649                    return JSValue();
    650650                }
     
    691691                        break;
    692692                    case TokRBracket:
    693                         m_parseErrorMessage = "Unexpected token ']'";
     693                        m_parseErrorMessage = ASCIILiteral("Unexpected token ']'");
    694694                        return JSValue();
    695695                    case TokRBrace:
    696                         m_parseErrorMessage = "Unexpected token '}'";
     696                        m_parseErrorMessage = ASCIILiteral("Unexpected token '}'");
    697697                        return JSValue();
    698698                    case TokIdentifier: {
     
    705705                    }
    706706                    case TokColon:
    707                         m_parseErrorMessage = "Unexpected token ':'";
     707                        m_parseErrorMessage = ASCIILiteral("Unexpected token ':'");
    708708                        return JSValue();
    709709                    case TokLParen:
    710                         m_parseErrorMessage = "Unexpected token '('";
     710                        m_parseErrorMessage = ASCIILiteral("Unexpected token '('");
    711711                        return JSValue();
    712712                    case TokRParen:
    713                         m_parseErrorMessage = "Unexpected token ')'";
     713                        m_parseErrorMessage = ASCIILiteral("Unexpected token ')'");
    714714                        return JSValue();
    715715                    case TokComma:
    716                         m_parseErrorMessage = "Unexpected token ','";
     716                        m_parseErrorMessage = ASCIILiteral("Unexpected token ','");
    717717                        return JSValue();
    718718                    case TokDot:
    719                         m_parseErrorMessage = "Unexpected token '.'";
     719                        m_parseErrorMessage = ASCIILiteral("Unexpected token '.'");
    720720                        return JSValue();
    721721                    case TokAssign:
    722                         m_parseErrorMessage = "Unexpected token '='";
     722                        m_parseErrorMessage = ASCIILiteral("Unexpected token '='");
    723723                        return JSValue();
    724724                    case TokSemi:
    725                         m_parseErrorMessage = "Unexpected token ';'";
     725                        m_parseErrorMessage = ASCIILiteral("Unexpected token ';'");
    726726                        return JSValue();
    727727                    case TokEnd:
    728                         m_parseErrorMessage = "Unexpected EOF";
     728                        m_parseErrorMessage = ASCIILiteral("Unexpected EOF");
    729729                        return JSValue();
    730730                    case TokError:
    731731                    default:
    732732                        // Error
    733                         m_parseErrorMessage = "Could not parse value expression";
     733                        m_parseErrorMessage = ASCIILiteral("Could not parse value expression");
    734734                        return JSValue();
    735735                }
     
    749749                    }
    750750                    case TokRBracket:
    751                         m_parseErrorMessage = "Unexpected token ']'";
     751                        m_parseErrorMessage = ASCIILiteral("Unexpected token ']'");
    752752                        return JSValue();
    753753                    case TokLBrace:
    754                         m_parseErrorMessage = "Unexpected token '{'";
     754                        m_parseErrorMessage = ASCIILiteral("Unexpected token '{'");
    755755                        return JSValue();
    756756                    case TokRBrace:
    757                         m_parseErrorMessage = "Unexpected token '}'";
     757                        m_parseErrorMessage = ASCIILiteral("Unexpected token '}'");
    758758                        return JSValue();
    759759                    case TokIdentifier:
    760                         m_parseErrorMessage = "Unexpected identifier";
     760                        m_parseErrorMessage = ASCIILiteral("Unexpected identifier");
    761761                        return JSValue();
    762762                    case TokColon:
    763                         m_parseErrorMessage = "Unexpected token ':'";
     763                        m_parseErrorMessage = ASCIILiteral("Unexpected token ':'");
    764764                        return JSValue();
    765765                    case TokRParen:
    766                         m_parseErrorMessage = "Unexpected token ')'";
     766                        m_parseErrorMessage = ASCIILiteral("Unexpected token ')'");
    767767                        return JSValue();
    768768                    case TokComma:
    769                         m_parseErrorMessage = "Unexpected token ','";
     769                        m_parseErrorMessage = ASCIILiteral("Unexpected token ','");
    770770                        return JSValue();
    771771                    case TokTrue:
    772                         m_parseErrorMessage = "Unexpected token 'true'";
     772                        m_parseErrorMessage = ASCIILiteral("Unexpected token 'true'");
    773773                        return JSValue();
    774774                    case TokFalse:
    775                         m_parseErrorMessage = "Unexpected token 'false'";
     775                        m_parseErrorMessage = ASCIILiteral("Unexpected token 'false'");
    776776                        return JSValue();
    777777                    case TokNull:
    778                         m_parseErrorMessage = "Unexpected token 'null'";
     778                        m_parseErrorMessage = ASCIILiteral("Unexpected token 'null'");
    779779                        return JSValue();
    780780                    case TokEnd:
    781                         m_parseErrorMessage = "Unexpected EOF";
     781                        m_parseErrorMessage = ASCIILiteral("Unexpected EOF");
    782782                        return JSValue();
    783783                    case TokDot:
    784                         m_parseErrorMessage = "Unexpected token '.'";
     784                        m_parseErrorMessage = ASCIILiteral("Unexpected token '.'");
    785785                        return JSValue();
    786786                    case TokAssign:
    787                         m_parseErrorMessage = "Unexpected token '='";
     787                        m_parseErrorMessage = ASCIILiteral("Unexpected token '='");
    788788                        return JSValue();
    789789                    case TokSemi:
    790                         m_parseErrorMessage = "Unexpected token ';'";
     790                        m_parseErrorMessage = ASCIILiteral("Unexpected token ';'");
    791791                        return JSValue();
    792792                    case TokError:
    793793                    default:
    794                         m_parseErrorMessage = "Could not parse statement";
     794                        m_parseErrorMessage = ASCIILiteral("Could not parse statement");
    795795                        return JSValue();
    796796                }
     
    802802                if (m_lexer.next() == TokEnd)
    803803                    return lastValue;
    804                 m_parseErrorMessage = "Unexpected content at end of JSON literal";
     804                m_parseErrorMessage = ASCIILiteral("Unexpected content at end of JSON literal");
    805805                return JSValue();
    806806            }
  • trunk/Source/JavaScriptCore/runtime/LiteralParser.h

    r127191 r127505  
    101101        if (!m_parseErrorMessage.isEmpty())
    102102            return String::format("JSON Parse error: %s", m_parseErrorMessage.ascii().data()).impl();
    103         return "JSON Parse error: Unable to parse JSON string";
     103        return ASCIILiteral("JSON Parse error: Unable to parse JSON string");
    104104    }
    105105   
  • trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp

    r127191 r127505  
    379379    bool isUndefined;
    380380    if (!getIntegerArgumentInRange(exec, 0, 20, decimalPlacesInExponent, isUndefined))
    381         return throwVMError(exec, createRangeError(exec, "toExponential() argument must be between 0 and 20"));
     381        return throwVMError(exec, createRangeError(exec, ASCIILiteral("toExponential() argument must be between 0 and 20")));
    382382
    383383    // Handle NaN and Infinity.
     
    410410    bool isUndefined; // This is ignored; undefined treated as 0.
    411411    if (!getIntegerArgumentInRange(exec, 0, 20, decimalPlaces, isUndefined))
    412         return throwVMError(exec, createRangeError(exec, "toFixed() argument must be between 0 and 20"));
     412        return throwVMError(exec, createRangeError(exec, ASCIILiteral("toFixed() argument must be between 0 and 20")));
    413413
    414414    // 15.7.4.5.7 states "If x >= 10^21, then let m = ToString(x)"
     
    443443    bool isUndefined;
    444444    if (!getIntegerArgumentInRange(exec, 1, 21, significantFigures, isUndefined))
    445         return throwVMError(exec, createRangeError(exec, "toPrecision() argument must be between 1 and 21"));
     445        return throwVMError(exec, createRangeError(exec, ASCIILiteral("toPrecision() argument must be between 1 and 21")));
    446446
    447447    // To precision called with no argument is treated as ToString.
     
    498498    int32_t radix = extractRadixFromArgs(exec);
    499499    if (radix < 2 || radix > 36)
    500         return throwVMError(exec, createRangeError(exec, "toString() radix argument must be between 2 and 36"));
     500        return throwVMError(exec, createRangeError(exec, ASCIILiteral("toString() radix argument must be between 2 and 36")));
    501501
    502502    int32_t integerValue = static_cast<int32_t>(doubleValue);
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r127191 r127505  
    138138{
    139139    if (!exec->argument(0).isObject())
    140         return throwVMError(exec, createTypeError(exec, "Requested prototype of a value that is not an object."));
     140        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Requested prototype of a value that is not an object.")));
    141141    JSObject* object = asObject(exec->argument(0));
    142142    if (!object->allowsAccessFrom(exec->trueCallerFrame()))
     
    148148{
    149149    if (!exec->argument(0).isObject())
    150         return throwVMError(exec, createTypeError(exec, "Requested property descriptor of a value that is not an object."));
     150        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Requested property descriptor of a value that is not an object.")));
    151151    String propertyName = exec->argument(1).toString(exec)->value(exec);
    152152    if (exec->hadException())
     
    180180{
    181181    if (!exec->argument(0).isObject())
    182         return throwVMError(exec, createTypeError(exec, "Requested property names of a value that is not an object."));
     182        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Requested property names of a value that is not an object.")));
    183183    PropertyNameArray properties(exec);
    184184    asObject(exec->argument(0))->methodTable()->getOwnPropertyNames(asObject(exec->argument(0)), exec, properties, IncludeDontEnumProperties);
     
    194194{
    195195    if (!exec->argument(0).isObject())
    196         return throwVMError(exec, createTypeError(exec, "Requested keys of a value that is not an object."));
     196        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Requested keys of a value that is not an object.")));
    197197    PropertyNameArray properties(exec);
    198198    asObject(exec->argument(0))->methodTable()->getOwnPropertyNames(asObject(exec->argument(0)), exec, properties, ExcludeDontEnumProperties);
     
    208208{
    209209    if (!in.isObject()) {
    210         throwError(exec, createTypeError(exec, "Property description must be an object."));
     210        throwError(exec, createTypeError(exec, ASCIILiteral("Property description must be an object.")));
    211211        return false;
    212212    }
     
    250250            CallData callData;
    251251            if (getCallData(get, callData) == CallTypeNone) {
    252                 throwError(exec, createTypeError(exec, "Getter must be a function."));
     252                throwError(exec, createTypeError(exec, ASCIILiteral("Getter must be a function.")));
    253253                return false;
    254254            }
     
    265265            CallData callData;
    266266            if (getCallData(set, callData) == CallTypeNone) {
    267                 throwError(exec, createTypeError(exec, "Setter must be a function."));
     267                throwError(exec, createTypeError(exec, ASCIILiteral("Setter must be a function.")));
    268268                return false;
    269269            }
     
    276276
    277277    if (desc.value()) {
    278         throwError(exec, createTypeError(exec, "Invalid property.  'value' present on property with getter or setter."));
     278        throwError(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'value' present on property with getter or setter.")));
    279279        return false;
    280280    }
    281281
    282282    if (desc.writablePresent()) {
    283         throwError(exec, createTypeError(exec, "Invalid property.  'writable' present on property with getter or setter."));
     283        throwError(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'writable' present on property with getter or setter.")));
    284284        return false;
    285285    }
     
    290290{
    291291    if (!exec->argument(0).isObject())
    292         return throwVMError(exec, createTypeError(exec, "Properties can only be defined on Objects."));
     292        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));
    293293    JSObject* O = asObject(exec->argument(0));
    294294    String propertyName = exec->argument(1).toString(exec)->value(exec);
     
    341341{
    342342    if (!exec->argument(0).isObject())
    343         return throwVMError(exec, createTypeError(exec, "Properties can only be defined on Objects."));
     343        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));
    344344    return JSValue::encode(defineProperties(exec, asObject(exec->argument(0)), exec->argument(1).toObject(exec)));
    345345}
     
    348348{
    349349    if (!exec->argument(0).isObject() && !exec->argument(0).isNull())
    350         return throwVMError(exec, createTypeError(exec, "Object prototype may only be an Object or null."));
     350        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object prototype may only be an Object or null.")));
    351351    JSValue proto = exec->argument(0);
    352352    JSObject* newObject = proto.isObject() ? constructEmptyObject(exec, asObject(proto)->inheritorID(exec->globalData())) : constructEmptyObject(exec, exec->lexicalGlobalObject()->nullPrototypeObjectStructure());
     
    354354        return JSValue::encode(newObject);
    355355    if (!exec->argument(1).isObject())
    356         return throwVMError(exec, createTypeError(exec, "Property descriptor list must be an Object."));
     356        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Property descriptor list must be an Object.")));
    357357    return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1))));
    358358}
     
    363363    JSValue obj = exec->argument(0);
    364364    if (!obj.isObject())
    365         return throwVMError(exec, createTypeError(exec, "Object.seal can only be called on Objects."));
     365        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.seal can only be called on Objects.")));
    366366    JSObject* object = asObject(obj);
    367367
     
    400400    JSValue obj = exec->argument(0);
    401401    if (!obj.isObject())
    402         return throwVMError(exec, createTypeError(exec, "Object.freeze can only be called on Objects."));
     402        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.freeze can only be called on Objects.")));
    403403    JSObject* object = asObject(obj);
    404404
     
    440440    JSValue obj = exec->argument(0);
    441441    if (!obj.isObject())
    442         return throwVMError(exec, createTypeError(exec, "Object.preventExtensions can only be called on Objects."));
     442        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.preventExtensions can only be called on Objects.")));
    443443    asObject(obj)->preventExtensions(exec->globalData());
    444444    return JSValue::encode(obj);
     
    450450    JSValue obj = exec->argument(0);
    451451    if (!obj.isObject())
    452         return throwVMError(exec, createTypeError(exec, "Object.isSealed can only be called on Objects."));
     452        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.isSealed can only be called on Objects.")));
    453453    JSObject* object = asObject(obj);
    454454
     
    480480    JSValue obj = exec->argument(0);
    481481    if (!obj.isObject())
    482         return throwVMError(exec, createTypeError(exec, "Object.isFrozen can only be called on Objects."));
     482        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.isFrozen can only be called on Objects.")));
    483483    JSObject* object = asObject(obj);
    484484
     
    510510    JSValue obj = exec->argument(0);
    511511    if (!obj.isObject())
    512         return throwVMError(exec, createTypeError(exec, "Object.isExtensible can only be called on Objects."));
     512        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object.isExtensible can only be called on Objects.")));
    513513    return JSValue::encode(jsBoolean(asObject(obj)->isExtensible()));
    514514}
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r116828 r127505  
    158158    CallData callData;
    159159    if (getCallData(get, callData) == CallTypeNone)
    160         return throwVMError(exec, createSyntaxError(exec, "invalid getter usage"));
     160        return throwVMError(exec, createSyntaxError(exec, ASCIILiteral("invalid getter usage")));
    161161
    162162    PropertyDescriptor descriptor;
     
    178178    CallData callData;
    179179    if (getCallData(set, callData) == CallTypeNone)
    180         return throwVMError(exec, createSyntaxError(exec, "invalid setter usage"));
     180        return throwVMError(exec, createSyntaxError(exec, ASCIILiteral("invalid setter usage")));
    181181
    182182    PropertyDescriptor descriptor;
     
    248248    JSValue thisValue = exec->hostThisValue();
    249249    if (thisValue.isUndefinedOrNull())
    250         return JSValue::encode(jsNontrivialString(exec, thisValue.isUndefined() ? "[object Undefined]" : "[object Null]"));
     250        return JSValue::encode(jsNontrivialString(exec, String(thisValue.isUndefined() ? ASCIILiteral("[object Undefined]") : ASCIILiteral("[object Null]"))));
    251251    JSObject* thisObject = thisValue.toObject(exec);
    252252
  • trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp

    r127191 r127505  
    263263    if (arg0.inherits(&RegExpObject::s_info)) {
    264264        if (!arg1.isUndefined())
    265             return throwError(exec, createTypeError(exec, "Cannot supply flags when constructing one RegExp from another."));
     265            return throwError(exec, createTypeError(exec, ASCIILiteral("Cannot supply flags when constructing one RegExp from another.")));
    266266        // If called as a function, this just returns the first argument (see 15.10.3.1).
    267267        if (callAsConstructor) {
     
    282282            return 0;
    283283        if (flags == InvalidFlags)
    284             return throwError(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
     284            return throwError(exec, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
    285285    }
    286286
  • trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp

    r127191 r127505  
    131131{
    132132    if (throwException)
    133         throwTypeError(exec, message);
     133        throwTypeError(exec, ASCIILiteral(message));
    134134    return false;
    135135}
     
    192192    // that would match the same thing.
    193193    if (!length)
    194         return jsString(exec, "(?:)");
     194        return jsNontrivialString(exec, ASCIILiteral("(?:)"));
    195195
    196196    // early return for strings that don't contain a forwards slash and LineTerminator
     
    252252                result.append('r');
    253253            else if (ch == 0x2028)
    254                 result.append("u2028");
     254                result.appendLiteral("u2028");
    255255            else
    256                 result.append("u2029");
     256                result.appendLiteral("u2029");
    257257        } else
    258258            result.append(ch);
  • trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp

    r127191 r127505  
    107107    if (arg0.inherits(&RegExpObject::s_info)) {
    108108        if (!arg1.isUndefined())
    109             return throwVMError(exec, createTypeError(exec, "Cannot supply flags when constructing one RegExp from another."));
     109            return throwVMError(exec, createTypeError(exec, ASCIILiteral("Cannot supply flags when constructing one RegExp from another.")));
    110110        regExp = asRegExpObject(arg0)->regExp();
    111111    } else {
     
    120120                return JSValue::encode(jsUndefined());
    121121            if (flags == InvalidFlags)
    122                 return throwVMError(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
     122                return throwVMError(exec, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
    123123        }
    124124        regExp = RegExp::create(exec->globalData(), pattern, flags);
  • trunk/Source/JavaScriptCore/runtime/StringObject.cpp

    r127191 r127505  
    8686        if (!object->isExtensible()) {
    8787            if (throwException)
    88                 throwError(exec, createTypeError(exec, "Attempting to define property on object that is not extensible."));
     88                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
    8989            return false;
    9090        }
    9191        if (descriptor.configurablePresent() && descriptor.configurable()) {
    9292            if (throwException)
    93                 throwError(exec, createTypeError(exec, "Attempting to configurable attribute of unconfigurable property."));
     93                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
    9494            return false;
    9595        }
    9696        if (descriptor.enumerablePresent() && descriptor.enumerable()) {
    9797            if (throwException)
    98                 throwError(exec, createTypeError(exec, "Attempting to change enumerable attribute of unconfigurable property."));
     98                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
    9999            return false;
    100100        }
    101101        if (descriptor.isAccessorDescriptor()) {
    102102            if (throwException)
    103                 throwError(exec, createTypeError(exec, "Attempting to change access mechanism for an unconfigurable property."));
     103                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
    104104            return false;
    105105        }
    106106        if (descriptor.writablePresent() && descriptor.writable()) {
    107107            if (throwException)
    108                 throwError(exec, createTypeError(exec, "Attempting to change writable attribute of unconfigurable property."));
     108                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
    109109            return false;
    110110        }
     
    114114            return true;
    115115        if (throwException)
    116             throwError(exec, createTypeError(exec, "Attempting to change value of a readonly property."));
     116            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
    117117        return false;
    118118    }
  • trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp

    r127349 r127505  
    288288
    289289    if (!totalLength)
    290         return jsString(exec, "");
     290        return jsEmptyString(exec);
    291291
    292292    if (source.is8Bit()) {
     
    349349
    350350    if (!totalLength)
    351         return jsString(exec, "");
     351        return jsEmptyString(exec);
    352352
    353353    if (source.is8Bit() && allSeperators8Bit) {
Note: See TracChangeset for help on using the changeset viewer.