Changeset 59811 in webkit


Ignore:
Timestamp:
May 19, 2010, 7:38:01 PM (15 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Bug 39393 - JSFunction need not be a subclass of InternalFunction.

Reviewed by Oliver Hunt.

re-landing r59800.

(JSC::Interpreter::retrieveCaller):
(JSC::Interpreter::findFunctionCallFrame):

  • interpreter/Interpreter.h:
  • profiler/Profiler.cpp:

(JSC::Profiler::createCallIdentifier):

  • runtime/FunctionPrototype.cpp:

(JSC::functionProtoFuncToString):

  • runtime/JSFunction.cpp:

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

  • runtime/JSFunction.h:
  • runtime/JSObject.cpp:

(JSC::JSObject::putDirectFunction):
(JSC::JSObject::putDirectFunctionWithoutTransition):

  • runtime/JSObject.h:
  • runtime/Lookup.cpp:

(JSC::setUpStaticFunctionSlot):

WebCore: Rubber Stamped by Sam Weinig.

JSFunctions are no longer a subclass of InternalFunction.

  • bindings/js/ScriptCallStack.cpp:

(WebCore::ScriptCallStack::ScriptCallStack):
(WebCore::ScriptCallStack::initialize):

  • bindings/js/ScriptCallStack.h:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r59801 r59811  
     12010-05-19  Gavin Barraclough  <[email protected]>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Bug 39393 - JSFunction need not be a subclass of InternalFunction.
     6
     7        re-landing r59800.
     8
     9        * JavaScriptCore.exp:
     10        * interpreter/Interpreter.cpp:
     11        (JSC::Interpreter::retrieveCaller):
     12        (JSC::Interpreter::findFunctionCallFrame):
     13        * interpreter/Interpreter.h:
     14        * profiler/Profiler.cpp:
     15        (JSC::Profiler::createCallIdentifier):
     16        * runtime/FunctionPrototype.cpp:
     17        (JSC::functionProtoFuncToString):
     18        * runtime/JSFunction.cpp:
     19        (JSC::):
     20        (JSC::JSFunction::JSFunction):
     21        (JSC::JSFunction::name):
     22        (JSC::JSFunction::displayName):
     23        (JSC::JSFunction::calculatedDisplayName):
     24        * runtime/JSFunction.h:
     25        * runtime/JSObject.cpp:
     26        (JSC::JSObject::putDirectFunction):
     27        (JSC::JSObject::putDirectFunctionWithoutTransition):
     28        * runtime/JSObject.h:
     29        * runtime/Lookup.cpp:
     30        (JSC::setUpStaticFunctionSlot):
     31
    1322010-05-19  Gavin Barraclough  <[email protected]>
    233
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r59801 r59811  
    110110__ZN3JSC10Identifier4fromEPNS_9ExecStateEj
    111111__ZN3JSC10Identifier5equalEPKN7WebCore10StringImplEPKc
     112__ZN3JSC10JSFunction4infoE
     113__ZN3JSC10JSFunction4nameEPNS_9ExecStateE
    112114__ZN3JSC10JSFunctionC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESA_RKNS_7ArgListEE
    113115__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
     
    265267__ZN3JSC8JSObject17createInheritorIDEv
    266268__ZN3JSC8JSObject17defineOwnPropertyEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
     269__ZN3JSC8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_10JSFunctionEj
    267270__ZN3JSC8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_16InternalFunctionEj
    268271__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
     
    453456__ZN7WebCoreplERKNS_6StringES2_
    454457__ZNK3JSC10JSFunction23isHostFunctionNonInlineEv
    455 __ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE
     458__ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_10JSFunctionE
    456459__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
    457460__ZNK3JSC12PropertySlot14functionGetterEPNS_9ExecStateE
  • trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r59526 r59811  
    246246    ?resolveRope@JSString@JSC@@ABEXPAVExecState@2@@Z
    247247    ?restoreAll@Profile@JSC@@QAEXXZ
    248     ?retrieveCaller@Interpreter@JSC@@QBE?AVJSValue@2@PAVExecState@2@PAVInternalFunction@2@@Z
    249248    ?retrieveLastCaller@Interpreter@JSC@@QBEXPAVExecState@2@AAH1AAVUString@2@AAVJSValue@2@@Z
    250249    ?setAccessorDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@0I@Z
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r59801 r59811  
    44254425}
    44264426
    4427 JSValue Interpreter::retrieveCaller(CallFrame* callFrame, InternalFunction* function) const
     4427JSValue Interpreter::retrieveCaller(CallFrame* callFrame, JSFunction* function) const
    44284428{
    44294429    CallFrame* functionCallFrame = findFunctionCallFrame(callFrame, function);
     
    44634463}
    44644464
    4465 CallFrame* Interpreter::findFunctionCallFrame(CallFrame* callFrame, InternalFunction* function)
     4465CallFrame* Interpreter::findFunctionCallFrame(CallFrame* callFrame, JSFunction* function)
    44664466{
    44674467    for (CallFrame* candidate = callFrame; candidate; candidate = candidate->callerFrame()->removeHostCallFrameFlag()) {
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r59801 r59811  
    4545    class EvalExecutable;
    4646    class FunctionExecutable;
    47     class InternalFunction;
    4847    class JSFunction;
    4948    class JSGlobalObject;
     
    102101
    103102        JSValue retrieveArguments(CallFrame*, JSFunction*) const;
    104         JSValue retrieveCaller(CallFrame*, InternalFunction*) const;
     103        JSValue retrieveCaller(CallFrame*, JSFunction*) const;
    105104        void retrieveLastCaller(CallFrame*, int& lineNumber, intptr_t& sourceID, UString& sourceURL, JSValue& function) const;
    106105       
     
    144143        static ALWAYS_INLINE CallFrame* slideRegisterWindowForCall(CodeBlock*, RegisterFile*, CallFrame*, size_t registerOffset, int argc);
    145144
    146         static CallFrame* findFunctionCallFrame(CallFrame*, InternalFunction*);
     145        static CallFrame* findFunctionCallFrame(CallFrame*, JSFunction*);
    147146
    148147        JSValue privateExecute(ExecutionFlag, RegisterFile*, CallFrame*, JSValue* exception);
  • trunk/JavaScriptCore/profiler/Profiler.cpp

    r59801 r59811  
    3333#include "CallFrame.h"
    3434#include "CodeBlock.h"
     35#include "InternalFunction.h"
    3536#include "JSFunction.h"
    3637#include "JSGlobalObject.h"
     
    147148            return createCallIdentifierFromFunctionImp(exec, function);
    148149    }
     150    if (asObject(functionValue)->inherits(&JSFunction::info))
     151        return CallIdentifier(static_cast<JSFunction*>(asObject(functionValue))->name(exec), defaultSourceURL, defaultLineNumber);
    149152    if (asObject(functionValue)->inherits(&InternalFunction::info))
    150153        return CallIdentifier(static_cast<InternalFunction*>(asObject(functionValue))->name(exec), defaultSourceURL, defaultLineNumber);
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r59801 r59811  
    8888    if (thisValue.inherits(&JSFunction::info)) {
    8989        JSFunction* function = asFunction(thisValue);
    90         if (!function->isHostFunction()) {
    91             FunctionExecutable* executable = function->jsExecutable();
    92             UString sourceString = executable->source().toString();
    93             insertSemicolonIfNeeded(sourceString);
    94             return jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString);
    95         }
     90        if (function->isHostFunction())
     91            return jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n    [native code]\n}");
     92        FunctionExecutable* executable = function->jsExecutable();
     93        UString sourceString = executable->source().toString();
     94        insertSemicolonIfNeeded(sourceString);
     95        return jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString);
    9696    }
    9797
  • trunk/JavaScriptCore/runtime/JSFunction.cpp

    r59801 r59811  
    4444ASSERT_CLASS_FITS_IN_CELL(JSFunction);
    4545
    46 const ClassInfo JSFunction::info = { "Function", &InternalFunction::info, 0, 0 };
     46const ClassInfo JSFunction::info = { "Function", 0, 0, 0 };
    4747
    4848bool JSFunction::isHostFunctionNonInline() const
     
    5959
    6060JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, PassRefPtr<NativeExecutable> thunk)
    61     : Base(&exec->globalData(), structure, name)
     61    : Base(structure)
    6262#if ENABLE(JIT)
    6363    , m_executable(thunk)
     
    6565    , m_scopeChain(NoScopeChain())
    6666{
     67    putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
    6768#if ENABLE(JIT)
    6869    putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
     
    7576
    7677JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, NativeFunction func)
    77     : Base(&exec->globalData(), structure, name)
     78    : Base(structure)
    7879#if ENABLE(JIT)
    7980    , m_executable(exec->globalData().getHostFunction(func))
     
    8182    , m_scopeChain(NoScopeChain())
    8283{
     84    putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
    8385#if ENABLE(JIT)
    8486    putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
     
    9193
    9294JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<FunctionExecutable> executable, ScopeChainNode* scopeChainNode)
    93     : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), executable->name())
     95    : Base(exec->lexicalGlobalObject()->functionStructure())
    9496    , m_executable(executable)
    9597    , m_scopeChain(scopeChainNode)
    9698{
     99    const Identifier& name = static_cast<FunctionExecutable*>(m_executable.get())->name();
     100    putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
    97101}
    98102
     
    115119}
    116120
     121const UString& JSFunction::name(ExecState* exec)
     122{
     123    return asString(getDirect(exec->globalData().propertyNames->name))->value(exec);
     124}
     125
     126const UString JSFunction::displayName(ExecState* exec)
     127{
     128    JSValue displayName = getDirect(exec->globalData().propertyNames->displayName);
     129   
     130    if (displayName && isJSString(&exec->globalData(), displayName))
     131        return asString(displayName)->value(exec);
     132   
     133    return UString::null();
     134}
     135
     136const UString JSFunction::calculatedDisplayName(ExecState* exec)
     137{
     138    const UString explicitName = displayName(exec);
     139   
     140    if (!explicitName.isEmpty())
     141        return explicitName;
     142   
     143    return name(exec);
     144}
     145
    117146void JSFunction::markChildren(MarkStack& markStack)
    118147{
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r59801 r59811  
    2525#define JSFunction_h
    2626
    27 #include "InternalFunction.h"
     27#include "JSObject.h"
    2828
    2929namespace JSC {
     
    3636    class NativeExecutable;
    3737
    38     class JSFunction : public InternalFunction {
     38    class JSFunction : public JSObject {
    3939        friend class JIT;
    4040        friend class JSGlobalData;
    4141
    42         typedef InternalFunction Base;
     42        typedef JSObject Base;
    4343
    4444    public:
     
    5050        JSObject* construct(ExecState*, const ArgList&);
    5151        JSValue call(ExecState*, JSValue thisValue, const ArgList&);
     52
     53        const UString& name(ExecState*);
     54        const UString displayName(ExecState*);
     55        const UString calculatedDisplayName(ExecState*);
    5256
    5357        ScopeChain& scope()
     
    8185
    8286    protected:
    83         const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesMarkChildren | OverridesGetPropertyNames | InternalFunction::StructureFlags;
     87        const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesMarkChildren | OverridesGetPropertyNames | JSObject::StructureFlags;
    8488
    8589    private:
  • trunk/JavaScriptCore/runtime/JSObject.cpp

    r59801 r59811  
    2828#include "ErrorConstructor.h"
    2929#include "GetterSetter.h"
     30#include "JSFunction.h"
    3031#include "JSGlobalObject.h"
    3132#include "NativeErrorConstructor.h"
     
    510511}
    511512
     513void JSObject::putDirectFunction(ExecState* exec, JSFunction* function, unsigned attr)
     514{
     515    putDirectFunction(Identifier(exec, function->name(exec)), function, attr);
     516}
     517
    512518void JSObject::putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr)
     519{
     520    putDirectFunctionWithoutTransition(Identifier(exec, function->name(exec)), function, attr);
     521}
     522
     523void JSObject::putDirectFunctionWithoutTransition(ExecState* exec, JSFunction* function, unsigned attr)
    513524{
    514525    putDirectFunctionWithoutTransition(Identifier(exec, function->name(exec)), function, attr);
  • trunk/JavaScriptCore/runtime/JSObject.h

    r59801 r59811  
    177177        void putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot);
    178178        void putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr = 0);
     179        void putDirectFunction(ExecState* exec, JSFunction* function, unsigned attr = 0);
    179180
    180181        void putDirectWithoutTransition(const Identifier& propertyName, JSValue value, unsigned attr = 0);
    181182        void putDirectFunctionWithoutTransition(const Identifier& propertyName, JSCell* value, unsigned attr = 0);
    182183        void putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr = 0);
     184        void putDirectFunctionWithoutTransition(ExecState* exec, JSFunction* function, unsigned attr = 0);
    183185
    184186        // Fast access to known property offsets.
  • trunk/JavaScriptCore/runtime/Lookup.cpp

    r59801 r59811  
    7676
    7777    if (!location) {
    78         InternalFunction* function;
     78        NativeFunctionWrapper* function;
    7979#if ENABLE(JIT)
    8080        if (entry->generator())
  • trunk/WebCore/ChangeLog

    r59797 r59811  
     12010-05-19  Gavin Barraclough  <[email protected]>
     2
     3        Rubber Stamped by Sam Weinig.
     4
     5        JSFunctions are no longer a subclass of InternalFunction.
     6
     7        * bindings/js/ScriptCallStack.cpp:
     8        (WebCore::ScriptCallStack::ScriptCallStack):
     9        (WebCore::ScriptCallStack::initialize):
     10        * bindings/js/ScriptCallStack.h:
     11
    1122010-05-19  Jian Li  <[email protected]>
    213
  • trunk/WebCore/bindings/js/ScriptCallStack.cpp

    r57231 r59811  
    3434#include <interpreter/CallFrame.h>
    3535#include <interpreter/Interpreter.h>
    36 #include <runtime/InternalFunction.h>
     36#include <runtime/JSFunction.h>
    3737#include <runtime/JSValue.h>
    3838#include <runtime/UString.h>
     
    5858
    5959    if (function) {
    60         m_caller = asInternalFunction(function);
     60        m_caller = asFunction(function);
    6161        m_frames.append(ScriptCallFrame(m_caller->name(m_exec), urlString, lineNumber, args, skipArgumentCount));
    6262    } else {
     
    9494    JSValue func = m_exec->interpreter()->retrieveCaller(m_exec, m_caller);
    9595    while (!func.isNull()) {
    96         InternalFunction* internalFunction = asInternalFunction(func);
     96        JSFunction* jsFunction = asFunction(func);
    9797        ArgList emptyArgList;
    98         m_frames.append(ScriptCallFrame(internalFunction->name(m_exec), UString(), 0, emptyArgList, 0));
    99         func = m_exec->interpreter()->retrieveCaller(m_exec, internalFunction);
     98        m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), UString(), 0, emptyArgList, 0));
     99        func = m_exec->interpreter()->retrieveCaller(m_exec, jsFunction);
    100100    }
    101101    m_initialized = true;
  • trunk/WebCore/bindings/js/ScriptCallStack.h

    r57231 r59811  
    6262        JSC::ExecState* m_exec;
    6363        Vector<ScriptCallFrame> m_frames;
    64         JSC::InternalFunction* m_caller;
     64        JSC::JSFunction* m_caller;
    6565    };
    6666
Note: See TracChangeset for help on using the changeset viewer.