Hi Jay,

I attached a runnable version of the benchmark. Does it compute the score
correctly? If yes, could you please tell me what scores do you get?

My scores are in range 11170-11299 for V8 TOT, the second version of this
CL, and my new CL.

Cheers,
Ulan.



On Mon, Oct 1, 2012 at 10:01 PM, Jay Conrod <[email protected]> wrote:

> LGTM. I refactored the original patch, but I think your new CL came out
> cleaner.
>
> I've attached stringSHA1.txt (rename to .js; our e-mail system rejects .js
> files). We have a shell-based driver script, but it would take a while to
> get through legal review, and it's probably faster if you write your own.
> Call the "run" method in a loop which terminates in 2000 iterations or 2000
> ms, whichever comes first. The score is iterations per second.
>
>
> On 10/01/2012 11:10 AM, [email protected] wrote:
>
>> Hi Jay,
>>
>> While waiting for the new revision of this patch set, I started
>> prototyping
>> implementation of ROR for ia32 and x64 architectures, so that we can
>> get rid of
>> the ARM specific #ifdef in hydrogen.cc.
>>
>> You can review the CL at https://chromiumcodereview.**
>> appspot.com/11033005/ <https://chromiumcodereview.appspot.com/11033005/>
>>
>> Once you upload new patch set, we can combine both CLs to get
>> something in
>> landable state.
>>
>> I also added some tests and moved detection of the ROR pattern to the
>> visitor of
>> the bitwise OR. This seems cleaner to me than adding a new hydrogen
>> phase just
>> to detect one specific pattern, WDYT?
>>
>> Please note that I checked the generated code but didn't check
>> performance on
>> StringSHA1 yet. How can I do this?
>>
>> https://chromiumcodereview.**appspot.com/10984057/<https://chromiumcodereview.appspot.com/10984057/>
>>
>
>
>

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
/** 
 * SHA-1 generating speed test.
 * Based on solution introduced in 
http://www.webtoolkit.info/javascript-sha1.html
 */
var stringSHA1 = {
        
        content: "scDfce",
        
        init: function() {
        },
        
        run: function() {
                this.SHA1(this.content);
        },
        
        SHA1: function(msg) {

            var blockstart;
            var i, j;
            var W = new Array(80);
            var H0 = 0x67452301;
            var H1 = 0xEFCDAB89;
            var H2 = 0x98BADCFE;
            var H3 = 0x10325476;
            var H4 = 0xC3D2E1F0;
            var A, B, C, D, E;
            var temp;
        
            msg = this.utf8Encode(msg);
        
            var msgLen = msg.length;
        
            var wordArray = new Array();
            for (i = 0; i < msgLen - 3; i += 4) {
                j = msg.charCodeAt(i) << 24 
                        | msg.charCodeAt(i+1) << 16 
                        | msg.charCodeAt(i+2)<<8 
                        | msg.charCodeAt(i+3);
                wordArray.push( j );
            }
        
            switch (msgLen % 4) {
                case 0:
                    i = 0x080000000;
                break;
                case 1:
                    i = msg.charCodeAt(msgLen - 1) << 24 | 0x0800000;
                break;
        
                case 2:
                    i = msg.charCodeAt(msgLen - 2) << 24 | 
msg.charCodeAt(msgLen - 1) << 16 | 0x08000;
                break;
        
                case 3:
                    i = msg.charCodeAt(msgLen - 3) << 24 
                        | msg.charCodeAt(msgLen-2) << 16 
                        | msg.charCodeAt(msgLen - 1) << 8 
                        | 0x80;
                break;
            }
        
            wordArray.push( i );
        
            while ((wordArray.length % 16) != 14 ) wordArray.push(0);
        
            wordArray.push(msgLen >>> 29);
            wordArray.push((msgLen << 3) &0x0ffffffff );
        
            for (blockstart = 0; blockstart < wordArray.length; blockstart += 
16 ) {
        
                for (i = 0; i < 16; i++) W[i] = wordArray[blockstart + i];
                for (i = 16; i <= 79; i++) W[i] = this.rotateLeft(W[i - 3] ^ 
W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
        
                A = H0;
                B = H1;
                C = H2;
                D = H3;
                E = H4;
        
                for( i = 0; i <= 19; i++ ) {
                    temp = (this.rotateLeft(A,5) + ((B&C) | (~B&D)) + E + W[i] 
+ 0x5A827999) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = this.rotateLeft(B, 30);
                    B = A;
                    A = temp;
                }
        
                for( i = 20; i <= 39; i++ ) {
                    temp = (this.rotateLeft(A,5) + (B ^ C ^ D) + E + W[i] + 
0x6ED9EBA1) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = this.rotateLeft(B, 30);
                    B = A;
                    A = temp;
                }
        
                for( i = 40; i <= 59; i++ ) {
                    temp = (this.rotateLeft(A,5) + ((B&C) | (B&D) | (C&D)) + E 
+ W[i] + 0x8F1BBCDC) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = this.rotateLeft(B, 30);
                    B = A;
                    A = temp;
                }
        
                for( i = 60; i <= 79; i++ ) {
                    temp = (this.rotateLeft(A,5) + (B ^ C ^ D) + E + W[i] + 
0xCA62C1D6) & 0x0ffffffff;
                    E = D;
                    D = C;
                    C = this.rotateLeft(B, 30);
                    B = A;
                    A = temp;
                }
        
                H0 = (H0 + A) & 0x0ffffffff;
                H1 = (H1 + B) & 0x0ffffffff;
                H2 = (H2 + C) & 0x0ffffffff;
                H3 = (H3 + D) & 0x0ffffffff;
                H4 = (H4 + E) & 0x0ffffffff;
        
            }
        
            var temp = this.cvtHex(H0) + this.cvtHex(H1) + this.cvtHex(H2) + 
this.cvtHex(H3) + this.cvtHex(H4);
        
            return temp.toLowerCase();
        
        },      

    rotateLeft: function(n, s) {
        var t4 = ( n << s ) | (n >>> (32 - s));
        // if (n > 0xFFFFFFFF/2 || n < -0xFFFFFFFF/2
        //   || t4 > 0xFFFFFFFF/2 || t4 < -0xFFFFFFFF/2) print(n + " " + t4);
        return t4;
    },

    lsbHex: function(val) {
        var str = "";
        var i;
        var vh;
        var vl;

        for( i=0; i<=6; i+=2 ) {
            vh = (val>>>(i*4+4))&0x0f;
            vl = (val>>>(i*4))&0x0f;
            str += vh.toString(16) + vl.toString(16);
        }
        return str;
    },

    cvtHex: function(val) {
        var str="";
        var i;
        var v;

        for( i=7; i>=0; i-- ) {
            v = (val>>>(i*4))&0x0f;
            str += v.toString(16);
        }
        return str;
    },


    utf8Encode: function(string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    }
        
}

function go() {
  var elapsed = 0;
  var start = new Date();
  for (var n = 0; elapsed < 2000 && n < 2000; n++) {
    stringSHA1.run();
    elapsed = new Date() - start;
  }
  print('Score: ' + (n * 1000 / elapsed));
}

go();

Reply via email to