Title: [153547] trunk/Source/_javascript_Core
Revision
153547
Author
[email protected]
Date
2013-07-31 16:57:23 -0700 (Wed, 31 Jul 2013)

Log Message

Reduce JSC API static value setter/getter overhead.
https://bugs.webkit.org/show_bug.cgi?id=119277

Patch by Yi Shen <[email protected]> on 2013-07-31
Reviewed by Geoffrey Garen.

Add property name to the static value entry, so that OpaqueJSString::create() doesn't
need to get called every time when set or get the static value.

* API/JSCallbackObjectFunctions.h:
(JSC::::put):
(JSC::::putByIndex):
(JSC::::getStaticValue):
* API/JSClassRef.cpp:
(OpaqueJSClassContextData::OpaqueJSClassContextData):
* API/JSClassRef.h:
(StaticValueEntry::StaticValueEntry):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h (153546 => 153547)


--- trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2013-07-31 23:54:09 UTC (rev 153546)
+++ trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h	2013-07-31 23:57:23 UTC (rev 153547)
@@ -263,13 +263,11 @@
                     if (entry->attributes & kJSPropertyAttributeReadOnly)
                         return;
                     if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
-                        if (!propertyNameRef)
-                            propertyNameRef = OpaqueJSString::create(name);
                         JSValueRef exception = 0;
                         bool result;
                         {
                             APICallbackShim callbackShim(exec);
-                            result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
+                            result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
                         }
                         if (exception)
                             throwError(exec, toJS(exec, exception));
@@ -324,13 +322,11 @@
                 if (entry->attributes & kJSPropertyAttributeReadOnly)
                     return;
                 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
-                    if (!propertyNameRef)
-                        propertyNameRef = OpaqueJSString::create(propertyName.impl());
                     JSValueRef exception = 0;
                     bool result;
                     {
                         APICallbackShim callbackShim(exec);
-                        result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
+                        result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
                     }
                     if (exception)
                         throwError(exec, toJS(exec, exception));
@@ -580,20 +576,17 @@
 JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, PropertyName propertyName)
 {
     JSObjectRef thisRef = toRef(this);
-    RefPtr<OpaqueJSString> propertyNameRef;
     
     if (StringImpl* name = propertyName.publicName()) {
         for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
             if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
                 if (StaticValueEntry* entry = staticValues->get(name)) {
                     if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
-                        if (!propertyNameRef)
-                            propertyNameRef = OpaqueJSString::create(name);
                         JSValueRef exception = 0;
                         JSValueRef value;
                         {
                             APICallbackShim callbackShim(exec);
-                            value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
+                            value = getProperty(toRef(exec), thisRef, entry->propertyNameRef.get(), &exception);
                         }
                         if (exception) {
                             throwError(exec, toJS(exec, exception));

Modified: trunk/Source/_javascript_Core/API/JSClassRef.cpp (153546 => 153547)


--- trunk/Source/_javascript_Core/API/JSClassRef.cpp	2013-07-31 23:54:09 UTC (rev 153546)
+++ trunk/Source/_javascript_Core/API/JSClassRef.cpp	2013-07-31 23:57:23 UTC (rev 153547)
@@ -66,7 +66,7 @@
         while (staticValue->name) {
             String valueName = String::fromUTF8(staticValue->name);
             if (!valueName.isNull())
-                m_staticValues->set(valueName.impl(), adoptPtr(new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes)));
+                m_staticValues->set(valueName.impl(), adoptPtr(new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes, valueName)));
             ++staticValue;
         }
     }
@@ -135,7 +135,8 @@
         OpaqueJSClassStaticValuesTable::const_iterator end = jsClass->m_staticValues->end();
         for (OpaqueJSClassStaticValuesTable::const_iterator it = jsClass->m_staticValues->begin(); it != end; ++it) {
             ASSERT(!it->key->isIdentifier());
-            staticValues->add(it->key->isolatedCopy(), adoptPtr(new StaticValueEntry(it->value->getProperty, it->value->setProperty, it->value->attributes)));
+            String valueName = it->key->isolatedCopy();
+            staticValues->add(valueName.impl(), adoptPtr(new StaticValueEntry(it->value->getProperty, it->value->setProperty, it->value->attributes, valueName)));
         }
     }
 

Modified: trunk/Source/_javascript_Core/API/JSClassRef.h (153546 => 153547)


--- trunk/Source/_javascript_Core/API/JSClassRef.h	2013-07-31 23:54:09 UTC (rev 153546)
+++ trunk/Source/_javascript_Core/API/JSClassRef.h	2013-07-31 23:57:23 UTC (rev 153547)
@@ -26,24 +26,25 @@
 #ifndef JSClassRef_h
 #define JSClassRef_h
 
+#include "OpaqueJSString.h"
+#include "Protect.h"
+#include "Weak.h"
 #include <_javascript_Core/JSObjectRef.h>
-
-#include "Weak.h"
-#include "Protect.h"
 #include <wtf/HashMap.h>
 #include <wtf/text/WTFString.h>
 
 struct StaticValueEntry {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes)
-        : getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes)
+    StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes, String& propertyName)
+    : getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes), propertyNameRef(OpaqueJSString::create(propertyName))
     {
     }
     
     JSObjectGetPropertyCallback getProperty;
     JSObjectSetPropertyCallback setProperty;
     JSPropertyAttributes attributes;
+    RefPtr<OpaqueJSString> propertyNameRef;
 };
 
 struct StaticFunctionEntry {

Modified: trunk/Source/_javascript_Core/ChangeLog (153546 => 153547)


--- trunk/Source/_javascript_Core/ChangeLog	2013-07-31 23:54:09 UTC (rev 153546)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-07-31 23:57:23 UTC (rev 153547)
@@ -1,3 +1,22 @@
+2013-07-31  Yi Shen  <[email protected]>
+
+        Reduce JSC API static value setter/getter overhead.
+        https://bugs.webkit.org/show_bug.cgi?id=119277
+
+        Reviewed by Geoffrey Garen.
+
+        Add property name to the static value entry, so that OpaqueJSString::create() doesn't
+        need to get called every time when set or get the static value.
+
+        * API/JSCallbackObjectFunctions.h:
+        (JSC::::put):
+        (JSC::::putByIndex):
+        (JSC::::getStaticValue):
+        * API/JSClassRef.cpp:
+        (OpaqueJSClassContextData::OpaqueJSClassContextData):
+        * API/JSClassRef.h:
+        (StaticValueEntry::StaticValueEntry):
+
 2013-07-31  Kwang Yul Seo  <[email protected]>
 
         Use emptyString instead of String("")
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to