Changeset 59742 in webkit for trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
- Timestamp:
- May 18, 2010, 10:10:11 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r59064 r59742 175 175 } 176 176 177 ++m_codeBlock->m_numVars; 178 r0 = newRegister(); 177 r0 = addVar(); 179 178 return true; 180 179 } … … 296 295 , m_scopeNode(functionBody) 297 296 , m_codeBlock(codeBlock) 297 , m_activationRegister(0) 298 298 , m_finallyDepth(0) 299 299 , m_dynamicScopeDepth(0) … … 313 313 codeBlock->setGlobalData(m_globalData); 314 314 315 bool usesArguments = functionBody->usesArguments();316 codeBlock->setUsesArguments(usesArguments);317 if (usesArguments) {318 m_argumentsRegister.setIndex(RegisterFile::OptionalCalleeArguments);319 addVar(propertyNames().arguments, false);320 }321 322 315 if (m_codeBlock->needsFullScopeChain()) { 323 ++m_codeBlock->m_numVars; 324 m_activationRegisterIndex = newRegister()->index(); 316 m_activationRegister = addVar(); 325 317 emitOpcode(op_enter_with_activation); 326 instructions().append(m_activationRegister Index);318 instructions().append(m_activationRegister->index()); 327 319 } else 328 320 emitOpcode(op_enter); 329 321 330 if (usesArguments) { 322 // Both op_tear_off_activation and op_tear_off_arguments tear off the 'arguments' 323 // object, if created. 324 if (m_codeBlock->needsFullScopeChain() || functionBody->usesArguments()) { 325 RegisterID* unmodifiedArgumentsRegister = addVar(); // Anonymous, so it can't be modified by user code. 326 RegisterID* argumentsRegister = addVar(propertyNames().arguments, false); // Can be changed by assigning to 'arguments'. 327 328 // We can save a little space by hard-coding the knowledge that the two 329 // 'arguments' values are stored in consecutive registers, and storing 330 // only the index of the assignable one. 331 codeBlock->setArgumentsRegister(argumentsRegister->index()); 332 ASSERT_UNUSED(unmodifiedArgumentsRegister, unmodifiedArgumentsRegister->index() == JSC::unmodifiedArgumentsRegister(codeBlock->argumentsRegister())); 333 331 334 emitOpcode(op_init_arguments); 335 instructions().append(argumentsRegister->index()); 332 336 333 337 // The debugger currently retrieves the arguments object from an activation rather than pulling 334 338 // it from a call frame. In the long-term it should stop doing that (<rdar://problem/6911886>), 335 339 // but for now we force eager creation of the arguments object when debugging. 336 if (m_shouldEmitDebugHooks) 340 if (m_shouldEmitDebugHooks) { 337 341 emitOpcode(op_create_arguments); 342 instructions().append(argumentsRegister->index()); 343 } 338 344 } 339 345 … … 1386 1392 } 1387 1393 1388 1389 1394 RegisterID* BytecodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n) 1390 1395 { … … 1405 1410 void BytecodeGenerator::createArgumentsIfNecessary() 1406 1411 { 1407 if (m_codeBlock->usesArguments() && m_codeType == FunctionCode) 1408 emitOpcode(op_create_arguments); 1412 if (m_codeType != FunctionCode) 1413 return; 1414 ASSERT(m_codeBlock->usesArguments()); 1415 1416 emitOpcode(op_create_arguments); 1417 instructions().append(m_codeBlock->argumentsRegister()); 1409 1418 } 1410 1419 1411 1420 RegisterID* BytecodeGenerator::emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset) 1412 1421 { 1413 createArgumentsIfNecessary();1414 1422 return emitCall(op_call_eval, dst, func, thisRegister, argumentsNode, divot, startOffset, endOffset); 1415 1423 } … … 1527 1535 if (m_codeBlock->needsFullScopeChain()) { 1528 1536 emitOpcode(op_tear_off_activation); 1529 instructions().append(m_activationRegisterIndex); 1530 } else if (m_codeBlock->usesArguments() && m_codeBlock->m_numParameters > 1) 1537 instructions().append(m_activationRegister->index()); 1538 instructions().append(m_codeBlock->argumentsRegister()); 1539 } else if (m_codeBlock->usesArguments() && m_codeBlock->m_numParameters > 1) { // If there are no named parameters, there's nothing to tear off, since extra / unnamed parameters get copied to the arguments object at construct time. 1531 1540 emitOpcode(op_tear_off_arguments); 1541 instructions().append(m_codeBlock->argumentsRegister()); 1542 } 1532 1543 1533 1544 return emitUnaryNoDstOp(op_ret, src); … … 1636 1647 m_scopeContextStack.append(context); 1637 1648 m_dynamicScopeDepth++; 1638 createArgumentsIfNecessary();1639 1649 1640 1650 return emitUnaryNoDstOp(op_push_scope, scope); … … 1900 1910 m_scopeContextStack.append(context); 1901 1911 m_dynamicScopeDepth++; 1902 1903 createArgumentsIfNecessary();1904 1912 1905 1913 emitOpcode(op_push_new_scope);
Note:
See TracChangeset
for help on using the changeset viewer.