Title: [225664] trunk/Source/_javascript_Core
Revision
225664
Author
sbar...@apple.com
Date
2017-12-07 18:08:03 -0800 (Thu, 07 Dec 2017)

Log Message

Modify our dollar VM clflush intrinsic to aid in some perf testing
https://bugs.webkit.org/show_bug.cgi?id=180559

Reviewed by Mark Lam.

* tools/JSDollarVM.cpp:
(JSC::functionCpuClflush):
(JSC::functionDeltaBetweenButterflies):
(JSC::JSDollarVM::finishCreation):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (225663 => 225664)


--- trunk/Source/_javascript_Core/ChangeLog	2017-12-08 01:53:31 UTC (rev 225663)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-12-08 02:08:03 UTC (rev 225664)
@@ -1,3 +1,15 @@
+2017-12-07  Saam Barati  <sbar...@apple.com>
+
+        Modify our dollar VM clflush intrinsic to aid in some perf testing
+        https://bugs.webkit.org/show_bug.cgi?id=180559
+
+        Reviewed by Mark Lam.
+
+        * tools/JSDollarVM.cpp:
+        (JSC::functionCpuClflush):
+        (JSC::functionDeltaBetweenButterflies):
+        (JSC::JSDollarVM::finishCreation):
+
 2017-12-07  Eric Carlson  <eric.carl...@apple.com>
 
         Simplify log channel configuration UI

Modified: trunk/Source/_javascript_Core/tools/JSDollarVM.cpp (225663 => 225664)


--- trunk/Source/_javascript_Core/tools/JSDollarVM.cpp	2017-12-08 01:53:31 UTC (rev 225663)
+++ trunk/Source/_javascript_Core/tools/JSDollarVM.cpp	2017-12-08 02:08:03 UTC (rev 225664)
@@ -1107,32 +1107,28 @@
         asm volatile ("clflush %0" :: "m"(*ptrToFlush) : "memory");
     };
 
+    Vector<void*> toFlush;
+
     uint32_t offset = exec->argument(1).asUInt32();
 
-    char* ptr = nullptr;
-    if (JSArrayBuffer* buffer = jsDynamicCast<JSArrayBuffer*>(vm, exec->argument(0))) {
-        if (ArrayBuffer* impl = buffer->impl()) {
-            if (offset < impl->byteLength()) {
-                clflush(impl);
-                ptr = bitwise_cast<char*>(impl) + offset;
-            }
-        }
-    } else if (JSArrayBufferView* view = jsDynamicCast<JSArrayBufferView*>(vm, exec->argument(0)))
-        ptr = bitwise_cast<char*>(view);
+    if (JSArrayBufferView* view = jsDynamicCast<JSArrayBufferView*>(vm, exec->argument(0)))
+        toFlush.append(bitwise_cast<char*>(view->vector()) + offset);
     else if (JSObject* object = jsDynamicCast<JSObject*>(vm, exec->argument(0))) {
         switch (object->indexingType()) {
         case ALL_INT32_INDEXING_TYPES:
         case ALL_CONTIGUOUS_INDEXING_TYPES:
         case ALL_DOUBLE_INDEXING_TYPES:
-            clflush(object);
-            ptr = bitwise_cast<char*>(object->butterfly()) + offset;
+            toFlush.append(bitwise_cast<char*>(object) + JSObject::butterflyOffset());
+            toFlush.append(bitwise_cast<char*>(object->butterfly()) + Butterfly::offsetOfVectorLength());
+            toFlush.append(bitwise_cast<char*>(object->butterfly()) + Butterfly::offsetOfPublicLength());
         }
     }
 
-    if (!ptr)
+    if (!toFlush.size())
         return JSValue::encode(jsBoolean(false));
 
-    clflush(ptr);
+    for (void* ptr : toFlush)
+        clflush(ptr);
     return JSValue::encode(jsBoolean(true));
 #else
     UNUSED_PARAM(exec);
@@ -1698,6 +1694,22 @@
     return JSValue::encode(JSTestCustomGetterSetter::create(vm, globalObject, JSTestCustomGetterSetter::createStructure(vm, globalObject)));
 }
 
+static EncodedJSValue JSC_HOST_CALL functionDeltaBetweenButterflies(ExecState* exec)
+{
+    VM& vm = exec->vm();
+    JSObject* a = jsDynamicCast<JSObject*>(vm, exec->argument(0));
+    JSObject* b = jsDynamicCast<JSObject*>(vm, exec->argument(1));
+    if (!a || !b)
+        return JSValue::encode(jsNumber(PNaN));
+
+    ptrdiff_t delta = bitwise_cast<char*>(a->butterfly()) - bitwise_cast<char*>(b->butterfly());
+    if (delta < 0)
+        return JSValue::encode(jsNumber(PNaN));
+    if (delta > std::numeric_limits<int32_t>::max())
+        return JSValue::encode(jsNumber(PNaN));
+    return JSValue::encode(jsNumber(static_cast<int32_t>(delta)));
+}
+
 void JSDollarVM::finishCreation(VM& vm)
 {
     Base::finishCreation(vm);
@@ -1779,6 +1791,8 @@
     addFunction(vm, "getGetterSetter", functionGetGetterSetter, 2);
     addFunction(vm, "loadGetterFromGetterSetter", functionLoadGetterFromGetterSetter, 1);
     addFunction(vm, "createCustomTestGetterSetter", functionCreateCustomTestGetterSetter, 1);
+
+    addFunction(vm, "deltaBetweenButterflies", functionDeltaBetweenButterflies, 2);
 }
 
 void JSDollarVM::addFunction(VM& vm, JSGlobalObject* globalObject, const char* name, NativeFunction function, unsigned arguments)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to