Ignore:
Timestamp:
Feb 25, 2015, 2:29:26 PM (10 years ago)
Author:
[email protected]
Message:

Make ParserError immutable by design
https://bugs.webkit.org/show_bug.cgi?id=141955

Reviewed by Geoffrey Garen.

This patch enforce that no field of ParserError can
be modified after the constructor.

  • parser/ParserError.h:

Move the attributes to pack the integer + 2 bytes together.
This is irrelevant for memory impact, it is to remve a load-store
when copying by value.

Also move the attributes to be private.

(JSC::ParserError::isValid):
To client of the interface cared about the type of the error,
the only information needed was: is there an error.

(JSC::ParserError::ParserError):
(JSC::ParserError::syntaxErrorType):
(JSC::ParserError::token):
(JSC::ParserError::message):
(JSC::ParserError::line):
(JSC::ParserError::toErrorObject):

  • API/JSScriptRef.cpp:
  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::createBuiltinExecutable):

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::fromGlobalCode):
(JSC::UnlinkedFunctionExecutable::codeBlockFor):

  • bytecode/UnlinkedCodeBlock.h:
  • inspector/agents/InspectorRuntimeAgent.cpp:

(Inspector::InspectorRuntimeAgent::parse):

  • jsc.cpp:

(runInteractive):

  • parser/Parser.h:

(JSC::parse):

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/CodeCache.h:
  • runtime/Completion.h:
  • runtime/Executable.cpp:

(JSC::ProgramExecutable::checkSyntax):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::createProgramCodeBlock):
(JSC::JSGlobalObject::createEvalCodeBlock):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r180570 r180637  
    782782
    783783    if (hasDebugger())
    784         debugger()->sourceParsed(callFrame, executable->source().provider(), error.m_line, error.m_message);
    785 
    786     if (error.m_type != ParserError::ErrorNone) {
     784        debugger()->sourceParsed(callFrame, executable->source().provider(), error.line(), error.message());
     785
     786    if (error.isValid()) {
    787787        *exception = error.toErrorObject(this, executable->source());
    788         return 0;
     788        return nullptr;
    789789    }
    790790   
     
    801801
    802802    if (hasDebugger())
    803         debugger()->sourceParsed(callFrame, executable->source().provider(), error.m_line, error.m_message);
    804 
    805     if (error.m_type != ParserError::ErrorNone) {
     803        debugger()->sourceParsed(callFrame, executable->source().provider(), error.line(), error.message());
     804
     805    if (error.isValid()) {
    806806        throwVMError(callFrame, error.toErrorObject(this, executable->source()));
    807         return 0;
     807        return nullptr;
    808808    }
    809809
Note: See TracChangeset for help on using the changeset viewer.