Changeset 50537 in webkit for trunk/JavaScriptCore/bytecode


Ignore:
Timestamp:
Nov 4, 2009, 6:22:08 PM (16 years ago)
Author:
[email protected]
Message:

Fix dumping of constants in bytecode so that they aren't printed as large positive register numbers.

Reviewed by Sam Weinig.

We do this by having the registerName function return information about the constant if the register
number corresponds to a constant. This requires that registerName, and several functions that call it,
be converted to member functions of CodeBlock so that the constant value can be retrieved. The
ExecState also needs to be threaded down through these functions so that it can be passed on to
constantName when needed.

  • bytecode/CodeBlock.cpp:

(JSC::constantName):
(JSC::CodeBlock::registerName):
(JSC::CodeBlock::printUnaryOp):
(JSC::CodeBlock::printBinaryOp):
(JSC::CodeBlock::printConditionalJump):
(JSC::CodeBlock::printGetByIdOp):
(JSC::CodeBlock::printPutByIdOp):
(JSC::CodeBlock::dump):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::isConstantRegisterIndex):

Location:
trunk/JavaScriptCore/bytecode
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.cpp

    r50254 r50537  
    7272}
    7373
    74 static CString registerName(int r)
     74static CString constantName(ExecState* exec, int k, JSValue value)
     75{
     76    return (valueToSourceString(exec, value) + "(@k" + UString::from(k - FirstConstantRegisterIndex) + ")").UTF8String();
     77}
     78
     79static CString idName(int id0, const Identifier& ident)
     80{
     81    return (ident.ustring() + "(@id" + UString::from(id0) +")").UTF8String();
     82}
     83
     84CString CodeBlock::registerName(ExecState* exec, int r) const
    7585{
    7686    if (r == missingThisObjectMarker())
    7787        return "<null>";
    7888
     89    if (isConstantRegisterIndex(r))
     90        return constantName(exec, r, getConstant(r));
     91
    7992    return (UString("r") + UString::from(r)).UTF8String();
    80 }
    81 
    82 static CString constantName(ExecState* exec, int k, JSValue value)
    83 {
    84     return (valueToSourceString(exec, value) + "(@k" + UString::from(k) + ")").UTF8String();
    85 }
    86 
    87 static CString idName(int id0, const Identifier& ident)
    88 {
    89     return (ident.ustring() + "(@id" + UString::from(id0) +")").UTF8String();
    9093}
    9194
     
    136139}
    137140
    138 static void printUnaryOp(int location, Vector<Instruction>::const_iterator& it, const char* op)
     141void CodeBlock::printUnaryOp(ExecState* exec, int location, Vector<Instruction>::const_iterator& it, const char* op) const
    139142{
    140143    int r0 = (++it)->u.operand;
    141144    int r1 = (++it)->u.operand;
    142145
    143     printf("[%4d] %s\t\t %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str());
    144 }
    145 
    146 static void printBinaryOp(int location, Vector<Instruction>::const_iterator& it, const char* op)
     146    printf("[%4d] %s\t\t %s, %s\n", location, op, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
     147}
     148
     149void CodeBlock::printBinaryOp(ExecState* exec, int location, Vector<Instruction>::const_iterator& it, const char* op) const
    147150{
    148151    int r0 = (++it)->u.operand;
    149152    int r1 = (++it)->u.operand;
    150153    int r2 = (++it)->u.operand;
    151     printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
    152 }
    153 
    154 static void printConditionalJump(const Vector<Instruction>::const_iterator&, Vector<Instruction>::const_iterator& it, int location, const char* op)
     154    printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
     155}
     156
     157void CodeBlock::printConditionalJump(ExecState* exec, const Vector<Instruction>::const_iterator&, Vector<Instruction>::const_iterator& it, int location, const char* op) const
    155158{
    156159    int r0 = (++it)->u.operand;
    157160    int offset = (++it)->u.operand;
    158     printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, location + offset);
    159 }
    160 
    161 static void printGetByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& m_identifiers, const char* op)
     161    printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(exec, r0).c_str(), offset, location + offset);
     162}
     163
     164void CodeBlock::printGetByIdOp(ExecState* exec, int location, Vector<Instruction>::const_iterator& it, const char* op) const
    162165{
    163166    int r0 = (++it)->u.operand;
    164167    int r1 = (++it)->u.operand;
    165168    int id0 = (++it)->u.operand;
    166     printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
     169    printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
    167170    it += 4;
    168171}
    169172
    170 static void printPutByIdOp(int location, Vector<Instruction>::const_iterator& it, const Vector<Identifier>& m_identifiers, const char* op)
     173void CodeBlock::printPutByIdOp(ExecState* exec, int location, Vector<Instruction>::const_iterator& it, const char* op) const
    171174{
    172175    int r0 = (++it)->u.operand;
    173176    int id0 = (++it)->u.operand;
    174177    int r1 = (++it)->u.operand;
    175     printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
     178    printf("[%4d] %s\t %s, %s, %s\n", location, op, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
    176179    it += 4;
    177180}
     
    358361        size_t i = 0;
    359362        do {
    360             printf("   r%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue()).ascii());
     363            printf("   k%u = %s\n", registerIndex, valueToSourceString(exec, m_constantRegisters[i].jsValue()).ascii());
    361364            ++i;
    362365            ++registerIndex;
     
    482485        case op_enter_with_activation: {
    483486            int r0 = (++it)->u.operand;
    484             printf("[%4d] enter_with_activation %s\n", location, registerName(r0).c_str());
     487            printf("[%4d] enter_with_activation %s\n", location, registerName(exec, r0).c_str());
    485488            break;
    486489        }
     
    495498        case op_convert_this: {
    496499            int r0 = (++it)->u.operand;
    497             printf("[%4d] convert_this %s\n", location, registerName(r0).c_str());
     500            printf("[%4d] convert_this %s\n", location, registerName(exec, r0).c_str());
    498501            break;
    499502        }
    500503        case op_new_object: {
    501504            int r0 = (++it)->u.operand;
    502             printf("[%4d] new_object\t %s\n", location, registerName(r0).c_str());
     505            printf("[%4d] new_object\t %s\n", location, registerName(exec, r0).c_str());
    503506            break;
    504507        }
     
    507510            int argv = (++it)->u.operand;
    508511            int argc = (++it)->u.operand;
    509             printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(dst).c_str(), registerName(argv).c_str(), argc);
     512            printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, argv).c_str(), argc);
    510513            break;
    511514        }
     
    513516            int r0 = (++it)->u.operand;
    514517            int re0 = (++it)->u.operand;
    515             printf("[%4d] new_regexp\t %s, %s\n", location, registerName(r0).c_str(), regexpName(re0, regexp(re0)).c_str());
     518            printf("[%4d] new_regexp\t %s, %s\n", location, registerName(exec, r0).c_str(), regexpName(re0, regexp(re0)).c_str());
    516519            break;
    517520        }
     
    519522            int r0 = (++it)->u.operand;
    520523            int r1 = (++it)->u.operand;
    521             printf("[%4d] mov\t\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str());
     524            printf("[%4d] mov\t\t %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
    522525            break;
    523526        }
    524527        case op_not: {
    525             printUnaryOp(location, it, "not");
     528            printUnaryOp(exec, location, it, "not");
    526529            break;
    527530        }
    528531        case op_eq: {
    529             printBinaryOp(location, it, "eq");
     532            printBinaryOp(exec, location, it, "eq");
    530533            break;
    531534        }
    532535        case op_eq_null: {
    533             printUnaryOp(location, it, "eq_null");
     536            printUnaryOp(exec, location, it, "eq_null");
    534537            break;
    535538        }
    536539        case op_neq: {
    537             printBinaryOp(location, it, "neq");
     540            printBinaryOp(exec, location, it, "neq");
    538541            break;
    539542        }
    540543        case op_neq_null: {
    541             printUnaryOp(location, it, "neq_null");
     544            printUnaryOp(exec, location, it, "neq_null");
    542545            break;
    543546        }
    544547        case op_stricteq: {
    545             printBinaryOp(location, it, "stricteq");
     548            printBinaryOp(exec, location, it, "stricteq");
    546549            break;
    547550        }
    548551        case op_nstricteq: {
    549             printBinaryOp(location, it, "nstricteq");
     552            printBinaryOp(exec, location, it, "nstricteq");
    550553            break;
    551554        }
    552555        case op_less: {
    553             printBinaryOp(location, it, "less");
     556            printBinaryOp(exec, location, it, "less");
    554557            break;
    555558        }
    556559        case op_lesseq: {
    557             printBinaryOp(location, it, "lesseq");
     560            printBinaryOp(exec, location, it, "lesseq");
    558561            break;
    559562        }
    560563        case op_pre_inc: {
    561564            int r0 = (++it)->u.operand;
    562             printf("[%4d] pre_inc\t\t %s\n", location, registerName(r0).c_str());
     565            printf("[%4d] pre_inc\t\t %s\n", location, registerName(exec, r0).c_str());
    563566            break;
    564567        }
    565568        case op_pre_dec: {
    566569            int r0 = (++it)->u.operand;
    567             printf("[%4d] pre_dec\t\t %s\n", location, registerName(r0).c_str());
     570            printf("[%4d] pre_dec\t\t %s\n", location, registerName(exec, r0).c_str());
    568571            break;
    569572        }
    570573        case op_post_inc: {
    571             printUnaryOp(location, it, "post_inc");
     574            printUnaryOp(exec, location, it, "post_inc");
    572575            break;
    573576        }
    574577        case op_post_dec: {
    575             printUnaryOp(location, it, "post_dec");
     578            printUnaryOp(exec, location, it, "post_dec");
    576579            break;
    577580        }
    578581        case op_to_jsnumber: {
    579             printUnaryOp(location, it, "to_jsnumber");
     582            printUnaryOp(exec, location, it, "to_jsnumber");
    580583            break;
    581584        }
    582585        case op_negate: {
    583             printUnaryOp(location, it, "negate");
     586            printUnaryOp(exec, location, it, "negate");
    584587            break;
    585588        }
    586589        case op_add: {
    587             printBinaryOp(location, it, "add");
     590            printBinaryOp(exec, location, it, "add");
    588591            ++it;
    589592            break;
    590593        }
    591594        case op_mul: {
    592             printBinaryOp(location, it, "mul");
     595            printBinaryOp(exec, location, it, "mul");
    593596            ++it;
    594597            break;
    595598        }
    596599        case op_div: {
    597             printBinaryOp(location, it, "div");
     600            printBinaryOp(exec, location, it, "div");
    598601            ++it;
    599602            break;
    600603        }
    601604        case op_mod: {
    602             printBinaryOp(location, it, "mod");
     605            printBinaryOp(exec, location, it, "mod");
    603606            break;
    604607        }
    605608        case op_sub: {
    606             printBinaryOp(location, it, "sub");
     609            printBinaryOp(exec, location, it, "sub");
    607610            ++it;
    608611            break;
    609612        }
    610613        case op_lshift: {
    611             printBinaryOp(location, it, "lshift");
     614            printBinaryOp(exec, location, it, "lshift");
    612615            break;           
    613616        }
    614617        case op_rshift: {
    615             printBinaryOp(location, it, "rshift");
     618            printBinaryOp(exec, location, it, "rshift");
    616619            break;
    617620        }
    618621        case op_urshift: {
    619             printBinaryOp(location, it, "urshift");
     622            printBinaryOp(exec, location, it, "urshift");
    620623            break;
    621624        }
    622625        case op_bitand: {
    623             printBinaryOp(location, it, "bitand");
     626            printBinaryOp(exec, location, it, "bitand");
    624627            ++it;
    625628            break;
    626629        }
    627630        case op_bitxor: {
    628             printBinaryOp(location, it, "bitxor");
     631            printBinaryOp(exec, location, it, "bitxor");
    629632            ++it;
    630633            break;
    631634        }
    632635        case op_bitor: {
    633             printBinaryOp(location, it, "bitor");
     636            printBinaryOp(exec, location, it, "bitor");
    634637            ++it;
    635638            break;
    636639        }
    637640        case op_bitnot: {
    638             printUnaryOp(location, it, "bitnot");
     641            printUnaryOp(exec, location, it, "bitnot");
    639642            break;
    640643        }
     
    644647            int r2 = (++it)->u.operand;
    645648            int r3 = (++it)->u.operand;
    646             printf("[%4d] instanceof\t\t %s, %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), registerName(r3).c_str());
     649            printf("[%4d] instanceof\t\t %s, %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str(), registerName(exec, r3).c_str());
    647650            break;
    648651        }
    649652        case op_typeof: {
    650             printUnaryOp(location, it, "typeof");
     653            printUnaryOp(exec, location, it, "typeof");
    651654            break;
    652655        }
    653656        case op_is_undefined: {
    654             printUnaryOp(location, it, "is_undefined");
     657            printUnaryOp(exec, location, it, "is_undefined");
    655658            break;
    656659        }
    657660        case op_is_boolean: {
    658             printUnaryOp(location, it, "is_boolean");
     661            printUnaryOp(exec, location, it, "is_boolean");
    659662            break;
    660663        }
    661664        case op_is_number: {
    662             printUnaryOp(location, it, "is_number");
     665            printUnaryOp(exec, location, it, "is_number");
    663666            break;
    664667        }
    665668        case op_is_string: {
    666             printUnaryOp(location, it, "is_string");
     669            printUnaryOp(exec, location, it, "is_string");
    667670            break;
    668671        }
    669672        case op_is_object: {
    670             printUnaryOp(location, it, "is_object");
     673            printUnaryOp(exec, location, it, "is_object");
    671674            break;
    672675        }
    673676        case op_is_function: {
    674             printUnaryOp(location, it, "is_function");
     677            printUnaryOp(exec, location, it, "is_function");
    675678            break;
    676679        }
    677680        case op_in: {
    678             printBinaryOp(location, it, "in");
     681            printBinaryOp(exec, location, it, "in");
    679682            break;
    680683        }
     
    682685            int r0 = (++it)->u.operand;
    683686            int id0 = (++it)->u.operand;
    684             printf("[%4d] resolve\t\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
     687            printf("[%4d] resolve\t\t %s, %s\n", location, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
    685688            break;
    686689        }
     
    689692            int id0 = (++it)->u.operand;
    690693            int skipLevels = (++it)->u.operand;
    691             printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), skipLevels);
     694            printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), skipLevels);
    692695            break;
    693696        }
     
    696699            JSValue scope = JSValue((++it)->u.jsCell);
    697700            int id0 = (++it)->u.operand;
    698             printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), idName(id0, m_identifiers[id0]).c_str());
     701            printf("[%4d] resolve_global\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), valueToSourceString(exec, scope).ascii(), idName(id0, m_identifiers[id0]).c_str());
    699702            it += 2;
    700703            break;
     
    704707            int index = (++it)->u.operand;
    705708            int skipLevels = (++it)->u.operand;
    706             printf("[%4d] get_scoped_var\t %s, %d, %d\n", location, registerName(r0).c_str(), index, skipLevels);
     709            printf("[%4d] get_scoped_var\t %s, %d, %d\n", location, registerName(exec, r0).c_str(), index, skipLevels);
    707710            break;
    708711        }
     
    711714            int skipLevels = (++it)->u.operand;
    712715            int r0 = (++it)->u.operand;
    713             printf("[%4d] put_scoped_var\t %d, %d, %s\n", location, index, skipLevels, registerName(r0).c_str());
     716            printf("[%4d] put_scoped_var\t %d, %d, %s\n", location, index, skipLevels, registerName(exec, r0).c_str());
    714717            break;
    715718        }
     
    718721            JSValue scope = JSValue((++it)->u.jsCell);
    719722            int index = (++it)->u.operand;
    720             printf("[%4d] get_global_var\t %s, %s, %d\n", location, registerName(r0).c_str(), valueToSourceString(exec, scope).ascii(), index);
     723            printf("[%4d] get_global_var\t %s, %s, %d\n", location, registerName(exec, r0).c_str(), valueToSourceString(exec, scope).ascii(), index);
    721724            break;
    722725        }
     
    725728            int index = (++it)->u.operand;
    726729            int r0 = (++it)->u.operand;
    727             printf("[%4d] put_global_var\t %s, %d, %s\n", location, valueToSourceString(exec, scope).ascii(), index, registerName(r0).c_str());
     730            printf("[%4d] put_global_var\t %s, %d, %s\n", location, valueToSourceString(exec, scope).ascii(), index, registerName(exec, r0).c_str());
    728731            break;
    729732        }
     
    731734            int r0 = (++it)->u.operand;
    732735            int id0 = (++it)->u.operand;
    733             printf("[%4d] resolve_base\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
     736            printf("[%4d] resolve_base\t %s, %s\n", location, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str());
    734737            break;
    735738        }
     
    738741            int r1 = (++it)->u.operand;
    739742            int id0 = (++it)->u.operand;
    740             printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
     743            printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
    741744            break;
    742745        }
    743746        case op_get_by_id: {
    744             printGetByIdOp(location, it, m_identifiers, "get_by_id");
     747            printGetByIdOp(exec, location, it, "get_by_id");
    745748            break;
    746749        }
    747750        case op_get_by_id_self: {
    748             printGetByIdOp(location, it, m_identifiers, "get_by_id_self");
     751            printGetByIdOp(exec, location, it, "get_by_id_self");
    749752            break;
    750753        }
    751754        case op_get_by_id_self_list: {
    752             printGetByIdOp(location, it, m_identifiers, "get_by_id_self_list");
     755            printGetByIdOp(exec, location, it, "get_by_id_self_list");
    753756            break;
    754757        }
    755758        case op_get_by_id_proto: {
    756             printGetByIdOp(location, it, m_identifiers, "get_by_id_proto");
     759            printGetByIdOp(exec, location, it, "get_by_id_proto");
    757760            break;
    758761        }
    759762        case op_get_by_id_proto_list: {
    760             printGetByIdOp(location, it, m_identifiers, "op_get_by_id_proto_list");
     763            printGetByIdOp(exec, location, it, "op_get_by_id_proto_list");
    761764            break;
    762765        }
    763766        case op_get_by_id_chain: {
    764             printGetByIdOp(location, it, m_identifiers, "get_by_id_chain");
     767            printGetByIdOp(exec, location, it, "get_by_id_chain");
    765768            break;
    766769        }
    767770        case op_get_by_id_generic: {
    768             printGetByIdOp(location, it, m_identifiers, "get_by_id_generic");
     771            printGetByIdOp(exec, location, it, "get_by_id_generic");
    769772            break;
    770773        }
    771774        case op_get_array_length: {
    772             printGetByIdOp(location, it, m_identifiers, "get_array_length");
     775            printGetByIdOp(exec, location, it, "get_array_length");
    773776            break;
    774777        }
    775778        case op_get_string_length: {
    776             printGetByIdOp(location, it, m_identifiers, "get_string_length");
     779            printGetByIdOp(exec, location, it, "get_string_length");
    777780            break;
    778781        }
    779782        case op_put_by_id: {
    780             printPutByIdOp(location, it, m_identifiers, "put_by_id");
     783            printPutByIdOp(exec, location, it, "put_by_id");
    781784            break;
    782785        }
    783786        case op_put_by_id_replace: {
    784             printPutByIdOp(location, it, m_identifiers, "put_by_id_replace");
     787            printPutByIdOp(exec, location, it, "put_by_id_replace");
    785788            break;
    786789        }
    787790        case op_put_by_id_transition: {
    788             printPutByIdOp(location, it, m_identifiers, "put_by_id_transition");
     791            printPutByIdOp(exec, location, it, "put_by_id_transition");
    789792            break;
    790793        }
    791794        case op_put_by_id_generic: {
    792             printPutByIdOp(location, it, m_identifiers, "put_by_id_generic");
     795            printPutByIdOp(exec, location, it, "put_by_id_generic");
    793796            break;
    794797        }
     
    797800            int id0 = (++it)->u.operand;
    798801            int r1 = (++it)->u.operand;
    799             printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
     802            printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
    800803            break;
    801804        }
     
    804807            int id0 = (++it)->u.operand;
    805808            int r1 = (++it)->u.operand;
    806             printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
     809            printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
    807810            break;
    808811        }
     
    815818            int r1 = (++it)->u.operand;
    816819            int id0 = (++it)->u.operand;
    817             printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
     820            printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), idName(id0, m_identifiers[id0]).c_str());
    818821            break;
    819822        }
     
    822825            int r1 = (++it)->u.operand;
    823826            int r2 = (++it)->u.operand;
    824             printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
     827            printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
    825828            break;
    826829        }
     
    832835            int r4 = (++it)->u.operand;
    833836            int r5 = (++it)->u.operand;
    834             printf("[%4d] get_by_pname\t %s, %s, %s, %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), registerName(r3).c_str(), registerName(r4).c_str(), registerName(r5).c_str());
     837            printf("[%4d] get_by_pname\t %s, %s, %s, %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str(), registerName(exec, r3).c_str(), registerName(exec, r4).c_str(), registerName(exec, r5).c_str());
    835838            break;
    836839        }
     
    839842            int r1 = (++it)->u.operand;
    840843            int r2 = (++it)->u.operand;
    841             printf("[%4d] put_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
     844            printf("[%4d] put_by_val\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
    842845            break;
    843846        }
     
    846849            int r1 = (++it)->u.operand;
    847850            int r2 = (++it)->u.operand;
    848             printf("[%4d] del_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
     851            printf("[%4d] del_by_val\t %s, %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str());
    849852            break;
    850853        }
     
    853856            unsigned n0 = (++it)->u.operand;
    854857            int r1 = (++it)->u.operand;
    855             printf("[%4d] put_by_index\t %s, %u, %s\n", location, registerName(r0).c_str(), n0, registerName(r1).c_str());
     858            printf("[%4d] put_by_index\t %s, %u, %s\n", location, registerName(exec, r0).c_str(), n0, registerName(exec, r1).c_str());
    856859            break;
    857860        }
     
    867870        }
    868871        case op_jtrue: {
    869             printConditionalJump(begin, it, location, "jtrue");
     872            printConditionalJump(exec, begin, it, location, "jtrue");
    870873            break;
    871874        }
    872875        case op_loop_if_true: {
    873             printConditionalJump(begin, it, location, "loop_if_true");
     876            printConditionalJump(exec, begin, it, location, "loop_if_true");
    874877            break;
    875878        }
    876879        case op_jfalse: {
    877             printConditionalJump(begin, it, location, "jfalse");
     880            printConditionalJump(exec, begin, it, location, "jfalse");
    878881            break;
    879882        }
    880883        case op_jeq_null: {
    881             printConditionalJump(begin, it, location, "jeq_null");
     884            printConditionalJump(exec, begin, it, location, "jeq_null");
    882885            break;
    883886        }
    884887        case op_jneq_null: {
    885             printConditionalJump(begin, it, location, "jneq_null");
     888            printConditionalJump(exec, begin, it, location, "jneq_null");
    886889            break;
    887890        }
     
    890893            int r1 = (++it)->u.operand;
    891894            int offset = (++it)->u.operand;
    892             printf("[%4d] jneq_ptr\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset);
     895            printf("[%4d] jneq_ptr\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
    893896            break;
    894897        }
     
    897900            int r1 = (++it)->u.operand;
    898901            int offset = (++it)->u.operand;
    899             printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset);
     902            printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
    900903            break;
    901904        }
     
    904907            int r1 = (++it)->u.operand;
    905908            int offset = (++it)->u.operand;
    906             printf("[%4d] jnlesseq\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset);
     909            printf("[%4d] jnlesseq\t\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
    907910            break;
    908911        }
     
    911914            int r1 = (++it)->u.operand;
    912915            int offset = (++it)->u.operand;
    913             printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset);
     916            printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
    914917            break;
    915918        }
     
    918921            int r1 = (++it)->u.operand;
    919922            int offset = (++it)->u.operand;
    920             printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset);
     923            printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), offset, location + offset);
    921924            break;
    922925        }
     
    925928            int defaultTarget = (++it)->u.operand;
    926929            int scrutineeRegister = (++it)->u.operand;
    927             printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).c_str());
     930            printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(exec, scrutineeRegister).c_str());
    928931            break;
    929932        }
     
    932935            int defaultTarget = (++it)->u.operand;
    933936            int scrutineeRegister = (++it)->u.operand;
    934             printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).c_str());
     937            printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(exec, scrutineeRegister).c_str());
    935938            break;
    936939        }
     
    939942            int defaultTarget = (++it)->u.operand;
    940943            int scrutineeRegister = (++it)->u.operand;
    941             printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).c_str());
     944            printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(exec, scrutineeRegister).c_str());
    942945            break;
    943946        }
     
    945948            int r0 = (++it)->u.operand;
    946949            int f0 = (++it)->u.operand;
    947             printf("[%4d] new_func\t\t %s, f%d\n", location, registerName(r0).c_str(), f0);
     950            printf("[%4d] new_func\t\t %s, f%d\n", location, registerName(exec, r0).c_str(), f0);
    948951            break;
    949952        }
     
    951954            int r0 = (++it)->u.operand;
    952955            int f0 = (++it)->u.operand;
    953             printf("[%4d] new_func_exp\t %s, f%d\n", location, registerName(r0).c_str(), f0);
     956            printf("[%4d] new_func_exp\t %s, f%d\n", location, registerName(exec, r0).c_str(), f0);
    954957            break;
    955958        }
     
    959962            int argCount = (++it)->u.operand;
    960963            int registerOffset = (++it)->u.operand;
    961             printf("[%4d] call\t\t %s, %s, %d, %d\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset);
     964            printf("[%4d] call\t\t %s, %s, %d, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), argCount, registerOffset);
    962965            break;
    963966        }
     
    967970            int argCount = (++it)->u.operand;
    968971            int registerOffset = (++it)->u.operand;
    969             printf("[%4d] call_eval\t %s, %s, %d, %d\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset);
     972            printf("[%4d] call_eval\t %s, %s, %d, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), argCount, registerOffset);
    970973            break;
    971974        }
     
    975978            int argCount = (++it)->u.operand;
    976979            int registerOffset = (++it)->u.operand;
    977             printf("[%4d] call_varargs\t %s, %s, %s, %d\n", location, registerName(dst).c_str(), registerName(func).c_str(), registerName(argCount).c_str(), registerOffset);
     980            printf("[%4d] call_varargs\t %s, %s, %s, %d\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), registerName(exec, argCount).c_str(), registerOffset);
    978981            break;
    979982        }
    980983        case op_load_varargs: {
    981             printUnaryOp(location, it, "load_varargs");
     984            printUnaryOp(exec, location, it, "load_varargs");
    982985            break;
    983986        }
    984987        case op_tear_off_activation: {
    985988            int r0 = (++it)->u.operand;
    986             printf("[%4d] tear_off_activation\t %s\n", location, registerName(r0).c_str());
     989            printf("[%4d] tear_off_activation\t %s\n", location, registerName(exec, r0).c_str());
    987990            break;
    988991        }
     
    993996        case op_ret: {
    994997            int r0 = (++it)->u.operand;
    995             printf("[%4d] ret\t\t %s\n", location, registerName(r0).c_str());
     998            printf("[%4d] ret\t\t %s\n", location, registerName(exec, r0).c_str());
    996999            break;
    9971000        }
     
    10031006            int proto = (++it)->u.operand;
    10041007            int thisRegister = (++it)->u.operand;
    1005             printf("[%4d] construct\t %s, %s, %d, %d, %s, %s\n", location, registerName(dst).c_str(), registerName(func).c_str(), argCount, registerOffset, registerName(proto).c_str(), registerName(thisRegister).c_str());
     1008            printf("[%4d] construct\t %s, %s, %d, %d, %s, %s\n", location, registerName(exec, dst).c_str(), registerName(exec, func).c_str(), argCount, registerOffset, registerName(exec, proto).c_str(), registerName(exec, thisRegister).c_str());
    10061009            break;
    10071010        }
     
    10091012            int r0 = (++it)->u.operand;
    10101013            int r1 = (++it)->u.operand;
    1011             printf("[%4d] construct_verify\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str());
     1014            printf("[%4d] construct_verify\t %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
    10121015            break;
    10131016        }
     
    10161019            int r1 = (++it)->u.operand;
    10171020            int count = (++it)->u.operand;
    1018             printf("[%4d] op_strcat\t %s, %s, %d\n", location, registerName(r0).c_str(), registerName(r1).c_str(), count);
     1021            printf("[%4d] op_strcat\t %s, %s, %d\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), count);
    10191022            break;
    10201023        }
     
    10221025            int r0 = (++it)->u.operand;
    10231026            int r1 = (++it)->u.operand;
    1024             printf("[%4d] op_to_primitive\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str());
     1027            printf("[%4d] op_to_primitive\t %s, %s\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str());
    10251028            break;
    10261029        }
     
    10311034            int r3 = it[4].u.operand;
    10321035            int offset = it[5].u.operand;
    1033             printf("[%4d] get_pnames\t %s, %s, %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), registerName(r3).c_str(), offset, location + offset);
     1036            printf("[%4d] get_pnames\t %s, %s, %s, %s, %d(->%d)\n", location, registerName(exec, r0).c_str(), registerName(exec, r1).c_str(), registerName(exec, r2).c_str(), registerName(exec, r3).c_str(), offset, location + offset);
    10341037            it += OPCODE_LENGTH(op_get_pnames) - 1;
    10351038            break;
     
    10391042            int iter = it[4].u.operand;
    10401043            int offset = it[5].u.operand;
    1041             printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, location + offset);
     1044            printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(exec, dest).c_str(), registerName(exec, iter).c_str(), offset, location + offset);
    10421045            it += OPCODE_LENGTH(op_next_pname) - 1;
    10431046            break;
     
    10451048        case op_push_scope: {
    10461049            int r0 = (++it)->u.operand;
    1047             printf("[%4d] push_scope\t %s\n", location, registerName(r0).c_str());
     1050            printf("[%4d] push_scope\t %s\n", location, registerName(exec, r0).c_str());
    10481051            break;
    10491052        }
     
    10561059            int id0 = (++it)->u.operand;
    10571060            int r1 = (++it)->u.operand;
    1058             printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(r1).c_str());
     1061            printf("[%4d] push_new_scope \t%s, %s, %s\n", location, registerName(exec, r0).c_str(), idName(id0, m_identifiers[id0]).c_str(), registerName(exec, r1).c_str());
    10591062            break;
    10601063        }
     
    10671070        case op_catch: {
    10681071            int r0 = (++it)->u.operand;
    1069             printf("[%4d] catch\t\t %s\n", location, registerName(r0).c_str());
     1072            printf("[%4d] catch\t\t %s\n", location, registerName(exec, r0).c_str());
    10701073            break;
    10711074        }
    10721075        case op_throw: {
    10731076            int r0 = (++it)->u.operand;
    1074             printf("[%4d] throw\t\t %s\n", location, registerName(r0).c_str());
     1077            printf("[%4d] throw\t\t %s\n", location, registerName(exec, r0).c_str());
    10751078            break;
    10761079        }
     
    10791082            int errorType = (++it)->u.operand;
    10801083            int k0 = (++it)->u.operand;
    1081             printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, getConstant(k0)).c_str());
     1084            printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(exec, r0).c_str(), errorType, constantName(exec, k0, getConstant(k0)).c_str());
    10821085            break;
    10831086        }
     
    10851088            int retAddrDst = (++it)->u.operand;
    10861089            int offset = (++it)->u.operand;
    1087             printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, location + offset);
     1090            printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(exec, retAddrDst).c_str(), offset, location + offset);
    10881091            break;
    10891092        }
    10901093        case op_sret: {
    10911094            int retAddrSrc = (++it)->u.operand;
    1092             printf("[%4d] sret\t\t %s\n", location, registerName(retAddrSrc).c_str());
     1095            printf("[%4d] sret\t\t %s\n", location, registerName(exec, retAddrSrc).c_str());
    10931096            break;
    10941097        }
     
    11021105        case op_profile_will_call: {
    11031106            int function = (++it)->u.operand;
    1104             printf("[%4d] profile_will_call %s\n", location, registerName(function).c_str());
     1107            printf("[%4d] profile_will_call %s\n", location, registerName(exec, function).c_str());
    11051108            break;
    11061109        }
    11071110        case op_profile_did_call: {
    11081111            int function = (++it)->u.operand;
    1109             printf("[%4d] profile_did_call\t %s\n", location, registerName(function).c_str());
     1112            printf("[%4d] profile_did_call\t %s\n", location, registerName(exec, function).c_str());
    11101113            break;
    11111114        }
    11121115        case op_end: {
    11131116            int r0 = (++it)->u.operand;
    1114             printf("[%4d] end\t\t %s\n", location, registerName(r0).c_str());
     1117            printf("[%4d] end\t\t %s\n", location, registerName(exec, r0).c_str());
    11151118            break;
    11161119        }
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r48836 r50537  
    439439        void addConstantRegister(const Register& r) { return m_constantRegisters.append(r); }
    440440        Register& constantRegister(int index) { return m_constantRegisters[index - FirstConstantRegisterIndex]; }
    441         ALWAYS_INLINE bool isConstantRegisterIndex(int index) { return index >= FirstConstantRegisterIndex; }
     441        ALWAYS_INLINE bool isConstantRegisterIndex(int index) const { return index >= FirstConstantRegisterIndex; }
    442442        ALWAYS_INLINE JSValue getConstant(int index) const { return m_constantRegisters[index - FirstConstantRegisterIndex].jsValue(); }
    443443
     
    483483#if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING)
    484484        void dump(ExecState*, const Vector<Instruction>::const_iterator& begin, Vector<Instruction>::const_iterator&) const;
     485
     486        CString registerName(ExecState*, int r) const;
     487        void printUnaryOp(ExecState*, int location, Vector<Instruction>::const_iterator&, const char* op) const;
     488        void printBinaryOp(ExecState*, int location, Vector<Instruction>::const_iterator&, const char* op) const;
     489        void printConditionalJump(ExecState*, const Vector<Instruction>::const_iterator&, Vector<Instruction>::const_iterator&, int location, const char* op) const;
     490        void printGetByIdOp(ExecState*, int location, Vector<Instruction>::const_iterator&, const char* op) const;
     491        void printPutByIdOp(ExecState*, int location, Vector<Instruction>::const_iterator&, const char* op) const;
    485492#endif
    486493
Note: See TracChangeset for help on using the changeset viewer.