Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (184119 => 184120)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2015-05-11 20:42:39 UTC (rev 184119)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2015-05-11 21:13:53 UTC (rev 184120)
@@ -539,7 +539,6 @@
runtime/Operations.cpp
runtime/Options.cpp
runtime/PropertyDescriptor.cpp
- runtime/PropertyNameArray.cpp
runtime/PropertySlot.cpp
runtime/PropertyTable.cpp
runtime/PrototypeMap.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (184119 => 184120)
--- trunk/Source/_javascript_Core/ChangeLog 2015-05-11 20:42:39 UTC (rev 184119)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-05-11 21:13:53 UTC (rev 184120)
@@ -1,3 +1,25 @@
+2015-05-11 Andreas Kling <[email protected]>
+
+ PropertyNameArray should use a Vector when there are few entries.
+ <https://webkit.org/b/144874>
+
+ Reviewed by Geoffrey Garen.
+
+ Bring back an optimization that was lost in the for-in refactoring.
+ PropertyNameArray now holds a Vector<AtomicStringImpl*> until there are
+ enough (20) entries to justify converting to a HashSet for contains().
+
+ Also inlined the code while we're here, since it has so few clients and
+ the call overhead adds up.
+
+ ~5% progression on Kraken/json-stringify-tinderbox.
+
+ * runtime/PropertyNameArray.cpp: Removed.
+ * runtime/PropertyNameArray.h:
+ (JSC::PropertyNameArray::canAddKnownUniqueForStructure):
+ (JSC::PropertyNameArray::add):
+ (JSC::PropertyNameArray::addKnownUnique):
+
2015-05-11 Matt Baker <[email protected]>
Web Inspector: REGRESSION (r175203): No profile information is shown in Inspector
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj (184119 => 184120)
--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj 2015-05-11 20:42:39 UTC (rev 184119)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj 2015-05-11 21:13:53 UTC (rev 184120)
@@ -799,7 +799,6 @@
<ClCompile Include="..\runtime\Operations.cpp" />
<ClCompile Include="..\runtime\Options.cpp" />
<ClCompile Include="..\runtime\PropertyDescriptor.cpp" />
- <ClCompile Include="..\runtime\PropertyNameArray.cpp" />
<ClCompile Include="..\runtime\PropertySlot.cpp" />
<ClCompile Include="..\runtime\PropertyTable.cpp" />
<ClCompile Include="..\runtime\PrototypeMap.cpp" />
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters (184119 => 184120)
--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters 2015-05-11 20:42:39 UTC (rev 184119)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters 2015-05-11 21:13:53 UTC (rev 184120)
@@ -780,9 +780,6 @@
<ClCompile Include="..\runtime\PropertyDescriptor.cpp">
<Filter>runtime</Filter>
</ClCompile>
- <ClCompile Include="..\runtime\PropertyNameArray.cpp">
- <Filter>runtime</Filter>
- </ClCompile>
<ClCompile Include="..\runtime\PropertySlot.cpp">
<Filter>runtime</Filter>
</ClCompile>
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (184119 => 184120)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2015-05-11 20:42:39 UTC (rev 184119)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2015-05-11 21:13:53 UTC (rev 184120)
@@ -819,7 +819,6 @@
14469DE4107EC7E700650446 /* NumberPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2680C40E16D4E900A06E92 /* NumberPrototype.cpp */; };
14469DE5107EC7E700650446 /* ObjectConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2680C60E16D4E900A06E92 /* ObjectConstructor.cpp */; };
14469DE6107EC7E700650446 /* ObjectPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2680C80E16D4E900A06E92 /* ObjectPrototype.cpp */; };
- 14469DE7107EC7E700650446 /* PropertyNameArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */; };
14469DE8107EC7E700650446 /* PropertySlot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* PropertySlot.cpp */; };
14469DEB107EC7E700650446 /* StringConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC18C3C00E16EE3300B34460 /* StringConstructor.cpp */; };
14469DEC107EC7E700650446 /* StringObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC18C3C20E16EE3300B34460 /* StringObject.cpp */; };
@@ -2678,7 +2677,6 @@
652A3A221651C69700A80AFE /* A64DOpcode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = A64DOpcode.cpp; path = disassembler/ARM64/A64DOpcode.cpp; sourceTree = "<group>"; };
652A3A231651C69700A80AFE /* A64DOpcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = A64DOpcode.h; path = disassembler/ARM64/A64DOpcode.h; sourceTree = "<group>"; };
65303D631447B9E100D3F904 /* ParserTokens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserTokens.h; sourceTree = "<group>"; };
- 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyNameArray.cpp; sourceTree = "<group>"; };
65400C100A69BAF200509887 /* PropertyNameArray.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PropertyNameArray.h; sourceTree = "<group>"; };
6546F51F1A32A59C006F07D5 /* NullGetterFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = NullGetterFunction.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
6546F5201A32A59C006F07D5 /* NullGetterFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullGetterFunction.h; sourceTree = "<group>"; };
@@ -4637,7 +4635,6 @@
A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */,
BC95437C0EBA70FD0072B6D3 /* PropertyMapHashTable.h */,
86158AB2155C8B3F00B45C9C /* PropertyName.h */,
- 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */,
65400C100A69BAF200509887 /* PropertyNameArray.h */,
0FF7168A15A3B231008F5DAA /* PropertyOffset.h */,
65621E6B089E859700760F35 /* PropertySlot.cpp */,
@@ -7486,7 +7483,6 @@
0FB1058D1675483700F8AB6E /* ProfilerOSRExitSite.cpp in Sources */,
0F13912B16771C3A009CCB07 /* ProfilerProfiledBytecodes.cpp in Sources */,
A7FB60A4103F7DC20017A286 /* PropertyDescriptor.cpp in Sources */,
- 14469DE7107EC7E700650446 /* PropertyNameArray.cpp in Sources */,
14469DE8107EC7E700650446 /* PropertySlot.cpp in Sources */,
ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */,
65FB5117184EEE7000C12B70 /* ProtoCallFrame.cpp in Sources */,
Deleted: trunk/Source/_javascript_Core/runtime/PropertyNameArray.cpp (184119 => 184120)
--- trunk/Source/_javascript_Core/runtime/PropertyNameArray.cpp 2015-05-11 20:42:39 UTC (rev 184119)
+++ trunk/Source/_javascript_Core/runtime/PropertyNameArray.cpp 2015-05-11 21:13:53 UTC (rev 184120)
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "PropertyNameArray.h"
-
-#include "JSCInlines.h"
-#include "JSObject.h"
-#include "JSPropertyNameEnumerator.h"
-#include "Structure.h"
-#include "StructureChain.h"
-
-namespace JSC {
-
-void PropertyNameArray::add(AtomicStringImpl* identifier)
-{
- ASSERT(identifier);
-
- if (!m_set.add(identifier).isNewEntry)
- return;
-
- addKnownUnique(identifier);
-}
-
-} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/PropertyNameArray.h (184119 => 184120)
--- trunk/Source/_javascript_Core/runtime/PropertyNameArray.h 2015-05-11 20:42:39 UTC (rev 184119)
+++ trunk/Source/_javascript_Core/runtime/PropertyNameArray.h 2015-05-11 21:13:53 UTC (rev 184120)
@@ -70,13 +70,9 @@
add(Identifier::from(m_vm, index));
}
- void add(const Identifier& identifier) { add(identifier.impl()); }
- JS_EXPORT_PRIVATE void add(AtomicStringImpl*);
- void addKnownUnique(AtomicStringImpl* identifier)
- {
- m_set.add(identifier);
- m_data->propertyNameVector().append(Identifier::fromUid(m_vm, identifier));
- }
+ void add(const Identifier&);
+ void add(AtomicStringImpl*);
+ void addKnownUnique(AtomicStringImpl*);
Identifier& operator[](unsigned i) { return m_data->propertyNameVector()[i]; }
const Identifier& operator[](unsigned i) const { return m_data->propertyNameVector()[i]; }
@@ -86,7 +82,7 @@
PassRefPtr<PropertyNameArrayData> releaseData() { return m_data.release(); }
// FIXME: Remove these functions.
- bool canAddKnownUniqueForStructure() const { return m_set.isEmpty(); }
+ bool canAddKnownUniqueForStructure() const { return m_data->propertyNameVector().isEmpty(); }
typedef PropertyNameArrayData::PropertyNameVector::const_iterator const_iterator;
size_t size() const { return m_data->propertyNameVector().size(); }
const_iterator begin() const { return m_data->propertyNameVector().begin(); }
@@ -98,6 +94,37 @@
VM* m_vm;
};
+ALWAYS_INLINE void PropertyNameArray::add(const Identifier& identifier)
+{
+ add(identifier.impl());
+}
+
+ALWAYS_INLINE void PropertyNameArray::addKnownUnique(AtomicStringImpl* identifier)
+{
+ m_data->propertyNameVector().append(Identifier::fromUid(m_vm, identifier));
+}
+
+ALWAYS_INLINE void PropertyNameArray::add(AtomicStringImpl* identifier)
+{
+ static const unsigned setThreshold = 20;
+
+ ASSERT(identifier);
+
+ if (size() < setThreshold) {
+ if (m_data->propertyNameVector().contains(identifier))
+ return;
+ } else {
+ if (m_set.isEmpty()) {
+ for (Identifier& name : m_data->propertyNameVector())
+ m_set.add(name.impl());
+ }
+ if (!m_set.add(identifier).isNewEntry)
+ return;
+ }
+
+ addKnownUnique(identifier);
+}
+
} // namespace JSC
#endif // PropertyNameArray_h