Ignore:
Timestamp:
May 27, 2008, 4:22:52 PM (17 years ago)
Author:
Adam Roben
Message:

add printInstruction

File:
1 edited

Legend:

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

    r34105 r34156  
    113113}
    114114
     115static void printInstruction(const char* name, int location, const char* argumentsFormat = 0, ...)
     116{
     117    printf("[%4d] %-20s ", location, name);
     118
     119    if (argumentsFormat) {
     120        va_list arguments;
     121        va_start(arguments, argumentsFormat);
     122        vprintf(argumentsFormat, arguments);
     123        va_end(arguments);
     124    }
     125
     126    printf("\n");
     127}
     128
    115129static void printUnaryOp(int location, Vector<Instruction>::const_iterator& it, const char* op)
    116130{
     
    118132    int r1 = (++it)->u.operand;
    119133
    120     printf("[%4d] %s\t\t %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str());
     134    printInstruction(op, location, "%s, %s", registerName(r0).c_str(), registerName(r1).c_str());
    121135}
    122136
     
    126140    int r1 = (++it)->u.operand;
    127141    int r2 = (++it)->u.operand;
    128     printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
     142    printInstruction(op, location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
    129143}
    130144
     
    133147    int r0 = (++it)->u.operand;
    134148    int offset = (++it)->u.operand;
    135     printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, jumpTarget(begin, it, offset));
     149    printInstruction(op, location, "%s, %d(->%d)", registerName(r0).c_str(), offset, jumpTarget(begin, it, offset));
    136150}
    137151
     
    197211            int r0 = (++it)->u.operand;
    198212            int k0 = (++it)->u.operand;
    199             printf("[%4d] load\t\t %s, %s\t\t\n", location, registerName(r0).c_str(), constantName(exec, k0, jsValues[k0]).c_str());
     213            printInstruction("load", location, "%s, %s", registerName(r0).c_str(), constantName(exec, k0, jsValues[k0]).c_str());
    200214            break;
    201215        }
    202216        case op_new_object: {
    203217            int r0 = (++it)->u.operand;
    204             printf("[%4d] new_object\t %s\n", location, registerName(r0).c_str());
     218            printInstruction("new_object", location, "%s", registerName(r0).c_str());
    205219            break;
    206220        }
    207221        case op_new_array: {
    208222            int r0 = (++it)->u.operand;
    209             printf("[%4d] new_array\t %s\n", location, registerName(r0).c_str());
     223            printInstruction("new_array", location, "%s", registerName(r0).c_str());
    210224            break;
    211225        }
     
    213227            int r0 = (++it)->u.operand;
    214228            int re0 = (++it)->u.operand;
    215             printf("[%4d] new_regexp\t %s, %s\n", location, registerName(r0).c_str(), regexpName(re0, regexps[re0].get()).c_str());
     229            printInstruction("new_regexp", location, "%s, %s", registerName(r0).c_str(), regexpName(re0, regexps[re0].get()).c_str());
    216230            break;
    217231        }
     
    219233            int r0 = (++it)->u.operand;
    220234            int r1 = (++it)->u.operand;
    221             printf("[%4d] mov\t\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str());
     235            printInstruction("mov", location, "%s, %s", registerName(r0).c_str(), registerName(r1).c_str());
    222236            break;
    223237        }
     
    252266        case op_pre_inc: {
    253267            int r0 = (++it)->u.operand;
    254             printf("[%4d] pre_inc\t\t %s\n", location, registerName(r0).c_str());
     268            printInstruction("pre_inc", location, "%s", registerName(r0).c_str());
    255269            break;
    256270        }
    257271        case op_pre_dec: {
    258272            int r0 = (++it)->u.operand;
    259             printf("[%4d] pre_dec\t\t %s\n", location, registerName(r0).c_str());
     273            printInstruction("pre_dec", location, "%s", registerName(r0).c_str());
    260274            break;
    261275        }
     
    339353            int r0 = (++it)->u.operand;
    340354            int id0 = (++it)->u.operand;
    341             printf("[%4d] resolve\t\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str());
     355            printInstruction("resolve", location, "%s, %s", registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str());
    342356            break;
    343357        }
     
    346360            int id0 = (++it)->u.operand;
    347361            int skipLevels = (++it)->u.operand;
    348             printf("[%4d] resolve_skip\t %s, %s, %d\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), skipLevels);
     362            printInstruction("resolve_skip", location, "%s, %s, %d", registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), skipLevels);
    349363            break;
    350364        }
     
    353367            int index = (++it)->u.operand;
    354368            int skipLevels = (++it)->u.operand;
    355             printf("[%4d] get_scoped_var\t\t %s, %d, %d\n", location, registerName(r0).c_str(), index, skipLevels);
     369            printInstruction("get_scoped_var", location, "%s, %d, %d", registerName(r0).c_str(), index, skipLevels);
    356370            break;
    357371        }
     
    360374            int skipLevels = (++it)->u.operand;
    361375            int r0 = (++it)->u.operand;
    362             printf("[%4d] put_scoped_var\t\t %d, %d, %s\n", location, index, skipLevels, registerName(r0).c_str());
     376            printInstruction("put_scoped_var", location, "%d, %d, %s", index, skipLevels, registerName(r0).c_str());
    363377            break;
    364378        }
     
    366380            int r0 = (++it)->u.operand;
    367381            int id0 = (++it)->u.operand;
    368             printf("[%4d] resolve_base\t %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str());
     382            printInstruction("resolve_base", location, "%s, %s", registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str());
    369383            break;
    370384        }
     
    373387            int r1 = (++it)->u.operand;
    374388            int id0 = (++it)->u.operand;
    375             printf("[%4d] resolve_with_base %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
     389            printInstruction("resolve_with_base", location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
    376390            break;
    377391        }
     
    380394            int r1 = (++it)->u.operand;
    381395            int id0 = (++it)->u.operand;
    382             printf("[%4d] resolve_func\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
     396            printInstruction("resolve_func", location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
    383397            break;
    384398        }
     
    387401            int r1 = (++it)->u.operand;
    388402            int id0 = (++it)->u.operand;
    389             printf("[%4d] get_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
     403            printInstruction("get_by_id", location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
    390404            break;
    391405        }
     
    394408            int id0 = (++it)->u.operand;
    395409            int r1 = (++it)->u.operand;
    396             printf("[%4d] put_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
     410            printInstruction("put_by_id", location, "%s, %s, %s", registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
    397411            break;
    398412        }
     
    401415            int id0 = (++it)->u.operand;
    402416            int r1 = (++it)->u.operand;
    403             printf("[%4d] put_getter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
     417            printInstruction("put_getter", location, "%s, %s, %s", registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
    404418            break;
    405419        }
     
    408422            int id0 = (++it)->u.operand;
    409423            int r1 = (++it)->u.operand;
    410             printf("[%4d] put_setter\t %s, %s, %s\n", location, registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
     424            printInstruction("put_setter", location, "%s, %s, %s", registerName(r0).c_str(), idName(id0, identifiers[id0]).c_str(), registerName(r1).c_str());
    411425            break;
    412426        }
     
    415429            int r1 = (++it)->u.operand;
    416430            int id0 = (++it)->u.operand;
    417             printf("[%4d] del_by_id\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
     431            printInstruction("del_by_id", location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), idName(id0, identifiers[id0]).c_str());
    418432            break;
    419433        }
     
    422436            int r1 = (++it)->u.operand;
    423437            int r2 = (++it)->u.operand;
    424             printf("[%4d] get_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
     438            printInstruction("get_by_val", location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
    425439            break;
    426440        }
     
    429443            int r1 = (++it)->u.operand;
    430444            int r2 = (++it)->u.operand;
    431             printf("[%4d] put_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
     445            printInstruction("put_by_val", location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
    432446            break;
    433447        }
     
    436450            int r1 = (++it)->u.operand;
    437451            int r2 = (++it)->u.operand;
    438             printf("[%4d] del_by_val\t %s, %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
     452            printInstruction("del_by_val", location, "%s, %s, %s", registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str());
    439453            break;
    440454        }
     
    443457            unsigned n0 = (++it)->u.operand;
    444458            int r1 = (++it)->u.operand;
    445             printf("[%4d] put_by_index\t %s, %u, %s\n", location, registerName(r0).c_str(), n0, registerName(r1).c_str());
     459            printInstruction("put_by_index", location, "%s, %u, %s", registerName(r0).c_str(), n0, registerName(r1).c_str());
    446460            break;
    447461        }
    448462        case op_jmp: {
    449463            int offset = (++it)->u.operand;
    450             printf("[%4d] jmp\t\t %d(->%d)\n", location, offset, jumpTarget(begin, it, offset));
     464            printInstruction("jmp", location, "%d(->%d)", offset, jumpTarget(begin, it, offset));
    451465            break;
    452466        }
     
    462476            int r0 = (++it)->u.operand;
    463477            int f0 = (++it)->u.operand;
    464             printf("[%4d] new_func\t\t %s, f%d\n", location, registerName(r0).c_str(), f0);
     478            printInstruction("new_func", location, "%s, f%d", registerName(r0).c_str(), f0);
    465479            break;
    466480        }
     
    468482            int r0 = (++it)->u.operand;
    469483            int f0 = (++it)->u.operand;
    470             printf("[%4d] new_func_exp\t %s, f%d\n", location, registerName(r0).c_str(), f0);
     484            printInstruction("new_func_exp", location, "%s, f%d", registerName(r0).c_str(), f0);
    471485            break;
    472486        }
     
    477491            int tempCount = (++it)->u.operand;
    478492            int argCount = (++it)->u.operand;
    479             printf("[%4d] call\t\t %s, %s, %s, %d, %d\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), tempCount, argCount);
     493            printInstruction("call", location, "%s, %s, %s, %d, %d", registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), tempCount, argCount);
    480494            break;
    481495        }
     
    486500            int tempCount = (++it)->u.operand;
    487501            int argCount = (++it)->u.operand;
    488             printf("[%4d] call_eval\t\t %s, %s, %s, %d, %d\n", location, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), tempCount, argCount);
     502            printInstruction("call_eval", location, "%s, %s, %s, %d, %d", registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str(), tempCount, argCount);
    489503            break;
    490504        }
    491505        case op_ret: {
    492506            int r0 = (++it)->u.operand;
    493             printf("[%4d] ret\t\t %s\n", location, registerName(r0).c_str());
     507            printInstruction("ret", location, "%s", registerName(r0).c_str());
    494508            break;
    495509        }
     
    499513            int tempCount = (++it)->u.operand;
    500514            int argCount = (++it)->u.operand;
    501             printf("[%4d] construct\t %s, %s, %d, %d\n", location, registerName(r0).c_str(), registerName(r1).c_str(), tempCount, argCount);
     515            printInstruction("construct", location, "%s, %s, %d, %d", registerName(r0).c_str(), registerName(r1).c_str(), tempCount, argCount);
    502516            break;
    503517        }
     
    505519            int r0 = (++it)->u.operand;
    506520            int r1 = (++it)->u.operand;
    507             printf("[%4d] get_pnames\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str());
     521            printInstruction("get_pnames", location, "%s, %s", registerName(r0).c_str(), registerName(r1).c_str());
    508522            break;
    509523        }
     
    512526            int iter = (++it)->u.operand;
    513527            int offset = (++it)->u.operand;
    514             printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, jumpTarget(begin, it, offset));
     528            printInstruction("next_pname", location, "%s, %s, %d(->%d)", registerName(dest).c_str(), registerName(iter).c_str(), offset, jumpTarget(begin, it, offset));
    515529            break;
    516530        }
    517531        case op_push_scope: {
    518532            int r0 = (++it)->u.operand;
    519             printf("[%4d] push_scope\t %s\n", location, registerName(r0).c_str());
     533            printInstruction("push_scope", location, "%s", registerName(r0).c_str());
    520534            break;
    521535        }
    522536        case op_pop_scope: {
    523             printf("[%4d] pop_scope\n", location);
     537            printInstruction("pop_scope", location);
    524538            break;
    525539        }
     
    527541            int scopeDelta = (++it)->u.operand;
    528542            int offset = (++it)->u.operand;
    529             printf("[%4d] jmp_scopes\t^%d, %d(->%d)\n", location, scopeDelta, offset, jumpTarget(begin, it, offset));
     543            printInstruction("jmp_scopes", location, "^%d, %d(->%d)", scopeDelta, offset, jumpTarget(begin, it, offset));
    530544            break;
    531545        }
    532546        case op_catch: {
    533547            int r0 = (++it)->u.operand;
    534             printf("[%4d] catch\t\t %s\n", location, registerName(r0).c_str());
     548            printInstruction("catch", location, "%s", registerName(r0).c_str());
    535549            break;
    536550        }
    537551        case op_throw: {
    538552            int r0 = (++it)->u.operand;
    539             printf("[%4d] throw\t\t %s\n", location, registerName(r0).c_str());
     553            printInstruction("throw", location, "%s", registerName(r0).c_str());
    540554            break;
    541555        }
     
    544558            int errorType = (++it)->u.operand;
    545559            int k0 = (++it)->u.operand;
    546             printf("[%4d] new_error\t %s, %d, %s\n", location, registerName(r0).c_str(), errorType, constantName(exec, k0, jsValues[k0]).c_str());
     560            printInstruction("new_error", location, "%s, %d, %s", registerName(r0).c_str(), errorType, constantName(exec, k0, jsValues[k0]).c_str());
    547561            break;
    548562        }
     
    550564            int retAddrDst = (++it)->u.operand;
    551565            int offset = (++it)->u.operand;
    552             printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, jumpTarget(begin, it, offset));
     566            printInstruction("jsr", location, "%s, %d(->%d)", registerName(retAddrDst).c_str(), offset, jumpTarget(begin, it, offset));
    553567            break;
    554568        }
    555569        case op_sret: {
    556570            int retAddrSrc = (++it)->u.operand;
    557             printf("[%4d] sret\t\t %s\n", location, registerName(retAddrSrc).c_str());
     571            printInstruction("sret", location, "%s", registerName(retAddrSrc).c_str());
    558572            break;
    559573        }
     
    562576            int firstLine = (++it)->u.operand;
    563577            int lastLine = (++it)->u.operand;
    564             printf("[%4d] debug\t\t %s, %d, %d\n", location, debugHookName(debugHookID), firstLine, lastLine);
     578            printInstruction("debug", location, "%s, %d, %d", debugHookName(debugHookID), firstLine, lastLine);
    565579            break;
    566580        }
    567581        case op_end: {
    568582            int r0 = (++it)->u.operand;
    569             printf("[%4d] end\t\t %s\n", location, registerName(r0).c_str());
     583            printInstruction("end", location, "%s", registerName(r0).c_str());
    570584            break;
    571585        }
Note: See TracChangeset for help on using the changeset viewer.