Changeset 42478 in webkit


Ignore:
Timestamp:
Apr 13, 2009 11:24:43 PM (15 years ago)
Author:
oliver@apple.com
Message:

BUG 25171: It should be possible to manually set the name of an anonymous function
<https://bugs.webkit.org/show_bug.cgi?id=25171>

Submitted by Francisco Tolmasky <francisco@280north.com>
Reviewed by Oliver Hunt.

This change adds the displayName property to functions, which when set overrides the
normal name when appearing in the console.

Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r42466 r42478  
     12009-04-13  Francisco Tolmasky  <francisco@280north.com>
     2
     3        Reviewed by Oliver Hunt.
     4       
     5        BUG 25171: It should be possible to manually set the name of an anonymous function
     6        <https://bugs.webkit.org/show_bug.cgi?id=25171>
     7
     8        This change adds the displayName property to functions, which when set overrides the
     9        normal name when appearing in the console.
     10
     11        * profiler/Profiler.cpp:
     12        (JSC::createCallIdentifierFromFunctionImp): Changed call to InternalFunction::name to InternalFunction::calculatedDisplayName
     13        * runtime/CommonIdentifiers.h: Added displayName common identifier.
     14        * runtime/InternalFunction.cpp:
     15        (JSC::InternalFunction::displayName): Access to user settable displayName property
     16        (JSC::InternalFunction::calculatedDisplayName): Returns displayName if it exists, if not then the natural name
     17
    1182009-04-13  Geoffrey Garen  <ggaren@apple.com>
    219
  • trunk/JavaScriptCore/profiler/Profiler.cpp

    r41407 r42478  
    149149CallIdentifier createCallIdentifierFromFunctionImp(JSGlobalData* globalData, JSFunction* function)
    150150{
    151     const UString& name = function->name(globalData);
     151    const UString& name = function->calculatedDisplayName(globalData);
    152152    return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->body()->sourceURL(), function->body()->lineNo());
    153153}
  • trunk/JavaScriptCore/runtime/CommonIdentifiers.h

    r38138 r42478  
    6464    macro(toString) \
    6565    macro(UTC) \
    66     macro(valueOf)
     66    macro(valueOf) \
     67    macro(displayName)
    6768
    6869namespace JSC {
  • trunk/JavaScriptCore/runtime/InternalFunction.cpp

    r38440 r42478  
    4949}
    5050
     51const UString& InternalFunction::displayName(JSGlobalData* globalData)
     52{
     53    JSValuePtr displayName = getDirect(globalData->propertyNames->displayName);
     54   
     55    if (displayName)
     56        return asString(displayName)->value();
     57   
     58    return UString::null();
     59}
     60
     61const UString& InternalFunction::calculatedDisplayName(JSGlobalData* globalData)
     62{
     63    const UString& explicitName = displayName(globalData);
     64   
     65    if (!explicitName.isEmpty())
     66        return explicitName;
     67   
     68    return name(globalData);
     69}
     70
    5171} // namespace JSC
  • trunk/JavaScriptCore/runtime/InternalFunction.h

    r39670 r42478  
    3838
    3939        const UString& name(JSGlobalData*);
     40        const UString& displayName(JSGlobalData*);
     41        const UString& calculatedDisplayName(JSGlobalData*);
    4042
    4143        static PassRefPtr<Structure> createStructure(JSValuePtr proto)
  • trunk/LayoutTests/ChangeLog

    r42467 r42478  
     12009-04-13  Francisco Tolmasky  <francisco@280north.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        BUG 25171: It should be possible to manually set the name of an anonymous function
     6        <https://bugs.webkit.org/show_bug.cgi?id=25171>
     7
     8        Added test cases for using displayName property on anonymous and named functions.
     9
     10        * fast/profiler/anonymous-functions-with-display-names-expected.txt: Added.
     11        * fast/profiler/anonymous-functions-with-display-names.html: Added.
     12        * fast/profiler/named-functions-with-display-names-expected.txt: Added.
     13        * fast/profiler/named-functions-with-display-names.html: Added.
     14
    1152009-04-13  Darin Adler  <darin@apple.com>
    216
Note: See TracChangeset for help on using the changeset viewer.