Changeset 95205 in webkit


Ignore:
Timestamp:
Sep 15, 2011 11:47:20 AM (13 years ago)
Author:
barraclough@apple.com
Message:

devirtualize preventExtensions
https://bugs.webkit.org/show_bug.cgi?id=68176

Reviewed by Oliver Hunt.

This is virtual due to problems in JSFunction putting the prototype
property, but we can fix this problem a different way, just setting
the checkReadOnly flag to false in the put.

  • runtime/JSFunction.cpp:

(JSC::JSFunction::getOwnPropertySlot):

  • runtime/JSFunction.h:
  • runtime/JSObject.h:
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95201 r95205  
     12011-09-15  Gavin Barraclough  <barraclough@apple.com>
     2
     3        devirtualize preventExtensions
     4        https://bugs.webkit.org/show_bug.cgi?id=68176
     5
     6        Reviewed by Oliver Hunt.
     7
     8        This is virtual due to problems in JSFunction putting the prototype
     9        property, but we can fix this problem a different way, just setting
     10        the checkReadOnly flag to false in the put.
     11
     12        * runtime/JSFunction.cpp:
     13        (JSC::JSFunction::getOwnPropertySlot):
     14        * runtime/JSFunction.h:
     15        * runtime/JSObject.h:
     16
    1172011-09-15  Geoffrey Garen  <ggaren@apple.com>
    218
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r94701 r95205  
    176176}
    177177
    178 static inline WriteBarrierBase<Unknown>* createPrototypeProperty(JSGlobalData& globalData, JSGlobalObject* globalObject, JSFunction* function)
    179 {
    180     ASSERT(!function->isHostFunction());
    181 
    182     ExecState* exec = globalObject->globalExec();
    183     if (WriteBarrierBase<Unknown>* location = function->getDirectLocation(globalData, exec->propertyNames().prototype))
    184         return location;
    185     JSObject* prototype = constructEmptyObject(exec, globalObject->emptyObjectStructure());
    186     prototype->putDirect(globalData, exec->propertyNames().constructor, function, DontEnum);
    187     function->putDirect(globalData, exec->propertyNames().prototype, prototype, DontDelete | DontEnum);
    188     return function->getDirectLocation(exec->globalData(), exec->propertyNames().prototype);
    189 }
    190 
    191 void JSFunction::preventExtensions(JSGlobalData& globalData)
    192 {
    193     if (!isHostFunction())
    194         createPrototypeProperty(globalData, scope()->globalObject.get(), this);
    195     JSObject::preventExtensions(globalData);
    196 }
    197 
    198178bool JSFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    199179{
     
    204184        WriteBarrierBase<Unknown>* location = getDirectLocation(exec->globalData(), propertyName);
    205185
    206         if (!location)
    207             location = createPrototypeProperty(exec->globalData(), scope()->globalObject.get(), this);
     186        if (!location) {
     187            JSObject* prototype = constructEmptyObject(exec, globalObject()->emptyObjectStructure());
     188            prototype->putDirect(exec->globalData(), exec->propertyNames().constructor, this, DontEnum);
     189            PutPropertySlot slot;
     190            putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | DontEnum, false, slot);
     191            location = getDirectLocation(exec->globalData(), exec->propertyNames().prototype);
     192        }
    208193
    209194        slot.setValue(this, location->get(), offsetForLocation(location));
  • trunk/Source/JavaScriptCore/runtime/JSFunction.h

    r94929 r95205  
    149149        bool isHostFunctionNonInline() const;
    150150
    151         virtual void preventExtensions(JSGlobalData&);
    152151        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    153152        virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r95167 r95205  
    212212        void seal(JSGlobalData&);
    213213        void freeze(JSGlobalData&);
    214         virtual void preventExtensions(JSGlobalData&);
     214        void preventExtensions(JSGlobalData&);
    215215        bool isSealed(JSGlobalData& globalData) { return m_structure->isSealed(globalData); }
    216216        bool isFrozen(JSGlobalData& globalData) { return m_structure->isFrozen(globalData); }
Note: See TracChangeset for help on using the changeset viewer.