Diff
Modified: trunk/JSTests/ChangeLog (222016 => 222017)
--- trunk/JSTests/ChangeLog 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/JSTests/ChangeLog 2017-09-14 11:17:45 UTC (rev 222017)
@@ -1,3 +1,13 @@
+2017-09-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray
+ https://bugs.webkit.org/show_bug.cgi?id=176867
+
+ Reviewed by Sam Weinig.
+
+ * microbenchmarks/object-get-own-property-symbols.js: Added.
+ (test):
+
2017-09-13 Mark Lam <[email protected]>
Rolling out r221832: Regresses Speedometer by ~4% and Dromaeo CSS YUI by ~20%.
Added: trunk/JSTests/microbenchmarks/object-get-own-property-symbols.js (0 => 222017)
--- trunk/JSTests/microbenchmarks/object-get-own-property-symbols.js (rev 0)
+++ trunk/JSTests/microbenchmarks/object-get-own-property-symbols.js 2017-09-14 11:17:45 UTC (rev 222017)
@@ -0,0 +1,13 @@
+var object = {};
+for (var i = 0; i < 1e3; ++i) {
+ object[Symbol(i + 'prop')] = i;
+}
+
+function test(object)
+{
+ return Object.getOwnPropertySymbols(object);
+}
+noInline(test);
+
+for (var i = 0; i < 1e3; ++i)
+ test(object);
Modified: trunk/Source/_javascript_Core/API/JSObjectRef.cpp (222016 => 222017)
--- trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -647,7 +647,7 @@
JSObject* jsObject = toJS(object);
JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(vm);
- PropertyNameArray array(vm, PropertyNameMode::Strings);
+ PropertyNameArray array(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
jsObject->methodTable(*vm)->getPropertyNames(jsObject, exec, array, EnumerationMode());
size_t size = array.size();
Modified: trunk/Source/_javascript_Core/ChangeLog (222016 => 222017)
--- trunk/Source/_javascript_Core/ChangeLog 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-09-14 11:17:45 UTC (rev 222017)
@@ -1,3 +1,59 @@
+2017-09-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray
+ https://bugs.webkit.org/show_bug.cgi?id=176867
+
+ Reviewed by Sam Weinig.
+
+ We rarely require private symbols when enumerating property names.
+ This patch adds PrivateSymbolMode::{Include,Exclude}. If PrivateSymbolMode::Exclude
+ is specified, PropertyNameArray does not include private symbols.
+ This removes many ad-hoc `Identifier::isPrivateName()` in enumeration operations.
+
+ One additional good thing is that we do not need to filter private symbols out from PropertyNameArray.
+ It allows us to use Object.keys()'s fast path for Object.getOwnPropertySymbols.
+
+ object-get-own-property-symbols 48.6275+-1.0021 ^ 38.1846+-1.7934 ^ definitely 1.2735x faster
+
+ * API/JSObjectRef.cpp:
+ (JSObjectCopyPropertyNames):
+ * bindings/ScriptValue.cpp:
+ (Inspector::jsToInspectorValue):
+ * bytecode/ObjectAllocationProfile.h:
+ (JSC::ObjectAllocationProfile::possibleDefaultPropertyCount):
+ * runtime/EnumerationMode.h:
+ * runtime/IntlObject.cpp:
+ (JSC::supportedLocales):
+ * runtime/JSONObject.cpp:
+ (JSC::Stringifier::Stringifier):
+ (JSC::Stringifier::Holder::appendNextProperty):
+ (JSC::Walker::walk):
+ * runtime/JSPropertyNameEnumerator.cpp:
+ (JSC::JSPropertyNameEnumerator::create):
+ * runtime/JSPropertyNameEnumerator.h:
+ (JSC::propertyNameEnumerator):
+ * runtime/ObjectConstructor.cpp:
+ (JSC::objectConstructorGetOwnPropertyDescriptors):
+ (JSC::objectConstructorAssign):
+ (JSC::objectConstructorValues):
+ (JSC::defineProperties):
+ (JSC::setIntegrityLevel):
+ (JSC::testIntegrityLevel):
+ (JSC::ownPropertyKeys):
+ * runtime/PropertyNameArray.h:
+ (JSC::PropertyNameArray::PropertyNameArray):
+ (JSC::PropertyNameArray::propertyNameMode const):
+ (JSC::PropertyNameArray::privateSymbolMode const):
+ (JSC::PropertyNameArray::addUncheckedInternal):
+ (JSC::PropertyNameArray::addUnchecked):
+ (JSC::PropertyNameArray::add):
+ (JSC::PropertyNameArray::isUidMatchedToTypeMode):
+ (JSC::PropertyNameArray::includeSymbolProperties const):
+ (JSC::PropertyNameArray::includeStringProperties const):
+ (JSC::PropertyNameArray::mode const): Deleted.
+ * runtime/ProxyObject.cpp:
+ (JSC::ProxyObject::performGetOwnPropertyNames):
+
2017-09-13 Mark Lam <[email protected]>
Rolling out r221832: Regresses Speedometer by ~4% and Dromaeo CSS YUI by ~20%.
Modified: trunk/Source/_javascript_Core/bindings/ScriptValue.cpp (222016 => 222017)
--- trunk/Source/_javascript_Core/bindings/ScriptValue.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/bindings/ScriptValue.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -79,7 +79,7 @@
}
auto inspectorObject = InspectorObject::create();
auto& object = *value.getObject();
- PropertyNameArray propertyNames(&scriptState, PropertyNameMode::Strings);
+ PropertyNameArray propertyNames(&scriptState.vm(), PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
object.methodTable()->getOwnPropertyNames(&object, &scriptState, propertyNames, EnumerationMode());
for (auto& name : propertyNames) {
auto inspectorValue = jsToInspectorValue(scriptState, object.get(&scriptState, name), maxDepth);
Modified: trunk/Source/_javascript_Core/bytecode/ObjectAllocationProfile.h (222016 => 222017)
--- trunk/Source/_javascript_Core/bytecode/ObjectAllocationProfile.h 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/bytecode/ObjectAllocationProfile.h 2017-09-14 11:17:45 UTC (rev 222017)
@@ -132,7 +132,7 @@
return 0;
size_t count = 0;
- PropertyNameArray propertyNameArray(&vm, PropertyNameMode::StringsAndSymbols);
+ PropertyNameArray propertyNameArray(&vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Include);
prototype->structure()->getPropertyNamesFromStructure(vm, propertyNameArray, EnumerationMode());
PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArray.data()->propertyNameVector();
for (size_t i = 0; i < propertyNameVector.size(); ++i) {
Modified: trunk/Source/_javascript_Core/runtime/EnumerationMode.h (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/EnumerationMode.h 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/EnumerationMode.h 2017-09-14 11:17:45 UTC (rev 222017)
@@ -33,6 +33,11 @@
StringsAndSymbols = Symbols | Strings,
};
+enum class PrivateSymbolMode {
+ Include,
+ Exclude
+};
+
enum class DontEnumPropertiesMode {
Include,
Exclude
Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -830,7 +830,7 @@
: lookupSupportedLocales(state, availableLocales, requestedLocales);
RETURN_IF_EXCEPTION(scope, JSValue());
- PropertyNameArray keys(&state, PropertyNameMode::Strings);
+ PropertyNameArray keys(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
supportedLocales->getOwnPropertyNames(supportedLocales, &state, keys, EnumerationMode());
RETURN_IF_EXCEPTION(scope, JSValue());
Modified: trunk/Source/_javascript_Core/runtime/JSONObject.cpp (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/JSONObject.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/JSONObject.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -224,7 +224,7 @@
: m_exec(exec)
, m_replacer(replacer)
, m_usingArrayReplacer(false)
- , m_arrayReplacerPropertyNames(exec, PropertyNameMode::Strings)
+ , m_arrayReplacerPropertyNames(&exec->vm(), PropertyNameMode::Strings, PrivateSymbolMode::Exclude)
, m_replacerCallType(CallType::None)
{
VM& vm = exec->vm();
@@ -484,7 +484,7 @@
if (stringifier.m_usingArrayReplacer)
m_propertyNames = stringifier.m_arrayReplacerPropertyNames.data();
else {
- PropertyNameArray objectPropertyNames(exec, PropertyNameMode::Strings);
+ PropertyNameArray objectPropertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
m_object->methodTable(vm)->getOwnPropertyNames(m_object.get(), exec, objectPropertyNames, EnumerationMode());
RETURN_IF_EXCEPTION(scope, false);
m_propertyNames = objectPropertyNames.releaseData();
@@ -705,7 +705,7 @@
JSObject* object = asObject(inValue);
objectStack.push(object);
indexStack.append(0);
- propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
+ propertyStack.append(PropertyNameArray(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude));
object->methodTable(vm)->getOwnPropertyNames(object, m_exec, propertyStack.last(), EnumerationMode());
RETURN_IF_EXCEPTION(scope, { });
}
Modified: trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.cpp (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -37,7 +37,7 @@
JSPropertyNameEnumerator* JSPropertyNameEnumerator::create(VM& vm)
{
if (!vm.emptyPropertyNameEnumerator.get()) {
- PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings);
+ PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
vm.emptyPropertyNameEnumerator = Strong<JSCell>(vm, create(vm, 0, 0, 0, WTFMove(propertyNames)));
}
return jsCast<JSPropertyNameEnumerator*>(vm.emptyPropertyNameEnumerator.get());
Modified: trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.h (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.h 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/JSPropertyNameEnumerator.h 2017-09-14 11:17:45 UTC (rev 222017)
@@ -113,7 +113,7 @@
uint32_t numberStructureProperties = 0;
- PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
+ PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
if (structure->canAccessPropertiesQuicklyForEnumeration() && indexedLength == base->getArrayLength()) {
base->methodTable(vm)->getStructurePropertyNames(base, exec, propertyNames, EnumerationMode());
Modified: trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -214,7 +214,7 @@
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
- PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
+ PropertyNameArray properties(&vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
RETURN_IF_EXCEPTION(scope, { });
@@ -316,7 +316,7 @@
JSObject* source = sourceValue.toObject(exec);
RETURN_IF_EXCEPTION(scope, { });
- PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
+ PropertyNameArray properties(&vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude);
source->methodTable(vm)->getOwnPropertyNames(source, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
RETURN_IF_EXCEPTION(scope, { });
@@ -358,7 +358,8 @@
if (foundSymbol) {
for (unsigned j = 0; j < numProperties; j++) {
const auto& propertyName = properties[j];
- if (propertyName.isSymbol() && !propertyName.isPrivateName()) {
+ if (propertyName.isSymbol()) {
+ ASSERT(!propertyName.isPrivateName());
assign(propertyName);
RETURN_IF_EXCEPTION(scope, { });
}
@@ -382,7 +383,7 @@
JSArray* values = constructEmptyArray(exec, nullptr);
RETURN_IF_EXCEPTION(scope, { });
- PropertyNameArray properties(exec, PropertyNameMode::Strings);
+ PropertyNameArray properties(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
target->methodTable(vm)->getOwnPropertyNames(target, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
RETURN_IF_EXCEPTION(scope, { });
@@ -543,7 +544,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
- PropertyNameArray propertyNames(exec, PropertyNameMode::StringsAndSymbols);
+ PropertyNameArray propertyNames(&vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude);
asObject(properties)->methodTable(vm)->getOwnPropertyNames(asObject(properties), exec, propertyNames, EnumerationMode(DontEnumPropertiesMode::Exclude));
RETURN_IF_EXCEPTION(scope, { });
size_t numProperties = propertyNames.size();
@@ -569,9 +570,9 @@
}
}
for (size_t i = 0; i < numProperties; i++) {
- Identifier propertyName = propertyNames[i];
- if (propertyName.isPrivateName())
- continue;
+ auto& propertyName = propertyNames[i];
+ ASSERT(!propertyName.isPrivateName());
+
object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, descriptors[i], true);
RETURN_IF_EXCEPTION(scope, { });
}
@@ -629,15 +630,14 @@
if (UNLIKELY(!success))
return false;
- PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
+ PropertyNameArray properties(&vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
RETURN_IF_EXCEPTION(scope, false);
PropertyNameArray::const_iterator end = properties.end();
for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
- Identifier propertyName = *iter;
- if (propertyName.isPrivateName())
- continue;
+ auto& propertyName = *iter;
+ ASSERT(!propertyName.isPrivateName());
PropertyDescriptor desc;
if (level == IntegrityLevel::Sealed)
@@ -677,7 +677,7 @@
return false;
// 6. Let keys be ? O.[[OwnPropertyKeys]]().
- PropertyNameArray keys(exec, PropertyNameMode::StringsAndSymbols);
+ PropertyNameArray keys(&vm, PropertyNameMode::StringsAndSymbols, PrivateSymbolMode::Exclude);
object->methodTable(vm)->getOwnPropertyNames(object, exec, keys, EnumerationMode(DontEnumPropertiesMode::Include));
RETURN_IF_EXCEPTION(scope, { });
@@ -684,9 +684,8 @@
// 7. For each element k of keys, do
PropertyNameArray::const_iterator end = keys.end();
for (PropertyNameArray::const_iterator iter = keys.begin(); iter != end; ++iter) {
- Identifier propertyName = *iter;
- if (propertyName.isPrivateName())
- continue;
+ auto& propertyName = *iter;
+ ASSERT(!propertyName.isPrivateName());
// a. Let currentDesc be ? O.[[GetOwnProperty]](k)
PropertyDescriptor desc;
@@ -836,7 +835,7 @@
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
- PropertyNameArray properties(exec, propertyNameMode);
+ PropertyNameArray properties(&vm, propertyNameMode, PrivateSymbolMode::Exclude);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(dontEnumPropertiesMode));
RETURN_IF_EXCEPTION(scope, nullptr);
@@ -854,18 +853,26 @@
// If !mustFilterProperty and PropertyNameMode::Strings mode, we do not need to filter out any entries in PropertyNameArray.
// We can use fast allocation and initialization.
- if (!mustFilterProperty && propertyNameMode == PropertyNameMode::Strings && properties.size() < MIN_SPARSE_ARRAY_INDEX) {
- auto* globalObject = exec->lexicalGlobalObject();
- if (LIKELY(!globalObject->isHavingABadTime())) {
- size_t numProperties = properties.size();
- JSArray* keys = JSArray::create(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), numProperties);
- WriteBarrier<Unknown>* buffer = keys->butterfly()->contiguous().data();
- for (size_t i = 0; i < numProperties; i++) {
- const auto& identifier = properties[i];
- ASSERT(!identifier.isSymbol());
- buffer[i].set(vm, keys, jsOwnedString(&vm, identifier.string()));
+ if (propertyNameMode != PropertyNameMode::StringsAndSymbols) {
+ ASSERT(propertyNameMode == PropertyNameMode::Strings || propertyNameMode == PropertyNameMode::Symbols);
+ if (!mustFilterProperty && properties.size() < MIN_SPARSE_ARRAY_INDEX) {
+ auto* globalObject = exec->lexicalGlobalObject();
+ if (LIKELY(!globalObject->isHavingABadTime())) {
+ size_t numProperties = properties.size();
+ JSArray* keys = JSArray::create(vm, globalObject->originalArrayStructureForIndexingType(ArrayWithContiguous), numProperties);
+ WriteBarrier<Unknown>* buffer = keys->butterfly()->contiguous().data();
+ for (size_t i = 0; i < numProperties; i++) {
+ const auto& identifier = properties[i];
+ if (propertyNameMode == PropertyNameMode::Strings) {
+ ASSERT(!identifier.isSymbol());
+ buffer[i].set(vm, keys, jsOwnedString(&vm, identifier.string()));
+ } else {
+ ASSERT(identifier.isSymbol());
+ buffer[i].set(vm, keys, Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())));
+ }
+ }
+ return keys;
}
- return keys;
}
}
@@ -897,13 +904,12 @@
for (size_t i = 0; i < numProperties; i++) {
const auto& identifier = properties[i];
ASSERT(identifier.isSymbol());
- if (!identifier.isPrivateName()) {
- bool hasProperty = filterPropertyIfNeeded(identifier);
- EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
- if (hasProperty)
- pushDirect(exec, keys, Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())));
- RETURN_IF_EXCEPTION(scope, nullptr);
- }
+ ASSERT(!identifier.isPrivateName());
+ bool hasProperty = filterPropertyIfNeeded(identifier);
+ EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
+ if (hasProperty)
+ pushDirect(exec, keys, Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())));
+ RETURN_IF_EXCEPTION(scope, nullptr);
}
break;
}
@@ -913,15 +919,17 @@
size_t numProperties = properties.size();
for (size_t i = 0; i < numProperties; i++) {
const auto& identifier = properties[i];
- if (identifier.isSymbol() && !identifier.isPrivateName())
+ if (identifier.isSymbol()) {
+ ASSERT(!identifier.isPrivateName());
propertySymbols.append(identifier);
- else {
- bool hasProperty = filterPropertyIfNeeded(identifier);
- EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
- if (hasProperty)
- pushDirect(exec, keys, jsOwnedString(exec, identifier.string()));
- RETURN_IF_EXCEPTION(scope, nullptr);
+ continue;
}
+
+ bool hasProperty = filterPropertyIfNeeded(identifier);
+ EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
+ if (hasProperty)
+ pushDirect(exec, keys, jsOwnedString(exec, identifier.string()));
+ RETURN_IF_EXCEPTION(scope, nullptr);
}
// To ensure the order defined in the spec (9.1.12), we append symbols at the last elements of keys.
Modified: trunk/Source/_javascript_Core/runtime/PropertyNameArray.h (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/PropertyNameArray.h 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/PropertyNameArray.h 2017-09-14 11:17:45 UTC (rev 222017)
@@ -47,18 +47,14 @@
// FIXME: Rename to PropertyNameArrayBuilder.
class PropertyNameArray {
public:
- PropertyNameArray(VM* vm, PropertyNameMode mode)
+ PropertyNameArray(VM* vm, PropertyNameMode propertyNameMode, PrivateSymbolMode privateSymbolMode)
: m_data(PropertyNameArrayData::create())
, m_vm(vm)
- , m_mode(mode)
+ , m_propertyNameMode(propertyNameMode)
+ , m_privateSymbolMode(privateSymbolMode)
{
}
- PropertyNameArray(ExecState* exec, PropertyNameMode mode)
- : PropertyNameArray(&exec->vm(), mode)
- {
- }
-
VM* vm() { return m_vm; }
void add(uint32_t index)
@@ -83,17 +79,21 @@
const_iterator begin() const { return m_data->propertyNameVector().begin(); }
const_iterator end() const { return m_data->propertyNameVector().end(); }
- PropertyNameMode mode() const { return m_mode; }
bool includeSymbolProperties() const;
bool includeStringProperties() const;
+ PropertyNameMode propertyNameMode() const { return m_propertyNameMode; }
+ PrivateSymbolMode privateSymbolMode() const { return m_privateSymbolMode; }
+
private:
+ void addUncheckedInternal(UniquedStringImpl*);
bool isUidMatchedToTypeMode(UniquedStringImpl* identifier);
RefPtr<PropertyNameArrayData> m_data;
HashSet<UniquedStringImpl*> m_set;
VM* m_vm;
- PropertyNameMode m_mode;
+ PropertyNameMode m_propertyNameMode;
+ PrivateSymbolMode m_privateSymbolMode;
};
ALWAYS_INLINE void PropertyNameArray::add(const Identifier& identifier)
@@ -101,11 +101,16 @@
add(identifier.impl());
}
+ALWAYS_INLINE void PropertyNameArray::addUncheckedInternal(UniquedStringImpl* identifier)
+{
+ m_data->propertyNameVector().append(Identifier::fromUid(m_vm, identifier));
+}
+
ALWAYS_INLINE void PropertyNameArray::addUnchecked(UniquedStringImpl* identifier)
{
if (!isUidMatchedToTypeMode(identifier))
return;
- m_data->propertyNameVector().append(Identifier::fromUid(m_vm, identifier));
+ addUncheckedInternal(identifier);
}
ALWAYS_INLINE void PropertyNameArray::add(UniquedStringImpl* identifier)
@@ -129,24 +134,29 @@
return;
}
- addUnchecked(identifier);
+ addUncheckedInternal(identifier);
}
ALWAYS_INLINE bool PropertyNameArray::isUidMatchedToTypeMode(UniquedStringImpl* identifier)
{
- if (identifier->isSymbol())
- return includeSymbolProperties();
+ if (identifier->isSymbol()) {
+ if (!includeSymbolProperties())
+ return false;
+ if (UNLIKELY(m_privateSymbolMode == PrivateSymbolMode::Include))
+ return true;
+ return !static_cast<SymbolImpl*>(identifier)->isPrivate();
+ }
return includeStringProperties();
}
ALWAYS_INLINE bool PropertyNameArray::includeSymbolProperties() const
{
- return static_cast<std::underlying_type<PropertyNameMode>::type>(m_mode) & static_cast<std::underlying_type<PropertyNameMode>::type>(PropertyNameMode::Symbols);
+ return static_cast<std::underlying_type<PropertyNameMode>::type>(m_propertyNameMode) & static_cast<std::underlying_type<PropertyNameMode>::type>(PropertyNameMode::Symbols);
}
ALWAYS_INLINE bool PropertyNameArray::includeStringProperties() const
{
- return static_cast<std::underlying_type<PropertyNameMode>::type>(m_mode) & static_cast<std::underlying_type<PropertyNameMode>::type>(PropertyNameMode::Strings);
+ return static_cast<std::underlying_type<PropertyNameMode>::type>(m_propertyNameMode) & static_cast<std::underlying_type<PropertyNameMode>::type>(PropertyNameMode::Strings);
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/ProxyObject.cpp (222016 => 222017)
--- trunk/Source/_javascript_Core/runtime/ProxyObject.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/_javascript_Core/runtime/ProxyObject.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -911,7 +911,7 @@
JSValue arrayLikeObject = call(exec, ownKeysMethod, callType, callData, handler, arguments);
RETURN_IF_EXCEPTION(scope, void());
- PropertyNameMode propertyNameMode = trapResult.mode();
+ PropertyNameMode propertyNameMode = trapResult.propertyNameMode();
RuntimeTypeMask resultFilter = 0;
switch (propertyNameMode) {
case PropertyNameMode::Symbols:
@@ -949,7 +949,7 @@
bool targetIsExensible = target->isExtensible(exec);
RETURN_IF_EXCEPTION(scope, void());
- PropertyNameArray targetKeys(&vm, propertyNameMode);
+ PropertyNameArray targetKeys(&vm, propertyNameMode, trapResult.privateSymbolMode());
target->methodTable(vm)->getOwnPropertyNames(target, exec, targetKeys, enumerationMode);
RETURN_IF_EXCEPTION(scope, void());
Vector<UniquedStringImpl*> targetConfigurableKeys;
Modified: trunk/Source/WebCore/ChangeLog (222016 => 222017)
--- trunk/Source/WebCore/ChangeLog 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebCore/ChangeLog 2017-09-14 11:17:45 UTC (rev 222017)
@@ -1,3 +1,16 @@
+2017-09-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray
+ https://bugs.webkit.org/show_bug.cgi?id=176867
+
+ Reviewed by Sam Weinig.
+
+ * bindings/js/JSDOMConvertRecord.h:
+ * bindings/js/SerializedScriptValue.cpp:
+ (WebCore::CloneSerializer::serialize):
+ * bridge/NP_jsobject.cpp:
+ (_NPN_Enumerate):
+
2017-09-14 Joseph Pecoraro <[email protected]>
Web Inspector: Timeline should show when events preventDefault() was called on an event or not
Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertRecord.h (222016 => 222017)
--- trunk/Source/WebCore/bindings/js/JSDOMConvertRecord.h 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertRecord.h 2017-09-14 11:17:45 UTC (rev 222017)
@@ -85,7 +85,7 @@
ReturnType result;
// 4. Let keys be ? O.[[OwnPropertyKeys]]().
- JSC::PropertyNameArray keys(&vm, JSC::PropertyNameMode::Strings);
+ JSC::PropertyNameArray keys(&vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude);
object->methodTable(vm)->getOwnPropertyNames(object, &state, keys, JSC::EnumerationMode());
RETURN_IF_EXCEPTION(scope, { });
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (222016 => 222017)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -1490,7 +1490,7 @@
indexStack.removeLast();
lengthStack.removeLast();
- propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
+ propertyStack.append(PropertyNameArray(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude));
array->methodTable(vm)->getOwnNonIndexPropertyNames(array, m_exec, propertyStack.last(), EnumerationMode());
if (propertyStack.last().size()) {
write(NonIndexPropertiesTag);
@@ -1540,7 +1540,7 @@
return SerializationReturnCode::DataCloneError;
inputObjectStack.append(inObject);
indexStack.append(0);
- propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
+ propertyStack.append(PropertyNameArray(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude));
inObject->methodTable(vm)->getOwnPropertyNames(inObject, m_exec, propertyStack.last(), EnumerationMode());
}
objectStartVisitMember:
@@ -1608,7 +1608,7 @@
mapIteratorStack.removeLast();
JSObject* object = inputObjectStack.last();
ASSERT(jsDynamicDowncast<JSMap*>(vm, object));
- propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
+ propertyStack.append(PropertyNameArray(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude));
object->methodTable(vm)->getOwnPropertyNames(object, m_exec, propertyStack.last(), EnumerationMode());
write(NonMapPropertiesTag);
indexStack.append(0);
@@ -1652,7 +1652,7 @@
setIteratorStack.removeLast();
JSObject* object = inputObjectStack.last();
ASSERT(jsDynamicDowncast<JSSet*>(vm, object));
- propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
+ propertyStack.append(PropertyNameArray(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude));
object->methodTable(vm)->getOwnPropertyNames(object, m_exec, propertyStack.last(), EnumerationMode());
write(NonSetPropertiesTag);
indexStack.append(0);
Modified: trunk/Source/WebCore/bridge/NP_jsobject.cpp (222016 => 222017)
--- trunk/Source/WebCore/bridge/NP_jsobject.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebCore/bridge/NP_jsobject.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -484,7 +484,7 @@
auto scope = DECLARE_CATCH_SCOPE(vm);
ExecState* exec = globalObject->globalExec();
- PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
+ PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
obj->imp->methodTable(vm)->getPropertyNames(obj->imp, exec, propertyNames, EnumerationMode());
unsigned size = static_cast<unsigned>(propertyNames.size());
Modified: trunk/Source/WebKit/ChangeLog (222016 => 222017)
--- trunk/Source/WebKit/ChangeLog 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebKit/ChangeLog 2017-09-14 11:17:45 UTC (rev 222017)
@@ -1,3 +1,13 @@
+2017-09-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray
+ https://bugs.webkit.org/show_bug.cgi?id=176867
+
+ Reviewed by Sam Weinig.
+
+ * WebProcess/Plugins/Netscape/NPJSObject.cpp:
+ (WebKit::NPJSObject::enumerate):
+
2017-09-14 Maureen Daum <[email protected]>
Introduce the option to mark an HTML element as having AutoFill available.
Modified: trunk/Source/WebKit/WebProcess/Plugins/Netscape/NPJSObject.cpp (222016 => 222017)
--- trunk/Source/WebKit/WebProcess/Plugins/Netscape/NPJSObject.cpp 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebKit/WebProcess/Plugins/Netscape/NPJSObject.cpp 2017-09-14 11:17:45 UTC (rev 222017)
@@ -253,7 +253,7 @@
VM& vm = exec->vm();
JSLockHolder lock(vm);
- PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
+ PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
m_jsObject->methodTable(vm)->getPropertyNames(m_jsObject.get(), exec, propertyNames, EnumerationMode());
NPIdentifier* nameIdentifiers = npnMemNewArray<NPIdentifier>(propertyNames.size());
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (222016 => 222017)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2017-09-14 11:17:45 UTC (rev 222017)
@@ -1,3 +1,13 @@
+2017-09-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray
+ https://bugs.webkit.org/show_bug.cgi?id=176867
+
+ Reviewed by Sam Weinig.
+
+ * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+ (WebKit::NetscapePluginInstanceProxy::enumerate):
+
2017-09-13 Andy Estes <[email protected]>
[CF] Upstream CFNetwork-related WebKitSystemInterface functions
Modified: trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm (222016 => 222017)
--- trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm 2017-09-14 09:22:54 UTC (rev 222016)
+++ trunk/Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm 2017-09-14 11:17:45 UTC (rev 222017)
@@ -1276,7 +1276,7 @@
ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
- PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
+ PropertyNameArray propertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
object->methodTable(vm)->getPropertyNames(object, exec, propertyNames, EnumerationMode());
RetainPtr<NSMutableArray*> array = adoptNS([[NSMutableArray alloc] init]);