Changeset 72360 in webkit for trunk/JavaScriptCore/bytecode/CodeBlock.cpp
- Timestamp:
- Nov 18, 2010, 6:35:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bytecode/CodeBlock.cpp
r72351 r72360 1262 1262 macro(characterSwitchJumpTables) \ 1263 1263 macro(stringSwitchJumpTables) \ 1264 macro(functionRegisterInfos) 1265 1266 #define FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(macro) \ 1264 macro(evalCodeCache) \ 1267 1265 macro(expressionInfo) \ 1268 1266 macro(lineInfo) \ 1269 macro(getByIdExceptionInfo) \ 1270 macro(pcVector) 1267 macro(callReturnIndexVector) 1271 1268 1272 1269 template<typename T> … … 1282 1279 FOR_EACH_MEMBER_VECTOR(DEFINE_VARS) 1283 1280 FOR_EACH_MEMBER_VECTOR_RARE_DATA(DEFINE_VARS) 1284 FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(DEFINE_VARS)1285 1281 #undef DEFINE_VARS 1286 1282 … … 1291 1287 size_t symbolTableTotalSize = 0; 1292 1288 1293 size_t hasExceptionInfo = 0;1294 1289 size_t hasRareData = 0; 1295 1290 … … 1309 1304 symbolTableIsNotEmpty++; 1310 1305 symbolTableTotalSize += (codeBlock->m_symbolTable.capacity() * (sizeof(SymbolTable::KeyType) + sizeof(SymbolTable::MappedType))); 1311 }1312 1313 if (codeBlock->m_exceptionInfo) {1314 hasExceptionInfo++;1315 #define GET_STATS(name) if (!codeBlock->m_exceptionInfo->m_##name.isEmpty()) { name##IsNotEmpty++; name##TotalSize += sizeInBytes(codeBlock->m_exceptionInfo->m_##name); }1316 FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_STATS)1317 #undef GET_STATS1318 1306 } 1319 1307 … … 1346 1334 FOR_EACH_MEMBER_VECTOR(GET_TOTAL_SIZE) 1347 1335 FOR_EACH_MEMBER_VECTOR_RARE_DATA(GET_TOTAL_SIZE) 1348 FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_TOTAL_SIZE)1349 1336 #undef GET_TOTAL_SIZE 1350 1337 … … 1361 1348 printf("Number of EvalCode CodeBlocks: %zu (%.3f%%)\n", isEvalCode, static_cast<double>(isEvalCode) * 100.0 / liveCodeBlockSet.size()); 1362 1349 1363 printf("Number of CodeBlocks with exception info: %zu (%.3f%%)\n", hasExceptionInfo, static_cast<double>(hasExceptionInfo) * 100.0 / liveCodeBlockSet.size());1364 1350 printf("Number of CodeBlocks with rare data: %zu (%.3f%%)\n", hasRareData, static_cast<double>(hasRareData) * 100.0 / liveCodeBlockSet.size()); 1365 1351 … … 1367 1353 FOR_EACH_MEMBER_VECTOR(PRINT_STATS) 1368 1354 FOR_EACH_MEMBER_VECTOR_RARE_DATA(PRINT_STATS) 1369 FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(PRINT_STATS)1370 1355 #undef PRINT_STATS 1371 1356 … … 1400 1385 , m_sourceOffset(sourceOffset) 1401 1386 , m_symbolTable(symTab) 1402 , m_exceptionInfo(adoptPtr(new ExceptionInfo))1403 1387 { 1404 1388 ASSERT(m_source); … … 1559 1543 } 1560 1544 1561 bool CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)1562 {1563 if (m_exceptionInfo)1564 return true;1565 1566 ASSERT(!m_rareData || !m_rareData->m_exceptionHandlers.size());1567 ScopeChainNode* scopeChain = callFrame->scopeChain();1568 if (m_needsFullScopeChain) {1569 if (codeType() == FunctionCode && !callFrame->r(activationRegister()).jsValue()) {1570 createActivation(callFrame);1571 scopeChain = callFrame->scopeChain();1572 }1573 ScopeChain sc(scopeChain);1574 int scopeDelta = sc.localDepth();1575 if (m_codeType == EvalCode)1576 scopeDelta -= static_cast<EvalCodeBlock*>(this)->baseScopeDepth();1577 else if (m_codeType == FunctionCode)1578 scopeDelta++; // Compilation of function code assumes activation is not on the scope chain yet.1579 ASSERT(scopeDelta >= 0);1580 while (scopeDelta--)1581 scopeChain = scopeChain->next;1582 }1583 1584 m_exceptionInfo = m_ownerExecutable->reparseExceptionInfo(scopeChain, this);1585 return m_exceptionInfo;1586 }1587 1588 1545 HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset) 1589 1546 { … … 1604 1561 } 1605 1562 1606 int CodeBlock::lineNumberForBytecodeOffset( CallFrame* callFrame,unsigned bytecodeOffset)1563 int CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset) 1607 1564 { 1608 1565 ASSERT(bytecodeOffset < m_instructionCount); 1609 1566 1610 if (!reparseForExceptionInfoIfNecessary(callFrame) || !m_exceptionInfo->m_lineInfo.size()) 1611 return m_ownerExecutable->source().firstLine(); // Empty function or unable to reparse 1567 if (!m_rareData) 1568 return m_ownerExecutable->source().firstLine(); 1569 1570 Vector<LineInfo>& lineInfo = m_rareData->m_lineInfo; 1612 1571 1613 1572 int low = 0; 1614 int high = m_exceptionInfo->m_lineInfo.size();1573 int high = lineInfo.size(); 1615 1574 while (low < high) { 1616 1575 int mid = low + (high - low) / 2; 1617 if ( m_exceptionInfo->m_lineInfo[mid].instructionOffset <= bytecodeOffset)1576 if (lineInfo[mid].instructionOffset <= bytecodeOffset) 1618 1577 low = mid + 1; 1619 1578 else 1620 1579 high = mid; 1621 1580 } 1622 1581 1623 1582 if (!low) 1624 1583 return m_ownerExecutable->source().firstLine(); 1625 return m_exceptionInfo->m_lineInfo[low - 1].lineNumber;1626 } 1627 1628 void CodeBlock::expressionRangeForBytecodeOffset( CallFrame* callFrame,unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)1584 return lineInfo[low - 1].lineNumber; 1585 } 1586 1587 void CodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset) 1629 1588 { 1630 1589 ASSERT(bytecodeOffset < m_instructionCount); 1631 1590 1632 if (!reparseForExceptionInfoIfNecessary(callFrame) || !m_exceptionInfo->m_expressionInfo.size()) { 1633 // We didn't think anything could throw. Apparently we were wrong. 1634 // Alternatively something went wrong when trying to reparse 1591 if (!m_rareData) { 1635 1592 startOffset = 0; 1636 1593 endOffset = 0; … … 1639 1596 } 1640 1597 1598 Vector<ExpressionRangeInfo>& expressionInfo = m_rareData->m_expressionInfo; 1599 1641 1600 int low = 0; 1642 int high = m_exceptionInfo->m_expressionInfo.size();1601 int high = expressionInfo.size(); 1643 1602 while (low < high) { 1644 1603 int mid = low + (high - low) / 2; 1645 if ( m_exceptionInfo->m_expressionInfo[mid].instructionOffset <= bytecodeOffset)1604 if (expressionInfo[mid].instructionOffset <= bytecodeOffset) 1646 1605 low = mid + 1; 1647 1606 else … … 1657 1616 } 1658 1617 1659 startOffset = m_exceptionInfo->m_expressionInfo[low - 1].startOffset;1660 endOffset = m_exceptionInfo->m_expressionInfo[low - 1].endOffset;1661 divot = m_exceptionInfo->m_expressionInfo[low - 1].divotPoint + m_sourceOffset;1618 startOffset = expressionInfo[low - 1].startOffset; 1619 endOffset = expressionInfo[low - 1].endOffset; 1620 divot = expressionInfo[low - 1].divotPoint + m_sourceOffset; 1662 1621 return; 1663 1622 } … … 1726 1685 m_constantRegisters.shrinkToFit(); 1727 1686 1728 if (m_exceptionInfo) {1729 m_exceptionInfo->m_expressionInfo.shrinkToFit();1730 m_exceptionInfo->m_lineInfo.shrinkToFit();1731 }1732 1733 1687 if (m_rareData) { 1734 1688 m_rareData->m_exceptionHandlers.shrinkToFit(); … … 1737 1691 m_rareData->m_characterSwitchJumpTables.shrinkToFit(); 1738 1692 m_rareData->m_stringSwitchJumpTables.shrinkToFit(); 1693 m_rareData->m_expressionInfo.shrinkToFit(); 1694 m_rareData->m_lineInfo.shrinkToFit(); 1739 1695 } 1740 1696 }
Note:
See TracChangeset
for help on using the changeset viewer.