Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (232659 => 232660)
--- trunk/Source/_javascript_Core/ChangeLog 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,3 +1,13 @@
+2018-06-08 Darin Adler <[email protected]>
+
+ [Cocoa] Remove all uses of NSAutoreleasePool as part of preparation for ARC
+ https://bugs.webkit.org/show_bug.cgi?id=186436
+
+ Reviewed by Anders Carlsson.
+
+ * heap/Heap.cpp: Include FoundationSPI.h rather than directly including
+ objc-internal.h and explicitly declaring the alternative.
+
2018-06-08 Wenson Hsieh <[email protected]>
[WebKit on watchOS] Upstream watchOS source additions to OpenSource (Part 1)
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (232659 => 232660)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2018-06-09 16:27:16 UTC (rev 232660)
@@ -62,10 +62,10 @@
#include "SamplingProfiler.h"
#include "ShadowChicken.h"
#include "SpaceTimeMutatorScheduler.h"
+#include "StochasticSpaceTimeMutatorScheduler.h"
+#include "StopIfNecessaryTimer.h"
#include "SubspaceInlines.h"
#include "SuperSampler.h"
-#include "StochasticSpaceTimeMutatorScheduler.h"
-#include "StopIfNecessaryTimer.h"
#include "SweepingScope.h"
#include "SynchronousStopTheWorldMutatorScheduler.h"
#include "TypeProfiler.h"
@@ -77,9 +77,6 @@
#include "WeakMapImplInlines.h"
#include "WeakSetInlines.h"
#include <algorithm>
-#if PLATFORM(IOS)
-#include <bmalloc/bmalloc.h>
-#endif
#include <wtf/ListDump.h>
#include <wtf/MainThread.h>
#include <wtf/ParallelVectorIterator.h>
@@ -88,14 +85,13 @@
#include <wtf/SimpleStats.h>
#include <wtf/Threading.h>
+#if PLATFORM(IOS)
+#include <bmalloc/bmalloc.h>
+#endif
+
#if USE(FOUNDATION)
-#if __has_include(<objc/objc-internal.h>)
-#include <objc/objc-internal.h>
-#else
-extern "C" void* objc_autoreleasePoolPush(void);
-extern "C" void objc_autoreleasePoolPop(void *context);
+#include <wtf/spi/cocoa/FoundationSPI.h>
#endif
-#endif // USE(FOUNDATION)
#if USE(GLIB)
#include "JSCGLibWrapperObject.h"
Modified: trunk/Source/WTF/ChangeLog (232659 => 232660)
--- trunk/Source/WTF/ChangeLog 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WTF/ChangeLog 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,3 +1,25 @@
+2018-06-08 Darin Adler <[email protected]>
+
+ [Cocoa] Remove all uses of NSAutoreleasePool as part of preparation for ARC
+ https://bugs.webkit.org/show_bug.cgi?id=186436
+
+ Reviewed by Anders Carlsson.
+
+ * WTF.xcodeproj/project.pbxproj: Added FoundationSPI.h.
+
+ * wtf/AutodrainedPool.h: Streamlined header a bit, added some comments.
+
+ * wtf/PlatformMac.cmake: Added FoundationSPI.h.
+
+ * wtf/cocoa/AutodrainedPool.cpp: Moved here from AutodrainedPoolMac.mm.
+ (WTF::AutodrainedPool::AutodrainedPool): Use objc_autoreleasePoolPush/Pop instead of
+ the NSAutoreleasePool class.
+ (WTF::AutodrainedPool::~AutodrainedPool): Ditto.
+
+ * wtf/spi/cocoa/FoundationSPI.h: Moved from Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h.
+ Changed both include and declarations so it's the objc_autoreleasePoolPush/Pop instead
+ of the higher level NS functions that call them.
+
2018-06-08 Brian Burg <[email protected]>
[Cocoa] Web Automation: include browser name and version in listing for automation targets
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (232659 => 232660)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2018-06-09 16:27:16 UTC (rev 232660)
@@ -53,7 +53,7 @@
1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419116EAAF6D0024E146 /* RunLoopTimerCF.cpp */; };
1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1469419516EAAFF80024E146 /* SchedulePairMac.mm */; };
1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419816EAB0410024E146 /* SchedulePairCF.cpp */; };
- 1469419D16EAB10A0024E146 /* AutodrainedPoolMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1469419B16EAB10A0024E146 /* AutodrainedPoolMac.mm */; };
+ 1469419D16EAB10A0024E146 /* AutodrainedPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */; };
1A1D8B9E1731879800141DA4 /* FunctionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */; };
1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */; };
1C181C7F1D3078DA00F5FA16 /* TextBreakIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C181C7D1D3078DA00F5FA16 /* TextBreakIterator.cpp */; };
@@ -284,7 +284,7 @@
1469419516EAAFF80024E146 /* SchedulePairMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SchedulePairMac.mm; sourceTree = "<group>"; };
1469419816EAB0410024E146 /* SchedulePairCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchedulePairCF.cpp; sourceTree = "<group>"; };
1469419A16EAB10A0024E146 /* AutodrainedPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutodrainedPool.h; sourceTree = "<group>"; };
- 1469419B16EAB10A0024E146 /* AutodrainedPoolMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutodrainedPoolMac.mm; sourceTree = "<group>"; };
+ 1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutodrainedPool.cpp; sourceTree = "<group>"; };
149EF16216BBFE0D000A4331 /* TriState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriState.h; sourceTree = "<group>"; };
14C8279718FDD73400E1800C /* mbmalloc.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = mbmalloc.xcconfig; sourceTree = "<group>"; };
14E785E71DFB330100209BD1 /* OrdinalNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrdinalNumber.h; sourceTree = "<group>"; };
@@ -408,6 +408,7 @@
93934BD218A1E8C300D0D6A1 /* StringViewObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = StringViewObjC.mm; path = mac/StringViewObjC.mm; sourceTree = "<group>"; };
93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringViewCF.cpp; path = cf/StringViewCF.cpp; sourceTree = "<group>"; };
93AC91A718942FC400244939 /* LChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LChar.h; sourceTree = "<group>"; };
+ 93D191CF20CAECE800C51B8E /* FoundationSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FoundationSPI.h; sourceTree = "<group>"; };
93DDE9311CDC052D00FD3491 /* dyldSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dyldSPI.h; sourceTree = "<group>"; };
93F1993D19D7958D00C2390B /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = "<group>"; };
974CFC8D16A4F327006D5404 /* WeakPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakPtr.h; sourceTree = "<group>"; };
@@ -807,7 +808,6 @@
A8A4725C151A825A004123FF /* Assertions.h */,
A8A4725D151A825A004123FF /* Atomics.h */,
1469419A16EAB10A0024E146 /* AutodrainedPool.h */,
- 1469419B16EAB10A0024E146 /* AutodrainedPoolMac.mm */,
0F43D8EF1DB5ADDC00108FB6 /* AutomaticThread.cpp */,
0F43D8F01DB5ADDC00108FB6 /* AutomaticThread.h */,
DCEE22041CEB9869000C2396 /* BackwardsGraph.h */,
@@ -1269,6 +1269,7 @@
CE46516C19DB1FB4003ECA05 /* cocoa */ = {
isa = PBXGroup;
children = (
+ 93D191CF20CAECE800C51B8E /* FoundationSPI.h */,
CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */,
A5098B011C16A4F900087797 /* SecuritySPI.h */,
);
@@ -1322,6 +1323,7 @@
E4A0AD3B1A96251900536DF6 /* cocoa */ = {
isa = PBXGroup;
children = (
+ 1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */,
E38C41241EB4E04C0042957D /* CPUTimeCocoa.mm */,
143DDE9520C8BC37007F76FA /* Entitlements.cpp */,
143DDE9720C8BE99007F76FA /* Entitlements.h */,
@@ -1445,7 +1447,7 @@
70ECA60D1B02426800449739 /* AtomicStringImpl.cpp in Sources */,
A5BA15FA182435A600A82E69 /* AtomicStringImplCF.cpp in Sources */,
9BC70F05176C379D00101DEC /* AtomicStringTable.cpp in Sources */,
- 1469419D16EAB10A0024E146 /* AutodrainedPoolMac.mm in Sources */,
+ 1469419D16EAB10A0024E146 /* AutodrainedPool.cpp in Sources */,
0F43D8F11DB5ADDC00108FB6 /* AutomaticThread.cpp in Sources */,
8134013815B092FD001FF0B8 /* Base64.cpp in Sources */,
A8A473A8151A825B004123FF /* bignum-dtoa.cc in Sources */,
Modified: trunk/Source/WTF/wtf/AutodrainedPool.h (232659 => 232660)
--- trunk/Source/WTF/wtf/AutodrainedPool.h 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WTF/wtf/AutodrainedPool.h 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,31 +26,35 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef AutodrainedPool_h
-#define AutodrainedPool_h
+#pragma once
+#ifdef __OBJC__
+#error Please use @autoreleasepool instead of AutodrainedPool.
+#endif
+
#include <wtf/Noncopyable.h>
-#if USE(FOUNDATION) && !defined(__OBJC__)
-typedef struct objc_object *id;
-#endif
-
namespace WTF {
+// This class allows non-Objective-C C++ code to create an autorelease pool.
+// It cannot be used in Objective-C++ code, won't be compiled; instead @autoreleasepool should be used.
+// It can be used in cross-platform code; will compile down to nothing for non-Cocoa platforms.
+
class AutodrainedPool {
WTF_MAKE_NONCOPYABLE(AutodrainedPool);
+
public:
#if USE(FOUNDATION)
WTF_EXPORT_PRIVATE AutodrainedPool();
WTF_EXPORT_PRIVATE ~AutodrainedPool();
#else
- explicit AutodrainedPool() { }
+ AutodrainedPool() { }
~AutodrainedPool() { }
#endif
-
+
private:
#if USE(FOUNDATION)
- id m_pool;
+ void* m_autoreleasePool;
#endif
};
@@ -57,5 +61,3 @@
} // namespace WTF
using WTF::AutodrainedPool;
-
-#endif
Deleted: trunk/Source/WTF/wtf/AutodrainedPoolMac.mm (232659 => 232660)
--- trunk/Source/WTF/wtf/AutodrainedPoolMac.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WTF/wtf/AutodrainedPoolMac.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007, 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "AutodrainedPool.h"
-
-#import <Foundation/Foundation.h>
-
-namespace WTF {
-
-AutodrainedPool::AutodrainedPool()
- : m_pool([[NSAutoreleasePool alloc] init])
-{
-}
-
-AutodrainedPool::~AutodrainedPool()
-{
- [m_pool drain];
-}
-
-} // namespace WTF
Modified: trunk/Source/WTF/wtf/PlatformMac.cmake (232659 => 232660)
--- trunk/Source/WTF/wtf/PlatformMac.cmake 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WTF/wtf/PlatformMac.cmake 2018-06-09 16:27:16 UTC (rev 232660)
@@ -21,6 +21,7 @@
spi/cf/CFBundleSPI.h
spi/cf/CFStringSPI.h
+ spi/cocoa/FoundationSPI.h
spi/cocoa/NSMapTableSPI.h
spi/cocoa/SecuritySPI.h
@@ -32,7 +33,6 @@
)
list(APPEND WTF_SOURCES
- AutodrainedPoolMac.mm
BlockObjCExceptions.mm
RunLoopTimerCF.cpp
SchedulePairCF.cpp
@@ -41,8 +41,7 @@
cf/LanguageCF.cpp
cf/RunLoopCF.cpp
- text/mac/TextBreakIteratorInternalICUMac.mm
-
+ cocoa/AutodrainedPool.mm
cocoa/CPUTimeCocoa.mm
cocoa/Entitlements.cpp
cocoa/MachSendRight.cpp
@@ -61,6 +60,7 @@
text/mac/StringImplMac.mm
text/mac/StringMac.mm
text/mac/StringViewObjC.mm
+ text/mac/TextBreakIteratorInternalICUMac.mm
)
list(APPEND WTF_PRIVATE_INCLUDE_DIRECTORIES
Copied: trunk/Source/WTF/wtf/cocoa/AutodrainedPool.cpp (from rev 232659, trunk/Source/WTF/wtf/AutodrainedPoolMac.mm) (0 => 232660)
--- trunk/Source/WTF/wtf/cocoa/AutodrainedPool.cpp (rev 0)
+++ trunk/Source/WTF/wtf/cocoa/AutodrainedPool.cpp 2018-06-09 16:27:16 UTC (rev 232660)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2007-2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "AutodrainedPool.h"
+
+#import <wtf/spi/cocoa/FoundationSPI.h>
+
+namespace WTF {
+
+AutodrainedPool::AutodrainedPool()
+ : m_autoreleasePool { objc_autoreleasePoolPush() }
+{
+}
+
+AutodrainedPool::~AutodrainedPool()
+{
+ objc_autoreleasePoolPop(m_autoreleasePool);
+}
+
+} // namespace WTF
Copied: trunk/Source/WTF/wtf/spi/cocoa/FoundationSPI.h (from rev 232659, trunk/Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h) (0 => 232660)
--- trunk/Source/WTF/wtf/spi/cocoa/FoundationSPI.h (rev 0)
+++ trunk/Source/WTF/wtf/spi/cocoa/FoundationSPI.h 2018-06-09 16:27:16 UTC (rev 232660)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#include <objc/objc-internal.h>
+
+#else
+
+WTF_EXTERN_C_BEGIN
+
+void* objc_autoreleasePoolPush(void);
+void objc_autoreleasePoolPop(void* context);
+
+WTF_EXTERN_C_END
+
+#endif
Modified: trunk/Source/WebCore/ChangeLog (232659 => 232660)
--- trunk/Source/WebCore/ChangeLog 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/ChangeLog 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,3 +1,34 @@
+2018-06-08 Darin Adler <[email protected]>
+
+ [Cocoa] Remove all uses of NSAutoreleasePool as part of preparation for ARC
+ https://bugs.webkit.org/show_bug.cgi?id=186436
+
+ Reviewed by Anders Carlsson.
+
+ * bridge/objc/objc_class.mm: Use import instead of include.
+
+ * bridge/objc/objc_instance.h: Replaced _pool member to hold an object with
+ m_autoreleasePool member to hold a token from objc_autoreleasePoolPush. Also
+ initialize all data members here in the class definition.
+
+ * bridge/objc/objc_instance.mm:
+ (ObjcInstance::ObjcInstance): Moved most initialization to class definition.
+ (ObjcInstance::virtualBegin): Use objc_autoreleasePoolPush instead of
+ NSAutoreleasePool class.
+ (ObjcInstance::virtualEnd): Use objc_autoreleasePoolPop.
+
+ * bridge/objc/objc_runtime.mm: Use import instead of include.
+ * bridge/objc/objc_utility.mm: Ditto.
+
+ * platform/audio/mac/AudioBusMac.mm:
+ (WebCore::AudioBus::loadPlatformResource): Use @autoreleasepool.
+
+ * platform/ios/wak/WebCoreThread.mm: Re-sorted includes. Removed declaration of
+ autorelease pool SPI and use FoundationSPI.h instead.
+
+ * platform/network/cocoa/ResourceResponseCocoa.mm:
+ (WebCore::ResourceResponse::platformLazyInit): Use @autoreleasepool.
+
2018-06-08 Wenson Hsieh <[email protected]>
[WebKit on watchOS] Upstream watchOS source additions to OpenSource (Part 1)
Modified: trunk/Source/WebCore/PAL/ChangeLog (232659 => 232660)
--- trunk/Source/WebCore/PAL/ChangeLog 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/PAL/ChangeLog 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,3 +1,14 @@
+2018-06-08 Darin Adler <[email protected]>
+
+ [Cocoa] Remove all uses of NSAutoreleasePool as part of preparation for ARC
+ https://bugs.webkit.org/show_bug.cgi?id=186436
+
+ Reviewed by Anders Carlsson.
+
+ * PAL.xcodeproj/project.pbxproj: Removed FoundationSPI.h.
+ * pal/PlatformMac.cmake: Ditto.
+ * pal/spi/cocoa/FoundationSPI.h: Moved into WTF project.
+
2018-06-08 Wenson Hsieh <[email protected]>
[WebKit on watchOS] Upstream watchOS source additions to OpenSource (Part 1)
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (232659 => 232660)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2018-06-09 16:27:16 UTC (rev 232660)
@@ -112,7 +112,6 @@
57F12518205787D7001AB8A6 /* DeviceIdentitySPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 57F12517205787C8001AB8A6 /* DeviceIdentitySPI.h */; };
7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */; };
7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */; };
- A10265871F56746100B4C844 /* FoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265861F56746100B4C844 /* FoundationSPI.h */; };
A10265891F56747A00B4C844 /* HIToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265881F56747A00B4C844 /* HIToolboxSPI.h */; };
A102658B1F56748C00B4C844 /* QuickDrawSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A102658A1F56748C00B4C844 /* QuickDrawSPI.h */; };
A102658E1F567E9D00B4C844 /* HIServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A102658D1F567E9D00B4C844 /* HIServicesSPI.h */; };
@@ -261,7 +260,6 @@
7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSKeyedArchiverSPI.h; sourceTree = "<group>"; };
7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSImageSPI.h; sourceTree = "<group>"; };
93E5909C1F93BF1E0067F8CF /* UnencodableHandling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UnencodableHandling.h; sourceTree = "<group>"; };
- A10265861F56746100B4C844 /* FoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoundationSPI.h; sourceTree = "<group>"; };
A10265881F56747A00B4C844 /* HIToolboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HIToolboxSPI.h; sourceTree = "<group>"; };
A102658A1F56748C00B4C844 /* QuickDrawSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickDrawSPI.h; sourceTree = "<group>"; };
A102658D1F567E9D00B4C844 /* HIServicesSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HIServicesSPI.h; sourceTree = "<group>"; };
@@ -364,7 +362,6 @@
0C2DA1241F3BEB4900DBC317 /* CoreTextSPI.h */,
0C2DA1251F3BEB4900DBC317 /* DataDetectorsCoreSPI.h */,
57F12517205787C8001AB8A6 /* DeviceIdentitySPI.h */,
- A10265861F56746100B4C844 /* FoundationSPI.h */,
0C2DA1261F3BEB4900DBC317 /* IOPMLibSPI.h */,
0C2DA1271F3BEB4900DBC317 /* IOPSLibSPI.h */,
0C2DA1281F3BEB4900DBC317 /* IOReturnSPI.h */,
@@ -639,7 +636,6 @@
57F12518205787D7001AB8A6 /* DeviceIdentitySPI.h in Headers */,
0C2D9E731EEF5AF600DBC317 /* ExportMacros.h in Headers */,
F44291601FA5261E002CC93E /* FileSizeFormatter.h in Headers */,
- A10265871F56746100B4C844 /* FoundationSPI.h in Headers */,
0C5AF91B1F43A4C7002EAC02 /* GraphicsServicesSPI.h in Headers */,
A102658E1F567E9D00B4C844 /* HIServicesSPI.h in Headers */,
A10265891F56747A00B4C844 /* HIToolboxSPI.h in Headers */,
Modified: trunk/Source/WebCore/PAL/pal/PlatformMac.cmake (232659 => 232660)
--- trunk/Source/WebCore/PAL/pal/PlatformMac.cmake 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/PAL/pal/PlatformMac.cmake 2018-06-09 16:27:16 UTC (rev 232660)
@@ -17,7 +17,6 @@
spi/cocoa/CFNSURLConnectionSPI.h
spi/cocoa/CoreTextSPI.h
spi/cocoa/DataDetectorsCoreSPI.h
- spi/cocoa/FoundationSPI.h
spi/cocoa/IOPMLibSPI.h
spi/cocoa/IOPSLibSPI.h
spi/cocoa/IOReturnSPI.h
Deleted: trunk/Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h (232659 => 232660)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/FoundationSPI.h 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if USE(APPLE_INTERNAL_SDK)
-
-#include <Foundation/NSPrivateDecls.h>
-
-#endif
-
-typedef void* NSAutoreleasePoolMark;
-
-WTF_EXTERN_C_BEGIN
-
-NSAutoreleasePoolMark NSPushAutoreleasePool(NSUInteger capacity);
-void NSPopAutoreleasePool(NSAutoreleasePoolMark);
-
-WTF_EXTERN_C_END
Modified: trunk/Source/WebCore/bridge/objc/objc_class.mm (232659 => 232660)
--- trunk/Source/WebCore/bridge/objc/objc_class.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/bridge/objc/objc_class.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -23,12 +23,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "objc_class.h"
+#import "config.h"
+#import "objc_class.h"
-#include "objc_instance.h"
-#include "WebScriptObject.h"
-#include "WebScriptObjectProtocol.h"
+#import "WebScriptObject.h"
+#import "WebScriptObjectProtocol.h"
+#import "objc_instance.h"
namespace JSC {
namespace Bindings {
Modified: trunk/Source/WebCore/bridge/objc/objc_instance.h (232659 => 232660)
--- trunk/Source/WebCore/bridge/objc/objc_instance.h 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/bridge/objc/objc_instance.h 2018-06-09 16:27:16 UTC (rev 232660)
@@ -23,12 +23,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef BINDINGS_OBJC_INSTANCE_H_
-#define BINDINGS_OBJC_INSTANCE_H_
+#import "objc_class.h"
+#import "objc_utility.h"
-#include "objc_class.h"
-#include "objc_utility.h"
-
namespace JSC {
namespace Bindings {
@@ -75,13 +72,11 @@
virtual RuntimeObject* newRuntimeObject(ExecState*);
RetainPtr<ObjectStructPtr> _instance;
- mutable ObjcClass *_class;
- ObjectStructPtr _pool;
- int _beginCount;
+ mutable ObjcClass* _class { nullptr };
+ void* m_autoreleasePool { nullptr };
+ int _beginCount { 0 };
};
} // namespace Bindings
} // namespace JSC
-
-#endif // BINDINGS_OBJC_INSTANCE_H_
Modified: trunk/Source/WebCore/bridge/objc/objc_instance.mm (232659 => 232660)
--- trunk/Source/WebCore/bridge/objc/objc_instance.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/bridge/objc/objc_instance.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -40,6 +40,7 @@
#import <wtf/MainThread.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/ThreadSpecific.h>
+#import <wtf/spi/cocoa/FoundationSPI.h>
#ifdef NDEBUG
#define OBJC_LOG(formatAndArgs...) ((void)0)
@@ -100,9 +101,6 @@
ObjcInstance::ObjcInstance(id instance, RefPtr<RootObject>&& rootObject)
: Instance(WTFMove(rootObject))
, _instance(instance)
- , _class(0)
- , _pool(0)
- , _beginCount(0)
{
}
@@ -133,8 +131,8 @@
void ObjcInstance::virtualBegin()
{
- if (!_pool)
- _pool = [[NSAutoreleasePool alloc] init];
+ if (!m_autoreleasePool)
+ m_autoreleasePool = objc_autoreleasePoolPush();
_beginCount++;
}
@@ -143,8 +141,9 @@
_beginCount--;
ASSERT(_beginCount >= 0);
if (!_beginCount) {
- [_pool drain];
- _pool = 0;
+ ASSERT(m_autoreleasePool);
+ objc_autoreleasePoolPop(m_autoreleasePool);
+ m_autoreleasePool = nullptr;
}
}
@@ -507,13 +506,11 @@
JSC::JSValue ObjcInstance::numberValue(ExecState*) const
{
- // FIXME: Implement something sensible
return jsNumber(0);
}
JSC::JSValue ObjcInstance::booleanValue() const
{
- // FIXME: Implement something sensible
return jsBoolean(false);
}
Modified: trunk/Source/WebCore/bridge/objc/objc_runtime.mm (232659 => 232660)
--- trunk/Source/WebCore/bridge/objc/objc_runtime.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/bridge/objc/objc_runtime.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -23,20 +23,20 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "objc_runtime.h"
+#import "config.h"
+#import "objc_runtime.h"
-#include "JSDOMBinding.h"
-#include "ObjCRuntimeObject.h"
-#include "WebScriptObject.h"
-#include "WebScriptObjectProtocol.h"
-#include "objc_instance.h"
-#include "runtime_array.h"
-#include "runtime_object.h"
-#include <_javascript_Core/Error.h>
-#include <_javascript_Core/JSGlobalObject.h>
-#include <_javascript_Core/JSLock.h>
-#include <wtf/RetainPtr.h>
+#import "JSDOMBinding.h"
+#import "ObjCRuntimeObject.h"
+#import "WebScriptObject.h"
+#import "WebScriptObjectProtocol.h"
+#import "objc_instance.h"
+#import "runtime_array.h"
+#import "runtime_object.h"
+#import <_javascript_Core/Error.h>
+#import <_javascript_Core/JSGlobalObject.h>
+#import <_javascript_Core/JSLock.h>
+#import <wtf/RetainPtr.h>
using namespace WebCore;
Modified: trunk/Source/WebCore/bridge/objc/objc_utility.mm (232659 => 232660)
--- trunk/Source/WebCore/bridge/objc/objc_utility.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/bridge/objc/objc_utility.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -23,16 +23,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "objc_utility.h"
+#import "config.h"
+#import "objc_utility.h"
-#include "WebScriptObjectProtocol.h"
-#include "objc_instance.h"
-#include "runtime_array.h"
-#include "runtime_object.h"
-#include <_javascript_Core/JSGlobalObject.h>
-#include <_javascript_Core/JSLock.h>
-#include <wtf/Assertions.h>
+#import "WebScriptObjectProtocol.h"
+#import "objc_instance.h"
+#import "runtime_array.h"
+#import "runtime_object.h"
+#import <_javascript_Core/JSGlobalObject.h>
+#import <_javascript_Core/JSLock.h>
+#import <wtf/Assertions.h>
#if !defined(_C_LNG_LNG)
#define _C_LNG_LNG 'q'
Modified: trunk/Source/WebCore/platform/audio/mac/AudioBusMac.mm (232659 => 232660)
--- trunk/Source/WebCore/platform/audio/mac/AudioBusMac.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/platform/audio/mac/AudioBusMac.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -29,9 +29,6 @@
#import "AudioBus.h"
#import "AudioFileReader.h"
-#import <wtf/AutodrainedPool.h>
-#import <wtf/RefPtr.h>
-#import <Foundation/Foundation.h>
@interface WebCoreAudioBundleClass : NSObject
@end
@@ -43,17 +40,13 @@
RefPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, float sampleRate)
{
- // This method can be called from other than the main thread, so we need an auto-release pool.
- AutodrainedPool pool;
-
- NSBundle *bundle = [NSBundle bundleForClass:[WebCoreAudioBundleClass class]];
- NSURL *audioFileURL = [bundle URLForResource:[NSString stringWithUTF8String:name] withExtension:@"wav" subdirectory:@"audio"];
- NSDataReadingOptions options = NSDataReadingMappedIfSafe;
- NSData *audioData = [NSData dataWithContentsOfURL:audioFileURL options:options error:nil];
+ @autoreleasepool {
+ NSBundle *bundle = [NSBundle bundleForClass:[WebCoreAudioBundleClass class]];
+ NSURL *audioFileURL = [bundle URLForResource:[NSString stringWithUTF8String:name] withExtension:@"wav" subdirectory:@"audio"];
+ if (NSData *audioData = [NSData dataWithContentsOfURL:audioFileURL options:NSDataReadingMappedIfSafe error:nil])
+ return createBusFromInMemoryAudioFile([audioData bytes], [audioData length], false, sampleRate);
+ }
- if (audioData)
- return createBusFromInMemoryAudioFile([audioData bytes], [audioData length], false, sampleRate);
-
ASSERT_NOT_REACHED();
return nullptr;
}
Modified: trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm (232659 => 232660)
--- trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,24 +34,23 @@
#import "RuntimeApplicationChecks.h"
#import "ThreadGlobalData.h"
#import "WAKWindow.h"
+#import "WKUtilities.h"
#import "WebCoreThreadInternal.h"
#import "WebCoreThreadMessage.h"
#import "WebCoreThreadRun.h"
-#import "WKUtilities.h"
-
+#import <Foundation/NSInvocation.h>
#import <_javascript_Core/InitializeThreading.h>
#import <_javascript_Core/JSLock.h>
+#import <libkern/OSAtomic.h>
+#import <objc/runtime.h>
#import <wtf/Assertions.h>
#import <wtf/MainThread.h>
#import <wtf/RecursiveLockAdapter.h>
#import <wtf/RunLoop.h>
#import <wtf/Threading.h>
+#import <wtf/spi/cocoa/FoundationSPI.h>
#import <wtf/text/AtomicString.h>
-#import <Foundation/NSInvocation.h>
-#import <libkern/OSAtomic.h>
-#import <objc/runtime.h>
-
#define LOG_MESSAGES 0
#define LOG_WEB_LOCK 0
#define LOG_MAIN_THREAD_LOCKING 0
@@ -82,21 +81,11 @@
@end
-using NSAutoreleasePoolMark = void*;
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern NSAutoreleasePoolMark NSPushAutoreleasePool(unsigned ignored);
-extern void NSPopAutoreleasePool(NSAutoreleasePoolMark token);
-#ifdef __cplusplus
-}
-#endif
-
static RecursiveLock webLock;
static Lock webThreadReleaseLock;
static RecursiveLock webCoreReleaseLock;
-static NSAutoreleasePoolMark autoreleasePoolMark;
+static void* autoreleasePoolMark;
static CFRunLoopRef webThreadRunLoop;
static NSRunLoop* webThreadNSRunLoop;
static pthread_t webThread;
@@ -104,7 +93,7 @@
static BOOL webThreadStarted;
static unsigned webThreadLockCount;
-static NSAutoreleasePoolMark savedAutoreleasePoolMark;
+static void* savedAutoreleasePoolMark;
static BOOL isNestedWebThreadRunLoop;
typedef enum {
PushOrPopAutoreleasePool,
@@ -465,7 +454,7 @@
{
_WebThreadLock();
if (poolOperation == PushOrPopAutoreleasePool)
- autoreleasePoolMark = NSPushAutoreleasePool(0);
+ autoreleasePoolMark = objc_autoreleasePoolPush();
isWebThreadLocked = YES;
}
@@ -479,7 +468,7 @@
}
if (poolOperation == PushOrPopAutoreleasePool)
- NSPopAutoreleasePool(autoreleasePoolMark);
+ objc_autoreleasePoolPop(autoreleasePoolMark);
_WebThreadUnlock();
isWebThreadLocked = NO;
Modified: trunk/Source/WebCore/platform/network/cocoa/ResourceResponseCocoa.mm (232659 => 232660)
--- trunk/Source/WebCore/platform/network/cocoa/ResourceResponseCocoa.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebCore/platform/network/cocoa/ResourceResponseCocoa.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -33,7 +33,6 @@
#import <Foundation/Foundation.h>
#import <limits>
#import <pal/spi/cf/CFNetworkSPI.h>
-#import <wtf/AutodrainedPool.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/StdLibExtras.h>
#import <wtf/cf/TypeCastsCF.h>
@@ -175,27 +174,29 @@
if (m_isNull || !m_nsResponse)
return;
- AutodrainedPool pool;
+ @autoreleasepool {
- NSHTTPURLResponse *httpResponse = [m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]] ? (NSHTTPURLResponse *)m_nsResponse.get() : nullptr;
+ NSHTTPURLResponse *httpResponse = [m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]] ? (NSHTTPURLResponse *)m_nsResponse.get() : nullptr;
- if (m_initLevel < CommonFieldsOnly) {
- m_url = [m_nsResponse.get() URL];
- m_mimeType = [m_nsResponse.get() MIMEType];
- m_expectedContentLength = [m_nsResponse.get() expectedContentLength];
- // Stripping double quotes as a workaround for <rdar://problem/8757088>, can be removed once that is fixed.
- m_textEncodingName = stripLeadingAndTrailingDoubleQuote([m_nsResponse.get() textEncodingName]);
- m_httpStatusCode = httpResponse ? [httpResponse statusCode] : 0;
+ if (m_initLevel < CommonFieldsOnly) {
+ m_url = [m_nsResponse.get() URL];
+ m_mimeType = [m_nsResponse.get() MIMEType];
+ m_expectedContentLength = [m_nsResponse.get() expectedContentLength];
+ // Stripping double quotes as a workaround for <rdar://problem/8757088>, can be removed once that is fixed.
+ m_textEncodingName = stripLeadingAndTrailingDoubleQuote([m_nsResponse.get() textEncodingName]);
+ m_httpStatusCode = httpResponse ? [httpResponse statusCode] : 0;
+ }
+ if (httpResponse) {
+ if (initLevel == AllFields) {
+ auto messageRef = CFURLResponseGetHTTPResponse([httpResponse _CFURLResponse]);
+ m_httpStatusText = extractHTTPStatusText(messageRef);
+ m_httpVersion = String(adoptCF(CFHTTPMessageCopyVersion(messageRef)).get()).convertToASCIIUppercase();
+ initializeHTTPHeaders(OnlyCommonHeaders::No, httpResponse, m_httpHeaderFields);
+ } else
+ initializeHTTPHeaders(OnlyCommonHeaders::Yes, httpResponse, m_httpHeaderFields);
+ }
+
}
- if (httpResponse) {
- if (initLevel == AllFields) {
- auto messageRef = CFURLResponseGetHTTPResponse([httpResponse _CFURLResponse]);
- m_httpStatusText = extractHTTPStatusText(messageRef);
- m_httpVersion = String(adoptCF(CFHTTPMessageCopyVersion(messageRef)).get()).convertToASCIIUppercase();
- initializeHTTPHeaders(OnlyCommonHeaders::No, httpResponse, m_httpHeaderFields);
- } else
- initializeHTTPHeaders(OnlyCommonHeaders::Yes, httpResponse, m_httpHeaderFields);
- }
m_initLevel = initLevel;
}
Modified: trunk/Source/WebKitLegacy/mac/Carbon/CarbonUtils.m (232659 => 232660)
--- trunk/Source/WebKitLegacy/mac/Carbon/CarbonUtils.m 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebKitLegacy/mac/Carbon/CarbonUtils.m 2018-06-09 16:27:16 UTC (rev 232660)
@@ -29,13 +29,13 @@
#ifndef __LP64__
#include "CarbonUtils.h"
-#import <pal/spi/cocoa/FoundationSPI.h>
+#import <wtf/spi/cocoa/FoundationSPI.h>
extern CGImageRef _NSCreateImageRef( unsigned char *const bitmapData[5], int pixelsWide, int pixelsHigh, int bitsPerSample, int samplesPerPixel, int bitsPerPixel, int bytesPerRow, BOOL isPlanar, BOOL hasAlpha, NSString *colorSpaceName, CGColorSpaceRef customColorSpace, id sourceObj);
static void PoolCleaner( EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void *inUserData );
-static NSAutoreleasePool* sPool;
+static void* sPool;
static unsigned numPools;
static EventLoopRef poolLoop;
@@ -43,9 +43,9 @@
static unsigned getNSAutoreleasePoolCount(void)
{
- void* v = NSPushAutoreleasePool(0);
+ void* v = objc_autoreleasePoolPush();
uintptr_t numPools = (uintptr_t)v;
- NSPopAutoreleasePool(v);
+ objc_autoreleasePoolPop(v);
return numPools;
}
@@ -63,7 +63,7 @@
GetCurrentProcess( &process );
NSApplicationLoad();
- sPool = [[NSAutoreleasePool allocWithZone:NULL] init];
+ sPool = objc_autoreleasePoolPush();
numPools = getNSAutoreleasePoolCount();
poolLoop = GetCurrentEventLoop ();
@@ -95,9 +95,8 @@
if ( CFEqual( mode, kCFRunLoopDefaultMode ) && thisLoop == poolLoop) {
unsigned currentNumPools = getNSAutoreleasePoolCount()-1;
if (currentNumPools == numPools){
- [sPool drain];
-
- sPool = [[NSAutoreleasePool allocWithZone:NULL] init];
+ objc_autoreleasePoolPop(sPool);
+ sPool = objc_autoreleasePoolPush();
numPools = getNSAutoreleasePoolCount();
}
}
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (232659 => 232660)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,3 +1,23 @@
+2018-06-08 Darin Adler <[email protected]>
+
+ [Cocoa] Remove all uses of NSAutoreleasePool as part of preparation for ARC
+ https://bugs.webkit.org/show_bug.cgi?id=186436
+
+ Reviewed by Anders Carlsson.
+
+ * Carbon/CarbonUtils.m: Updated include location of FoundationSPI.h.
+ (getNSAutoreleasePoolCount): Use objc_autoreleasePoolPush/Pop.
+ (WebInitForCarbon): Use objc_autoreleasePoolPush/Pop instead of NSAutoreleasePool object.
+ (PoolCleaner): Ditto.
+
+ * History/WebHistory.mm:
+ (-[WebHistoryPrivate loadHistoryGutsFromURL:savedItemsCount:collectDiscardedItemsInto:error:]):
+ Use @autoreleasepool instead of NSAutoreleasePool object. No need to do the "drain pool only
+ every 50 times"; the -[WebHistory loadFromURL] family of methods were once used by Safari, and
+ now hardly used if at all.
+ * WebView/WebView.mm:
+ (-[WebView rectsForTextMatches]): Ditto.
+
2018-06-08 Wenson Hsieh <[email protected]>
[WebKit on watchOS] Upstream watchOS source additions to OpenSource (Part 1)
Modified: trunk/Source/WebKitLegacy/mac/History/WebHistory.mm (232659 => 232660)
--- trunk/Source/WebKitLegacy/mac/History/WebHistory.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebKitLegacy/mac/History/WebHistory.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -591,41 +591,34 @@
int itemCountLimit = [self historyItemLimit];
NSTimeInterval ageLimitDate = [[self ageLimitDate] timeIntervalSinceReferenceDate];
- NSEnumerator *enumerator = [array objectEnumerator];
BOOL ageLimitPassed = NO;
BOOL itemLimitPassed = NO;
ASSERT(*numberOfItemsLoaded == 0);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSDictionary *itemAsDictionary;
- while ((itemAsDictionary = [enumerator nextObject]) != nil) {
- WebHistoryItem *item = [[WebHistoryItem alloc] initFromDictionaryRepresentation:itemAsDictionary];
+ for (NSDictionary *itemAsDictionary in array) {
+ @autoreleasepool {
+ WebHistoryItem *item = [[WebHistoryItem alloc] initFromDictionaryRepresentation:itemAsDictionary];
- // item without URL is useless; data on disk must have been bad; ignore
- if ([item URLString]) {
- // Test against date limit. Since the items are ordered newest to oldest, we can stop comparing
- // once we've found the first item that's too old.
- if (!ageLimitPassed && [item lastVisitedTimeInterval] <= ageLimitDate)
- ageLimitPassed = YES;
+ // item without URL is useless; data on disk must have been bad; ignore
+ if ([item URLString]) {
+ // Test against date limit. Since the items are ordered newest to oldest, we can stop comparing
+ // once we've found the first item that's too old.
+ if (!ageLimitPassed && [item lastVisitedTimeInterval] <= ageLimitDate)
+ ageLimitPassed = YES;
- if (ageLimitPassed || itemLimitPassed)
- [discardedItems addObject:item];
- else {
- if ([self addItem:item discardDuplicate:YES])
- ++(*numberOfItemsLoaded);
- if (*numberOfItemsLoaded == itemCountLimit)
- itemLimitPassed = YES;
-
- // Draining the autorelease pool every 50 iterations was found by experimentation to be optimal
- if (*numberOfItemsLoaded % 50 == 0) {
- [pool drain];
- pool = [[NSAutoreleasePool alloc] init];
+ if (ageLimitPassed || itemLimitPassed)
+ [discardedItems addObject:item];
+ else {
+ if ([self addItem:item discardDuplicate:YES])
+ ++(*numberOfItemsLoaded);
+ if (*numberOfItemsLoaded == itemCountLimit)
+ itemLimitPassed = YES;
}
}
+
+ [item release];
}
- [item release];
}
- [pool drain];
return YES;
}
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (232659 => 232660)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -7903,28 +7903,21 @@
if ([view conformsToProtocol:@protocol(WebMultipleTextMatches)]) {
NSView <WebMultipleTextMatches> *documentView = (NSView <WebMultipleTextMatches> *)view;
NSRect documentViewVisibleRect = [documentView visibleRect];
- NSArray *originalRects = [documentView rectsForTextMatches];
- unsigned rectCount = [originalRects count];
- unsigned rectIndex;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- for (rectIndex = 0; rectIndex < rectCount; ++rectIndex) {
- NSRect r = [[originalRects objectAtIndex:rectIndex] rectValue];
+ for (NSValue *rect in [documentView rectsForTextMatches]) {
+ NSRect r = [rect rectValue];
// Clip rect to document view's visible rect so rect is confined to subframe
r = NSIntersectionRect(r, documentViewVisibleRect);
if (NSIsEmptyRect(r))
continue;
-
- // Convert rect to our coordinate system
- r = [documentView convertRect:r toView:self];
- [result addObject:[NSValue valueWithRect:r]];
- if (rectIndex % 10 == 0) {
- [pool drain];
- pool = [[NSAutoreleasePool alloc] init];
+
+ @autoreleasepool {
+ // Convert rect to our coordinate system
+ r = [documentView convertRect:r toView:self];
+ [result addObject:[NSValue valueWithRect:r]];
}
}
- [pool drain];
}
-
+
frame = incrementFrame(frame);
} while (frame);
Modified: trunk/Tools/ChangeLog (232659 => 232660)
--- trunk/Tools/ChangeLog 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Tools/ChangeLog 2018-06-09 16:27:16 UTC (rev 232660)
@@ -1,3 +1,18 @@
+2018-06-08 Darin Adler <[email protected]>
+
+ [Cocoa] Remove all uses of NSAutoreleasePool as part of preparation for ARC
+ https://bugs.webkit.org/show_bug.cgi?id=186436
+
+ Reviewed by Anders Carlsson.
+
+ * TestWebKitAPI/Tests/WebKitObjC/CustomProtocolsTest.mm:
+ (TestWebKitAPI::WebKit2CustomProtocolsTest_ProcessPoolDestroyedDuringLoading):
+ Use @autoreleasepool.
+ * TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:
+ (TestWebKitAPI::buildAndPerformTest): Ditto.
+ * TestWebKitAPI/Tests/mac/StopLoadingFromDidFinishLoading.mm:
+ (TestWebKitAPI::WebKitLegacy_StopLoadingFromDidFinishLoading): Ditto.
+
2018-06-08 Wenson Hsieh <[email protected]>
[WebKit on watchOS] Upstream watchOS source additions to OpenSource (Part 1)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitObjC/CustomProtocolsTest.mm (232659 => 232660)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitObjC/CustomProtocolsTest.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitObjC/CustomProtocolsTest.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -34,7 +34,6 @@
#import "TestProtocol.h"
#import <WebKit/WKContextPrivate.h>
#import <WebKit/WKProcessGroupPrivate.h>
-#import <wtf/AutodrainedPool.h>
#import <wtf/RetainPtr.h>
#if WK_API_ENABLED && PLATFORM(MAC)
@@ -171,8 +170,7 @@
{
[ProcessPoolDestroyedDuringLoadingProtocol registerWithScheme:@"custom"];
- {
- AutodrainedPool pool;
+ @autoreleasepool {
auto browsingContextGroup = adoptNS([[WKBrowsingContextGroup alloc] initWithIdentifier:@"TestIdentifier"]);
auto processGroup = adoptNS([[WKProcessGroup alloc] init]);
auto wkView = adoptNS([[WKView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) processGroup:processGroup.get() browsingContextGroup:browsingContextGroup.get()]);
Modified: trunk/Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm (232659 => 232660)
--- trunk/Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -29,7 +29,6 @@
#import <Carbon/Carbon.h> // For GetCurrentEventTime
#import <WebCore/PlatformEventFactoryMac.h>
#import <pal/spi/mac/NSMenuSPI.h>
-#import <wtf/AutodrainedPool.h>
#import <wtf/RetainPtr.h>
#import <wtf/mac/AppKitCompatibilityDeclarations.h>
@@ -42,25 +41,26 @@
static void buildAndPerformTest(NSEventType buttonEvent, NSEventModifierFlags modifierFlags, WebCore::MouseButton expectedButton, NSMenuType expectedMenu)
{
- AutodrainedPool pool;
- RetainPtr<WebView> webView = adoptNS([[WebView alloc] init]);
- NSEvent *event = [NSEvent mouseEventWithType:buttonEvent
- location:NSMakePoint(100, 100)
- modifierFlags:modifierFlags
- timestamp:GetCurrentEventTime()
- windowNumber:[[webView window] windowNumber]
- context:[NSGraphicsContext currentContext]
- eventNumber:0
- clickCount:0
- pressure:0];
-
- auto pme = WebCore::PlatformEventFactory::createPlatformMouseEvent(event, nil, webView.get());
-
- EXPECT_EQ(expectedButton, pme.button());
- EXPECT_TRUE(!modifierFlags || pme.modifierFlags() & modifierFlags);
- EXPECT_EQ(expectedMenu, pme.menuTypeForEvent());
- if (canCallMenuTypeForEvent())
- EXPECT_EQ(expectedMenu, [NSMenu menuTypeForEvent:event]);
+ @autoreleasepool {
+ auto webView = adoptNS([[WebView alloc] init]);
+ NSEvent *event = [NSEvent mouseEventWithType:buttonEvent
+ location:NSMakePoint(100, 100)
+ modifierFlags:modifierFlags
+ timestamp:GetCurrentEventTime()
+ windowNumber:[[webView window] windowNumber]
+ context:[NSGraphicsContext currentContext]
+ eventNumber:0
+ clickCount:0
+ pressure:0];
+
+ auto pme = WebCore::PlatformEventFactory::createPlatformMouseEvent(event, nil, webView.get());
+
+ EXPECT_EQ(expectedButton, pme.button());
+ EXPECT_TRUE(!modifierFlags || pme.modifierFlags() & modifierFlags);
+ EXPECT_EQ(expectedMenu, pme.menuTypeForEvent());
+ if (canCallMenuTypeForEvent())
+ EXPECT_EQ(expectedMenu, [NSMenu menuTypeForEvent:event]);
+ }
}
TEST(WebKitLegacy, MenuAndButtonForNormalLeftClick)
Modified: trunk/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidFinishLoading.mm (232659 => 232660)
--- trunk/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidFinishLoading.mm 2018-06-09 03:12:20 UTC (rev 232659)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/StopLoadingFromDidFinishLoading.mm 2018-06-09 16:27:16 UTC (rev 232660)
@@ -24,12 +24,11 @@
*/
#import "config.h"
+
#import "PlatformUtilities.h"
-#import <wtf/AutodrainedPool.h>
#import <wtf/RetainPtr.h>
-@interface StopLoadingFromDidFinishLoadingDelegate : NSObject <WebResourceLoadDelegate> {
-}
+@interface StopLoadingFromDidFinishLoadingDelegate : NSObject <WebResourceLoadDelegate>
@end
static bool finished = false;
@@ -48,12 +47,12 @@
TEST(WebKitLegacy, StopLoadingFromDidFinishLoading)
{
- AutodrainedPool pool;
- RetainPtr<WebView> webView = adoptNS([[WebView alloc] init]);
- RetainPtr<StopLoadingFromDidFinishLoadingDelegate> delegate = adoptNS([[StopLoadingFromDidFinishLoadingDelegate alloc] init]);
- webView.get().resourceLoadDelegate = delegate.get();
- [webView.get().mainFrame loadHTMLString:@"Hello, World!" baseURL:[NSURL URLWithString:@""]];
- Util::run(&finished);
+ @autoreleasepool {
+ auto webView = adoptNS([[WebView alloc] init]);
+ webView.get().resourceLoadDelegate = adoptNS([[StopLoadingFromDidFinishLoadingDelegate alloc] init]).get();
+ [webView.get().mainFrame loadHTMLString:@"Hello, World!" baseURL:[NSURL URLWithString:@""]];
+ Util::run(&finished);
+ }
// No crash means the test passed.
}