JavaScriptCore:
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Feb 2008 17:33:07 +0000 (17:33 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Feb 2008 17:33:07 +0000 (17:33 +0000)
        Reviewed by Sam.

        - replace calls to put to set up properties with calls to putDirect, to
          prepare for a future change where put won't take attributes any more,
          and for a slight performance boost

        * API/JSObjectRef.cpp:
        (JSObjectMakeConstructor): Use putDirect instead of put.
        * kjs/CommonIdentifiers.h: Removed lastIndex.
        * kjs/JSGlobalObject.cpp:
        (KJS::JSGlobalObject::reset): Use putDirect instead of put.
        * kjs/array_object.cpp:
        (KJS::arrayProtoFuncConcat): Took out extra call to get length (unused).
        (KJS::ArrayObjectImp::ArrayObjectImp): Use putDirect instead of put.
        * kjs/error_object.cpp:
        (KJS::ErrorPrototype::ErrorPrototype): Use putDirect instead of put.
        * kjs/function.cpp:
        (KJS::Arguments::Arguments): Use putDirect instead of put.
        (KJS::PrototypeFunction::PrototypeFunction): Use putDirect instead of put.
        * kjs/function_object.cpp:
        (KJS::FunctionObjectImp::construct): Use putDirect instead of put.
        * kjs/nodes.cpp:
        (KJS::FuncDeclNode::makeFunction): Use putDirect instead of put.
        (KJS::FuncExprNode::evaluate): Use putDirect instead of put.
        * kjs/regexp_object.cpp:
        (KJS::regExpProtoFuncCompile): Use setLastIndex instead of put(lastIndex).
        (KJS::RegExpImp::match): Get and set lastIndex by using m_lastIndex instead of
        calling get and put.
        * kjs/regexp_object.h:
        (KJS::RegExpImp::setLastIndex): Added.
        * kjs/string_object.cpp:
        (KJS::stringProtoFuncMatch): Use setLastIndex instead of put(lastIndex).

WebCore:

        Reviewed by Sam.

        - replace calls to put to set up properties with calls to putDirect, to
          prepare for a future change where put won't take attributes any more,
          and for a slight performance boost

        * bindings/js/JSAudioConstructor.cpp:
        (WebCore::JSAudioConstructor::JSAudioConstructor): Use putDirect instead of put.
        * bindings/js/JSEventTargetBase.h:
        (WebCore::JSEventTargetPrototype::self): Ditto.
        * bindings/js/JSHTMLOptionElementConstructor.cpp:
        (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor): Ditto.
        * bindings/js/JSSQLResultSetRowListCustom.cpp:
        (WebCore::JSSQLResultSetRowList::item): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30040 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
JavaScriptCore/API/JSObjectRef.cpp
JavaScriptCore/ChangeLog
JavaScriptCore/kjs/CommonIdentifiers.h
JavaScriptCore/kjs/JSGlobalObject.cpp
JavaScriptCore/kjs/array_object.cpp
JavaScriptCore/kjs/error_object.cpp
JavaScriptCore/kjs/function.cpp
JavaScriptCore/kjs/function_object.cpp
JavaScriptCore/kjs/nodes.cpp
JavaScriptCore/kjs/regexp_object.cpp
JavaScriptCore/kjs/regexp_object.h
JavaScriptCore/kjs/string_object.cpp
WebCore/ChangeLog
WebCore/bindings/js/JSAudioConstructor.cpp
WebCore/bindings/js/JSEventTargetBase.h
WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp

index 8c3e35eeae8f347e7cec989097b672ead98e98b8..c6cda256818c7afc07a1527cf0562d74bee83a90 100644 (file)
@@ -102,8 +102,8 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje
         ? jsClass->prototype(ctx)
         : exec->dynamicGlobalObject()->objectPrototype();
     
-    JSObject* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);
-    constructor->put(exec, exec->propertyNames().prototype, jsPrototype, DontEnum|DontDelete|ReadOnly);
+    JSCallbackConstructor* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);
+    constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
     return toRef(constructor);
 }
 
index 991fd1400c8f5b66173bce9e53b5c0a11177acb5..53dfdc20afa2dc90e5439ded365d1a0c650641bc 100644 (file)
@@ -1,3 +1,38 @@
+2008-02-06  Darin Adler  <darin@apple.com>
+
+        Reviewed by Sam.
+
+        - replace calls to put to set up properties with calls to putDirect, to
+          prepare for a future change where put won't take attributes any more,
+          and for a slight performance boost
+
+        * API/JSObjectRef.cpp:
+        (JSObjectMakeConstructor): Use putDirect instead of put.
+        * kjs/CommonIdentifiers.h: Removed lastIndex.
+        * kjs/JSGlobalObject.cpp:
+        (KJS::JSGlobalObject::reset): Use putDirect instead of put.
+        * kjs/array_object.cpp:
+        (KJS::arrayProtoFuncConcat): Took out extra call to get length (unused).
+        (KJS::ArrayObjectImp::ArrayObjectImp): Use putDirect instead of put.
+        * kjs/error_object.cpp:
+        (KJS::ErrorPrototype::ErrorPrototype): Use putDirect instead of put.
+        * kjs/function.cpp:
+        (KJS::Arguments::Arguments): Use putDirect instead of put.
+        (KJS::PrototypeFunction::PrototypeFunction): Use putDirect instead of put.
+        * kjs/function_object.cpp:
+        (KJS::FunctionObjectImp::construct): Use putDirect instead of put.
+        * kjs/nodes.cpp:
+        (KJS::FuncDeclNode::makeFunction): Use putDirect instead of put.
+        (KJS::FuncExprNode::evaluate): Use putDirect instead of put.
+        * kjs/regexp_object.cpp:
+        (KJS::regExpProtoFuncCompile): Use setLastIndex instead of put(lastIndex).
+        (KJS::RegExpImp::match): Get and set lastIndex by using m_lastIndex instead of
+        calling get and put.
+        * kjs/regexp_object.h:
+        (KJS::RegExpImp::setLastIndex): Added.
+        * kjs/string_object.cpp:
+        (KJS::stringProtoFuncMatch): Use setLastIndex instead of put(lastIndex).
+
 2008-02-05  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Anders Carlsson.
index 6f2aa697d3a57d33b1dc7614fe16d880df1c76aa..ae5c778ffdeac4a64cd672d83099b766b503e46e 100644 (file)
@@ -36,7 +36,6 @@
     macro(ignoreCase) \
     macro(index) \
     macro(input) \
-    macro(lastIndex) \
     macro(length) \
     macro(message) \
     macro(multiline) \
index 5466f7416dec3f0cc4612a404a7ae500d1975baa..4f6a89aa16557af3678583db6ed93af651dbb644 100644 (file)
@@ -259,23 +259,23 @@ void JSGlobalObject::reset(JSValue* prototype)
     d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype);
     d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype);
     
-    d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
-
-    d()->objectPrototype->put(exec, exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->arrayPrototype->put(exec, exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->booleanPrototype->put(exec, exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->stringPrototype->put(exec, exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->numberPrototype->put(exec, exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->datePrototype->put(exec, exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->regExpPrototype->put(exec, exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->errorPrototype->put(exec, exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);
-    d()->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
+
+    d()->objectPrototype->putDirect(exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->functionPrototype->putDirect(exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->arrayPrototype->putDirect(exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->booleanPrototype->putDirect(exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->stringPrototype->putDirect(exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->numberPrototype->putDirect(exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->datePrototype->putDirect(exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->regExpPrototype->putDirect(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);
+    d()->URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);
 
     // Set global constructors
 
index 40da7d03965276bf9febe4b354d596c3909ababb..9409db97fe5e74c187267a1eab14b91416a8aa5d 100644 (file)
@@ -102,7 +102,7 @@ JSValue* arrayProtoFuncToString(ExecState* exec, JSObject* thisObj, const List&)
     UString str = *empty;
 
     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
-    for (unsigned int k = 0; k < length; k++) {
+    for (unsigned k = 0; k < length; k++) {
         if (k >= 1)
             str += separator;
         if (str.isNull()) {
@@ -144,7 +144,7 @@ JSValue* arrayProtoFuncToLocaleString(ExecState* exec, JSObject* thisObj, const
     UString str = *empty;
 
     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
-    for (unsigned int k = 0; k < length; k++) {
+    for (unsigned k = 0; k < length; k++) {
         if (k >= 1)
             str += separator;
         if (str.isNull()) {
@@ -191,7 +191,7 @@ JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const List& args
         separator = args[0]->toString(exec);
 
     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
-    for (unsigned int k = 0; k < length; k++) {
+    for (unsigned k = 0; k < length; k++) {
         if (k >= 1)
             str += separator;
         if (str.isNull()) {
@@ -226,13 +226,12 @@ JSValue* arrayProtoFuncConcat(ExecState* exec, JSObject* thisObj, const List& ar
     JSObject* curObj = static_cast<JSObject* >(thisObj);
     List::const_iterator it = args.begin();
     List::const_iterator end = args.end();
-    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     while (1) {
         if (curArg->isObject() && curObj->inherits(&ArrayInstance::info)) {
-            unsigned int k = 0;
+            unsigned k = 0;
             // Older versions tried to optimize out getting the length of thisObj
             // by checking for n != 0, but that doesn't work if thisObj is an empty array.
-            length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
+            unsigned length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
             while (k < length) {
                 if (JSValue* v = getProperty(exec, curObj, k))
                     arr->put(exec, n, v);
@@ -270,7 +269,7 @@ JSValue* arrayProtoFuncPop(ExecState* exec, JSObject* thisObj, const List&)
 JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const List& args)
 {
     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
-    for (unsigned int n = 0; n < args.size(); n++)
+    for (unsigned n = 0; n < args.size(); n++)
         thisObj->put(exec, length + n, args[n]);
     length += args.size();
     thisObj->put(exec, exec->propertyNames().length, jsNumber(length), DontEnum | DontDelete);
@@ -280,9 +279,9 @@ JSValue* arrayProtoFuncPush(ExecState* exec, JSObject* thisObj, const List& args
 JSValue* arrayProtoFuncReverse(ExecState* exec, JSObject* thisObj, const List&)
 {
     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
-    unsigned int middle = length / 2;
+    unsigned middle = length / 2;
 
-    for (unsigned int k = 0; k < middle; k++) {
+    for (unsigned k = 0; k < middle; k++) {
         unsigned lk1 = length - k - 1;
         JSValue* obj2 = getProperty(exec, thisObj, lk1);
         JSValue* obj = getProperty(exec, thisObj, k);
@@ -310,7 +309,7 @@ JSValue* arrayProtoFuncShift(ExecState* exec, JSObject* thisObj, const List&)
         result = jsUndefined();
     } else {
         result = thisObj->get(exec, 0);
-        for (unsigned int k = 1; k < length; k++) {
+        for (unsigned k = 1; k < length; k++) {
             if (JSValue* obj = getProperty(exec, thisObj, k))
                 thisObj->put(exec, k - 1, obj);
             else
@@ -391,11 +390,11 @@ JSValue* arrayProtoFuncSort(ExecState* exec, JSObject* thisObj, const List& args
 
     // "Min" sort. Not the fastest, but definitely less code than heapsort
     // or quicksort, and much less swapping than bubblesort/insertionsort.
-    for (unsigned int i = 0 ; i < length - 1 ; ++i) {
+    for (unsigned i = 0 ; i < length - 1 ; ++i) {
         JSValue* iObj = thisObj->get(exec, i);
-        unsigned int themin = i;
+        unsigned themin = i;
         JSValue* minObj = iObj;
-        for (unsigned int j = i + 1 ; j < length ; ++j) {
+        for (unsigned j = i + 1 ; j < length ; ++j) {
             JSValue* jObj = thisObj->get(exec, j);
             double compareResult;
             if (jObj->isUndefined())
@@ -438,31 +437,31 @@ JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const List& ar
     else
         begin = std::min<int>(begin, length);
 
-    unsigned int deleteCount;
+    unsigned deleteCount;
     if (args.size() > 1)
         deleteCount = std::min<int>(std::max<int>(args[1]->toUInt32(exec), 0), length - begin);
     else
         deleteCount = length - begin;
 
-    for (unsigned int k = 0; k < deleteCount; k++) {
+    for (unsigned k = 0; k < deleteCount; k++) {
         if (JSValue* v = getProperty(exec, thisObj, k + begin))
             resObj->put(exec, k, v);
     }
     resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount), DontEnum | DontDelete);
 
-    unsigned int additionalArgs = std::max<int>(args.size() - 2, 0);
+    unsigned additionalArgs = std::max<int>(args.size() - 2, 0);
     if (additionalArgs != deleteCount) {
         if (additionalArgs < deleteCount) {
-            for (unsigned int k = begin; k < length - deleteCount; ++k) {
+            for (unsigned k = begin; k < length - deleteCount; ++k) {
                 if (JSValue* v = getProperty(exec, thisObj, k + deleteCount))
                     thisObj->put(exec, k + additionalArgs, v);
                 else
                     thisObj->deleteProperty(exec, k + additionalArgs);
             }
-            for (unsigned int k = length ; k > length - deleteCount + additionalArgs; --k)
+            for (unsigned k = length ; k > length - deleteCount + additionalArgs; --k)
                 thisObj->deleteProperty(exec, k - 1);
         } else {
-            for (unsigned int k = length - deleteCount; (int)k > begin; --k) {
+            for (unsigned k = length - deleteCount; (int)k > begin; --k) {
                 if (JSValue* obj = getProperty(exec, thisObj, k + deleteCount - 1))
                     thisObj->put(exec, k + additionalArgs - 1, obj);
                 else
@@ -470,7 +469,7 @@ JSValue* arrayProtoFuncSplice(ExecState* exec, JSObject* thisObj, const List& ar
             }
         }
     }
-    for (unsigned int k = 0; k < additionalArgs; ++k)
+    for (unsigned k = 0; k < additionalArgs; ++k)
         thisObj->put(exec, k + begin, args[k + 2]);
 
     thisObj->put(exec, exec->propertyNames().length, jsNumber(length - deleteCount + additionalArgs), DontEnum | DontDelete);
@@ -481,14 +480,14 @@ JSValue* arrayProtoFuncUnShift(ExecState* exec, JSObject* thisObj, const List& a
 {
     // 15.4.4.13
     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
-    unsigned int nrArgs = args.size();
-    for (unsigned int k = length; k > 0; --k) {
+    unsigned nrArgs = args.size();
+    for (unsigned k = length; k > 0; --k) {
         if (JSValue* v = getProperty(exec, thisObj, k - 1))
             thisObj->put(exec, k + nrArgs-1, v);
         else
             thisObj->deleteProperty(exec, k + nrArgs-1);
     }
-    for (unsigned int k = 0; k < nrArgs; ++k)
+    for (unsigned k = 0; k < nrArgs; ++k)
         thisObj->put(exec, k, args[k]);
     JSValue* result = jsNumber(length + nrArgs);
     thisObj->put(exec, exec->propertyNames().length, result, DontEnum | DontDelete);
@@ -724,10 +723,10 @@ ArrayObjectImp::ArrayObjectImp(ExecState* exec, FunctionPrototype* funcProto, Ar
     : InternalFunctionImp(funcProto, arrayProto->classInfo()->className)
 {
     // ECMA 15.4.3.1 Array.prototype
-    put(exec, exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
+    putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
 
     // no. of arguments for constructor
-    put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+    putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 bool ArrayObjectImp::implementsConstruct() const
index 7c0eee125696f79e39b9e10168e97fcdcabf4368..75ef0ba117b0696e635677dcd2923fde22c61bfb 100644 (file)
@@ -46,8 +46,8 @@ ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectPrototype
 {
     // The constructor will be added later in ErrorObjectImp's constructor
 
-    put(exec, exec->propertyNames().name, jsString("Error"), DontEnum);
-    put(exec, exec->propertyNames().message, jsString("Unknown error"), DontEnum);
+    putDirect(exec->propertyNames().name, jsString("Error"), DontEnum);
+    putDirect(exec->propertyNames().message, jsString("Unknown error"), DontEnum);
 
     putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
 }
index f5b0391a7d0e62cef7100fc55348b56674e68a91..4ba54fda60556ca1adffd9092d50579801f3a8e6 100644 (file)
@@ -281,20 +281,20 @@ const ClassInfo Arguments::info = { "Arguments", 0, 0 };
 
 // ECMA 10.1.8
 Arguments::Arguments(ExecState* exec, FunctionImp* func, const List& args, ActivationImp* act)
-: JSObject(exec->lexicalGlobalObject()->objectPrototype()), 
-_activationObject(act),
-indexToNameMap(func, args)
+    : JSObject(exec->lexicalGlobalObject()->objectPrototype())
+    , _activationObject(act)
+    , indexToNameMap(func, args)
 {
-  putDirect(exec->propertyNames().callee, func, DontEnum);
-  putDirect(exec->propertyNames().length, args.size(), DontEnum);
+    putDirect(exec->propertyNames().callee, func, DontEnum);
+    putDirect(exec->propertyNames().length, args.size(), DontEnum);
   
-  int i = 0;
-  List::const_iterator end = args.end();
-  for (List::const_iterator it = args.begin(); it != end; ++it, ++i) {
-    if (!indexToNameMap.isMapped(Identifier::from(i))) {
-      JSObject::put(exec, Identifier::from(i), *it, DontEnum);
+    int i = 0;
+    List::const_iterator end = args.end();
+    for (List::const_iterator it = args.begin(); it != end; ++it, ++i) {
+        Identifier name = Identifier::from(i);
+        if (!indexToNameMap.isMapped(name))
+            putDirect(name, *it, DontEnum);
     }
-  }
 }
 
 void Arguments::mark() 
@@ -866,7 +866,7 @@ PrototypeFunction::PrototypeFunction(ExecState* exec, int len, const Identifier&
     , m_function(function)
 {
     ASSERT_ARG(function, function);
-    put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
+    putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
 }
 
 PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, JSMemberFunction function)
@@ -874,7 +874,7 @@ PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functio
     , m_function(function)
 {
     ASSERT_ARG(function, function);
-    put(exec, exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
+    putDirect(exec->propertyNames().length, jsNumber(len), DontDelete | ReadOnly | DontEnum);
 }
 
 JSValue* PrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
index dc20e707d8d69ea96e6e7181556a25a3a71f0269..5af2970367d1599858ef1d54e828dfbf9f9c8d55 100644 (file)
@@ -224,8 +224,8 @@ JSObject* FunctionObjectImp::construct(ExecState* exec, const List& args, const
 
     JSObject* objCons = exec->lexicalGlobalObject()->objectConstructor();
     JSObject* prototype = objCons->construct(exec, exec->emptyList());
-    prototype->put(exec, exec->propertyNames().constructor, fimp, DontEnum | DontDelete | ReadOnly);
-    fimp->put(exec, exec->propertyNames().prototype, prototype, Internal | DontDelete);
+    prototype->putDirect(exec->propertyNames().constructor, fimp, DontEnum | DontDelete | ReadOnly);
+    fimp->putDirect(exec->propertyNames().prototype, prototype, Internal | DontDelete);
     return fimp;
 }
 
index 59f7dec27a9087e694b5a3865ae3ed1f951287a0..8732f855094eaf17bdc642a00e9d176f970b5117 100644 (file)
@@ -4669,10 +4669,9 @@ FunctionImp* FuncDeclNode::makeFunction(ExecState* exec)
     FunctionImp* func = new FunctionImp(exec, m_ident, m_body.get(), exec->scopeChain());
 
     JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
-    proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
-    func->put(exec, exec->propertyNames().prototype, proto, Internal|DontDelete);
-
-    func->put(exec, exec->propertyNames().length, jsNumber(m_body->parameters().size()), ReadOnly|DontDelete|DontEnum);
+    proto->putDirect(exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
+    func->putDirect(exec->propertyNames().prototype, proto, Internal | DontDelete);
+    func->putDirect(exec->propertyNames().length, jsNumber(m_body->parameters().size()), ReadOnly | DontDelete | DontEnum);
     return func;
 }
 
@@ -4707,11 +4706,11 @@ JSValue* FuncExprNode::evaluate(ExecState* exec)
 
     FunctionImp* func = new FunctionImp(exec, m_ident, m_body.get(), exec->scopeChain());
     JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, exec->emptyList());
-    proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
-    func->put(exec, exec->propertyNames().prototype, proto, Internal | DontDelete);
+    proto->putDirect(exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
+    func->putDirect(exec->propertyNames().prototype, proto, Internal | DontDelete);
 
     if (named) {
-        functionScopeObject->put(exec, m_ident, func, Internal | ReadOnly | (exec->codeType() == EvalCode ? 0 : DontDelete));
+        functionScopeObject->putDirect(m_ident, func, Internal | ReadOnly | (exec->codeType() == EvalCode ? 0 : DontDelete));
         exec->popScope();
     }
 
index 58b1a8220feba58b593b0589044f594962001a81..217c8db404ad4b0885679ecd952f4ef8de8ec84a 100644 (file)
@@ -102,7 +102,7 @@ JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject* thisObj, const List&
         return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage()));
 
     static_cast<RegExpImp*>(thisObj)->setRegExp(regExp.release());
-    static_cast<RegExpImp*>(thisObj)->put(exec, exec->propertyNames().lastIndex, jsNumber(0), DontDelete|DontEnum);
+    static_cast<RegExpImp*>(thisObj)->setLastIndex(0);
     return jsUndefined();
 }
 
@@ -203,12 +203,11 @@ bool RegExpImp::match(ExecState* exec, const List& args)
     bool global = get(exec, exec->propertyNames().global)->toBoolean(exec);
     int lastIndex = 0;
     if (global) {
-        double lastIndexDouble = get(exec, exec->propertyNames().lastIndex)->toInteger(exec);
-        if (lastIndexDouble < 0 || lastIndexDouble > input.size()) {
-            put(exec, exec->propertyNames().lastIndex, jsNumber(0), DontDelete | DontEnum);
+        if (m_lastIndex < 0 || m_lastIndex > input.size()) {
+            m_lastIndex = 0;
             return false;
         }
-        lastIndex = static_cast<int>(lastIndexDouble);
+        lastIndex = static_cast<int>(m_lastIndex);
     }
 
     int foundIndex;
@@ -217,7 +216,7 @@ bool RegExpImp::match(ExecState* exec, const List& args)
 
     if (global) {
         lastIndex = foundIndex < 0 ? 0 : foundIndex + foundLength;
-        put(exec, exec->propertyNames().lastIndex, jsNumber(lastIndex), DontDelete | DontEnum);
+        m_lastIndex = lastIndex;
     }
 
     return foundIndex >= 0;
index 5fe82f18447ccf880b91ced0dfd8bc3b634ee0cd..1ce2f1636506874938c35e485d515de293b1a581 100644 (file)
@@ -59,6 +59,8 @@ namespace KJS {
         virtual const ClassInfo* classInfo() const { return &info; }
         static const ClassInfo info;
 
+        void setLastIndex(double lastIndex) { m_lastIndex = lastIndex; }
+
     private:
         bool match(ExecState*, const List& args);
 
index 3478f5eeb63d9ff2e6ec0f06114d3022766b2788..53b6ada4fa63c4d0c82e0df70c11ba3e5da9e497 100644 (file)
@@ -568,7 +568,7 @@ JSValue* stringProtoFuncMatch(ExecState* exec, JSObject* thisObj, const List& ar
         regExpObj->performMatch(reg, u, pos, pos, matchLength);
       }
       if (imp)
-        imp->put(exec, exec->propertyNames().lastIndex, jsNumber(lastIndex), DontDelete|DontEnum);
+        imp->setLastIndex(lastIndex);
       if (list.isEmpty()) {
         // if there are no matches at all, it's important to return
         // Null instead of an empty array, because this matches
index 642c6695bf76aa26c98ad433bec6c0f438c34305..19bbc23343a25e2aa78f0421849e20bfac749d09 100644 (file)
@@ -1,3 +1,20 @@
+2008-02-06  Darin Adler  <darin@apple.com>
+
+        Reviewed by Sam.
+
+        - replace calls to put to set up properties with calls to putDirect, to
+          prepare for a future change where put won't take attributes any more,
+          and for a slight performance boost
+
+        * bindings/js/JSAudioConstructor.cpp:
+        (WebCore::JSAudioConstructor::JSAudioConstructor): Use putDirect instead of put.
+        * bindings/js/JSEventTargetBase.h:
+        (WebCore::JSEventTargetPrototype::self): Ditto.
+        * bindings/js/JSHTMLOptionElementConstructor.cpp:
+        (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor): Ditto.
+        * bindings/js/JSSQLResultSetRowListCustom.cpp:
+        (WebCore::JSSQLResultSetRowList::item): Ditto.
+
 2008-02-06  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Darin Adler.
index bd90971e61f2d59ae1c1e837a66e6b158e1308da..1efb0d8d6c52425b90dcb302379bb9f51c1c0771 100644 (file)
@@ -41,7 +41,7 @@ JSAudioConstructor::JSAudioConstructor(ExecState* exec, Document* d)
     : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
     , m_doc(d)
 {
-    put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
+    putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
 bool JSAudioConstructor::implementsConstruct() const
index 07fd2f4913942030322158fbc66f79dbbd292919..e62459af0a106e442944d5def00462949aee4005 100644 (file)
@@ -134,7 +134,7 @@ namespace WebCore {
             }
 
             KJS::JSObject* newObject = new JSEventTargetPrototype<JSEventTargetPrototypeParent, JSEventTargetPrototypeInformation>(exec);
-            globalObject->put(exec, *prototypeName, newObject, KJS::Internal | KJS::DontEnum);
+            globalObject->putDirect(*prototypeName, newObject, KJS::Internal | KJS::DontEnum);
             return newObject;
         }
 
index e0de3f3802973d018b593e5d1319d6c81b41bb7d..0311b32126e4fd6e1521c9bc959cc9c8c86fb160 100644 (file)
@@ -33,7 +33,7 @@ JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor(ExecState* exec,
     : KJS::DOMObject(exec->lexicalGlobalObject()->objectPrototype())
     , m_doc(d)
 {
-    put(exec, exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum);
+    putDirect(exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum);
 }
 
 bool JSHTMLOptionElementConstructor::implementsConstruct() const
index 1d00eca63d4d6e430fed50caa6e75b0a729c3d48..62dcd5d016134304adf36094580688adc043bfea 100644 (file)
@@ -72,7 +72,7 @@ JSValue* JSSQLResultSetRowList::item(ExecState* exec, const List& args)
               ASSERT_NOT_REACHED();
         }
 
-        object->put(exec, m_impl->columnNames()[i], jsValue, DontDelete | ReadOnly);
+        object->putDirect(m_impl->columnNames()[i], jsValue, DontDelete | ReadOnly);
     }
 
     return object;