Changeset 37324 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 5, 2008, 11:00:58 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-05 Cameron Zwarich <[email protected]>

Reviewed by Oliver Hunt.

Bug 21364: Remove the branch in op_ret for OptionalCalleeActivation and OptionalCalleeArguments
<https://bugs.webkit.org/show_bug.cgi?id=21364>

Use information from the parser to detect whether an activation is
needed or 'arguments' is used, and emit explicit instructions to tear
them off before op_ret. This allows a branch to be removed from op_ret
and simplifies some other code. This does cause a small change in the
behaviour of 'f.arguments'; it is no longer live when 'arguments' is not
mentioned in the lexical scope of the function.

It should now be easy to remove the OptionaCalleeActivation slot in the
call frame, but this will be done in a later patch.

JavaScriptCore:

  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass):
  • VM/CodeBlock.cpp: (JSC::CodeBlock::dump):
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitReturn):
  • VM/CodeGenerator.h:
  • VM/Machine.cpp: (JSC::Machine::unwindCallFrame): (JSC::Machine::privateExecute): (JSC::Machine::retrieveArguments): (JSC::Machine::cti_op_create_arguments): (JSC::Machine::cti_op_tear_off_activation): (JSC::Machine::cti_op_tear_off_arguments):
  • VM/Machine.h:
  • VM/Opcode.h:
  • kjs/Arguments.cpp: (JSC::Arguments::mark):
  • kjs/Arguments.h: (JSC::Arguments::isTornOff): (JSC::Arguments::Arguments): (JSC::Arguments::copyRegisters): (JSC::JSActivation::copyRegisters):
  • kjs/JSActivation.cpp: (JSC::JSActivation::argumentsGetter):
  • kjs/JSActivation.h:

LayoutTests:

  • fast/js/function-dot-arguments-expected.txt:
  • fast/js/resources/function-dot-arguments.js:
Location:
trunk/JavaScriptCore/kjs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/Arguments.cpp

    r37268 r37324  
    6565    if (!d->callee->marked())
    6666        d->callee->mark();
    67 
    68     if (d->activation && !d->activation->marked())
    69         d->activation->mark();
    7067}
    7168
  • trunk/JavaScriptCore/kjs/Arguments.h

    r37268 r37324  
    3333
    3434    struct ArgumentsData : Noncopyable {
    35         JSActivation* activation;
    36 
    3735        unsigned numParameters;
    3836        ptrdiff_t firstParameterIndex;
     
    5553    public:
    5654        Arguments(ExecState*, Register* callFrame);
    57         Arguments(ExecState*, JSActivation*);
    5855        virtual ~Arguments();
    5956
     
    6562
    6663        void copyRegisters();
     64        bool isTornOff() const { return d->registerArray; }
    6765        void setRegisters(Register* registers) { d->registers = registers; }
    6866
     
    8280    };
    8381
    84     inline void Arguments::init(ExecState* exec, Register* callFrame)
     82    inline Arguments::Arguments(ExecState* exec, Register* callFrame)
     83        : JSObject(exec->lexicalGlobalObject()->argumentsStructure())
     84        , d(new ArgumentsData)
    8585    {
    8686        JSFunction* callee;
     
    116116    }
    117117
    118     inline Arguments::Arguments(ExecState* exec, Register* callFrame)
    119         : JSObject(exec->lexicalGlobalObject()->argumentsStructure())
    120         , d(new ArgumentsData)
    121     {
    122         d->activation = 0;
    123         init(exec, callFrame);
    124     }
    125 
    126     inline Arguments::Arguments(ExecState* exec, JSActivation* activation)
    127         : JSObject(exec->lexicalGlobalObject()->argumentsStructure())
    128         , d(new ArgumentsData)
    129     {
    130         ASSERT(activation);
    131         d->activation = activation;
    132         init(exec, &activation->registerAt(0));
    133     }
    134 
    135118    inline void Arguments::copyRegisters()
    136119    {
    137         ASSERT(!d->activation);
    138         ASSERT(!d->registerArray);
     120        ASSERT(!isTornOff());
    139121
    140122        if (!d->numParameters)
     
    151133
    152134    // This JSActivation function is defined here so it can get at Arguments::setRegisters.
    153     inline void JSActivation::copyRegisters(JSValue* arguments)
     135    inline void JSActivation::copyRegisters(Arguments* arguments)
    154136    {
    155137        ASSERT(!d()->registerArray);
     
    167149        Register* registerArray = copyRegisterArray(d()->registers - registerOffset, registerArraySize);
    168150        setRegisters(registerArray + registerOffset, registerArray);
    169         if (arguments) {
    170             ASSERT(arguments->isObject(&Arguments::info));
     151        if (arguments && !arguments->isTornOff())
    171152            static_cast<Arguments*>(arguments)->setRegisters(registerArray + registerOffset);
    172         }
    173153    }
    174154
  • trunk/JavaScriptCore/kjs/JSActivation.cpp

    r37285 r37324  
    156156    JSActivation* thisObj = static_cast<JSActivation*>(slot.slotBase());
    157157
    158     JSValue* arguments;
    159158    if (thisObj->d()->functionBody->usesArguments()) {
    160159        PropertySlot slot;
    161160        thisObj->symbolTableGet(exec->propertyNames().arguments, slot);
    162         arguments = slot.getValue(exec, exec->propertyNames().arguments);
    163     } else {
    164         arguments = thisObj->d()->registers[RegisterFile::OptionalCalleeArguments].getJSValue();
    165         if (!arguments) {
    166             arguments = new (exec) Arguments(exec, thisObj);
    167             thisObj->d()->registers[RegisterFile::OptionalCalleeArguments] = arguments;
    168         }
    169         ASSERT(arguments->isObject(&Arguments::info));
     161        return slot.getValue(exec, exec->propertyNames().arguments);
    170162    }
     163
     164    Arguments* arguments = static_cast<Arguments*>(thisObj->d()->registers[RegisterFile::OptionalCalleeArguments].getJSValue());
     165    if (!arguments) {
     166        arguments = new (exec) Arguments(exec, &thisObj->registerAt(0));
     167        arguments->copyRegisters();
     168        thisObj->d()->registers[RegisterFile::OptionalCalleeArguments] = arguments;
     169    }
     170    ASSERT(arguments->isObject(&Arguments::info));
    171171
    172172    return arguments;
  • trunk/JavaScriptCore/kjs/JSActivation.h

    r37285 r37324  
    6060        virtual JSObject* toThisObject(ExecState*) const;
    6161
    62         void copyRegisters(JSValue* arguments);
     62        void copyRegisters(Arguments* arguments);
    6363       
    6464        virtual const ClassInfo* classInfo() const { return &info; }
Note: See TracChangeset for help on using the changeset viewer.