Title: [173245] trunk/Source
Revision
173245
Author
ddkil...@apple.com
Date
2014-09-03 17:53:16 -0700 (Wed, 03 Sep 2014)

Log Message

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

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

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.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSBase.cpp (173244 => 173245)


--- trunk/Source/_javascript_Core/API/JSBase.cpp	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/API/JSBase.cpp	2014-09-04 00:53:16 UTC (rev 173245)
@@ -60,7 +60,7 @@
 
     // evaluate sets "this" to the global object if it is NULL
     JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
-    SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
+    SourceCode source = makeSource(script ? script->string() : String(), sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
 
     JSValue evaluationException;
     JSValue returnValue = evaluate(globalObject->globalExec(), source, jsThisObject, &evaluationException);

Modified: trunk/Source/_javascript_Core/API/JSScriptRef.cpp (173244 => 173245)


--- trunk/Source/_javascript_Core/API/JSScriptRef.cpp	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/API/JSScriptRef.cpp	2014-09-04 00:53:16 UTC (rev 173245)
@@ -84,7 +84,7 @@
 
     startingLineNumber = std::max(1, startingLineNumber);
 
-    RefPtr<OpaqueJSScript> result = OpaqueJSScript::create(vm, url->string(), startingLineNumber, String(StringImpl::createFromLiteral(source, length)));
+    RefPtr<OpaqueJSScript> result = OpaqueJSScript::create(vm, url ? url->string() : String(), startingLineNumber, String(StringImpl::createFromLiteral(source, length)));
 
     ParserError error;
     if (!parseScript(vm, SourceCode(result), error)) {

Modified: trunk/Source/_javascript_Core/API/JSStringRef.cpp (173244 => 173245)


--- trunk/Source/_javascript_Core/API/JSStringRef.cpp	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/API/JSStringRef.cpp	2014-09-04 00:53:16 UTC (rev 173245)
@@ -78,11 +78,15 @@
 
 size_t JSStringGetLength(JSStringRef string)
 {
+    if (!string)
+        return 0;
     return string->length();
 }
 
 const JSChar* JSStringGetCharactersPtr(JSStringRef string)
 {
+    if (!string)
+        return nullptr;
     return string->characters();
 }
 
@@ -94,7 +98,7 @@
 
 size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize)
 {
-    if (!bufferSize)
+    if (!string || !buffer || !bufferSize)
         return 0;
 
     char* destination = buffer;

Modified: trunk/Source/_javascript_Core/API/JSStringRefCF.cpp (173244 => 173245)


--- trunk/Source/_javascript_Core/API/JSStringRefCF.cpp	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/API/JSStringRefCF.cpp	2014-09-04 00:53:16 UTC (rev 173245)
@@ -57,7 +57,7 @@
 
 CFStringRef JSStringCopyCFString(CFAllocatorRef allocator, JSStringRef string)
 {
-    if (!string->length())
+    if (!string || !string->length())
         return CFSTR("");
 
     if (string->is8Bit())

Modified: trunk/Source/_javascript_Core/API/JSValueRef.cpp (173244 => 173245)


--- trunk/Source/_javascript_Core/API/JSValueRef.cpp	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/API/JSValueRef.cpp	2014-09-04 00:53:16 UTC (rev 173245)
@@ -318,7 +318,7 @@
     ExecState* exec = toJS(ctx);
     JSLockHolder locker(exec);
 
-    return toRef(exec, jsString(exec, string->string()));
+    return toRef(exec, jsString(exec, string ? string->string() : String()));
 }
 
 JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string)

Modified: trunk/Source/_javascript_Core/API/OpaqueJSString.cpp (173244 => 173245)


--- trunk/Source/_javascript_Core/API/OpaqueJSString.cpp	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/API/OpaqueJSString.cpp	2014-09-04 00:53:16 UTC (rev 173245)
@@ -56,16 +56,13 @@
 
 String OpaqueJSString::string() const
 {
-    if (!this)
-        return String();
-
     // Return a copy of the wrapped string, because the caller may make it an Identifier.
     return m_string.isolatedCopy();
 }
 
 Identifier OpaqueJSString::identifier(VM* vm) const
 {
-    if (!this || m_string.isNull())
+    if (m_string.isNull())
         return Identifier();
 
     if (m_string.isEmpty())
@@ -79,9 +76,6 @@
 
 const UChar* OpaqueJSString::characters()
 {
-    if (!this)
-        return nullptr;
-
     // m_characters is put in a local here to avoid an extra atomic load.
     UChar* characters = m_characters;
     if (characters)

Modified: trunk/Source/_javascript_Core/API/OpaqueJSString.h (173244 => 173245)


--- trunk/Source/_javascript_Core/API/OpaqueJSString.h	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/API/OpaqueJSString.h	2014-09-04 00:53:16 UTC (rev 173245)
@@ -55,10 +55,10 @@
 
     JS_EXPORT_PRIVATE ~OpaqueJSString();
 
-    bool is8Bit() { return this ? m_string.is8Bit() : false; }
-    const LChar* characters8() { return this ? m_string.characters8() : nullptr; }
-    const UChar* characters16() { return this ? m_string.characters16() : nullptr; }
-    unsigned length() { return this ? m_string.length() : 0; }
+    bool is8Bit() { return m_string.is8Bit(); }
+    const LChar* characters8() { return m_string.characters8(); }
+    const UChar* characters16() { return m_string.characters16(); }
+    unsigned length() { return m_string.length(); }
 
     const UChar* characters();
 

Modified: trunk/Source/_javascript_Core/ChangeLog (173244 => 173245)


--- trunk/Source/_javascript_Core/ChangeLog	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-09-04 00:53:16 UTC (rev 173245)
@@ -1,3 +1,45 @@
+2014-09-03  David Kilzer  <ddkil...@apple.com>
+
+        _javascript_Core should build with newer clang
+        <http://webkit.org/b/136002>
+        <rdar://problem/18020616>
+
+        Reviewed by Geoffrey Garen.
+
+        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|.
+
 2014-09-03  Filip Pizlo  <fpi...@apple.com>
 
         CallEdgeProfile::visitWeak() shouldn't attempt to despecify empty profiles

Modified: trunk/Source/_javascript_Core/parser/SourceProvider.h (173244 => 173245)


--- trunk/Source/_javascript_Core/parser/SourceProvider.h	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.h	2014-09-04 00:53:16 UTC (rev 173245)
@@ -54,9 +54,6 @@
         TextPosition startPosition() const { return m_startPosition; }
         intptr_t asID()
         {
-            ASSERT(this);
-            if (!this) // Be defensive in release mode.
-                return nullID;
             if (!m_id)
                 getID();
             return m_id;

Modified: trunk/Source/WebKit2/ChangeLog (173244 => 173245)


--- trunk/Source/WebKit2/ChangeLog	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/WebKit2/ChangeLog	2014-09-04 00:53:16 UTC (rev 173245)
@@ -1,3 +1,16 @@
+2014-09-03  David Kilzer  <ddkil...@apple.com>
+
+        _javascript_Core should build with newer clang
+        <http://webkit.org/b/136002>
+        <rdar://problem/18020616>
+
+        Reviewed by Geoffrey Garen.
+
+        * 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.
+
 2014-09-03  Enrica Casucci  <enr...@apple.com>
 
         Remove PLATFORM(IOS) from WebCore/editing (Part 1).

Modified: trunk/Source/WebKit2/Shared/API/c/WKString.cpp (173244 => 173245)


--- trunk/Source/WebKit2/Shared/API/c/WKString.cpp	2014-09-04 00:28:50 UTC (rev 173244)
+++ trunk/Source/WebKit2/Shared/API/c/WKString.cpp	2014-09-04 00:53:16 UTC (rev 173245)
@@ -85,7 +85,7 @@
 
 WKStringRef WKStringCreateWithJSString(JSStringRef jsStringRef)
 {
-    RefPtr<API::String> apiString = API::String::create(jsStringRef);
+    RefPtr<API::String> apiString = jsStringRef ? API::String::create(jsStringRef) : API::String::createNull();
     return toAPI(apiString.release().leakRef());
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to