Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (165795 => 165796)
--- trunk/Source/_javascript_Core/ChangeLog 2014-03-18 03:21:22 UTC (rev 165795)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-03-18 03:28:19 UTC (rev 165796)
@@ -1,3 +1,28 @@
+2014-03-17 Andreas Kling <[email protected]>
+
+ Add one-deep cache to opaque roots hashset.
+ <https://webkit.org/b/130357>
+
+ The vast majority of WebCore JS wrappers will have their Document*
+ as the root(). This change adds a simple optimization where we cache
+ the last lookup and avoid going to the hashset for repeated queries.
+
+ Looks like 0.4% progression on DYEB on my MBP.
+
+ Reviewed by Mark Hahnenberg.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * heap/OpaqueRootSet.h: Added.
+ (JSC::OpaqueRootSet::OpaqueRootSet):
+ (JSC::OpaqueRootSet::contains):
+ (JSC::OpaqueRootSet::isEmpty):
+ (JSC::OpaqueRootSet::clear):
+ (JSC::OpaqueRootSet::add):
+ (JSC::OpaqueRootSet::size):
+ (JSC::OpaqueRootSet::begin):
+ (JSC::OpaqueRootSet::end):
+ * heap/SlotVisitor.h:
+
2014-03-17 Tibor Meszaros <[email protected]>
Implement Math.hypot
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (165795 => 165796)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2014-03-18 03:21:22 UTC (rev 165795)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2014-03-18 03:28:19 UTC (rev 165796)
@@ -1280,6 +1280,7 @@
A7FB61001040C38B0017A286 /* PropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */; settings = {ATTRIBUTES = (Private, ); }; };
A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
+ ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; };
B59F89391891F29F00D5CCDC /* UnlinkedInstructionStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B59F89381891ADB500D5CCDC /* UnlinkedInstructionStream.cpp */; };
BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; };
@@ -2834,6 +2835,7 @@
A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = "<group>"; };
A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTable.cpp; sourceTree = "<group>"; };
+ ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; };
B59F89371891AD3300D5CCDC /* UnlinkedInstructionStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedInstructionStream.h; sourceTree = "<group>"; };
B59F89381891ADB500D5CCDC /* UnlinkedInstructionStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkedInstructionStream.cpp; sourceTree = "<group>"; };
BC021BF2136900C300FC5467 /* ToolExecutable.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ToolExecutable.xcconfig; sourceTree = "<group>"; };
@@ -3505,6 +3507,7 @@
142E312A134FF0A600AFADB5 /* heap */ = {
isa = PBXGroup;
children = (
+ ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */,
2AACE63A18CA5A0300ED0191 /* GCActivityCallback.cpp */,
2AACE63B18CA5A0300ED0191 /* GCActivityCallback.h */,
14816E19154CC56C00B8054C /* BlockAllocator.cpp */,
@@ -5331,6 +5334,7 @@
FEF6835F174343CC00A32E25 /* JITStubsARMv7.h in Headers */,
FEF68361174343CC00A32E25 /* JITStubsX86.h in Headers */,
FEF68360174343CC00A32E25 /* JITStubsX86_64.h in Headers */,
+ ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */,
A7A4AE1017973B4D005612B1 /* JITStubsX86Common.h in Headers */,
0F5EF91F16878F7D003E5C25 /* JITThunks.h in Headers */,
0FC712E317CD8793008CC93C /* JITToDFGDeferredCompilationCallback.h in Headers */,
Added: trunk/Source/_javascript_Core/heap/OpaqueRootSet.h (0 => 165796)
--- trunk/Source/_javascript_Core/heap/OpaqueRootSet.h (rev 0)
+++ trunk/Source/_javascript_Core/heap/OpaqueRootSet.h 2014-03-18 03:28:19 UTC (rev 165796)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef OpaqueRootSet_h
+#define OpaqueRootSet_h
+
+#include <wtf/HashSet.h>
+
+namespace JSC {
+
+class OpaqueRootSet {
+ WTF_MAKE_NONCOPYABLE(OpaqueRootSet);
+public:
+ OpaqueRootSet()
+ : m_lastQueriedRoot(nullptr)
+ , m_containsLastQueriedRoot(false)
+ {
+ }
+
+ bool contains(void* root) const
+ {
+ if (root != m_lastQueriedRoot) {
+ m_lastQueriedRoot = root;
+ m_containsLastQueriedRoot = m_roots.contains(root);
+ }
+ return m_containsLastQueriedRoot;
+ }
+
+ bool isEmpty() const
+ {
+ return m_roots.isEmpty();
+ }
+
+ void clear()
+ {
+ m_roots.clear();
+ m_lastQueriedRoot = nullptr;
+ m_containsLastQueriedRoot = false;
+ }
+
+ void add(void* root)
+ {
+ if (root == m_lastQueriedRoot)
+ m_containsLastQueriedRoot = true;
+ m_roots.add(root);
+ }
+
+ int size() const
+ {
+ return m_roots.size();
+ }
+
+ HashSet<void*>::const_iterator begin() const
+ {
+ return m_roots.begin();
+ }
+
+ HashSet<void*>::const_iterator end() const
+ {
+ return m_roots.end();
+ }
+
+
+private:
+ HashSet<void*> m_roots;
+ mutable void* m_lastQueriedRoot;
+ mutable bool m_containsLastQueriedRoot;
+};
+
+} // namespace JSC
+
+#endif // OpaqueRootSet_h
Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.h (165795 => 165796)
--- trunk/Source/_javascript_Core/heap/SlotVisitor.h 2014-03-18 03:21:22 UTC (rev 165795)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.h 2014-03-18 03:28:19 UTC (rev 165796)
@@ -29,6 +29,7 @@
#include "CopyToken.h"
#include "HandleTypes.h"
#include "MarkStack.h"
+#include "OpaqueRootSet.h"
#include <wtf/HashSet.h>
#include <wtf/text/StringHash.h>
@@ -134,7 +135,7 @@
void donateKnownParallel();
MarkStackArray m_stack;
- HashSet<void*> m_opaqueRoots; // Handle-owning data structures not visible to the garbage collector.
+ OpaqueRootSet m_opaqueRoots; // Handle-owning data structures not visible to the garbage collector.
size_t m_bytesVisited;
size_t m_bytesCopied;