Changeset 34527 in webkit for trunk/JavaScriptCore/VM/Opcode.cpp


Ignore:
Timestamp:
Jun 13, 2008, 9:12:45 PM (17 years ago)
Author:
[email protected]
Message:

2008-06-13 Maciej Stachowiak <[email protected]>

Reviewed by Oliver.


  • prettify opcode stats output


I changed things to be a bit more aligned, also there is a new
section listing most common opcodes and most common sequences that
include them.

  • VM/Opcode.cpp: (KJS::): (KJS::OpcodeStats::~OpcodeStats):
  • VM/Opcode.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/Opcode.cpp

    r34497 r34527  
    4646
    4747static const char* opcodeNames[] = {
    48     "load",
    49     "new_object",
    50     "new_array",
    51     "new_regexp",
    52     "mov",
    53    
    54     "not",
    55     "eq",
    56     "neq",
    57     "stricteq",
    58     "nstricteq",
    59     "less",
    60     "lesseq",
    61    
    62     "pre_inc",
    63     "pre_dec",
    64     "post_inc",
    65     "post_dec",
    66     "to_jsnumber",
    67     "negate",
    68     "add",
    69     "mul",
    70     "div",
    71     "mod",
    72     "sub",
    73    
    74     "lshift",
    75     "rshift",
    76     "urshift",
    77     "bitand",
    78     "bitxor",
    79     "bitor",
    80     "bitnot",
    81    
    82     "instanceof",
    83     "typeof",
    84     "in",
    85 
    86     "resolve",
     48    "load        ",
     49    "new_object  ",
     50    "new_array   ",
     51    "new_regexp  ",
     52    "mov         ",
     53   
     54    "not         ",
     55    "eq          ",
     56    "neq         ",
     57    "stricteq    ",
     58    "nstricteq   ",
     59    "less        ",
     60    "lesseq      ",
     61   
     62    "pre_inc     ",
     63    "pre_dec     ",
     64    "post_inc    ",
     65    "post_dec    ",
     66    "to_jsnumber ",
     67    "negate      ",
     68    "add         ",
     69    "mul         ",
     70    "div         ",
     71    "mod         ",
     72    "sub         ",
     73   
     74    "lshift      ",
     75    "rshift      ",
     76    "urshift     ",
     77    "bitand      ",
     78    "bitxor      ",
     79    "bitor       ",
     80    "bitnot      ",
     81   
     82    "instanceof  ",
     83    "typeof      ",
     84    "in          ",
     85
     86    "resolve     ",
    8787    "resolve_skip",
    8888    "get_scoped_var",
     
    9191    "resolve_with_base",
    9292    "resolve_func",
    93     "get_by_id",
    94     "put_by_id",
    95     "del_by_id",
    96     "get_by_val",
    97     "put_by_val",
    98     "del_by_val",
     93    "get_by_id   ",
     94    "put_by_id   ",
     95    "del_by_id   ",
     96    "get_by_val  ",
     97    "put_by_val  ",
     98    "del_by_val  ",
    9999    "put_by_index",
    100     "put_getter",
    101     "put_setter",
    102 
    103     "jmp",
    104     "jtrue",
    105     "jfalse",
    106     "jless",
    107     "jmp_scopes",
    108 
    109     "new_func",
     100    "put_getter  ",
     101    "put_setter  ",
     102
     103    "jmp         ",
     104    "jtrue       ",
     105    "jfalse      ",
     106    "jless       ",
     107    "jmp_scopes  ",
     108
     109    "new_func    ",
    110110    "new_func_exp",
    111     "call",
    112     "call_eval",
    113     "ret",
    114 
    115     "construct",
    116 
    117     "get_pnames",
    118     "next_pname",
    119 
    120     "push_scope",
    121     "pop_scope",
    122 
    123     "catch",
    124     "throw",
    125     "new_error",
    126 
    127     "jsr",
    128     "sret",
    129 
    130     "debug",
    131 
    132     "end"   
     111    "call        ",
     112    "call_eval   ",
     113    "ret         ",
     114
     115    "construct   ",
     116
     117    "get_pnames  ",
     118    "next_pname  ",
     119
     120    "push_scope  ",
     121    "pop_scope   ",
     122
     123    "catch       ",
     124    "throw       ",
     125    "new_error   ",
     126
     127    "jsr         ",
     128    "sret        ",
     129
     130    "debug       ",
     131
     132    "end         "
    133133};
    134134
     
    194194    mergesort(sortedPairIndices, numOpcodeIDs * numOpcodeIDs, sizeof(pair<int, int>), compareOpcodePairIndices);
    195195   
    196     printf("\nExecuted opcode statistics:\n\n");
     196    printf("\nExecuted opcode statistics\n");
    197197   
    198198    printf("Total instructions executed: %lld\n\n", totalInstructions);
    199    
     199
     200    printf("All opcodes by frequency:\n\n");
     201
    200202    for (int i = 0; i < numOpcodeIDs; ++i) {
    201203        int index = sortedIndices[i];
    202         printf("%s: %.2f%%\n", opcodeNames[index], ((double) opcodeCounts[index]) / ((double) totalInstructions) * 100.0);   
     204        printf("%s: %lld - %.2f%%\n", opcodeNames[index], opcodeCounts[index], ((double) opcodeCounts[index]) / ((double) totalInstructions) * 100.0);   
    203205    }
    204206   
    205207    printf("\n");
     208    printf("2-opcode sequences by frequency: %lld\n\n", totalInstructions);
    206209   
    207210    for (int i = 0; i < numOpcodeIDs * numOpcodeIDs; ++i) {
     
    212215            break;
    213216       
    214         printf("(%s, %s): %.2f%%\n", opcodeNames[indexPair.first], opcodeNames[indexPair.second], ((double) count) / ((double) totalInstructionPairs) * 100.0);
     217        printf("%s %s: %lld %.2f%%\n", opcodeNames[indexPair.first], opcodeNames[indexPair.second], count, ((double) count) / ((double) totalInstructionPairs) * 100.0);
    215218    }
    216219   
     220    printf("\n");
     221    printf("Most common opcodes and sequences:\n");
     222
     223    for (int i = 0; i < numOpcodeIDs; ++i) {
     224        int index = sortedIndices[i];
     225        long long opcodeCount = opcodeCounts[index];
     226        double opcodeProportion = ((double) opcodeCount) / ((double) totalInstructions);
     227        if (opcodeProportion < 0.0001)
     228            break;
     229        printf("\n%s: %lld - %.2f%%\n", opcodeNames[index], opcodeCount, opcodeProportion * 100.0);
     230
     231        for (int j = 0; j < numOpcodeIDs * numOpcodeIDs; ++j) {
     232            pair<int, int> indexPair = sortedPairIndices[j];
     233            long long pairCount = opcodePairCounts[indexPair.first][indexPair.second];
     234            double pairProportion = ((double) pairCount) / ((double) totalInstructionPairs);
     235       
     236            if (!pairCount || pairProportion < 0.0001 || pairProportion < opcodeProportion / 100)
     237                break;
     238
     239            if (indexPair.first != index && indexPair.second != index)
     240                continue;
     241
     242            printf("    %s %s: %lld - %.2f%%\n", opcodeNames[indexPair.first], opcodeNames[indexPair.second], pairCount, pairProportion * 100.0);
     243        }
     244       
     245    }
    217246    printf("\n");
    218247}
Note: See TracChangeset for help on using the changeset viewer.