Source/JavaScriptCore: Changed JSC to always record line number information so that error.stack
and window.onerror() can report proper line numbers.
https://bugs.webkit.org/show_bug.cgi?id=89410

Patch by Mark Lam <mark.lam@apple.com> on 2012-06-18
Reviewed by Geoffrey Garen.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::lineNumberForBytecodeOffset):
(JSC::CodeBlock::shrinkToFit): m_lineInfo is now available unconditionally.

* bytecode/CodeBlock.h:
(JSC::CodeBlock::addLineInfo):
(JSC::CodeBlock::hasLineInfo): Unused.  Now removed.
(JSC::CodeBlock::needsCallReturnIndices):
(CodeBlock):
(RareData):  Hoisted m_lineInfo out of m_rareData.  m_lineInfo is now
filled in unconditionally.

* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::addLineInfo):

LayoutTests: Ensure that error.stack and window.onerror always have the appropriate
line numbers of the exception being thrown.
https://bugs.webkit.org/show_bug.cgi?id=89410

Patch by Mark Lam <mark.lam@apple.com> on 2012-06-18
Reviewed by Geoffrey Garen.

* fast/js/exception-line-number-expected.txt: Added.
* fast/js/exception-line-number.html: Added.
* fast/js/script-tests/exception-line-number.js: Added.
(foo):
(window.onerror):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120676 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
index 5f4006c..60596d1 100644
--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -1600,6 +1600,7 @@
     , m_forcedOSRExitCounter(0)
     , m_optimizationDelayCounter(0)
     , m_reoptimizationRetryCounter(0)
+    , m_lineInfo(other.m_lineInfo)
 #if ENABLE(JIT)
     , m_canCompileWithDFGState(DFG::CapabilityLevelNotSet)
 #endif
@@ -1607,7 +1608,7 @@
     setNumParameters(other.numParameters());
     optimizeAfterWarmUp();
     jitAfterWarmUp();
-    
+
     if (other.m_rareData) {
         createRareDataIfNecessary();
         
@@ -1618,7 +1619,6 @@
         m_rareData->m_characterSwitchJumpTables = other.m_rareData->m_characterSwitchJumpTables;
         m_rareData->m_stringSwitchJumpTables = other.m_rareData->m_stringSwitchJumpTables;
         m_rareData->m_expressionInfo = other.m_rareData->m_expressionInfo;
-        m_rareData->m_lineInfo = other.m_rareData->m_lineInfo;
     }
 }
 
@@ -2163,10 +2163,7 @@
 {
     ASSERT(bytecodeOffset < instructions().size());
 
-    if (!m_rareData)
-        return m_ownerExecutable->source().firstLine();
-
-    Vector<LineInfo>& lineInfo = m_rareData->m_lineInfo;
+    Vector<LineInfo>& lineInfo = m_lineInfo;
 
     int low = 0;
     int high = lineInfo.size();
@@ -2291,6 +2288,7 @@
         m_constantRegisters.shrinkToFit();
     } // else don't shrink these, because we would have already pointed pointers into these tables.
 
+    m_lineInfo.shrinkToFit();
     if (m_rareData) {
         m_rareData->m_exceptionHandlers.shrinkToFit();
         m_rareData->m_regexps.shrinkToFit();
@@ -2298,7 +2296,6 @@
         m_rareData->m_characterSwitchJumpTables.shrinkToFit();
         m_rareData->m_stringSwitchJumpTables.shrinkToFit();
         m_rareData->m_expressionInfo.shrinkToFit();
-        m_rareData->m_lineInfo.shrinkToFit();
 #if ENABLE(JIT)
         m_rareData->m_callReturnIndexVector.shrinkToFit();
 #endif