Changeset 173245 in webkit for trunk/Source/JavaScriptCore/API


Ignore:
Timestamp:
Sep 3, 2014, 5:53:16 PM (11 years ago)
Author:
[email protected]
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/JavaScriptCore/API
Files:
7 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();
Note: See TracChangeset for help on using the changeset viewer.