Changeset 173120 in webkit for trunk/Source/JavaScriptCore/parser


Ignore:
Timestamp:
Aug 29, 2014, 2:33:30 PM (11 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Use ASCIILiteral where possible
https://bugs.webkit.org/show_bug.cgi?id=136179

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2014-08-29
Reviewed by Michael Saboff.

Source/JavaScriptCore:

General string / character related changes. Use ASCIILiteral where
possible, jsNontrivialString where possible, and replace string
literals with character literals in some places.

No new tests, no changes to functionality.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::nameForRegister):

  • bytecompiler/NodesCodegen.cpp:

(JSC::PostfixNode::emitBytecode):
(JSC::PrefixNode::emitBytecode):
(JSC::AssignErrorNode::emitBytecode):
(JSC::ForInNode::emitMultiLoopBytecode):
(JSC::ForOfNode::emitBytecode):
(JSC::ObjectPatternNode::toString):

  • dfg/DFGFunctionWhitelist.cpp:

(JSC::DFG::FunctionWhitelist::contains):

  • dfg/DFGOperations.cpp:

(JSC::DFG::newTypedArrayWithSize):
(JSC::DFG::newTypedArrayWithOneArgument):

  • inspector/ConsoleMessage.cpp:

(Inspector::ConsoleMessage::addToFrontend):

  • inspector/InspectorBackendDispatcher.cpp:

(Inspector::InspectorBackendDispatcher::dispatch):

  • inspector/ScriptCallStackFactory.cpp:

(Inspector::extractSourceInformationFromException):

  • inspector/scripts/codegen/generator_templates.py:
  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::Frame::functionName):
(JSC::StackVisitor::Frame::sourceURL):

  • jit/JITOperations.cpp:
  • jsc.cpp:

(functionDescribeArray):
(functionRun):
(functionLoad):
(functionReadFile):
(functionCheckSyntax):
(functionTransferArrayBuffer):
(runWithScripts):
(runInteractive):

  • parser/Lexer.cpp:

(JSC::Lexer<T>::invalidCharacterMessage):
(JSC::Lexer<T>::parseString):
(JSC::Lexer<T>::parseStringSlowCase):
(JSC::Lexer<T>::lex):

  • profiler/Profile.cpp:

(JSC::Profile::Profile):

  • runtime/Arguments.cpp:

(JSC::argumentsFuncIterator):

  • runtime/ArrayPrototype.cpp:

(JSC::performSlowSort):
(JSC::arrayProtoFuncSort):

  • runtime/ExceptionHelpers.cpp:

(JSC::createError):
(JSC::createInvalidParameterError):
(JSC::createNotAConstructorError):
(JSC::createNotAFunctionError):
(JSC::createNotAnObjectError):
(JSC::createErrorForInvalidGlobalAssignment):

  • runtime/FunctionPrototype.cpp:

(JSC::insertSemicolonIfNeeded):

  • runtime/JSArray.cpp:

(JSC::JSArray::defineOwnProperty):
(JSC::JSArray::pop):
(JSC::JSArray::push):

  • runtime/JSArrayBufferConstructor.cpp:

(JSC::JSArrayBufferConstructor::finishCreation):

  • runtime/JSArrayBufferPrototype.cpp:

(JSC::arrayBufferProtoFuncSlice):

  • runtime/JSDataView.cpp:

(JSC::JSDataView::create):

  • runtime/JSDataViewPrototype.cpp:

(JSC::getData):
(JSC::setData):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncProtoSetter):

  • runtime/JSPromiseConstructor.cpp:

(JSC::JSPromiseConstructor::finishCreation):

  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::Lexer::lex):
(JSC::LiteralParser<CharType>::Lexer::lexString):
(JSC::LiteralParser<CharType>::parse):

  • runtime/LiteralParser.h:

(JSC::LiteralParser::getErrorMessage):

  • runtime/TypeSet.cpp:

(JSC::TypeSet::seenTypes):
(JSC::TypeSet::displayName):
(JSC::TypeSet::allPrimitiveTypeNames):
(JSC::StructureShape::propertyHash):
(JSC::StructureShape::stringRepresentation):

Source/WTF:

  • wtf/text/WTFString.cpp:

(asciiDebug):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r172380 r173120  
    507507    switch (m_current) {
    508508    case 0:
    509         return "Invalid character: '\\0'";
     509        return ASCIILiteral("Invalid character: '\\0'");
    510510    case 10:
    511         return "Invalid character: '\\n'";
     511        return ASCIILiteral("Invalid character: '\\n'");
    512512    case 11:
    513         return "Invalid character: '\\v'";
     513        return ASCIILiteral("Invalid character: '\\v'");
    514514    case 13:
    515         return "Invalid character: '\\r'";
     515        return ASCIILiteral("Invalid character: '\\r'");
    516516    case 35:
    517         return "Invalid character: '#'";
     517        return ASCIILiteral("Invalid character: '#'");
    518518    case 64:
    519         return "Invalid character: '@'";
     519        return ASCIILiteral("Invalid character: '@'");
    520520    case 96:
    521         return "Invalid character: '`'";
     521        return ASCIILiteral("Invalid character: '`'");
    522522    default:
    523         return String::format("Invalid character '\\u%04u'", static_cast<unsigned>(m_current)).impl();
     523        return String::format("Invalid character '\\u%04u'", static_cast<unsigned>(m_current));
    524524    }
    525525}
     
    10271027                shift();
    10281028                if (!isASCIIHexDigit(m_current) || !isASCIIHexDigit(peek(1))) {
    1029                     m_lexErrorMessage = "\\x can only be followed by a hex character sequence";
     1029                    m_lexErrorMessage = ASCIILiteral("\\x can only be followed by a hex character sequence");
    10301030                    return (atEnd() || (isASCIIHexDigit(m_current) && (m_code + 1 == m_codeEnd))) ? StringUnterminated : StringCannotBeParsed;
    10311031                }
     
    10921092                shift();
    10931093                if (!isASCIIHexDigit(m_current) || !isASCIIHexDigit(peek(1))) {
    1094                     m_lexErrorMessage = "\\x can only be followed by a hex character sequence";
     1094                    m_lexErrorMessage = ASCIILiteral("\\x can only be followed by a hex character sequence");
    10951095                    return StringCannotBeParsed;
    10961096                }
     
    11101110                        record16('u');
    11111111                } else {
    1112                     m_lexErrorMessage = "\\u can only be followed by a Unicode character sequence";
     1112                    m_lexErrorMessage = ASCIILiteral("\\u can only be followed by a Unicode character sequence");
    11131113                    return character.valueType() == UnicodeHexValue::IncompleteHex ? StringUnterminated : StringCannotBeParsed;
    11141114                }
     
    11181118                shift();
    11191119                if (character1 != '0' || isASCIIDigit(m_current)) {
    1120                     m_lexErrorMessage = "The only valid numeric escape in strict mode is '\\0'";
     1120                    m_lexErrorMessage = ASCIILiteral("The only valid numeric escape in strict mode is '\\0'");
    11211121                    return StringCannotBeParsed;
    11221122                }
     
    11481148                shift();
    11491149            } else {
    1150                 m_lexErrorMessage = "Unterminated string constant";
     1150                m_lexErrorMessage = ASCIILiteral("Unterminated string constant");
    11511151                return StringUnterminated;
    11521152            }
     
    11611161            // New-line or end of input is not allowed
    11621162            if (atEnd() || isLineTerminator(m_current)) {
    1163                 m_lexErrorMessage = "Unexpected EOF";
     1163                m_lexErrorMessage = ASCIILiteral("Unexpected EOF");
    11641164                return atEnd() ? StringUnterminated : StringCannotBeParsed;
    11651165            }
     
    15231523            if (parseMultilineComment())
    15241524                goto start;
    1525             m_lexErrorMessage = "Multiline comment was not closed properly";
     1525            m_lexErrorMessage = ASCIILiteral("Multiline comment was not closed properly");
    15261526            token = UNTERMINATED_MULTILINE_COMMENT_ERRORTOK;
    15271527            goto returnError;
     
    16491649        if ((m_current | 0x20) == 'x') {
    16501650            if (!isASCIIHexDigit(peek(1))) {
    1651                 m_lexErrorMessage = "No hexadecimal digits after '0x'";
     1651                m_lexErrorMessage = ASCIILiteral("No hexadecimal digits after '0x'");
    16521652                token = INVALID_HEX_NUMBER_ERRORTOK;
    16531653                goto returnError;
     
    16551655            parseHex(tokenData->doubleValue);
    16561656            if (isIdentStart(m_current)) {
    1657                 m_lexErrorMessage = "No space between hexadecimal literal and identifier";
     1657                m_lexErrorMessage = ASCIILiteral("No space between hexadecimal literal and identifier");
    16581658                token = INVALID_HEX_NUMBER_ERRORTOK;
    16591659                goto returnError;
     
    16661666        record8('0');
    16671667        if (strictMode && isASCIIDigit(m_current)) {
    1668             m_lexErrorMessage = "Decimal integer literals with a leading zero are forbidden in strict mode";
     1668            m_lexErrorMessage = ASCIILiteral("Decimal integer literals with a leading zero are forbidden in strict mode");
    16691669            token = INVALID_OCTAL_NUMBER_ERRORTOK;
    16701670            goto returnError;
     
    16861686                if ((m_current | 0x20) == 'e') {
    16871687                    if (!parseNumberAfterExponentIndicator()) {
    1688                         m_lexErrorMessage = "Non-number found after exponent indicator";
     1688                        m_lexErrorMessage = ASCIILiteral("Non-number found after exponent indicator");
    16891689                        token = atEnd() ? UNTERMINATED_NUMERIC_LITERAL_ERRORTOK : INVALID_NUMERIC_LITERAL_ERRORTOK;
    16901690                        goto returnError;
     
    16991699        // No identifiers allowed directly after numeric literal, e.g. "3in" is bad.
    17001700        if (UNLIKELY(isIdentStart(m_current))) {
    1701             m_lexErrorMessage = "At least one digit must occur after a decimal point";
     1701            m_lexErrorMessage = ASCIILiteral("At least one digit must occur after a decimal point");
    17021702            token = atEnd() ? UNTERMINATED_NUMERIC_LITERAL_ERRORTOK : INVALID_NUMERIC_LITERAL_ERRORTOK;
    17031703            goto returnError;
     
    17501750    default:
    17511751        RELEASE_ASSERT_NOT_REACHED();
    1752         m_lexErrorMessage = "Internal Error";
     1752        m_lexErrorMessage = ASCIILiteral("Internal Error");
    17531753        token = ERRORTOK;
    17541754        goto returnError;
Note: See TracChangeset for help on using the changeset viewer.