Title: [201813] trunk/PerformanceTests
Revision
201813
Author
[email protected]
Date
2016-06-08 11:13:20 -0700 (Wed, 08 Jun 2016)

Log Message

Use more ES6 features in JSAir
https://bugs.webkit.org/show_bug.cgi?id=158497

Reviewed by Keith Miller.
        
This improves JSAir with the following ES6 features suggested by JoePeck:
        
- String interpolation.
- Destructuring inside PatchCustom.
- Default arguments.
        
All of these things are on hot paths.
        
Note that I didn't use string interpolation everywhere that I could, only in those places
where it made the code more readable. In Ruby, I used the style that if the interpolation
_expression_ has any non-trivial stuff (like a ternary operator, a chain of calls, or embedded
strings) then it's better to use regular strcat. I think that's what I carried over to here.
        
Note that the previous change (Add result validation to JSAir) also made the Proxy code not
dead, though it's not necessarily on the hot path. The Proxy isn't called into frequently
but it's used from a function that is otherwise hot, so if calling into the Proxy prevents
that function from being optimized then it will hurt so good.
        
I also reenabled tail calls in a few places.
        
This change doesn't seem to change the performance of the benchmark for us. That's expected
since these ES6 features are cheap. Note that this claim doesn't include Proxy, which was
added in a separate change and that change did make the benchmark overall more expensive.

* JSAir/allocate_stack.js:
(allocateStack):
* JSAir/arg.js:
(Arg.createBitImm64):
(Arg.createAddr):
(Arg.createStack):
(Arg.logScale):
(Arg.createIndex):
* JSAir/basic_block.js:
(BasicBlock.get headerString):
(BasicBlock.prototype.get if):
(BasicBlock):
* JSAir/benchmark.js:
(benchmark):
* JSAir/code.js:
(Code):
(Code.prototype.addBlock):
(Code.prototype.addStackSlot):
(Code.prototype.newTmp):
(Code.prototype.get size):
(Code.prototype.get blocks):
(Code.prototype.get stackSlots):
(Code.prototype.tmps):
(Code.prototype.get callArgAreaSize):
(Code.prototype.toString):
* JSAir/custom.js:
(const.PatchCustom.forEachArg):
* JSAir/inst.js:
(Inst):
* JSAir/reg.js:
(Reg.prototype.toString):
* JSAir/util.js:
(symbolName):
(lowerSymbolName):

Modified Paths

Diff

Modified: trunk/PerformanceTests/ChangeLog (201812 => 201813)


--- trunk/PerformanceTests/ChangeLog	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/ChangeLog	2016-06-08 18:13:20 UTC (rev 201813)
@@ -1,3 +1,69 @@
+2016-06-08  Filip Pizlo  <[email protected]>
+
+        Use more ES6 features in JSAir
+        https://bugs.webkit.org/show_bug.cgi?id=158497
+
+        Reviewed by Keith Miller.
+        
+        This improves JSAir with the following ES6 features suggested by JoePeck:
+        
+        - String interpolation.
+        - Destructuring inside PatchCustom.
+        - Default arguments.
+        
+        All of these things are on hot paths.
+        
+        Note that I didn't use string interpolation everywhere that I could, only in those places
+        where it made the code more readable. In Ruby, I used the style that if the interpolation
+        _expression_ has any non-trivial stuff (like a ternary operator, a chain of calls, or embedded
+        strings) then it's better to use regular strcat. I think that's what I carried over to here.
+        
+        Note that the previous change (Add result validation to JSAir) also made the Proxy code not
+        dead, though it's not necessarily on the hot path. The Proxy isn't called into frequently
+        but it's used from a function that is otherwise hot, so if calling into the Proxy prevents
+        that function from being optimized then it will hurt so good.
+        
+        I also reenabled tail calls in a few places.
+        
+        This change doesn't seem to change the performance of the benchmark for us. That's expected
+        since these ES6 features are cheap. Note that this claim doesn't include Proxy, which was
+        added in a separate change and that change did make the benchmark overall more expensive.
+
+        * JSAir/allocate_stack.js:
+        (allocateStack):
+        * JSAir/arg.js:
+        (Arg.createBitImm64):
+        (Arg.createAddr):
+        (Arg.createStack):
+        (Arg.logScale):
+        (Arg.createIndex):
+        * JSAir/basic_block.js:
+        (BasicBlock.get headerString):
+        (BasicBlock.prototype.get if):
+        (BasicBlock):
+        * JSAir/benchmark.js:
+        (benchmark):
+        * JSAir/code.js:
+        (Code):
+        (Code.prototype.addBlock):
+        (Code.prototype.addStackSlot):
+        (Code.prototype.newTmp):
+        (Code.prototype.get size):
+        (Code.prototype.get blocks):
+        (Code.prototype.get stackSlots):
+        (Code.prototype.tmps):
+        (Code.prototype.get callArgAreaSize):
+        (Code.prototype.toString):
+        * JSAir/custom.js:
+        (const.PatchCustom.forEachArg):
+        * JSAir/inst.js:
+        (Inst):
+        * JSAir/reg.js:
+        (Reg.prototype.toString):
+        * JSAir/util.js:
+        (symbolName):
+        (lowerSymbolName):
+
 2016-06-07  Filip Pizlo  <[email protected]>
 
         Add result validation to JSAir

Modified: trunk/PerformanceTests/JSAir/allocate_stack.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/allocate_stack.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/allocate_stack.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -227,8 +227,7 @@
                         // zero fills.
                         if (slot.byteSize != 8) {
                             throw new Error(
-                                "Bad spill slot size for ZDef: " + slot.byteSize + ", width is " +
-                                    width);
+                                `Bad spill slot size for ZDef: ${slot.byteSize}, width is ${width}`);
                         }
                         if (width != 32)
                             throw new Error("Bad width for ZDef");

Modified: trunk/PerformanceTests/JSAir/arg.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/arg.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/arg.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -333,10 +333,8 @@
         return result;
     }
     
-    static createAddr(base, offset)
+    static createAddr(base, offset = 0)
     {
-        if (offset == null)
-            offset = 0;
         let result = new Arg();
         result._kind = Arg.Addr;
         result._base = base;
@@ -344,10 +342,8 @@
         return result;
     }
     
-    static createStack(slot, offset)
+    static createStack(slot, offset = 0)
     {
-        if (offset == null)
-            offset = 0;
         let result = new Arg();
         result._kind = Arg.Stack;
         result._slot = slot;
@@ -400,12 +396,8 @@
         }
     }
     
-    static createIndex(base, index, scale, offset)
+    static createIndex(base, index, scale = 1, offset = 0)
     {
-        if (scale == null)
-            scale = 1;
-        if (offset == null)
-            offset = 0;
         let result = new Arg();
         result._kind = Arg.Index;
         result._base = base;

Modified: trunk/PerformanceTests/JSAir/basic_block.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/basic_block.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/basic_block.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -108,7 +108,7 @@
     get headerString()
     {
         let result = "";
-        result += "BB" + this + ": ; frequency = " + this._frequency + "\n";
+        result += `BB${this}: ; frequency = ${this._frequency}\n`;
         if (this._predecessors.length)
             result += "  Predecessors: " + this._predecessors.join(", ") + "\n";
         return result;
@@ -127,7 +127,7 @@
         let result = "";
         result += this.headerString;
         for (let inst of this)
-            result += "    " + inst + "\n";
+            result += `    ${inst}\n`;
         result += this.footerString;
         return result;
     }

Modified: trunk/PerformanceTests/JSAir/benchmark.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/benchmark.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/benchmark.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -52,7 +52,7 @@
             
             let hash = code.hash();
             if (hash != payload.earlyHash)
-                throw new Error("Wrong early hash for " + payload.generate.name +": " + hash);
+                throw new Error(`Wrong early hash for ${payload.generate.name}: ${hash}`);
             
             allocateStack(code);
             
@@ -63,7 +63,7 @@
 
             hash = code.hash();
             if (hash != payload.lateHash)
-                throw new Error("Wrong late hash for " + payload.generate.name +": " + hash);
+                throw new Error(`Wrong late hash for ${payload.generate.name}: ${hash}`);
         }
     }
     

Modified: trunk/PerformanceTests/JSAir/code.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/code.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/code.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -35,24 +35,19 @@
         this._frameSize = 0;
     }
     
-    addBlock(frequency)
+    addBlock(frequency = 1)
     {
-        if (frequency == null)
-            frequency = 1;
-        let result = addIndexed(this._blocks, BasicBlock, frequency);
-        return result;
+        return addIndexed(this._blocks, BasicBlock, frequency);
     }
     
     addStackSlot(byteSize, kind)
     {
-        let result = addIndexed(this._stackSlots, StackSlot, byteSize, kind);
-        return result;
+        return addIndexed(this._stackSlots, StackSlot, byteSize, kind);
     }
     
     newTmp(type)
     {
-        let result = addIndexed(this["_" + symbolName(type).toLowerCase() + "Tmps"], Tmp, type);
-        return result;
+        return addIndexed(this[`_${lowerSymbolName(type)}Tmps`], Tmp, type);
     }
     
     get size() { return this._blocks.length; }
@@ -66,7 +61,7 @@
     get blocks() { return this._blocks; }
     get stackSlots() { return this._stackSlots; }
     
-    tmps(type) { return this["_" + symbolName(type).toLowerCase() + "Tmps"]; }
+    tmps(type) { return this[`_${lowerSymbolName(type)}Tmps`]; }
     
     get callArgAreaSize() { return this._callArgAreaSize; }
     
@@ -116,12 +111,12 @@
         if (this.stackSlots.length) {
             result += "Stack slots:\n";
             for (let slot of this.stackSlots)
-                result += "    " + slot + "\n";
+                result += `    ${slot}\n`;
         }
         if (this._frameSize)
-            result += "Frame size: " + this._frameSize + "\n";
+            result += `Frame size: ${this._frameSize}\n`;
         if (this._callArgAreaSize)
-            result += "Call arg area size: " + this._callArgAreaSize + "\n";
+            result += `Call arg area size: ${this._callArgAreaSize}\n`;
         return result;
     }
 }

Modified: trunk/PerformanceTests/JSAir/custom.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/custom.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/custom.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -50,9 +50,8 @@
     forEachArg(inst, func)
     {
         for (let i = 0; i < inst.args.length; ++i) {
-            inst.visitArg(
-                i, func, inst.patchArgData[i].role, inst.patchArgData[i].type,
-                inst.patchArgData[i].width);
+            let {type, role, width} = inst.patchArgData[i];
+            inst.visitArg(i, func, role, type, width);
         }
     },
     

Modified: trunk/PerformanceTests/JSAir/inst.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/inst.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/inst.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -25,10 +25,10 @@
 "use strict";
 
 class Inst {
-    constructor(opcode, args)
+    constructor(opcode, args = [])
     {
         this._opcode = opcode;
-        this._args = args == null ? [] : args;
+        this._args = args;
     }
     
     append(...args)

Modified: trunk/PerformanceTests/JSAir/reg.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/reg.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/reg.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -55,7 +55,7 @@
     
     toString()
     {
-        return "%" + this._name;
+        return `%${this._name}`;
     }
     
     static extract(arg)
@@ -109,12 +109,12 @@
         Reg.rsi = newGPR("rsi");
         Reg.rdi = newGPR("rdi");
         for (let i = 8; i <= 15; ++i)
-            Reg["r" + i] = newGPR("r" + i, i >= 12);
+            Reg[`r${i}`] = newGPR(`r${i}`, i >= 12);
     }
 
     // Define X86_64 FPRs.
     for (let i = 0; i <= 15; ++i)
-        Reg["xmm" + i] = newReg(i, FP, "xmm" + i);
+        Reg[`xmm${i}`] = newReg(i, FP, `xmm${i}`);
 
     Reg.gprs = []
     Reg.fprs = []

Modified: trunk/PerformanceTests/JSAir/util.js (201812 => 201813)


--- trunk/PerformanceTests/JSAir/util.js	2016-06-08 18:03:08 UTC (rev 201812)
+++ trunk/PerformanceTests/JSAir/util.js	2016-06-08 18:13:20 UTC (rev 201813)
@@ -49,6 +49,11 @@
     return fullString.substring("Symbol(".length, fullString.length - ")".length);
 }
 
+function lowerSymbolName(symbol)
+{
+    return symbolName(symbol).toLowerCase();
+}
+
 function setToString(set)
 {
     let result = "";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to