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/SourceProvider.h

    r127191 r128542  
    11/*
    2  * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2009, 2012 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5757        }
    5858
    59         virtual String getRange(int start, int end) const = 0;
    60         virtual const StringImpl* data() const = 0;
    61         virtual int length() const = 0;
    62        
     59        virtual const String& source() const = 0;
     60        String getRange(int start, int end) const
     61        {
     62            return source().substringSharingImpl(start, end - start);
     63        }
     64
    6365        const String& url() { return m_url; }
    6466        TextPosition startPosition() const { return m_startPosition; }
     
    9496        }
    9597
    96         virtual String getRange(int start, int end) const OVERRIDE
     98        virtual const String& source() const OVERRIDE
    9799        {
    98             return m_source.substringSharingImpl(start, end - start);
     100            return m_source;
    99101        }
    100         const StringImpl* data() const { return m_source.impl(); }
    101         int length() const { return m_source.length(); }
    102102
    103103    private:
Note: See TracChangeset for help on using the changeset viewer.