Changeset 27072 in webkit for trunk/JavaScriptCore/kjs/function.h


Ignore:
Timestamp:
Oct 25, 2007, 3:29:55 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by Oliver Hunt.


Rolled out my last patch. It turns out that I needed 2 words, not 1,
so it didn't help.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/function.h

    r27068 r27072  
    144144  class ActivationImp : public JSObject {
    145145  public:
    146     class LazyArgumentsObject {
    147     public:
    148         LazyArgumentsObject(FunctionImp* f, const List& a)
    149             : arguments(a)
    150         {
    151             ASSERT(f);
    152             setFunction(f);
    153         }
    154 
    155         Arguments* getOrCreate(ExecState* exec, ActivationImp* activationImp)
    156         {
    157             if (!createdArgumentsObject())
    158                 createArgumentsObject(exec, activationImp);
    159             return argumentsObject();
    160         }
    161 
    162         void resetArguments() { arguments.reset(); }
    163         void mark();
    164 
    165     private:
    166         static const uintptr_t TagMask = 1; // Pointer alignment leaves this bit open for tagging.
    167        
    168         void setArgumentsObject(Arguments* a)
    169         {
    170             u.argumentsObject = a;
    171             u.bits |= TagMask;
    172         }
    173 
    174         Arguments* argumentsObject()
    175         {
    176             ASSERT(createdArgumentsObject());
    177             return reinterpret_cast<Arguments*>(u.bits & ~TagMask);
    178         }
    179 
    180         void setFunction(FunctionImp* f) { u.function = f; }
    181         FunctionImp* function()
    182         {
    183             ASSERT(!createdArgumentsObject());
    184             return u.function;
    185         }
    186 
    187         bool createdArgumentsObject() { return (u.bits & TagMask) != 0; }
    188         void createArgumentsObject(ExecState*, ActivationImp*);
    189 
    190         List arguments;
    191         union {
    192             // The low bit in this union is a flag: 0 means the union holds a
    193             // FunctionImp*; 1 means the union holds an Arguments*.
    194             uintptr_t bits;
    195             FunctionImp* function;
    196             Arguments* argumentsObject;
    197         } u;
    198     };
    199    
    200     ActivationImp::ActivationImp(FunctionImp* function, const List& arguments)
    201         : m_lazyArgumentsObject(function, arguments)
    202     {
    203     }
     146    ActivationImp(FunctionImp* function, const List& arguments);
    204147
    205148    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     
    214157    bool isActivation() { return true; }
    215158
    216     void resetArguments() { m_lazyArgumentsObject.resetArguments(); }
     159    void releaseArguments() { _arguments.reset(); }
    217160
    218161  private:
    219162    static PropertySlot::GetValueFunc getArgumentsGetter();
    220163    static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
    221    
    222     LazyArgumentsObject m_lazyArgumentsObject;
     164    void createArgumentsObject(ExecState*);
     165
     166    FunctionImp* _function;
     167    List _arguments;
     168    mutable Arguments* _argumentsObject;
    223169  };
    224170
Note: See TracChangeset for help on using the changeset viewer.