<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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173245
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
// 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);
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)) {
size_t JSStringGetLength(JSStringRef string)
{
+ if (!string)
+ return 0;
return string->length();
}
const JSChar* JSStringGetCharactersPtr(JSStringRef string)
{
+ if (!string)
+ return nullptr;
return string->characters();
}
size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize)
{
- if (!bufferSize)
+ if (!string || !buffer || !bufferSize)
return 0;
char* destination = buffer;
CFStringRef JSStringCopyCFString(CFAllocatorRef allocator, JSStringRef string)
{
- if (!string->length())
+ if (!string || !string->length())
return CFSTR("");
if (string->is8Bit())
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)
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())
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)
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();
+2014-09-03 David Kilzer <ddkilzer@apple.com>
+
+ JavaScriptCore 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 <fpizlo@apple.com>
CallEdgeProfile::visitWeak() shouldn't attempt to despecify empty profiles
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;
+2014-09-03 David Kilzer <ddkilzer@apple.com>
+
+ JavaScriptCore 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 <enrica@apple.com>
Remove PLATFORM(IOS) from WebCore/editing (Part 1).
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());
}