Changeset 15385 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jul 12, 2006, 3:01:06 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


  • Removed context and exception parameters from JSObjectGetPropertyEnumerator, removing the spurious use of ExecState inside JavaScriptCore that made us think this was necessary in the first place.

(StringInstance::getPropertyList): Use getString instead of toString because
we know we're dealing with a string -- we put it there in the first place.
While we're at it, store the string's size instead of retrieving it each time
through the loop, to avoid the unnecessary killing of puppies.

  • kjs/string_object.h:
Location:
trunk/JavaScriptCore
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSCallbackObject.cpp

    r15384 r15385  
    288288}
    289289
    290 void JSCallbackObject::getPropertyList(ExecState* exec, ReferenceList& propertyList, bool recursive)
    291 {
    292     JSContextRef context = toRef(exec);
     290void JSCallbackObject::getPropertyList(ReferenceList& propertyList, bool recursive)
     291{
    293292    JSObjectRef thisRef = toRef(this);
    294293
    295294    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
    296295        if (JSObjectAddPropertiesToListCallback addPropertiesToList = jsClass->callbacks.addPropertiesToList)
    297             addPropertiesToList(context, thisRef, toRef(&propertyList), toRef(exec->exceptionSlot()));
     296            addPropertiesToList(thisRef, toRef(&propertyList));
    298297
    299298        if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     
    320319    }
    321320
    322     JSObject::getPropertyList(exec, propertyList, recursive);
     321    JSObject::getPropertyList(propertyList, recursive);
    323322}
    324323
  • trunk/JavaScriptCore/API/JSCallbackObject.h

    r15384 r15385  
    6161    virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List &args);
    6262
    63     virtual void getPropertyList(ExecState*, ReferenceList& propertyList, bool recursive);
     63    virtual void getPropertyList(ReferenceList& propertyList, bool recursive);
    6464
    6565    virtual bool toBoolean(ExecState*) const;
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15376 r15385  
    272272};
    273273
    274 JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object)
    275 {
    276     JSLock lock;
    277     ExecState* exec = toJS(context);
     274JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSObjectRef object)
     275{
     276    JSLock lock;
    278277    JSObject* jsObject = toJS(object);
    279278   
    280279    JSPropertyEnumeratorRef enumerator = new __JSPropertyEnumerator();
    281     jsObject->getPropertyList(exec, enumerator->list);
     280    jsObject->getPropertyList(enumerator->list);
    282281    enumerator->iterator = enumerator->list.begin();
    283282   
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15384 r15385  
    156156@typedef JSObjectAddPropertiesToListCallback
    157157@abstract The callback invoked when adding an object's properties to a property list.
    158 @param context The current execution context.
    159158@param object The JSObject whose properties need to be added to propertyList.
    160159@param propertyList A JavaScript property list that will be used to enumerate object's properties.
    161 @param exception A pointer to a JSValueRef in which to return an exception, if any.
    162160@discussion If you named your function GetPropertyList, you would declare it like this:
    163161
    164 void AddPropertiesToList(JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception);
     162void AddPropertiesToList(JSObjectRef object, JSPropertyListRef propertyList);
    165163
    166164Use JSPropertyListAdd to add properties to propertyList.
     
    169167*/
    170168typedef void
    171 (*JSObjectAddPropertiesToListCallback) (JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception);
     169(*JSObjectAddPropertiesToListCallback) (JSObjectRef object, JSPropertyListRef propertyList);
    172170
    173171/*!
     
    261259@field setProperty The callback invoked when setting the value of a given property.
    262260@field deleteProperty The callback invoked when deleting a given property.
    263 @field getPropertyList The callback invoked when adding an object's properties to a property list.
     261@field addPropertiesToList The callback invoked when adding an object's properties to a property list.
    264262@field callAsFunction The callback invoked when an object is called as a function.
    265263@field hasInstance The callback invoked when an object is used in an 'instanceof' expression.
     
    507505@function
    508506@abstract Creates an enumerator for an object's properties.
    509 @param context The execution context to use.
    510507@param object The object whose properties you want to enumerate.
    511508@result A JSPropertyEnumerator with a list of object's properties. Ownership follows the Create Rule.
    512509*/
    513 JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object);
     510JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSObjectRef object);
    514511/*!
    515512@function
  • trunk/JavaScriptCore/API/testapi.c

    r15384 r15385  
    163163}
    164164
    165 static void MyObject_getPropertyList(JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception)
     165static void MyObject_addPropertiesToList(JSObjectRef object, JSPropertyListRef propertyList)
    166166{
    167167    UNUSED_PARAM(context);
     
    246246    MyObject_setProperty,
    247247    MyObject_deleteProperty,
    248     MyObject_getPropertyList,
     248    MyObject_addPropertiesToList,
    249249    MyObject_callAsFunction,
    250250    MyObject_callAsConstructor,
     
    538538    JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(1), kJSPropertyAttributeNone);
    539539    JSObjectSetProperty(context, o, jsCFIString,  JSValueMakeNumber(1), kJSPropertyAttributeDontEnum);
    540     JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(context, o);
     540    JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(o);
    541541    int count = 0;
    542542    while (JSPropertyEnumeratorGetNextName(enumerator))
  • trunk/JavaScriptCore/ChangeLog

    r15384 r15385  
     12006-07-12  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Maciej.
     4       
     5        - Removed context and exception parameters from JSObjectGetPropertyEnumerator,
     6        removing the spurious use of ExecState inside JavaScriptCore that made
     7        us think this was necessary in the first place.
     8
     9        (StringInstance::getPropertyList): Use getString instead of toString because
     10        we know we're dealing with a string -- we put it there in the first place.
     11        While we're at it, store the string's size instead of retrieving it each time
     12        through the loop, to avoid the unnecessary killing of puppies.
     13        * kjs/string_object.h:
     14
    1152006-07-12  Maciej Stachowiak  <[email protected]>
    216
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r15376 r15385  
    187187__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
    188188__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
    189 __ZN3KJS8JSObject15getPropertyListEPNS_9ExecStateERNS_13ReferenceListEb
     189__ZN3KJS8JSObject15getPropertyListERNS_13ReferenceListEb
    190190__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
    191191__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE
  • trunk/JavaScriptCore/kjs/array_instance.h

    r14951 r15385  
    4040    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    4141    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
    42     virtual void getPropertyList(ExecState*, ReferenceList& propertyList, bool recursive);
     42    virtual void getPropertyList(ReferenceList& propertyList, bool recursive);
    4343
    4444    virtual void mark();
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r15225 r15385  
    200200}
    201201
    202 void ArrayInstance::getPropertyList(ExecState* exec, ReferenceList& propertyList, bool recursive)
     202void ArrayInstance::getPropertyList(ReferenceList& propertyList, bool recursive)
    203203{
    204204  // avoid fetching this every time through the loop
     
    212212    }
    213213  }
    214   return JSObject::getPropertyList(exec, propertyList, recursive);
     214  return JSObject::getPropertyList(propertyList, recursive);
    215215}
    216216
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r15225 r15385  
    18791879  KJS_CHECKEXCEPTION
    18801880  v = e->toObject(exec);
    1881   v->getPropertyList(exec, propertyList);
     1881  v->getPropertyList(propertyList);
    18821882
    18831883  ReferenceListIterator propIt = propertyList.begin();
  • trunk/JavaScriptCore/kjs/object.cpp

    r15224 r15385  
    476476}
    477477
    478 void JSObject::getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive)
     478void JSObject::getPropertyList(ReferenceList& propertyList, bool recursive)
    479479{
    480480  _prop.addEnumerablesToReferenceList(propertyList, this);
     
    494494  }
    495495  if (_proto->isObject() && recursive)
    496       static_cast<JSObject*>(_proto)->getPropertyList(exec, propertyList, recursive);
     496      static_cast<JSObject*>(_proto)->getPropertyList(propertyList, recursive);
    497497}
    498498
  • trunk/JavaScriptCore/kjs/object.h

    r15310 r15385  
    457457     * @return A List of References to properties of the object.
    458458     **/
    459     virtual void getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive = true);
     459    virtual void getPropertyList(ReferenceList& propertyList, bool recursive = true);
    460460
    461461    /**
  • trunk/JavaScriptCore/kjs/scope_chain.cpp

    r15225 r15385  
    3838#ifndef NDEBUG
    3939
    40 void ScopeChain::print(ExecState* exec)
     40void ScopeChain::print()
    4141{
    4242    ScopeChainIterator scopeEnd = end();
     
    4444        JSObject* o = *scopeIter;
    4545        ReferenceList propertyList;
    46         o->getPropertyList(exec, propertyList, false);
     46        o->getPropertyList(propertyList, false);
    4747        ReferenceListIterator propEnd = propertyList.end();
    4848
  • trunk/JavaScriptCore/kjs/scope_chain.h

    r13960 r15385  
    8383
    8484#ifndef NDEBUG       
    85         void print(ExecState*);
     85        void print();
    8686#endif
    8787       
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r14951 r15385  
    9595}
    9696
    97 void StringInstance::getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive)
     97void StringInstance::getPropertyList(ReferenceList& propertyList, bool recursive)
    9898{
    9999  //### FIXME: should avoid duplicates with prototype
    100   UString str = internalValue()->toString(exec);
    101   for (int i = 0; i < str.size(); i++)
     100  int size = internalValue()->getString().size();
     101  for (int i = 0; i < size; i++)
    102102    propertyList.append(Reference(this, i));
    103   return JSObject::getPropertyList(exec, propertyList, recursive);
     103  return JSObject::getPropertyList(propertyList, recursive);
    104104}
    105105
  • trunk/JavaScriptCore/kjs/string_object.h

    r14951 r15385  
    3535    virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
    3636    virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    37     virtual void getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive);
     37    virtual void getPropertyList(ReferenceList& propertyList, bool recursive);
    3838
    3939    virtual const ClassInfo *classInfo() const { return &info; }
Note: See TracChangeset for help on using the changeset viewer.