Ignore:
Timestamp:
Sep 13, 2012, 6:50:17 PM (13 years ago)
Author:
[email protected]
Message:

Improve the SourceProvider hierarchy
https://bugs.webkit.org/show_bug.cgi?id=95635

Patch by Benjamin Poulain <[email protected]> on 2012-09-13
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

SourceProvider was designed to have subclasses magically handling the data without
decoding all of it. The virtual methods length() and getRange() were based
on these assumptions.

In practice, the magic was in our head, there is no implementation that takes
advantage of that.

SourceProvider is modified to adopt WebCore's ScriptSourceProvider::source() and base
everything on it.
The code using SourceProvider is also simplified.

  • interpreter/Interpreter.cpp:

(JSC::appendSourceToError): Keep a reference to the string instead of querying it for
each time it is used.

  • parser/Lexer.cpp:

(JSC::::setCode):
(JSC::::sourceCode):

  • parser/Parser.h:

(JSC::parse):

  • parser/SourceCode.h:

(JSC::SourceCode::SourceCode):
(JSC::SourceCode::subExpression):

  • parser/SourceProvider.h:

(SourceProvider):
(JSC::SourceProvider::getRange):

Source/WebCore:

Get rid of ScriptSourceProvider and StringSourceProvider, they have been made
useless by JavaScript updates.

On x86_64, this reduces the binary size by 6kb.

  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/CachedScriptSourceProvider.h:

(WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):

  • bindings/js/ScriptDebugServer.cpp:

(WebCore::ScriptDebugServer::updateCurrentStatementPosition):
(WebCore::ScriptDebugServer::dispatchDidParseSource):
(WebCore::ScriptDebugServer::dispatchFailedToParseSource):

  • bindings/js/ScriptSourceCode.h:

(WebCore::ScriptSourceCode::ScriptSourceCode):
(ScriptSourceCode):

  • bindings/js/ScriptSourceProvider.h: Removed.
  • bindings/js/StringSourceProvider.h: Removed.
  • bindings/js/WorkerScriptController.cpp:
  • bindings/objc/WebScriptObject.mm:
  • bridge/NP_jsobject.cpp:
  • bridge/jni/jni_jsobject.mm:

Source/WebKit/mac:

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm: Fix a #include abuse.
  • WebView/WebScriptDebugger.mm:

(toNSString): We can now use the (faster) implicit conversion
from String to NSString.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r127191 r128542  
    406406    m_lastToken = -1;
    407407   
    408     const StringImpl* sourceString = source.provider()->data();
    409 
    410     if (sourceString)
    411         setCodeStart(sourceString);
     408    const String& sourceString = source.provider()->source();
     409
     410    if (!sourceString.isNull())
     411        setCodeStart(sourceString.impl());
    412412    else
    413413        m_codeStart = 0;
     
    16901690SourceCode Lexer<T>::sourceCode(int openBrace, int closeBrace, int firstLine)
    16911691{
    1692     ASSERT((*m_source->provider()->data())[openBrace] == '{');
    1693     ASSERT((*m_source->provider()->data())[closeBrace] == '}');
     1692    ASSERT(m_source->provider()->source()[openBrace] == '{');
     1693    ASSERT(m_source->provider()->source()[closeBrace] == '}');
    16941694    return SourceCode(m_source->provider(), openBrace, closeBrace + 1, firstLine);
    16951695}
Note: See TracChangeset for help on using the changeset viewer.