Changeset 52343 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Dec 18, 2009, 2:18:11 PM (15 years ago)
Author:
[email protected]
Message:

Changed Register constructors to assignment operators, to streamline
moving values into registers. (In theory, there's no difference between
the two, since the constructor should just inline away, but there seems
to be a big difference in the addled mind of the GCC optimizer.)

Reviewed by Cameron Zwarich and Gavin Barraclough.

In the interpreter, this is a 3.5% SunSpider speedup and a 1K-2K
reduction in stack usage per privateExecute stack frame.

  • interpreter/CallFrame.h:

(JSC::ExecState::setCalleeArguments):
(JSC::ExecState::setCallerFrame):
(JSC::ExecState::setScopeChain):
(JSC::ExecState::init):
(JSC::ExecState::setArgumentCount):
(JSC::ExecState::setCallee):
(JSC::ExecState::setCodeBlock): Added a little bit of casting so these
functions could use the new Register assignment operators.

  • interpreter/Register.h:

(JSC::Register::withInt):
(JSC::Register::Register):
(JSC::Register::operator=): Swapped in assignment operators for constructors.

Location:
trunk/JavaScriptCore/interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/CallFrame.h

    r51672 r52343  
    111111        Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); }
    112112
    113         void setCalleeArguments(JSValue arguments) { this[RegisterFile::OptionalCalleeArguments] = arguments; }
    114         void setCallerFrame(CallFrame* callerFrame) { this[RegisterFile::CallerFrame] = callerFrame; }
    115         void setScopeChain(ScopeChainNode* scopeChain) { this[RegisterFile::ScopeChain] = scopeChain; }
     113        void setCalleeArguments(JSValue arguments) { static_cast<Register*>(this)[RegisterFile::OptionalCalleeArguments] = arguments; }
     114        void setCallerFrame(CallFrame* callerFrame) { static_cast<Register*>(this)[RegisterFile::CallerFrame] = callerFrame; }
     115        void setScopeChain(ScopeChainNode* scopeChain) { static_cast<Register*>(this)[RegisterFile::ScopeChain] = scopeChain; }
    116116
    117117        ALWAYS_INLINE void init(CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain,
     
    123123            setScopeChain(scopeChain);
    124124            setCallerFrame(callerFrame);
    125             this[RegisterFile::ReturnPC] = vPC; // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
    126             this[RegisterFile::ReturnValueRegister] = Register::withInt(returnValueRegister);
     125            static_cast<Register*>(this)[RegisterFile::ReturnPC] = vPC; // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
     126            static_cast<Register*>(this)[RegisterFile::ReturnValueRegister] = Register::withInt(returnValueRegister);
    127127            setArgumentCount(argc); // original argument count (for the sake of the "arguments" object)
    128128            setCallee(function);
     
    141141
    142142    private:
    143         void setArgumentCount(int count) { this[RegisterFile::ArgumentCount] = Register::withInt(count); }
    144         void setCallee(JSFunction* callee) { this[RegisterFile::Callee] = callee; }
    145         void setCodeBlock(CodeBlock* codeBlock) { this[RegisterFile::CodeBlock] = codeBlock; }
     143        void setArgumentCount(int count) { static_cast<Register*>(this)[RegisterFile::ArgumentCount] = Register::withInt(count); }
     144        void setCallee(JSFunction* callee) { static_cast<Register*>(this)[RegisterFile::Callee] = callee; }
     145        void setCodeBlock(CodeBlock* codeBlock) { static_cast<Register*>(this)[RegisterFile::CodeBlock] = codeBlock; }
    146146
    147147        static const intptr_t HostCallFrameFlag = 1;
  • trunk/JavaScriptCore/interpreter/Register.h

    r51624 r52343  
    5252    public:
    5353        Register();
    54         Register(JSValue);
    55 
     54
     55        Register(const JSValue&);
     56        Register& operator=(const JSValue&);
    5657        JSValue jsValue() const;
    5758       
    58         Register(JSActivation*);
    59         Register(CallFrame*);
    60         Register(CodeBlock*);
    61         Register(JSFunction*);
    62         Register(JSPropertyNameIterator*);
    63         Register(ScopeChainNode*);
    64         Register(Instruction*);
     59        Register& operator=(JSActivation*);
     60        Register& operator=(CallFrame*);
     61        Register& operator=(CodeBlock*);
     62        Register& operator=(JSFunction*);
     63        Register& operator=(JSPropertyNameIterator*);
     64        Register& operator=(ScopeChainNode*);
     65        Register& operator=(Instruction*);
    6566
    6667        int32_t i() const;
     
    7677        static Register withInt(int32_t i)
    7778        {
    78             return Register(i);
     79            Register r;
     80            r.u.i = i;
     81            return r;
    7982        }
    8083
    8184    private:
    82         Register(int32_t);
    83 
    8485        union {
    8586            int32_t i;
     
    99100    {
    100101#ifndef NDEBUG
    101         u.value = JSValue::encode(JSValue());
     102        *this = JSValue();
    102103#endif
    103104    }
    104105
    105     ALWAYS_INLINE Register::Register(JSValue v)
     106    ALWAYS_INLINE Register::Register(const JSValue& v)
    106107    {
    107108#if ENABLE(JSC_ZOMBIES)
     
    111112    }
    112113
     114    ALWAYS_INLINE Register& Register::operator=(const JSValue& v)
     115    {
     116#if ENABLE(JSC_ZOMBIES)
     117        ASSERT(!v.isZombie());
     118#endif
     119        u.value = JSValue::encode(v);
     120        return *this;
     121    }
     122
    113123    ALWAYS_INLINE JSValue Register::jsValue() const
    114124    {
     
    118128    // Interpreter functions
    119129
    120     ALWAYS_INLINE Register::Register(JSActivation* activation)
     130    ALWAYS_INLINE Register& Register::operator=(JSActivation* activation)
    121131    {
    122132        u.activation = activation;
    123     }
    124 
    125     ALWAYS_INLINE Register::Register(CallFrame* callFrame)
     133        return *this;
     134    }
     135
     136    ALWAYS_INLINE Register& Register::operator=(CallFrame* callFrame)
    126137    {
    127138        u.callFrame = callFrame;
    128     }
    129 
    130     ALWAYS_INLINE Register::Register(CodeBlock* codeBlock)
     139        return *this;
     140    }
     141
     142    ALWAYS_INLINE Register& Register::operator=(CodeBlock* codeBlock)
    131143    {
    132144        u.codeBlock = codeBlock;
    133     }
    134 
    135     ALWAYS_INLINE Register::Register(JSFunction* function)
     145        return *this;
     146    }
     147
     148    ALWAYS_INLINE Register& Register::operator=(JSFunction* function)
    136149    {
    137150        u.function = function;
    138     }
    139 
    140     ALWAYS_INLINE Register::Register(Instruction* vPC)
     151        return *this;
     152    }
     153
     154    ALWAYS_INLINE Register& Register::operator=(Instruction* vPC)
    141155    {
    142156        u.vPC = vPC;
    143     }
    144 
    145     ALWAYS_INLINE Register::Register(ScopeChainNode* scopeChain)
     157        return *this;
     158    }
     159
     160    ALWAYS_INLINE Register& Register::operator=(ScopeChainNode* scopeChain)
    146161    {
    147162        u.scopeChain = scopeChain;
    148     }
    149 
    150     ALWAYS_INLINE Register::Register(JSPropertyNameIterator* propertyNameIterator)
     163        return *this;
     164    }
     165
     166    ALWAYS_INLINE Register& Register::operator=(JSPropertyNameIterator* propertyNameIterator)
    151167    {
    152168        u.propertyNameIterator = propertyNameIterator;
    153     }
    154 
    155     ALWAYS_INLINE Register::Register(int32_t i)
    156     {
    157         u.i = i;
     169        return *this;
    158170    }
    159171
Note: See TracChangeset for help on using the changeset viewer.