Make source cache include more information about the function extent.
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 21:11:53 +0000 (21:11 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2012 21:11:53 +0000 (21:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103552

Reviewed by Gavin Barraclough.

Add a bit more information to the source cache.

* parser/Parser.cpp:
(JSC::::parseFunctionInfo):
   Store the function start offset
* parser/SourceProviderCacheItem.h:
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
(SourceProviderCacheItem):
   Add additional field for the start of the real function string, and re-arrange
   fields to avoid growing the struct.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136049 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/SourceProviderCacheItem.h

index 4066d80..49b1ba0 100644 (file)
@@ -1,3 +1,21 @@
+2012-11-28  Oliver Hunt  <oliver@apple.com>
+
+        Make source cache include more information about the function extent.
+        https://bugs.webkit.org/show_bug.cgi?id=103552
+
+        Reviewed by Gavin Barraclough.
+
+        Add a bit more information to the source cache.
+
+        * parser/Parser.cpp:
+        (JSC::::parseFunctionInfo):
+           Store the function start offset
+        * parser/SourceProviderCacheItem.h:
+        (JSC::SourceProviderCacheItem::SourceProviderCacheItem):
+        (SourceProviderCacheItem):
+           Add additional field for the start of the real function string, and re-arrange
+           fields to avoid growing the struct.
+
 2012-11-27  Filip Pizlo  <fpizlo@apple.com>
 
         Convert some remaining uses of FILE* to PrintStream&.
index 049a519..cf3cb4e 100644 (file)
@@ -812,6 +812,7 @@ template <FunctionRequirements requirements, bool nameIsInContainingScope, class
 {
     AutoPopScopeRef functionScope(this, pushScope());
     functionScope->setIsFunction();
+    int functionStart = m_token.m_location.startOffset;
     if (match(IDENT)) {
         name = m_token.m_data.ident;
         next();
@@ -865,7 +866,7 @@ template <FunctionRequirements requirements, bool nameIsInContainingScope, class
     OwnPtr<SourceProviderCacheItem> newInfo;
     int functionLength = closeBracePos - openBracePos;
     if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) {
-        newInfo = adoptPtr(new SourceProviderCacheItem(m_token.m_location.line, closeBracePos));
+        newInfo = adoptPtr(new SourceProviderCacheItem(functionStart, m_token.m_location.line, closeBracePos));
         functionScope->saveFunctionInfo(newInfo.get());
     }
     
index 9ca121e..ec38905 100644 (file)
@@ -35,8 +35,9 @@ namespace JSC {
 class SourceProviderCacheItem {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    SourceProviderCacheItem(int closeBraceLine, int closeBracePos)
-        : closeBraceLine(closeBraceLine) 
+    SourceProviderCacheItem(unsigned functionStart, unsigned closeBraceLine, unsigned closeBracePos)
+        : functionStart(functionStart)
+        , closeBraceLine(closeBraceLine)
         , closeBracePos(closeBracePos)
     {
     }
@@ -59,12 +60,16 @@ public:
         token.m_location.line = closeBraceLine;
         return token;
     }
+
+    unsigned functionStart : 31;
+    bool needsFullActivation : 1;
     
-    int closeBraceLine;
-    int closeBracePos;
-    bool usesEval;
-    bool strictMode;
-    bool needsFullActivation;
+    unsigned closeBraceLine : 31;
+    bool usesEval : 1;
+
+    unsigned closeBracePos : 31;
+    bool strictMode : 1;
+
     Vector<RefPtr<StringImpl> > usedVariables;
     Vector<RefPtr<StringImpl> > writtenVariables;
 };