Changeset 38349 in webkit for trunk/JavaScriptCore/bytecompiler/CodeGenerator.cpp
- Timestamp:
- Nov 12, 2008, 4:48:23 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bytecompiler/CodeGenerator.cpp
r38330 r38349 1220 1220 } 1221 1221 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)1222 RegisterID* 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 1227 RegisterID* 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 1232 RegisterID* CodeGenerator::emitCall(OpcodeID opcodeID, RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset) 1233 1233 { 1234 1234 ASSERT(opcodeID == op_call || opcodeID == op_call_eval); 1235 1235 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 1238 1251 // Generate code for arguments. 1239 1252 Vector<RefPtr<RegisterID>, 16> argv; 1240 argv.append( newTemporary()); // reserve space for "this"1253 argv.append(thisRegister); 1241 1254 for (ArgumentListNode* n = argumentsNode->m_listNode.get(); n; n = n->m_next.get()) { 1242 1255 argv.append(newTemporary()); … … 1256 1269 emitExpressionInfo(divot, startOffset, endOffset); 1257 1270 m_codeBlock->callLinkInfos.append(CallLinkInfo()); 1271 1272 // Emit call. 1258 1273 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 1264 1277 instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset 1265 1278 … … 1267 1280 emitOpcode(op_profile_did_call); 1268 1281 instructions().append(func->index()); 1282 1283 if (dst == func) { 1284 thisRegister->deref(); 1285 func->deref(); 1286 } 1269 1287 } 1270 1288 … … 1293 1311 { 1294 1312 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 } 1295 1323 1296 1324 RefPtr<RegisterID> funcProto = newTemporary(); … … 1320 1348 emitExpressionInfo(divot, startOffset, endOffset); 1321 1349 m_codeBlock->callLinkInfos.append(CallLinkInfo()); 1350 1322 1351 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 1328 1355 instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset 1356 instructions().append(funcProto->index()); // proto 1357 instructions().append(argv[0]->index()); // thisRegister 1329 1358 1330 1359 emitOpcode(op_construct_verify); … … 1335 1364 emitOpcode(op_profile_did_call); 1336 1365 instructions().append(func->index()); 1366 1367 if (dst == func) 1368 func->deref(); 1337 1369 } 1338 1370
Note:
See TracChangeset
for help on using the changeset viewer.