Changeset 173245 in webkit


Ignore:
Timestamp:
Sep 3, 2014 5:53:16 PM (10 years ago)
Author:
ddkilzer@apple.com
Message:

JavaScriptCore should build with newer clang
<http://webkit.org/b/136002>
<rdar://problem/18020616>

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Other than the JSC::SourceProvider::asID() change (which simply
removes code that the optimizing compiler would have discarded
in Release builds), we move the |this| checks in OpaqueJSString
to NULL checks in to JSBase, JSScriptRef, JSStringRef{CF} and
JSValueRef.

  • API/JSBase.cpp:

(JSEvaluateScript): Use String() in case |script| or |sourceURL|
are NULL.

  • API/JSScriptRef.cpp:

(JSScriptCreateReferencingImmortalASCIIText): Use String() in
case |url| is NULL.

  • API/JSStringRef.cpp:

(JSStringGetLength): Return early if NULL pointer is passed in.
(JSStringGetCharactersPtr): Ditto.
(JSStringGetUTF8CString): Ditto. Also check |buffer| parameter.

  • API/JSStringRefCF.cpp:

(JSStringCopyCFString): Ditto.

  • API/JSValueRef.cpp:

(JSValueMakeString): Use String() in case |string| is NULL.

  • API/OpaqueJSString.cpp:

(OpaqueJSString::string): Remove code that checks |this|.
(OpaqueJSString::identifier): Ditto.
(OpaqueJSString::characters): Ditto.

  • API/OpaqueJSString.h:

(OpaqueJSString::is8Bit): Remove code that checks |this|.
(OpaqueJSString::characters8): Ditto.
(OpaqueJSString::characters16): Ditto.
(OpaqueJSString::length): Ditto.

  • parser/SourceProvider.h:

(JSC::SourceProvider::asID): Remove code that checks |this|.

Source/WebKit2:

  • Shared/API/c/WKString.cpp:

(WKStringCreateWithJSString): Add NULL check to prevent
WebKitTestRunner crashes that relied on the previous |this|
behavior where NULL values were allowed.

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSBase.cpp

    r167326 r173245  
    6161    // evaluate sets "this" to the global object if it is NULL
    6262    JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
    63     SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
     63    SourceCode source = makeSource(script ? script->string() : String(), sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
    6464
    6565    JSValue evaluationException;
  • trunk/Source/JavaScriptCore/API/JSScriptRef.cpp

    r167313 r173245  
    8585    startingLineNumber = std::max(1, startingLineNumber);
    8686
    87     RefPtr<OpaqueJSScript> result = OpaqueJSScript::create(vm, url->string(), startingLineNumber, String(StringImpl::createFromLiteral(source, length)));
     87    RefPtr<OpaqueJSScript> result = OpaqueJSScript::create(vm, url ? url->string() : String(), startingLineNumber, String(StringImpl::createFromLiteral(source, length)));
    8888
    8989    ParserError error;
  • trunk/Source/JavaScriptCore/API/JSStringRef.cpp

    r165676 r173245  
    7979size_t JSStringGetLength(JSStringRef string)
    8080{
     81    if (!string)
     82        return 0;
    8183    return string->length();
    8284}
     
    8486const JSChar* JSStringGetCharactersPtr(JSStringRef string)
    8587{
     88    if (!string)
     89        return nullptr;
    8690    return string->characters();
    8791}
     
    9599size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize)
    96100{
    97     if (!bufferSize)
     101    if (!string || !buffer || !bufferSize)
    98102        return 0;
    99103
  • trunk/Source/JavaScriptCore/API/JSStringRefCF.cpp

    r165676 r173245  
    5858CFStringRef JSStringCopyCFString(CFAllocatorRef allocator, JSStringRef string)
    5959{
    60     if (!string->length())
     60    if (!string || !string->length())
    6161        return CFSTR("");
    6262
  • trunk/Source/JavaScriptCore/API/JSValueRef.cpp

    r171543 r173245  
    319319    JSLockHolder locker(exec);
    320320
    321     return toRef(exec, jsString(exec, string->string()));
     321    return toRef(exec, jsString(exec, string ? string->string() : String()));
    322322}
    323323
  • trunk/Source/JavaScriptCore/API/OpaqueJSString.cpp

    r165719 r173245  
    5757String OpaqueJSString::string() const
    5858{
    59     if (!this)
    60         return String();
    61 
    6259    // Return a copy of the wrapped string, because the caller may make it an Identifier.
    6360    return m_string.isolatedCopy();
     
    6663Identifier OpaqueJSString::identifier(VM* vm) const
    6764{
    68     if (!this || m_string.isNull())
     65    if (m_string.isNull())
    6966        return Identifier();
    7067
     
    8077const UChar* OpaqueJSString::characters()
    8178{
    82     if (!this)
    83         return nullptr;
    84 
    8579    // m_characters is put in a local here to avoid an extra atomic load.
    8680    UChar* characters = m_characters;
  • trunk/Source/JavaScriptCore/API/OpaqueJSString.h

    r165676 r173245  
    5656    JS_EXPORT_PRIVATE ~OpaqueJSString();
    5757
    58     bool is8Bit() { return this ? m_string.is8Bit() : false; }
    59     const LChar* characters8() { return this ? m_string.characters8() : nullptr; }
    60     const UChar* characters16() { return this ? m_string.characters16() : nullptr; }
    61     unsigned length() { return this ? m_string.length() : 0; }
     58    bool is8Bit() { return m_string.is8Bit(); }
     59    const LChar* characters8() { return m_string.characters8(); }
     60    const UChar* characters16() { return m_string.characters16(); }
     61    unsigned length() { return m_string.length(); }
    6262
    6363    const UChar* characters();
  • trunk/Source/JavaScriptCore/ChangeLog

    r173244 r173245  
     12014-09-03  David Kilzer  <ddkilzer@apple.com>
     2
     3        JavaScriptCore should build with newer clang
     4        <http://webkit.org/b/136002>
     5        <rdar://problem/18020616>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Other than the JSC::SourceProvider::asID() change (which simply
     10        removes code that the optimizing compiler would have discarded
     11        in Release builds), we move the |this| checks in OpaqueJSString
     12        to NULL checks in to JSBase, JSScriptRef, JSStringRef{CF} and
     13        JSValueRef.
     14
     15        * API/JSBase.cpp:
     16        (JSEvaluateScript): Use String() in case |script| or |sourceURL|
     17        are NULL.
     18        * API/JSScriptRef.cpp:
     19        (JSScriptCreateReferencingImmortalASCIIText): Use String() in
     20        case |url| is NULL.
     21        * API/JSStringRef.cpp:
     22        (JSStringGetLength): Return early if NULL pointer is passed in.
     23        (JSStringGetCharactersPtr): Ditto.
     24        (JSStringGetUTF8CString): Ditto.  Also check |buffer| parameter.
     25        * API/JSStringRefCF.cpp:
     26        (JSStringCopyCFString): Ditto.
     27        * API/JSValueRef.cpp:
     28        (JSValueMakeString): Use String() in case |string| is NULL.
     29
     30        * API/OpaqueJSString.cpp:
     31        (OpaqueJSString::string): Remove code that checks |this|.
     32        (OpaqueJSString::identifier): Ditto.
     33        (OpaqueJSString::characters): Ditto.
     34        * API/OpaqueJSString.h:
     35        (OpaqueJSString::is8Bit): Remove code that checks |this|.
     36        (OpaqueJSString::characters8): Ditto.
     37        (OpaqueJSString::characters16): Ditto.
     38        (OpaqueJSString::length): Ditto.
     39
     40        * parser/SourceProvider.h:
     41        (JSC::SourceProvider::asID): Remove code that checks |this|.
     42
    1432014-09-03  Filip Pizlo  <fpizlo@apple.com>
    244
  • trunk/Source/JavaScriptCore/parser/SourceProvider.h

    r165676 r173245  
    5555        intptr_t asID()
    5656        {
    57             ASSERT(this);
    58             if (!this) // Be defensive in release mode.
    59                 return nullID;
    6057            if (!m_id)
    6158                getID();
  • trunk/Source/WebKit2/ChangeLog

    r173235 r173245  
     12014-09-03  David Kilzer  <ddkilzer@apple.com>
     2
     3        JavaScriptCore should build with newer clang
     4        <http://webkit.org/b/136002>
     5        <rdar://problem/18020616>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        * Shared/API/c/WKString.cpp:
     10        (WKStringCreateWithJSString): Add NULL check to prevent
     11        WebKitTestRunner crashes that relied on the previous |this|
     12        behavior where NULL values were allowed.
     13
    1142014-09-03  Enrica Casucci  <enrica@apple.com>
    215
  • trunk/Source/WebKit2/Shared/API/c/WKString.cpp

    r160608 r173245  
    8686WKStringRef WKStringCreateWithJSString(JSStringRef jsStringRef)
    8787{
    88     RefPtr<API::String> apiString = API::String::create(jsStringRef);
     88    RefPtr<API::String> apiString = jsStringRef ? API::String::create(jsStringRef) : API::String::createNull();
    8989    return toAPI(apiString.release().leakRef());
    9090}
Note: See TracChangeset for help on using the changeset viewer.