Changeset 129297 in webkit for trunk/Source/JavaScriptCore/bytecompiler
- Timestamp:
- Sep 21, 2012, 11:34:59 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r129287 r129297 305 305 // FIXME: Move code that modifies the global object to Interpreter::execute. 306 306 307 codeBlock->m_numCapturedVars = codeBlock->m_numVars;308 309 307 if (compilationKind == OptimizingCompilation) 310 308 return; … … 393 391 } 394 392 393 symbolTable->setCaptureStart(m_codeBlock->m_numVars); 394 395 395 if (functionBody->usesArguments() || codeBlock->usesEval() || m_shouldEmitDebugHooks) { // May reify arguments object. 396 396 RegisterID* unmodifiedArgumentsRegister = addVar(); // Anonymous, so it can't be modified by user code. … … 424 424 } 425 425 426 bool mayReifyArgumentsObject = codeBlock->usesArguments() || codeBlock->usesEval() || m_shouldEmitDebugHooks; 426 bool shouldCaptureAllTheThings = m_shouldEmitDebugHooks || codeBlock->usesEval(); 427 427 428 bool capturesAnyArgumentByName = false; 428 if (functionBody->hasCapturedVariables()) { 429 Vector<RegisterID*> capturedArguments; 430 if (functionBody->hasCapturedVariables() || shouldCaptureAllTheThings) { 429 431 FunctionParameters& parameters = *functionBody->parameters(); 432 capturedArguments.resize(parameters.size()); 430 433 for (size_t i = 0; i < parameters.size(); ++i) { 431 if (!functionBody->captures(parameters[i])) 434 capturedArguments[i] = 0; 435 if (!functionBody->captures(parameters[i]) && !shouldCaptureAllTheThings) 432 436 continue; 433 437 capturesAnyArgumentByName = true; 434 break; 435 } 436 } 437 438 if (mayReifyArgumentsObject || capturesAnyArgumentByName) { 439 symbolTable->setCaptureMode(SharedSymbolTable::AllOfTheThings); 440 symbolTable->setCaptureStart(-CallFrame::offsetFor(symbolTable->parameterCountIncludingThis())); 441 } else { 442 symbolTable->setCaptureMode(SharedSymbolTable::SomeOfTheThings); 443 symbolTable->setCaptureStart(m_codeBlock->m_numVars); 444 } 445 446 if (mayReifyArgumentsObject && capturesAnyArgumentByName) { 438 capturedArguments[i] = addVar(); 439 } 440 } 441 442 if (capturesAnyArgumentByName && !codeBlock->isStrictMode()) { 447 443 size_t parameterCount = symbolTable->parameterCount(); 448 444 OwnArrayPtr<SlowArgument> slowArguments = adoptArrayPtr(new SlowArgument[parameterCount]); 449 445 for (size_t i = 0; i < parameterCount; ++i) { 446 if (!capturedArguments[i]) { 447 ASSERT(slowArguments[i].status == SlowArgument::Normal); 448 slowArguments[i].index = CallFrame::argumentOffset(i); 449 continue; 450 } 450 451 slowArguments[i].status = SlowArgument::Captured; 451 slowArguments[i].index IfCaptured = CallFrame::argumentOffset(i);452 slowArguments[i].index = capturedArguments[i]->index(); 452 453 } 453 454 symbolTable->setSlowArguments(slowArguments.release()); … … 492 493 } 493 494 494 codeBlock->m_numCapturedVars = codeBlock->m_numVars;495 symbolTable->setCaptureEnd(codeBlock->m_numVars); 495 496 496 497 m_firstLazyFunction = codeBlock->m_numVars; … … 519 520 } 520 521 521 if (m_shouldEmitDebugHooks || codeBlock->usesEval()) 522 codeBlock->m_numCapturedVars = codeBlock->m_numVars; 523 524 symbolTable->setCaptureEnd(codeBlock->m_numCapturedVars); 522 if (shouldCaptureAllTheThings) 523 symbolTable->setCaptureEnd(codeBlock->m_numVars); 525 524 526 525 FunctionParameters& parameters = *functionBody->parameters(); … … 532 531 m_codeBlock->addParameter(); 533 532 534 for (size_t i = 0; i < parameters.size(); ++i) 535 addParameter(parameters[i], nextParameterIndex--); 536 533 for (size_t i = 0; i < parameters.size(); ++i, --nextParameterIndex) { 534 int index = nextParameterIndex; 535 if (capturedArguments.size() && capturedArguments[i]) { 536 ASSERT((functionBody->hasCapturedVariables() && functionBody->captures(parameters[i])) || shouldCaptureAllTheThings); 537 index = capturedArguments[i]->index(); 538 RegisterID original(nextParameterIndex); 539 emitMove(capturedArguments[i], &original); 540 } 541 addParameter(parameters[i], index); 542 } 537 543 preserveLastVar(); 538 544 … … 604 610 variables.append(*varStack[i].first); 605 611 codeBlock->adoptVariables(variables); 606 codeBlock->m_numCapturedVars = codeBlock->m_numVars;607 612 preserveLastVar(); 608 613 }
Note:
See TracChangeset
for help on using the changeset viewer.