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


Ignore:
Timestamp:
Nov 15, 2008, 1:37:49 PM (17 years ago)
Author:
[email protected]
Message:

2008-11-15 Geoffrey Garen <[email protected]>

Suggested by Maciej Stachowiak.


Reverted most "opcode" => "bytecode" renames. We use "bytecode" as a
mass noun to refer to a stream of instructions. Each instruction may be
an opcode or an operand.

  • VM/CTI.cpp: (JSC::CTI::emitCTICall): (JSC::CTI::compileOpCall): (JSC::CTI::compileBinaryArithOp): (JSC::CTI::compileBinaryArithOpSlowCase): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileSlowCases): (JSC::CTI::privateCompile):
  • VM/CTI.h:
  • VM/CodeBlock.cpp: (JSC::CodeBlock::printStructureIDs): (JSC::CodeBlock::dump): (JSC::CodeBlock::derefStructureIDs): (JSC::CodeBlock::refStructureIDs):
  • VM/CodeBlock.h:
  • VM/ExceptionHelpers.cpp: (JSC::createNotAnObjectError):
  • VM/Instruction.h: (JSC::Instruction::Instruction): (JSC::Instruction::):
  • VM/Machine.cpp: (JSC::BytecodeInterpreter::isOpcode): (JSC::BytecodeInterpreter::throwException): (JSC::BytecodeInterpreter::tryCachePutByID): (JSC::BytecodeInterpreter::uncachePutByID): (JSC::BytecodeInterpreter::tryCacheGetByID): (JSC::BytecodeInterpreter::uncacheGetByID): (JSC::BytecodeInterpreter::privateExecute): (JSC::BytecodeInterpreter::tryCTICachePutByID): (JSC::BytecodeInterpreter::tryCTICacheGetByID):
  • VM/Machine.h: (JSC::BytecodeInterpreter::getOpcode): (JSC::BytecodeInterpreter::getOpcodeID): (JSC::BytecodeInterpreter::isCallBytecode):
  • VM/Opcode.cpp: (JSC::): (JSC::OpcodeStats::OpcodeStats): (JSC::compareOpcodeIndices): (JSC::compareOpcodePairIndices): (JSC::OpcodeStats::~OpcodeStats): (JSC::OpcodeStats::recordInstruction): (JSC::OpcodeStats::resetLastInstruction):
  • VM/Opcode.h: (JSC::): (JSC::padOpcodeName):
  • VM/SamplingTool.cpp: (JSC::ScopeSampleRecord::sample): (JSC::SamplingTool::run): (JSC::compareOpcodeIndicesSampling): (JSC::SamplingTool::dump):
  • VM/SamplingTool.h: (JSC::ScopeSampleRecord::ScopeSampleRecord): (JSC::SamplingTool::SamplingTool):
  • bytecompiler/CodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitLabel): (JSC::BytecodeGenerator::emitOpcode): (JSC::BytecodeGenerator::emitJump): (JSC::BytecodeGenerator::emitJumpIfTrue): (JSC::BytecodeGenerator::emitJumpIfFalse): (JSC::BytecodeGenerator::emitMove): (JSC::BytecodeGenerator::emitUnaryOp): (JSC::BytecodeGenerator::emitPreInc): (JSC::BytecodeGenerator::emitPreDec): (JSC::BytecodeGenerator::emitPostInc): (JSC::BytecodeGenerator::emitPostDec): (JSC::BytecodeGenerator::emitBinaryOp): (JSC::BytecodeGenerator::emitEqualityOp): (JSC::BytecodeGenerator::emitUnexpectedLoad): (JSC::BytecodeGenerator::emitInstanceOf): (JSC::BytecodeGenerator::emitResolve): (JSC::BytecodeGenerator::emitGetScopedVar): (JSC::BytecodeGenerator::emitPutScopedVar): (JSC::BytecodeGenerator::emitResolveBase): (JSC::BytecodeGenerator::emitResolveWithBase): (JSC::BytecodeGenerator::emitResolveFunction): (JSC::BytecodeGenerator::emitGetById): (JSC::BytecodeGenerator::emitPutById): (JSC::BytecodeGenerator::emitPutGetter): (JSC::BytecodeGenerator::emitPutSetter): (JSC::BytecodeGenerator::emitDeleteById): (JSC::BytecodeGenerator::emitGetByVal): (JSC::BytecodeGenerator::emitPutByVal): (JSC::BytecodeGenerator::emitDeleteByVal): (JSC::BytecodeGenerator::emitPutByIndex): (JSC::BytecodeGenerator::emitNewObject): (JSC::BytecodeGenerator::emitNewArray): (JSC::BytecodeGenerator::emitNewFunction): (JSC::BytecodeGenerator::emitNewRegExp): (JSC::BytecodeGenerator::emitNewFunctionExpression): (JSC::BytecodeGenerator::emitCall): (JSC::BytecodeGenerator::emitReturn): (JSC::BytecodeGenerator::emitUnaryNoDstOp): (JSC::BytecodeGenerator::emitConstruct): (JSC::BytecodeGenerator::emitPopScope): (JSC::BytecodeGenerator::emitDebugHook): (JSC::BytecodeGenerator::emitComplexJumpScopes): (JSC::BytecodeGenerator::emitJumpScopes): (JSC::BytecodeGenerator::emitNextPropertyName): (JSC::BytecodeGenerator::emitCatch): (JSC::BytecodeGenerator::emitNewError): (JSC::BytecodeGenerator::emitJumpSubroutine): (JSC::BytecodeGenerator::emitSubroutineReturn): (JSC::BytecodeGenerator::emitPushNewScope): (JSC::BytecodeGenerator::beginSwitch):
  • bytecompiler/CodeGenerator.h:
  • jsc.cpp: (runWithScripts):
  • masm/X86Assembler.h: (JSC::X86Assembler::): (JSC::X86Assembler::emitModRm_opr): (JSC::X86Assembler::emitModRm_opr_Unchecked): (JSC::X86Assembler::emitModRm_opm): (JSC::X86Assembler::emitModRm_opm_Unchecked): (JSC::X86Assembler::emitModRm_opmsib):
  • parser/Nodes.cpp: (JSC::UnaryOpNode::emitBytecode): (JSC::BinaryOpNode::emitBytecode): (JSC::ReverseBinaryOpNode::emitBytecode): (JSC::ThrowableBinaryOpNode::emitBytecode): (JSC::emitReadModifyAssignment): (JSC::ScopeNode::ScopeNode):
  • parser/Nodes.h: (JSC::UnaryPlusNode::): (JSC::NegateNode::): (JSC::BitwiseNotNode::): (JSC::LogicalNotNode::): (JSC::MultNode::): (JSC::DivNode::): (JSC::ModNode::): (JSC::AddNode::): (JSC::SubNode::): (JSC::LeftShiftNode::): (JSC::RightShiftNode::): (JSC::UnsignedRightShiftNode::): (JSC::LessNode::): (JSC::GreaterNode::): (JSC::LessEqNode::): (JSC::GreaterEqNode::): (JSC::InstanceOfNode::): (JSC::InNode::): (JSC::EqualNode::): (JSC::NotEqualNode::): (JSC::StrictEqualNode::): (JSC::NotStrictEqualNode::): (JSC::BitAndNode::): (JSC::BitOrNode::): (JSC::BitXOrNode::):
  • runtime/StructureID.cpp: (JSC::StructureID::fromDictionaryTransition):
  • wtf/Platform.h:
File:
1 edited

Legend:

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

    r38425 r38428  
    3535namespace JSC {
    3636
    37 #if ENABLE(BYTECODE_SAMPLING) || ENABLE(CODEBLOCK_SAMPLING) || ENABLE(BYTECODE_STATS)
     37#if ENABLE(OPCODE_SAMPLING) || ENABLE(CODEBLOCK_SAMPLING) || ENABLE(OPCODE_STATS)
    3838
    39 const char* const bytecodeNames[] = {
    40 #define BYTECODE_NAME_ENTRY(bytecode) #bytecode,
    41     FOR_EACH_BYTECODE_ID(BYTECODE_NAME_ENTRY)
    42 #undef BYTECODE_NAME_ENTRY
     39const char* const opcodeNames[] = {
     40#define OPCODE_NAME_ENTRY(opcode) #opcode,
     41    FOR_EACH_OPCODE_ID(OPCODE_NAME_ENTRY)
     42#undef OPCODE_NAME_ENTRY
    4343};
    4444
    4545#endif
    4646
    47 #if ENABLE(BYTECODE_STATS)
     47#if ENABLE(OPCODE_STATS)
    4848
    49 long long BytecodeStats::bytecodeCounts[numBytecodeIDs];
    50 long long BytecodeStats::bytecodePairCounts[numBytecodeIDs][numBytecodeIDs];
    51 int BytecodeStats::lastBytecode = -1;
     49long long OpcodeStats::opcodeCounts[numOpcodeIDs];
     50long long OpcodeStats::opcodePairCounts[numOpcodeIDs][numOpcodeIDs];
     51int OpcodeStats::lastOpcode = -1;
    5252
    53 static BytecodeStats logger;
     53static OpcodeStats logger;
    5454
    55 BytecodeStats::BytecodeStats()
     55OpcodeStats::OpcodeStats()
    5656{
    57     for (int i = 0; i < numBytecodeIDs; ++i)
    58         bytecodeCounts[i] = 0;
     57    for (int i = 0; i < numOpcodeIDs; ++i)
     58        opcodeCounts[i] = 0;
    5959   
    60     for (int i = 0; i < numBytecodeIDs; ++i)
    61         for (int j = 0; j < numBytecodeIDs; ++j)
    62             bytecodePairCounts[i][j] = 0;
     60    for (int i = 0; i < numOpcodeIDs; ++i)
     61        for (int j = 0; j < numOpcodeIDs; ++j)
     62            opcodePairCounts[i][j] = 0;
    6363}
    6464
    65 static int compareBytecodeIndices(const void* left, const void* right)
     65static int compareOpcodeIndices(const void* left, const void* right)
    6666{
    67     long long leftValue = BytecodeStats::bytecodeCounts[*(int*) left];
    68     long long rightValue = BytecodeStats::bytecodeCounts[*(int*) right];
     67    long long leftValue = OpcodeStats::opcodeCounts[*(int*) left];
     68    long long rightValue = OpcodeStats::opcodeCounts[*(int*) right];
    6969   
    7070    if (leftValue < rightValue)
     
    7676}
    7777
    78 static int compareBytecodePairIndices(const void* left, const void* right)
     78static int compareOpcodePairIndices(const void* left, const void* right)
    7979{
    8080    pair<int, int> leftPair = *(pair<int, int>*) left;
    81     long long leftValue = BytecodeStats::bytecodePairCounts[leftPair.first][leftPair.second];
     81    long long leftValue = OpcodeStats::opcodePairCounts[leftPair.first][leftPair.second];
    8282    pair<int, int> rightPair = *(pair<int, int>*) right;
    83     long long rightValue = BytecodeStats::bytecodePairCounts[rightPair.first][rightPair.second];
     83    long long rightValue = OpcodeStats::opcodePairCounts[rightPair.first][rightPair.second];
    8484   
    8585    if (leftValue < rightValue)
     
    9191}
    9292
    93 BytecodeStats::~BytecodeStats()
     93OpcodeStats::~OpcodeStats()
    9494{
    9595    long long totalInstructions = 0;
    96     for (int i = 0; i < numBytecodeIDs; ++i)
    97         totalInstructions += bytecodeCounts[i];
     96    for (int i = 0; i < numOpcodeIDs; ++i)
     97        totalInstructions += opcodeCounts[i];
    9898   
    9999    long long totalInstructionPairs = 0;
    100     for (int i = 0; i < numBytecodeIDs; ++i)
    101         for (int j = 0; j < numBytecodeIDs; ++j)
    102             totalInstructionPairs += bytecodePairCounts[i][j];
     100    for (int i = 0; i < numOpcodeIDs; ++i)
     101        for (int j = 0; j < numOpcodeIDs; ++j)
     102            totalInstructionPairs += opcodePairCounts[i][j];
    103103
    104     int sortedIndices[numBytecodeIDs];   
    105     for (int i = 0; i < numBytecodeIDs; ++i)
     104    int sortedIndices[numOpcodeIDs];   
     105    for (int i = 0; i < numOpcodeIDs; ++i)
    106106        sortedIndices[i] = i;
    107     qsort(sortedIndices, numBytecodeIDs, sizeof(int), compareBytecodeIndices);
     107    qsort(sortedIndices, numOpcodeIDs, sizeof(int), compareOpcodeIndices);
    108108   
    109     pair<int, int> sortedPairIndices[numBytecodeIDs * numBytecodeIDs];
     109    pair<int, int> sortedPairIndices[numOpcodeIDs * numOpcodeIDs];
    110110    pair<int, int>* currentPairIndex = sortedPairIndices;
    111     for (int i = 0; i < numBytecodeIDs; ++i)
    112         for (int j = 0; j < numBytecodeIDs; ++j)
     111    for (int i = 0; i < numOpcodeIDs; ++i)
     112        for (int j = 0; j < numOpcodeIDs; ++j)
    113113            *(currentPairIndex++) = make_pair(i, j);
    114     qsort(sortedPairIndices, numBytecodeIDs * numBytecodeIDs, sizeof(pair<int, int>), compareBytecodePairIndices);
     114    qsort(sortedPairIndices, numOpcodeIDs * numOpcodeIDs, sizeof(pair<int, int>), compareOpcodePairIndices);
    115115   
    116     printf("\nExecuted bytecode statistics\n");
     116    printf("\nExecuted opcode statistics\n");
    117117   
    118118    printf("Total instructions executed: %lld\n\n", totalInstructions);
    119119
    120     printf("All bytecodes by frequency:\n\n");
     120    printf("All opcodes by frequency:\n\n");
    121121
    122     for (int i = 0; i < numBytecodeIDs; ++i) {
     122    for (int i = 0; i < numOpcodeIDs; ++i) {
    123123        int index = sortedIndices[i];
    124         printf("%s:%s %lld - %.2f%%\n", bytecodeNames[index], padBytecodeName((BytecodeID)index, 28), bytecodeCounts[index], ((double) bytecodeCounts[index]) / ((double) totalInstructions) * 100.0);   
     124        printf("%s:%s %lld - %.2f%%\n", opcodeNames[index], padOpcodeName((OpcodeID)index, 28), opcodeCounts[index], ((double) opcodeCounts[index]) / ((double) totalInstructions) * 100.0);   
    125125    }
    126126   
    127127    printf("\n");
    128     printf("2-bytecode sequences by frequency: %lld\n\n", totalInstructions);
     128    printf("2-opcode sequences by frequency: %lld\n\n", totalInstructions);
    129129   
    130     for (int i = 0; i < numBytecodeIDs * numBytecodeIDs; ++i) {
     130    for (int i = 0; i < numOpcodeIDs * numOpcodeIDs; ++i) {
    131131        pair<int, int> indexPair = sortedPairIndices[i];
    132         long long count = bytecodePairCounts[indexPair.first][indexPair.second];
     132        long long count = opcodePairCounts[indexPair.first][indexPair.second];
    133133       
    134134        if (!count)
    135135            break;
    136136       
    137         printf("%s%s %s:%s %lld %.2f%%\n", bytecodeNames[indexPair.first], padBytecodeName((BytecodeID)indexPair.first, 28), bytecodeNames[indexPair.second], padBytecodeName((BytecodeID)indexPair.second, 28), count, ((double) count) / ((double) totalInstructionPairs) * 100.0);
     137        printf("%s%s %s:%s %lld %.2f%%\n", opcodeNames[indexPair.first], padOpcodeName((OpcodeID)indexPair.first, 28), opcodeNames[indexPair.second], padOpcodeName((OpcodeID)indexPair.second, 28), count, ((double) count) / ((double) totalInstructionPairs) * 100.0);
    138138    }
    139139   
    140140    printf("\n");
    141     printf("Most common bytecodes and sequences:\n");
     141    printf("Most common opcodes and sequences:\n");
    142142
    143     for (int i = 0; i < numBytecodeIDs; ++i) {
     143    for (int i = 0; i < numOpcodeIDs; ++i) {
    144144        int index = sortedIndices[i];
    145         long long bytecodeCount = bytecodeCounts[index];
    146         double bytecodeProportion = ((double) bytecodeCount) / ((double) totalInstructions);
    147         if (bytecodeProportion < 0.0001)
     145        long long opcodeCount = opcodeCounts[index];
     146        double opcodeProportion = ((double) opcodeCount) / ((double) totalInstructions);
     147        if (opcodeProportion < 0.0001)
    148148            break;
    149         printf("\n%s:%s %lld - %.2f%%\n", bytecodeNames[index], padBytecodeName((BytecodeID)index, 28), bytecodeCount, bytecodeProportion * 100.0);
     149        printf("\n%s:%s %lld - %.2f%%\n", opcodeNames[index], padOpcodeName((OpcodeID)index, 28), opcodeCount, opcodeProportion * 100.0);
    150150
    151         for (int j = 0; j < numBytecodeIDs * numBytecodeIDs; ++j) {
     151        for (int j = 0; j < numOpcodeIDs * numOpcodeIDs; ++j) {
    152152            pair<int, int> indexPair = sortedPairIndices[j];
    153             long long pairCount = bytecodePairCounts[indexPair.first][indexPair.second];
     153            long long pairCount = opcodePairCounts[indexPair.first][indexPair.second];
    154154            double pairProportion = ((double) pairCount) / ((double) totalInstructionPairs);
    155155       
    156             if (!pairCount || pairProportion < 0.0001 || pairProportion < bytecodeProportion / 100)
     156            if (!pairCount || pairProportion < 0.0001 || pairProportion < opcodeProportion / 100)
    157157                break;
    158158
     
    160160                continue;
    161161
    162             printf("    %s%s %s:%s %lld - %.2f%%\n", bytecodeNames[indexPair.first], padBytecodeName((BytecodeID)indexPair.first, 28), bytecodeNames[indexPair.second], padBytecodeName((BytecodeID)indexPair.second, 28), pairCount, pairProportion * 100.0);
     162            printf("    %s%s %s:%s %lld - %.2f%%\n", opcodeNames[indexPair.first], padOpcodeName((OpcodeID)indexPair.first, 28), opcodeNames[indexPair.second], padOpcodeName((OpcodeID)indexPair.second, 28), pairCount, pairProportion * 100.0);
    163163        }
    164164       
     
    167167}
    168168
    169 void BytecodeStats::recordInstruction(int bytecode)
     169void OpcodeStats::recordInstruction(int opcode)
    170170{
    171     bytecodeCounts[bytecode]++;
     171    opcodeCounts[opcode]++;
    172172   
    173     if (lastBytecode != -1)
    174         bytecodePairCounts[lastBytecode][bytecode]++;
     173    if (lastOpcode != -1)
     174        opcodePairCounts[lastOpcode][opcode]++;
    175175   
    176     lastBytecode = bytecode;
     176    lastOpcode = opcode;
    177177}
    178178
    179 void BytecodeStats::resetLastInstruction()
     179void OpcodeStats::resetLastInstruction()
    180180{
    181     lastBytecode = -1;
     181    lastOpcode = -1;
    182182}
    183183
Note: See TracChangeset for help on using the changeset viewer.