Ignore:
Timestamp:
Sep 14, 2017, 4:17:45 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray
https://bugs.webkit.org/show_bug.cgi?id=176867

Reviewed by Sam Weinig.

JSTests:

  • microbenchmarks/object-get-own-property-symbols.js: Added.

(test):

Source/JavaScriptCore:

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):

Source/WebCore:

  • bindings/js/JSDOMConvertRecord.h:
  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::serialize):

  • bridge/NP_jsobject.cpp:

(_NPN_Enumerate):

Source/WebKit:

  • WebProcess/Plugins/Netscape/NPJSObject.cpp:

(WebKit::NPJSObject::enumerate):

Source/WebKitLegacy/mac:

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::enumerate):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r221849 r222017  
    225225    , m_replacer(replacer)
    226226    , m_usingArrayReplacer(false)
    227     , m_arrayReplacerPropertyNames(exec, PropertyNameMode::Strings)
     227    , m_arrayReplacerPropertyNames(&exec->vm(), PropertyNameMode::Strings, PrivateSymbolMode::Exclude)
    228228    , m_replacerCallType(CallType::None)
    229229{
     
    485485                m_propertyNames = stringifier.m_arrayReplacerPropertyNames.data();
    486486            else {
    487                 PropertyNameArray objectPropertyNames(exec, PropertyNameMode::Strings);
     487                PropertyNameArray objectPropertyNames(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
    488488                m_object->methodTable(vm)->getOwnPropertyNames(m_object.get(), exec, objectPropertyNames, EnumerationMode());
    489489                RETURN_IF_EXCEPTION(scope, false);
     
    706706                objectStack.push(object);
    707707                indexStack.append(0);
    708                 propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
     708                propertyStack.append(PropertyNameArray(&vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude));
    709709                object->methodTable(vm)->getOwnPropertyNames(object, m_exec, propertyStack.last(), EnumerationMode());
    710710                RETURN_IF_EXCEPTION(scope, { });
Note: See TracChangeset for help on using the changeset viewer.