Ignore:
Timestamp:
Sep 11, 2012, 11:14:56 PM (13 years ago)
Author:
[email protected]
Message:

Don't allocate a backing store just for a function's name
https://bugs.webkit.org/show_bug.cgi?id=96468

Reviewed by Oliver Hunt.

Treat function.name like function.length etc., and use a custom getter.
This saves space in closures.

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::functionName):

  • debugger/DebuggerCallFrame.h:

(DebuggerCallFrame): Updated for interface change.

  • runtime/Executable.h:

(JSC::JSFunction::JSFunction): Do a little inlining.

  • runtime/JSFunction.cpp:

(JSC::JSFunction::finishCreation): Gone now. That's the point of the patch.

(JSC::JSFunction::name):
(JSC::JSFunction::displayName):
(JSC::JSFunction::nameGetter):
(JSC::JSFunction::getOwnPropertySlot):
(JSC::JSFunction::getOwnPropertyDescriptor):
(JSC::JSFunction::getOwnPropertyNames):
(JSC::JSFunction::put):
(JSC::JSFunction::deleteProperty):
(JSC::JSFunction::defineOwnProperty): Added custom accessors for .name
just like .length and others.

  • runtime/JSFunction.h:

(JSC::JSFunction::create):
(JSFunction): Updated for interface changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSFunction.h

    r127202 r128265  
    6060        static JSFunction* create(ExecState* exec, FunctionExecutable* executable, JSScope* scope)
    6161        {
    62             JSFunction* function = new (NotNull, allocateCell<JSFunction>(*exec->heap())) JSFunction(exec, executable, scope);
     62            JSGlobalData& globalData = exec->globalData();
     63            JSFunction* function = new (NotNull, allocateCell<JSFunction>(globalData.heap)) JSFunction(globalData, executable, scope);
    6364            ASSERT(function->structure()->globalObject());
    64             function->finishCreation(exec, executable, scope);
     65            function->finishCreation(globalData);
    6566            return function;
    6667        }
    6768       
    68         JS_EXPORT_PRIVATE const String& name(ExecState*);
    69         JS_EXPORT_PRIVATE const String displayName(ExecState*);
     69        JS_EXPORT_PRIVATE String name(ExecState*);
     70        JS_EXPORT_PRIVATE String displayName(ExecState*);
    7071        const String calculatedDisplayName(ExecState*);
    7172
     
    138139
    139140        JS_EXPORT_PRIVATE JSFunction(ExecState*, JSGlobalObject*, Structure*);
    140         JSFunction(ExecState*, FunctionExecutable*, JSScope*);
     141        JSFunction(JSGlobalData&, FunctionExecutable*, JSScope*);
    141142       
    142143        void finishCreation(ExecState*, NativeExecutable*, int length, const String& name);
    143         void finishCreation(ExecState*, FunctionExecutable*, JSScope*);
     144        using Base::finishCreation;
    144145
    145146        Structure* cacheInheritorID(ExecState*);
     
    164165        static JSValue callerGetter(ExecState*, JSValue, PropertyName);
    165166        static JSValue lengthGetter(ExecState*, JSValue, PropertyName);
     167        static JSValue nameGetter(ExecState*, JSValue, PropertyName);
    166168
    167169        WriteBarrier<ExecutableBase> m_executable;
Note: See TracChangeset for help on using the changeset viewer.