Ignore:
Timestamp:
Feb 1, 2012, 3:23:30 PM (13 years ago)
Author:
[email protected]
Message:

Add support for inferred function names
https://bugs.webkit.org/show_bug.cgi?id=77579

Reviewed by Gavin Barraclough.

Source/JavaScriptCore:

Add new "inferred" names to function expressions, getters, and setters.
This property is not exposed to JS, so is only visible in the debugger
and profiler.

(JSC::BytecodeGenerator::makeFunction):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::calculatedFunctionName):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createAssignResolve):
(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::makeAssignNode):

  • parser/Nodes.h:

(JSC::FunctionBodyNode::setInferredName):
(JSC::FunctionBodyNode::inferredName):
(FunctionBodyNode):

  • profiler/Profiler.cpp:

(JSC):
(JSC::Profiler::createCallIdentifier):
(JSC::createCallIdentifierFromFunctionImp):

  • runtime/Executable.cpp:

(JSC::FunctionExecutable::FunctionExecutable):
(JSC::FunctionExecutable::fromGlobalCode):

  • runtime/Executable.h:

(JSC::FunctionExecutable::create):
(JSC::FunctionExecutable::inferredName):
(FunctionExecutable):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::calculatedDisplayName):
(JSC):
(JSC::getCalculatedDisplayName):

  • runtime/JSFunction.h:

(JSC):

LayoutTests:

Update test case results.

  • fast/profiler/anonymous-event-handler-expected.txt:
  • fast/profiler/anonymous-function-called-from-different-contexts-expected.txt:
  • fast/profiler/anonymous-function-calls-built-in-functions-expected.txt:
  • fast/profiler/anonymous-function-calls-eval-expected.txt:
  • fast/profiler/built-in-function-calls-anonymous-expected.txt:
  • fast/profiler/inline-event-handler-expected.txt:
  • fast/profiler/many-calls-in-the-same-scope-expected.txt:
  • fast/profiler/multiple-and-different-scoped-anonymous-function-calls-expected.txt:
  • fast/profiler/multiple-and-different-scoped-function-calls-expected.txt:
  • fast/profiler/multiple-anonymous-functions-called-from-the-same-function-expected.txt:
  • fast/profiler/nested-anonymous-functon-expected.txt:
  • fast/profiler/start-and-stop-profiler-multiple-times-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r98887 r106504  
    250250    ExpressionNode* createAssignResolve(int lineNumber, const Identifier& ident, ExpressionNode* rhs, bool rhsHasAssignment, int start, int divot, int end)
    251251    {
     252        if (rhs->isFuncExprNode())
     253            static_cast<FuncExprNode*>(rhs)->body()->setInferredName(ident);
    252254        AssignResolveNode* node = new (m_globalData) AssignResolveNode(lineNumber, ident, rhs, rhsHasAssignment);
    253255        setExceptionLocation(node, start, divot, end);
     
    272274        ASSERT(name);
    273275        body->setLoc(bodyStartLine, bodyEndLine);
     276        body->setInferredName(*name);
    274277        return new (m_globalData) PropertyNode(m_globalData, *name, new (m_globalData) FuncExprNode(lineNumber, m_globalData->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBracePos, closeBracePos, bodyStartLine), params), type);
    275278    }
     
    281284    ArgumentListNode* createArgumentsList(int lineNumber, ArgumentListNode* args, ExpressionNode* arg) { return new (m_globalData) ArgumentListNode(lineNumber, args, arg); }
    282285
    283     template <bool> PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type) { return new (m_globalData) PropertyNode(m_globalData, *propertyName, node, type); }
     286    template <bool> PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type)
     287    {
     288        if (node->isFuncExprNode())
     289            static_cast<FuncExprNode*>(node)->body()->setInferredName(*propertyName);
     290        return new (m_globalData) PropertyNode(m_globalData, *propertyName, node, type);
     291    }
    284292    template <bool> PropertyNode* createProperty(JSGlobalData*, double propertyName, ExpressionNode* node, PropertyNode::Type type) { return new (m_globalData) PropertyNode(m_globalData, propertyName, node, type); }
    285293    PropertyListNode* createPropertyList(int lineNumber, PropertyNode* property) { return new (m_globalData) PropertyListNode(lineNumber, property); }
     
    904912        ResolveNode* resolve = static_cast<ResolveNode*>(loc);
    905913        if (op == OpEqual) {
     914            if (expr->isFuncExprNode())
     915                static_cast<FuncExprNode*>(expr)->body()->setInferredName(resolve->identifier());
    906916            AssignResolveNode* node = new (m_globalData) AssignResolveNode(lineNumber, resolve->identifier(), expr, exprHasAssignments);
    907917            setExceptionLocation(node, start, divot, end);
     
    920930    ASSERT(loc->isDotAccessorNode());
    921931    DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc);
    922     if (op == OpEqual)
     932    if (op == OpEqual) {
     933        if (expr->isFuncExprNode())
     934            static_cast<FuncExprNode*>(expr)->body()->setInferredName(dot->identifier());
    923935        return new (m_globalData) AssignDotNode(lineNumber, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot());
     936    }
    924937
    925938    ReadModifyDotNode* node = new (m_globalData) ReadModifyDotNode(lineNumber, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
Note: See TracChangeset for help on using the changeset viewer.