Title: [111358] trunk/Source
Revision
111358
Author
[email protected]
Date
2012-03-19 22:24:24 -0700 (Mon, 19 Mar 2012)

Log Message

Do not copy the script source in the SourceProvider, just reference the existing string
https://bugs.webkit.org/show_bug.cgi?id=81466

Reviewed by Geoffrey Garen.

Source/_javascript_Core: 

* parser/SourceCode.h: Remove the unused, and incorrect, function data().
* parser/SourceProvider.h: Add OVERRIDE for clarity.

Source/WebCore: 

Instead of creating a copy of the string with 16bits characters, we just return
a shared StringImpl.

* bindings/js/CachedScriptSourceProvider.h:
* bindings/js/StringSourceProvider.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (111357 => 111358)


--- trunk/Source/_javascript_Core/ChangeLog	2012-03-20 05:21:20 UTC (rev 111357)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-03-20 05:24:24 UTC (rev 111358)
@@ -1,3 +1,13 @@
+2012-03-19  Benjamin Poulain  <[email protected]>
+
+        Do not copy the script source in the SourceProvider, just reference the existing string
+        https://bugs.webkit.org/show_bug.cgi?id=81466
+
+        Reviewed by Geoffrey Garen.
+
+        * parser/SourceCode.h: Remove the unused, and incorrect, function data().
+        * parser/SourceProvider.h: Add OVERRIDE for clarity.
+
 2012-03-19  Filip Pizlo  <[email protected]>
 
         Division optimizations fail to infer cases of truncated division and

Modified: trunk/Source/_javascript_Core/parser/SourceCode.h (111357 => 111358)


--- trunk/Source/_javascript_Core/parser/SourceCode.h	2012-03-20 05:21:20 UTC (rev 111357)
+++ trunk/Source/_javascript_Core/parser/SourceCode.h	2012-03-20 05:24:24 UTC (rev 111358)
@@ -72,11 +72,6 @@
         int firstLine() const { return m_firstLine; }
         int startOffset() const { return m_startChar; }
         int endOffset() const { return m_endChar; }
-        const UChar* data() const
-        {
-            ASSERT(m_provider->data());
-            return m_provider->data()->characters16() + m_startChar;
-        }
         int length() const { return m_endChar - m_startChar; }
         
         SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine);

Modified: trunk/Source/_javascript_Core/parser/SourceProvider.h (111357 => 111358)


--- trunk/Source/_javascript_Core/parser/SourceProvider.h	2012-03-20 05:21:20 UTC (rev 111357)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.h	2012-03-20 05:24:24 UTC (rev 111358)
@@ -86,7 +86,7 @@
             return adoptRef(new UStringSourceProvider(source, url, startPosition));
         }
 
-        UString getRange(int start, int end) const
+        virtual UString getRange(int start, int end) const OVERRIDE
         {
             return m_source.substringSharingImpl(start, end - start);
         }

Modified: trunk/Source/WebCore/ChangeLog (111357 => 111358)


--- trunk/Source/WebCore/ChangeLog	2012-03-20 05:21:20 UTC (rev 111357)
+++ trunk/Source/WebCore/ChangeLog	2012-03-20 05:24:24 UTC (rev 111358)
@@ -1,3 +1,16 @@
+2012-03-19  Benjamin Poulain  <[email protected]>
+
+        Do not copy the script source in the SourceProvider, just reference the existing string
+        https://bugs.webkit.org/show_bug.cgi?id=81466
+
+        Reviewed by Geoffrey Garen.
+
+        Instead of creating a copy of the string with 16bits characters, we just return
+        a shared StringImpl.
+
+        * bindings/js/CachedScriptSourceProvider.h:
+        * bindings/js/StringSourceProvider.h:
+
 2012-03-19  Dana Jansens  <[email protected]>
 
         A quick early-out for Region::contains() test

Modified: trunk/Source/WebCore/bindings/js/CachedScriptSourceProvider.h (111357 => 111358)


--- trunk/Source/WebCore/bindings/js/CachedScriptSourceProvider.h	2012-03-20 05:21:20 UTC (rev 111357)
+++ trunk/Source/WebCore/bindings/js/CachedScriptSourceProvider.h	2012-03-20 05:24:24 UTC (rev 111358)
@@ -45,7 +45,16 @@
             m_cachedScript->removeClient(this);
         }
 
-        JSC::UString getRange(int start, int end) const { return JSC::UString(m_cachedScript->script().characters() + start, end - start); }
+        virtual JSC::UString getRange(int start, int end) const OVERRIDE
+        {
+            int length = end - start;
+            ASSERT(length >= 0);
+            ASSERT(start + length <= length());
+
+            String script = m_cachedScript->script();
+            return JSC::UString(StringImpl::create(script.impl(), start, length));
+        }
+
         const StringImpl* data() const { return m_cachedScript->script().impl(); }
         int length() const { return m_cachedScript->script().length(); }
         const String& source() const { return m_cachedScript->script(); }

Modified: trunk/Source/WebCore/bindings/js/StringSourceProvider.h (111357 => 111358)


--- trunk/Source/WebCore/bindings/js/StringSourceProvider.h	2012-03-20 05:21:20 UTC (rev 111357)
+++ trunk/Source/WebCore/bindings/js/StringSourceProvider.h	2012-03-20 05:24:24 UTC (rev 111358)
@@ -42,7 +42,15 @@
             return adoptRef(new StringSourceProvider(source, url, startPosition));
         }
 
-        JSC::UString getRange(int start, int end) const { return JSC::UString(m_source.characters() + start, end - start); }
+        virtual JSC::UString getRange(int start, int end) const OVERRIDE
+        {
+            int length = end - start;
+            ASSERT(length >= 0);
+            ASSERT(start + length <= length());
+
+            return JSC::UString(StringImpl::create(m_source.impl(), start, length));
+        }
+
         const StringImpl* data() const { return m_source.impl(); }
         int length() const { return m_source.length(); }
         const String& source() const { return m_source; }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to