Ignore:
Timestamp:
Jul 13, 2010, 5:27:13 PM (15 years ago)
Author:
[email protected]
Message:

Bug 42207 - Clean up interface to compile executables, always check for exceptions

Reviewed by Oliver Hunt.

Presently interface to compile executable is inconsistent between eval/program and
function code, and is error prone in allowing a caller to byte compile without JIT
compiling an executable (we rely on all executables with codeblocks having JIT code).
Unify on an interface where all compilation is performed by a single compile (with
ForCall|ForConstruct variants) method, and make all clients check for errors.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::unwindCallFrame):
(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::privateExecute):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • parser/Parser.h:

(JSC::Parser::isFunctionBodyNode):
(JSC::Parser::parse):

  • runtime/ArrayPrototype.cpp:

(JSC::isNumericCompareFunction):

  • runtime/ExceptionHelpers.cpp:

(JSC::createStackOverflowError):

  • runtime/ExceptionHelpers.h:
  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::checkSyntax):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::compileForConstructInternal):
(JSC::FunctionExecutable::reparseExceptionInfo):
(JSC::EvalExecutable::reparseExceptionInfo):
(JSC::FunctionExecutable::fromGlobalCode):

  • runtime/Executable.h:

(JSC::EvalExecutable::compile):
(JSC::EvalExecutable::generatedBytecode):
(JSC::EvalExecutable::generatedJITCode):
(JSC::ProgramExecutable::compile):
(JSC::ProgramExecutable::generatedBytecode):
(JSC::ProgramExecutable::generatedJITCode):
(JSC::FunctionExecutable::generatedBytecode):
(JSC::FunctionExecutable::compileForCall):
(JSC::FunctionExecutable::compileForConstruct):
(JSC::FunctionExecutable::generatedJITCodeForConstructWithArityCheck):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

  • runtime/JSActivation.cpp:

(JSC::JSActivation::argumentsGetter):

  • runtime/JSGlobalData.h:

(JSC::JSGlobalData::canUseJIT):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/Parser.h

    r47902 r63267  
    2525
    2626#include "Debugger.h"
     27#include "ExceptionHelpers.h"
    2728#include "Executable.h"
    2829#include "JSGlobalObject.h"
     
    3940
    4041    class FunctionBodyNode;
     42   
    4143    class ProgramNode;
    4244    class UString;
     
    4749    public:
    4850        template <class ParsedNode>
    49         PassRefPtr<ParsedNode> parse(JSGlobalData* globalData, Debugger*, ExecState*, const SourceCode& source, int* errLine = 0, UString* errMsg = 0);
     51        PassRefPtr<ParsedNode> parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger*, ExecState*, const SourceCode& source, JSObject** exception);
    5052
    5153        void didFinishParsing(SourceElements*, ParserArenaData<DeclarationStacks::VarStack>*,
     
    5658    private:
    5759        void parse(JSGlobalData*, int* errLine, UString* errMsg);
     60
     61        // Used to determine type of error to report.
     62        bool isFunctionBodyNode(ScopeNode*) { return false; }
     63        bool isFunctionBodyNode(FunctionBodyNode*) { return true; }
    5864
    5965        ParserArena m_arena;
     
    6874
    6975    template <class ParsedNode>
    70     PassRefPtr<ParsedNode> Parser::parse(JSGlobalData* globalData, Debugger* debugger, ExecState* debuggerExecState, const SourceCode& source, int* errLine, UString* errMsg)
     76    PassRefPtr<ParsedNode> Parser::parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger* debugger, ExecState* debuggerExecState, const SourceCode& source, JSObject** exception)
    7177    {
     78        ASSERT(exception && !*exception);
     79        int errLine;
     80        UString errMsg;
     81
    7282        m_source = &source;
    7383        if (ParsedNode::scopeIsFunction)
    7484            globalData->lexer->setIsReparsing();
    75         parse(globalData, errLine, errMsg);
     85        parse(globalData, &errLine, &errMsg);
    7686
    7787        RefPtr<ParsedNode> result;
     
    8595            m_numConstants);
    8696            result->setLoc(m_source->firstLine(), m_lastLine);
     97        } else if (lexicalGlobalObject) {
     98            // We can never see a syntax error when reparsing a function, since we should have
     99            // reported the error when parsing the containing program or eval code. So if we're
     100            // parsing a function body node, we assume that what actually happened here is that
     101            // we ran out of stack while parsing. If we see an error while parsing eval or program
     102            // code we assume that it was a syntax error since running out of stack is much less
     103            // likely, and we are currently unable to distinguish between the two cases.
     104            if (isFunctionBodyNode(static_cast<ParsedNode*>(0)))
     105                *exception = createStackOverflowError(lexicalGlobalObject);
     106            else
     107                *exception = addErrorInfo(globalData, createSyntaxError(lexicalGlobalObject, errMsg), errLine, source);
    87108        }
    88109
     
    95116
    96117        if (debugger && !ParsedNode::scopeIsFunction)
    97             debugger->sourceParsed(debuggerExecState, source, *errLine, *errMsg);
     118            debugger->sourceParsed(debuggerExecState, source, errLine, errMsg);
    98119        return result.release();
    99120    }
Note: See TracChangeset for help on using the changeset viewer.