Title: [154405] trunk/Source/_javascript_Core
Revision
154405
Author
[email protected]
Date
2013-08-21 12:51:20 -0700 (Wed, 21 Aug 2013)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=120127
Remove JSObject::propertyIsEnumerable

Reviewed by Sam Weinig.

This method is just a wart - it contains unnecessary const-casting, function call overhead, and LOC.

* runtime/JSObject.cpp:
* runtime/JSObject.h:
    - remove propertyIsEnumerable
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncPropertyIsEnumerable):
    - Move implementation here using getOwnPropertyDescriptor directly.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (154404 => 154405)


--- trunk/Source/_javascript_Core/ChangeLog	2013-08-21 19:50:36 UTC (rev 154404)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-08-21 19:51:20 UTC (rev 154405)
@@ -1,3 +1,19 @@
+2013-08-21  Gavin Barraclough  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=120127
+        Remove JSObject::propertyIsEnumerable
+
+        Reviewed by Sam Weinig.
+
+        This method is just a wart - it contains unnecessary const-casting, function call overhead, and LOC.
+
+        * runtime/JSObject.cpp:
+        * runtime/JSObject.h:
+            - remove propertyIsEnumerable
+        * runtime/ObjectPrototype.cpp:
+        (JSC::objectProtoFuncPropertyIsEnumerable):
+            - Move implementation here using getOwnPropertyDescriptor directly.
+
 2013-08-20  Filip Pizlo  <[email protected]>
 
         DFG should inline new typedArray()

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (154404 => 154405)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2013-08-21 19:50:36 UTC (rev 154404)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2013-08-21 19:51:20 UTC (rev 154405)
@@ -1407,14 +1407,6 @@
     return false;
 }
 
-bool JSObject::propertyIsEnumerable(ExecState* exec, const Identifier& propertyName) const
-{
-    PropertyDescriptor descriptor;
-    if (!const_cast<JSObject*>(this)->getOwnPropertyDescriptor(exec, propertyName, descriptor))
-        return false;
-    return descriptor.enumerable();
-}
-
 bool JSObject::getPropertySpecificValue(ExecState* exec, PropertyName propertyName, JSCell*& specificValue) const
 {
     unsigned attributes;

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (154404 => 154405)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2013-08-21 19:50:36 UTC (rev 154404)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2013-08-21 19:51:20 UTC (rev 154405)
@@ -121,6 +121,10 @@
 
     static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
     JS_EXPORT_PRIVATE static bool getOwnPropertySlotByIndex(JSObject*, ExecState*, unsigned propertyName, PropertySlot&);
+
+    // The key difference between this and getOwnPropertySlot is that getOwnPropertySlot
+    // currently returns incorrect results for the DOM window (wiith non-own properties)
+    // being returned. Once this is fixed we should migrate code & remove this method.
     bool getOwnPropertyDescriptor(ExecState*, PropertyName, PropertyDescriptor&);
 
     bool allowsAccessFrom(ExecState*);
@@ -458,8 +462,6 @@
     void putDirectWithoutTransition(VM&, PropertyName, JSValue, unsigned attributes = 0);
     void putDirectAccessor(ExecState*, PropertyName, JSValue, unsigned attributes);
 
-    bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const;
-
     JS_EXPORT_PRIVATE bool hasProperty(ExecState*, PropertyName) const;
     JS_EXPORT_PRIVATE bool hasProperty(ExecState*, unsigned propertyName) const;
     bool hasOwnProperty(ExecState*, PropertyName) const;

Modified: trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp (154404 => 154405)


--- trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp	2013-08-21 19:50:36 UTC (rev 154404)
+++ trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp	2013-08-21 19:51:20 UTC (rev 154405)
@@ -180,8 +180,12 @@
 
 EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec)
 {
-    JSValue thisValue = exec->hostThisValue().toThis(exec, StrictMode);
-    return JSValue::encode(jsBoolean(thisValue.toObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)))));
+    JSObject* thisObject = exec->hostThisValue().toThis(exec, StrictMode).toObject(exec);
+    Identifier propertyName(exec, exec->argument(0).toString(exec)->value(exec));
+
+    PropertyDescriptor descriptor;
+    bool enumerable = thisObject->getOwnPropertyDescriptor(exec, propertyName, descriptor) && descriptor.enumerable();
+    return JSValue::encode(jsBoolean(enumerable));
 }
 
 // 15.2.4.3 Object.prototype.toLocaleString()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to