Changeset 201766 in webkit


Ignore:
Timestamp:
Jun 7, 2016 12:51:41 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

calculatedDisplayName() and friends actually need a VM& and not a ExecState/CallFrame.
https://bugs.webkit.org/show_bug.cgi?id=158488

Reviewed by Geoffrey Garen.

calculatedDisplayName() (and some of its friends) actually just need a VM&.
Their work has nothing to do with an ExecState at all. This patch will make that
clear by changing these functions to take a VM& arg instead of an ExecState* or
CallFrame*.

Also removed the JS_EXPORT_PRIVATE attribute from Interpreter::StackFrame::toString().
The JS_EXPORT_PRIVATE attribute was a holdover from the days when WebInspector
was entirely in WebCore. It is no longer needed.

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::functionName):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::functionDetails):

  • inspector/ScriptCallStackFactory.cpp:

(Inspector::createScriptCallStackFromException):

  • interpreter/CallFrame.cpp:

(JSC::CallFrame::friendlyFunctionName):

  • interpreter/Interpreter.cpp:

(JSC::StackFrame::friendlySourceURL):
(JSC::StackFrame::friendlyFunctionName):
(JSC::StackFrame::expressionInfo):
(JSC::StackFrame::toString):
(JSC::Interpreter::stackTraceAsString):

  • interpreter/Interpreter.h:
  • interpreter/StackVisitor.cpp:

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

  • runtime/InternalFunction.cpp:

(JSC::InternalFunction::name):
(JSC::InternalFunction::displayName):
(JSC::InternalFunction::getCallData):
(JSC::InternalFunction::calculatedDisplayName):

  • runtime/InternalFunction.h:

(JSC::InternalFunction::createStructure):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::name):
(JSC::JSFunction::displayName):
(JSC::JSFunction::calculatedDisplayName):
(JSC::JSFunction::getConstructData):
(JSC::getCalculatedDisplayName):

  • runtime/JSFunction.h:

(JSC::JSFunction::executable):

  • runtime/JSObject.cpp:

(JSC::JSObject::calculatedClassName):

Location:
trunk/Source/JavaScriptCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r201756 r201766  
     12016-06-07  Mark Lam  <mark.lam@apple.com>
     2
     3        calculatedDisplayName() and friends actually need a VM& and not a ExecState/CallFrame.
     4        https://bugs.webkit.org/show_bug.cgi?id=158488
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        calculatedDisplayName() (and some of its friends) actually just need a VM&.
     9        Their work has nothing to do with an ExecState at all.  This patch will make that
     10        clear by changing these functions to take a VM& arg instead of an ExecState* or
     11        CallFrame*.
     12
     13        Also removed the JS_EXPORT_PRIVATE attribute from Interpreter::StackFrame::toString().
     14        The JS_EXPORT_PRIVATE attribute was a holdover from the days when WebInspector
     15        was entirely in WebCore.  It is no longer needed.
     16
     17        * debugger/DebuggerCallFrame.cpp:
     18        (JSC::DebuggerCallFrame::functionName):
     19        * inspector/JSInjectedScriptHost.cpp:
     20        (Inspector::JSInjectedScriptHost::functionDetails):
     21        * inspector/ScriptCallStackFactory.cpp:
     22        (Inspector::createScriptCallStackFromException):
     23        * interpreter/CallFrame.cpp:
     24        (JSC::CallFrame::friendlyFunctionName):
     25        * interpreter/Interpreter.cpp:
     26        (JSC::StackFrame::friendlySourceURL):
     27        (JSC::StackFrame::friendlyFunctionName):
     28        (JSC::StackFrame::expressionInfo):
     29        (JSC::StackFrame::toString):
     30        (JSC::Interpreter::stackTraceAsString):
     31        * interpreter/Interpreter.h:
     32        * interpreter/StackVisitor.cpp:
     33        (JSC::StackVisitor::Frame::functionName):
     34        * runtime/InternalFunction.cpp:
     35        (JSC::InternalFunction::name):
     36        (JSC::InternalFunction::displayName):
     37        (JSC::InternalFunction::getCallData):
     38        (JSC::InternalFunction::calculatedDisplayName):
     39        * runtime/InternalFunction.h:
     40        (JSC::InternalFunction::createStructure):
     41        * runtime/JSFunction.cpp:
     42        (JSC::JSFunction::name):
     43        (JSC::JSFunction::displayName):
     44        (JSC::JSFunction::calculatedDisplayName):
     45        (JSC::JSFunction::getConstructData):
     46        (JSC::getCalculatedDisplayName):
     47        * runtime/JSFunction.h:
     48        (JSC::JSFunction::executable):
     49        * runtime/JSObject.cpp:
     50        (JSC::JSObject::calculatedClassName):
     51
    1522016-06-07  Yusuke Suzuki  <utatane.tea@gmail.com>
    253
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp

    r201473 r201766  
    139139    if (isTailDeleted()) {
    140140        if (JSFunction* func = jsDynamicCast<JSFunction*>(m_shadowChickenFrame.callee))
    141             return func->calculatedDisplayName(m_validMachineFrame);
     141            return func->calculatedDisplayName(m_validMachineFrame->vm());
    142142        return m_shadowChickenFrame.codeBlock->inferredName().data();
    143143    }
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r200746 r201766  
    221221        columnNumber -= 1;
    222222
     223    VM& vm = exec->vm();
    223224    String scriptID = String::number(sourceCode->provider()->asID());
    224225    JSObject* location = constructEmptyObject(exec);
    225     location->putDirect(exec->vm(), Identifier::fromString(exec, "scriptId"), jsString(exec, scriptID));
    226     location->putDirect(exec->vm(), Identifier::fromString(exec, "lineNumber"), jsNumber(lineNumber));
    227     location->putDirect(exec->vm(), Identifier::fromString(exec, "columnNumber"), jsNumber(columnNumber));
     226    location->putDirect(vm, Identifier::fromString(exec, "scriptId"), jsString(exec, scriptID));
     227    location->putDirect(vm, Identifier::fromString(exec, "lineNumber"), jsNumber(lineNumber));
     228    location->putDirect(vm, Identifier::fromString(exec, "columnNumber"), jsNumber(columnNumber));
    228229
    229230    JSObject* result = constructEmptyObject(exec);
    230     result->putDirect(exec->vm(), Identifier::fromString(exec, "location"), location);
     231    result->putDirect(vm, Identifier::fromString(exec, "location"), location);
    231232
    232233    String name = function->name();
    233234    if (!name.isEmpty())
    234         result->putDirect(exec->vm(), Identifier::fromString(exec, "name"), jsString(exec, name));
    235 
    236     String displayName = function->displayName(exec);
     235        result->putDirect(vm, Identifier::fromString(exec, "name"), jsString(exec, name));
     236
     237    String displayName = function->displayName(vm);
    237238    if (!displayName.isEmpty())
    238         result->putDirect(exec->vm(), Identifier::fromString(exec, "displayName"), jsString(exec, displayName));
     239        result->putDirect(vm, Identifier::fromString(exec, "displayName"), jsString(exec, displayName));
    239240
    240241    // FIXME: provide function scope data in "scopesRaw" property when JSC supports it.
  • trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp

    r199852 r201766  
    139139    Vector<ScriptCallFrame> frames;
    140140    RefCountedArray<StackFrame> stackTrace = exception->stack();
     141    VM& vm = exec->vm();
    141142    for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) {
    142143        unsigned line;
    143144        unsigned column;
    144145        stackTrace[i].computeLineAndColumn(line, column);
    145         String functionName = stackTrace[i].friendlyFunctionName(exec);
     146        String functionName = stackTrace[i].friendlyFunctionName(vm);
    146147        frames.append(ScriptCallFrame(functionName, stackTrace[i].friendlySourceURL(), static_cast<SourceID>(stackTrace[i].sourceID), line, column));
    147148    }
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r196658 r201766  
    230230    case FunctionCode:
    231231        if (callee())
    232             return getCalculatedDisplayName(this, callee());
     232            return getCalculatedDisplayName(vm(), callee());
    233233        return emptyString();
    234234    }
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r201703 r201766  
    107107}
    108108
    109 String StackFrame::friendlyFunctionName(CallFrame* callFrame) const
     109String StackFrame::friendlyFunctionName(VM& vm) const
    110110{
    111111    String traceLine;
     
    121121    case StackFrameNativeCode:
    122122        if (callee)
    123             traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl();
     123            traceLine = getCalculatedDisplayName(vm, stackFrameCallee).impl();
    124124        break;
    125125    case StackFrameFunctionCode:
    126         traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl();
     126        traceLine = getCalculatedDisplayName(vm, stackFrameCallee).impl();
    127127        break;
    128128    case StackFrameGlobalCode:
     
    497497}
    498498
    499 String StackFrame::toString(CallFrame* callFrame)
     499String StackFrame::toString(VM& vm)
    500500{
    501501    StringBuilder traceBuild;
    502     String functionName = friendlyFunctionName(callFrame);
     502    String functionName = friendlyFunctionName(vm);
    503503    String sourceURL = friendlySourceURL();
    504504    traceBuild.append(functionName);
     
    594594    // FIXME: JSStringJoiner could be more efficient than StringBuilder here.
    595595    StringBuilder builder;
     596    VM& vm = exec->vm();
    596597    for (unsigned i = 0; i < stackTrace.size(); i++) {
    597         builder.append(String(stackTrace[i].toString(exec)));
     598        builder.append(String(stackTrace[i].toString(vm)));
    598599        if (i != stackTrace.size() - 1)
    599600            builder.append('\n');
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.h

    r200879 r201766  
    9696        String sourceURL;
    9797        intptr_t sourceID;
    98         JS_EXPORT_PRIVATE String toString(CallFrame*);
     98        String toString(VM&);
    9999        String friendlySourceURL() const;
    100         String friendlyFunctionName(CallFrame*) const;
     100        String friendlyFunctionName(VM&) const;
    101101        JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column);
    102102
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r201641 r201766  
    224224    case CodeType::Native:
    225225        if (callee)
    226             traceLine = getCalculatedDisplayName(callFrame(), callee).impl();
     226            traceLine = getCalculatedDisplayName(callFrame()->vm(), callee).impl();
    227227        break;
    228228    case CodeType::Function:
    229         traceLine = getCalculatedDisplayName(callFrame(), callee).impl();
     229        traceLine = getCalculatedDisplayName(callFrame()->vm(), callee).impl();
    230230        break;
    231231    case CodeType::Global:
  • trunk/Source/JavaScriptCore/runtime/InternalFunction.cpp

    r201495 r201766  
    6666}
    6767
    68 const String InternalFunction::displayName(ExecState* exec)
     68const String InternalFunction::displayName(VM& vm)
    6969{
    70     JSValue displayName = getDirect(exec->vm(), exec->vm().propertyNames->displayName);
     70    JSValue displayName = getDirect(vm, vm.propertyNames->displayName);
    7171   
    7272    if (displayName && isJSString(displayName))
     
    8282}
    8383
    84 const String InternalFunction::calculatedDisplayName(ExecState* exec)
     84const String InternalFunction::calculatedDisplayName(VM& vm)
    8585{
    86     const String explicitName = displayName(exec);
     86    const String explicitName = displayName(vm);
    8787   
    8888    if (!explicitName.isEmpty())
  • trunk/Source/JavaScriptCore/runtime/InternalFunction.h

    r200430 r201766  
    4242
    4343    JS_EXPORT_PRIVATE const String& name();
    44     const String displayName(ExecState*);
    45     const String calculatedDisplayName(ExecState*);
     44    const String displayName(VM&);
     45    const String calculatedDisplayName(VM&);
    4646
    4747    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r201703 r201766  
    179179}
    180180
    181 String JSFunction::displayName(ExecState* exec)
    182 {
    183     JSValue displayName = getDirect(exec->vm(), exec->vm().propertyNames->displayName);
     181String JSFunction::displayName(VM& vm)
     182{
     183    JSValue displayName = getDirect(vm, vm.propertyNames->displayName);
    184184   
    185185    if (displayName && isJSString(displayName))
     
    189189}
    190190
    191 const String JSFunction::calculatedDisplayName(ExecState* exec)
    192 {
    193     const String explicitName = displayName(exec);
     191const String JSFunction::calculatedDisplayName(VM& vm)
     192{
     193    const String explicitName = displayName(vm);
    194194   
    195195    if (!explicitName.isEmpty())
     
    557557}
    558558
    559 String getCalculatedDisplayName(CallFrame* callFrame, JSObject* object)
     559String getCalculatedDisplayName(VM& vm, JSObject* object)
    560560{
    561561    if (JSFunction* function = jsDynamicCast<JSFunction*>(object))
    562         return function->calculatedDisplayName(callFrame);
     562        return function->calculatedDisplayName(vm);
    563563    if (InternalFunction* function = jsDynamicCast<InternalFunction*>(object))
    564         return function->calculatedDisplayName(callFrame);
     564        return function->calculatedDisplayName(vm);
    565565    return emptyString();
    566566}
  • trunk/Source/JavaScriptCore/runtime/JSFunction.h

    r201703 r201766  
    5050JS_EXPORT_PRIVATE EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState*);
    5151
    52 JS_EXPORT_PRIVATE String getCalculatedDisplayName(CallFrame*, JSObject*);
     52JS_EXPORT_PRIVATE String getCalculatedDisplayName(VM&, JSObject*);
    5353
    5454class JSFunction : public JSCallee {
     
    8383
    8484    JS_EXPORT_PRIVATE String name();
    85     JS_EXPORT_PRIVATE String displayName(ExecState*);
    86     const String calculatedDisplayName(ExecState*);
     85    JS_EXPORT_PRIVATE String displayName(VM&);
     86    const String calculatedDisplayName(VM&);
    8787
    8888    ExecutableBase* executable() const { return m_executable.get(); }
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r201654 r201766  
    320320                if (JSCell* constructorCell = constructorValue.asCell()) {
    321321                    if (JSObject* ctorObject = constructorCell->getObject()) {
     322                        VM& vm = exec->vm();
    322323                        if (JSFunction* constructorFunction = jsDynamicCast<JSFunction*>(ctorObject))
    323                             prototypeFunctionName = constructorFunction->calculatedDisplayName(exec);
     324                            prototypeFunctionName = constructorFunction->calculatedDisplayName(vm);
    324325                        else if (InternalFunction* constructorFunction = jsDynamicCast<InternalFunction*>(ctorObject))
    325                             prototypeFunctionName = constructorFunction->calculatedDisplayName(exec);
     326                            prototypeFunctionName = constructorFunction->calculatedDisplayName(vm);
    326327                    }
    327328                }
Note: See TracChangeset for help on using the changeset viewer.