Add test for CoW conversions in the DFG/FTL
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2018 02:17:18 +0000 (02:17 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2018 02:17:18 +0000 (02:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186295

Reviewed by Saam Barati.

JSTests:

* stress/arrayprofile-should-not-convert-get-by-val-cow.js: Added.
(assertEq):
(withArrayArgInt32):
(withArrayLiteralInt32):
(withArrayArgDouble):
(withArrayLiteralDouble):
(withArrayArgContiguous):
(withArrayLiteralContiguous):
(test):

Source/JavaScriptCore:

Add a function to $vm that returns a JSString containing the
dataLog dump of the indexingMode of an Object.

* tools/JSDollarVM.cpp:
(JSC::functionIndexingMode):
(JSC::JSDollarVM::finishCreation):

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

JSTests/ChangeLog
JSTests/stress/arrayprofile-should-not-convert-get-by-val-cow.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/tools/JSDollarVM.cpp

index f4d2b34..f541ac7 100644 (file)
@@ -1,3 +1,20 @@
+2018-06-04  Keith Miller  <keith_miller@apple.com>
+
+        Add test for CoW conversions in the DFG/FTL
+        https://bugs.webkit.org/show_bug.cgi?id=186295
+
+        Reviewed by Saam Barati.
+
+        * stress/arrayprofile-should-not-convert-get-by-val-cow.js: Added.
+        (assertEq):
+        (withArrayArgInt32):
+        (withArrayLiteralInt32):
+        (withArrayArgDouble):
+        (withArrayLiteralDouble):
+        (withArrayArgContiguous):
+        (withArrayLiteralContiguous):
+        (test):
+
 2018-06-02  Caio Lima  <ticaiolima@gmail.com>
 
         [ESNext][BigInt] Implement support for addition operations
diff --git a/JSTests/stress/arrayprofile-should-not-convert-get-by-val-cow.js b/JSTests/stress/arrayprofile-should-not-convert-get-by-val-cow.js
new file mode 100644 (file)
index 0000000..bc59059
--- /dev/null
@@ -0,0 +1,57 @@
+function assertEq(a, b) {
+    if (a !== b)
+        throw new Error("values not the same: " + a + " and " + b);
+}
+
+function withArrayArgInt32(i, array) {
+    let result = array[i];
+    assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithInt32");
+}
+noInline(withArrayArgInt32);
+
+function withArrayLiteralInt32(i) {
+    let array = [0,1,2];
+    let result = array[i];
+    assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithInt32");
+}
+noInline(withArrayLiteralInt32);
+
+
+function withArrayArgDouble(i, array) {
+    let result = array[i];
+    assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
+}
+noInline(withArrayArgDouble);
+
+function withArrayLiteralDouble(i) {
+    let array = [0,1.3145,2];
+    let result = array[i];
+    assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
+}
+noInline(withArrayLiteralDouble);
+
+function withArrayArgContiguous(i, array) {
+    let result = array[i];
+    assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithContiguous");
+}
+noInline(withArrayArgContiguous);
+
+function withArrayLiteralContiguous(i) {
+    let array = [0,"string",2];
+    let result = array[i];
+    assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithContiguous");
+}
+noInline(withArrayLiteralContiguous);
+
+function test() {
+    withArrayArgInt32(0, [0,1,2]);
+    withArrayArgDouble(0, [0,1.3145,2]);
+    withArrayArgContiguous(0, [0,"string",2]);
+
+    withArrayLiteralInt32(0);
+    withArrayLiteralDouble(0);
+    withArrayLiteralContiguous(0);
+}
+
+for (let i = 0; i < 10000; i++)
+    test();
index 8f70c0a..3ef0238 100644 (file)
@@ -1,3 +1,17 @@
+2018-06-04  Keith Miller  <keith_miller@apple.com>
+
+        Add test for CoW conversions in the DFG/FTL
+        https://bugs.webkit.org/show_bug.cgi?id=186295
+
+        Reviewed by Saam Barati.
+
+        Add a function to $vm that returns a JSString containing the
+        dataLog dump of the indexingMode of an Object.
+
+        * tools/JSDollarVM.cpp:
+        (JSC::functionIndexingMode):
+        (JSC::JSDollarVM::finishCreation):
+
 2018-06-04  Saam Barati  <sbarati@apple.com>
 
         Set the activeLength of all ScratchBuffers to zero when exiting the VM
index 8d75484..96204c6 100644 (file)
@@ -1366,6 +1366,18 @@ static EncodedJSValue JSC_HOST_CALL functionPrintStack(ExecState* exec)
     return JSValue::encode(jsUndefined());
 }
 
+// Gets the dataLog dump of the indexingMode of the passed value.
+// Usage: print("indexingMode = " + $vm.indexingMode(jsValue))
+static EncodedJSValue JSC_HOST_CALL functionIndexingMode(ExecState* exec)
+{
+    if (!exec->argument(0).isObject())
+        return encodedJSUndefined();
+
+    WTF::StringPrintStream stream;
+    stream.print(IndexingTypeDump(exec->uncheckedArgument(0).getObject()->indexingMode()));
+    return JSValue::encode(jsString(exec, stream.toString()));
+}
+
 // Gets the dataLog dump of a given JS value as a string.
 // Usage: print("value = " + $vm.value(jsValue))
 static EncodedJSValue JSC_HOST_CALL functionValue(ExecState* exec)
@@ -1811,6 +1823,7 @@ void JSDollarVM::finishCreation(VM& vm)
     addFunction(vm, "printCallFrame", functionPrintCallFrame, 0);
     addFunction(vm, "printStack", functionPrintStack, 0);
 
+    addFunction(vm, "indexingMode", functionIndexingMode, 1);
     addFunction(vm, "value", functionValue, 1);
     addFunction(vm, "getpid", functionGetPID, 0);