Changeset 38349 in webkit for trunk/JavaScriptCore/bytecompiler


Ignore:
Timestamp:
Nov 12, 2008, 4:48:23 PM (17 years ago)
Author:
[email protected]
Message:

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

Reviewed by Sam Weinig.


Fixed https://bugs.webkit.org/show_bug.cgi?id=22192
+37 failures in fast/profiler


along with Darin's review comments in
https://bugs.webkit.org/show_bug.cgi?id=22174
Simplified op_call by nixing its responsibility for moving the value of
"this" into the first argument slot

  • VM/Machine.cpp: (JSC::returnToThrowTrampoline): (JSC::throwStackOverflowError): (JSC::Machine::cti_register_file_check): (JSC::Machine::cti_op_call_arityCheck): (JSC::Machine::cti_vm_throw): Moved the throw logic into a function, since functions are better than macros.
  • bytecompiler/CodeGenerator.cpp: (JSC::CodeGenerator::emitCall): (JSC::CodeGenerator::emitConstruct): Ensure that the function register is preserved if profiling is enabled, since the profiler uses that register.
  • runtime/JSGlobalData.h: Renamed throwReturnAddress to exceptionLocation, because I had a hard time understanding what "throwReturnAddress" meant.
Location:
trunk/JavaScriptCore/bytecompiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecompiler/CodeGenerator.cpp

    r38330 r38349  
    12201220}
    12211221
    1222 RegisterID* CodeGenerator::emitCall(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset)
    1223 {
    1224     return emitCall(op_call, dst, func, base, argumentsNode, divot, startOffset, endOffset);
    1225 }
    1226 
    1227 RegisterID* CodeGenerator::emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset)
    1228 {
    1229     return emitCall(op_call_eval, dst, func, base, argumentsNode, divot, startOffset, endOffset);
    1230 }
    1231 
    1232 RegisterID* CodeGenerator::emitCall(OpcodeID opcodeID, RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset)
     1222RegisterID* CodeGenerator::emitCall(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset)
     1223{
     1224    return emitCall(op_call, dst, func, thisRegister, argumentsNode, divot, startOffset, endOffset);
     1225}
     1226
     1227RegisterID* CodeGenerator::emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset)
     1228{
     1229    return emitCall(op_call_eval, dst, func, thisRegister, argumentsNode, divot, startOffset, endOffset);
     1230}
     1231
     1232RegisterID* CodeGenerator::emitCall(OpcodeID opcodeID, RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset)
    12331233{
    12341234    ASSERT(opcodeID == op_call || opcodeID == op_call_eval);
    12351235    ASSERT(func->refCount());
    1236     ASSERT(!base || base->refCount());
    1237    
     1236
     1237    if (m_shouldEmitProfileHooks) {
     1238        // If codegen decided to recycle func as this call's destination register,
     1239        // we need to undo that optimization here so that func will still be around
     1240        // for the sake of op_profile_did_call.
     1241        if (dst == func) {
     1242            RefPtr<RegisterID> protect = thisRegister;
     1243            RefPtr<RegisterID> movedThisRegister = emitMove(newTemporary(), thisRegister);
     1244            RefPtr<RegisterID> movedFunc = emitMove(thisRegister, func);
     1245           
     1246            thisRegister = movedThisRegister.release().releaseRef();
     1247            func = movedFunc.release().releaseRef();
     1248        }
     1249    }
     1250
    12381251    // Generate code for arguments.
    12391252    Vector<RefPtr<RegisterID>, 16> argv;
    1240     argv.append(newTemporary()); // reserve space for "this"
     1253    argv.append(thisRegister);
    12411254    for (ArgumentListNode* n = argumentsNode->m_listNode.get(); n; n = n->m_next.get()) {
    12421255        argv.append(newTemporary());
     
    12561269    emitExpressionInfo(divot, startOffset, endOffset);
    12571270    m_codeBlock->callLinkInfos.append(CallLinkInfo());
     1271
     1272    // Emit call.
    12581273    emitOpcode(opcodeID);
    1259     instructions().append(dst->index());
    1260     instructions().append(func->index());
    1261     instructions().append(base ? base->index() : missingThisObjectMarker()); // We encode the "this" value in the instruction stream, to avoid an explicit instruction for copying or loading it.
    1262     instructions().append(argv[0]->index()); // argv
    1263     instructions().append(argv.size()); // argc
     1274    instructions().append(dst->index()); // dst
     1275    instructions().append(func->index()); // func
     1276    instructions().append(argv.size()); // argCount
    12641277    instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset
    12651278
     
    12671280        emitOpcode(op_profile_did_call);
    12681281        instructions().append(func->index());
     1282
     1283        if (dst == func) {
     1284            thisRegister->deref();
     1285            func->deref();
     1286        }
    12691287    }
    12701288
     
    12931311{
    12941312    ASSERT(func->refCount());
     1313
     1314    if (m_shouldEmitProfileHooks) {
     1315        // If codegen decided to recycle func as this call's destination register,
     1316        // we need to undo that optimization here so that func will still be around
     1317        // for the sake of op_profile_did_call.
     1318        if (dst == func) {
     1319            RefPtr<RegisterID> movedFunc = emitMove(newTemporary(), func);
     1320            func = movedFunc.release().releaseRef();
     1321        }
     1322    }
    12951323
    12961324    RefPtr<RegisterID> funcProto = newTemporary();
     
    13201348    emitExpressionInfo(divot, startOffset, endOffset);
    13211349    m_codeBlock->callLinkInfos.append(CallLinkInfo());
     1350
    13221351    emitOpcode(op_construct);
    1323     instructions().append(dst->index());
    1324     instructions().append(func->index());
    1325     instructions().append(funcProto->index());
    1326     instructions().append(argv[0]->index()); // argv
    1327     instructions().append(argv.size()); // argc
     1352    instructions().append(dst->index()); // dst
     1353    instructions().append(func->index()); // func
     1354    instructions().append(argv.size()); // argCount
    13281355    instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset
     1356    instructions().append(funcProto->index()); // proto
     1357    instructions().append(argv[0]->index()); // thisRegister
    13291358
    13301359    emitOpcode(op_construct_verify);
     
    13351364        emitOpcode(op_profile_did_call);
    13361365        instructions().append(func->index());
     1366       
     1367        if (dst == func)
     1368            func->deref();
    13371369    }
    13381370
  • trunk/JavaScriptCore/bytecompiler/CodeGenerator.h

    r38330 r38349  
    274274        RegisterID* emitPutSetter(RegisterID* base, const Identifier& property, RegisterID* value);
    275275
    276         RegisterID* emitCall(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    277         RegisterID* emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
     276        RegisterID* emitCall(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
     277        RegisterID* emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    278278
    279279        RegisterID* emitReturn(RegisterID* src);
     
    346346        typedef HashMap<UString::Rep*, JSString*, IdentifierRepHash> IdentifierStringMap;
    347347
    348         RegisterID* emitCall(OpcodeID, RegisterID*, RegisterID*, RegisterID*, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
     348        RegisterID* emitCall(OpcodeID, RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset);
    349349       
    350350        RegisterID* newRegister();
Note: See TracChangeset for help on using the changeset viewer.