Title: [252256] trunk/Source/_javascript_Core
Revision
252256
Author
[email protected]
Date
2019-11-08 13:11:25 -0800 (Fri, 08 Nov 2019)

Log Message

[JSC] Use LinkTimeConstants and make some properties lazy
https://bugs.webkit.org/show_bug.cgi?id=203795

Reviewed by Keith Miller.

This patch makes Map and Set lazily initialized in JSGlobalObject by leveraging link-time-constant. @Set was accessed from
builtin-JS. So we cannot make it lazily-allocated. But now we have link-time-constant mechanism that makes such accesses
lazily-initialized. We use this to make Set lazily-allocated.

And, instead of JSGlobalObject's last sequence of initialization, we initialize watchpoint in MapPrototype::finishCreation
and SetPrototype::finishCreation. This allows us to make Map and Set lazily-allocated. We also refactor NumberPrototype to
align to this model.

* runtime/ArrayPrototype.cpp:
(JSC::speciesWatchpointIsValid):
* runtime/JSGlobalObject.cpp:
(JSC::setupAdaptiveWatchpoint):
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
(JSC::JSGlobalObject::tryInstallArraySpeciesWatchpoint):
(JSC::JSGlobalObject::installNumberPrototypeWatchpoint):
(JSC::JSGlobalObject::installMapPrototypeWatchpoint):
(JSC::JSGlobalObject::installSetPrototypeWatchpoint):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::numberProtoToStringFunction const):
(JSC::JSGlobalObject::mapPrototype const):
(JSC::JSGlobalObject::jsSetPrototype const):
(JSC::JSGlobalObject::numberObjectStructure const):
(JSC::JSGlobalObject::mapStructure const): Deleted.
* runtime/MapPrototype.cpp:
(JSC::MapPrototype::finishCreation):
* runtime/NumberPrototype.cpp:
(JSC::NumberPrototype::finishCreation):
* runtime/NumberPrototype.h:
* runtime/SetPrototype.cpp:
(JSC::SetPrototype::finishCreation):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (252255 => 252256)


--- trunk/Source/_javascript_Core/ChangeLog	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-11-08 21:11:25 UTC (rev 252256)
@@ -1,3 +1,42 @@
+2019-11-08  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Use LinkTimeConstants and make some properties lazy
+        https://bugs.webkit.org/show_bug.cgi?id=203795
+
+        Reviewed by Keith Miller.
+
+        This patch makes Map and Set lazily initialized in JSGlobalObject by leveraging link-time-constant. @Set was accessed from
+        builtin-JS. So we cannot make it lazily-allocated. But now we have link-time-constant mechanism that makes such accesses
+        lazily-initialized. We use this to make Set lazily-allocated.
+
+        And, instead of JSGlobalObject's last sequence of initialization, we initialize watchpoint in MapPrototype::finishCreation
+        and SetPrototype::finishCreation. This allows us to make Map and Set lazily-allocated. We also refactor NumberPrototype to
+        align to this model.
+
+        * runtime/ArrayPrototype.cpp:
+        (JSC::speciesWatchpointIsValid):
+        * runtime/JSGlobalObject.cpp:
+        (JSC::setupAdaptiveWatchpoint):
+        (JSC::JSGlobalObject::init):
+        (JSC::JSGlobalObject::visitChildren):
+        (JSC::JSGlobalObject::tryInstallArraySpeciesWatchpoint):
+        (JSC::JSGlobalObject::installNumberPrototypeWatchpoint):
+        (JSC::JSGlobalObject::installMapPrototypeWatchpoint):
+        (JSC::JSGlobalObject::installSetPrototypeWatchpoint):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::numberProtoToStringFunction const):
+        (JSC::JSGlobalObject::mapPrototype const):
+        (JSC::JSGlobalObject::jsSetPrototype const):
+        (JSC::JSGlobalObject::numberObjectStructure const):
+        (JSC::JSGlobalObject::mapStructure const): Deleted.
+        * runtime/MapPrototype.cpp:
+        (JSC::MapPrototype::finishCreation):
+        * runtime/NumberPrototype.cpp:
+        (JSC::NumberPrototype::finishCreation):
+        * runtime/NumberPrototype.h:
+        * runtime/SetPrototype.cpp:
+        (JSC::SetPrototype::finishCreation):
+
 2019-11-08  Mark Lam  <[email protected]>
 
         Remove invalid assertion in DFG's compileNewArray().

Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (252255 => 252256)


--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp	2019-11-08 21:11:25 UTC (rev 252256)
@@ -199,7 +199,7 @@
 
     if (globalObject->arraySpeciesWatchpointSet().stateOnJSThread() == ClearWatchpoint) {
         dataLogLnIf(ArrayPrototypeInternal::verbose, "Initializing Array species watchpoints for Array.prototype: ", pointerDump(arrayPrototype), " with structure: ", pointerDump(arrayPrototype->structure(vm)), "\nand Array: ", pointerDump(globalObject->arrayConstructor()), " with structure: ", pointerDump(globalObject->arrayConstructor()->structure(vm)));
-        globalObject->tryInstallArraySpeciesWatchpoint(globalObject);
+        globalObject->tryInstallArraySpeciesWatchpoint();
         ASSERT(globalObject->arraySpeciesWatchpointSet().stateOnJSThread() != ClearWatchpoint);
     }
 

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (252255 => 252256)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2019-11-08 21:11:25 UTC (rev 252256)
@@ -388,7 +388,9 @@
   Date                  JSGlobalObject::m_dateStructure              DontEnum|ClassStructure
   Error                 JSGlobalObject::m_errorStructure             DontEnum|ClassStructure
   Boolean               JSGlobalObject::m_booleanObjectStructure     DontEnum|ClassStructure
+  Map                   JSGlobalObject::m_mapStructure               DontEnum|ClassStructure
   Number                JSGlobalObject::m_numberObjectStructure      DontEnum|ClassStructure
+  Set                   JSGlobalObject::m_setStructure               DontEnum|ClassStructure
   Symbol                JSGlobalObject::m_symbolObjectStructure      DontEnum|ClassStructure
   WeakMap               JSGlobalObject::m_weakMapStructure           DontEnum|ClassStructure
   WeakSet               JSGlobalObject::m_weakSetStructure           DontEnum|ClassStructure
@@ -460,6 +462,29 @@
     return jsCast<GetterSetter*>(slot.getPureResult());
 }
 
+static ObjectPropertyCondition setupAdaptiveWatchpoint(JSGlobalObject* globalObject, JSObject* base, const Identifier& ident)
+{
+    // Performing these gets should not throw.
+    VM& vm = globalObject->vm();
+    auto catchScope = DECLARE_CATCH_SCOPE(vm);
+    PropertySlot slot(base, PropertySlot::InternalMethodType::Get);
+    bool result = base->getOwnPropertySlot(base, globalObject, ident, slot);
+    ASSERT_UNUSED(result, result);
+    catchScope.assertNoException();
+    RELEASE_ASSERT(slot.isCacheableValue());
+    JSValue functionValue = slot.getValue(globalObject, ident);
+    catchScope.assertNoException();
+    ASSERT(jsDynamicCast<JSFunction*>(vm, functionValue));
+
+    ObjectPropertyCondition condition = generateConditionForSelfEquivalence(vm, nullptr, base, ident.impl());
+    RELEASE_ASSERT(condition.requiredValue() == functionValue);
+
+    bool isWatchable = condition.isWatchable(PropertyCondition::EnsureWatchability);
+    RELEASE_ASSERT(isWatchable); // We allow this to install the necessary watchpoints.
+
+    return condition;
+}
+
 template<ErrorType errorType>
 void JSGlobalObject::initializeErrorConstructor(LazyClassStructure::Initializer& init)
 {
@@ -543,6 +568,11 @@
             init.set(JSFunction::create(init.vm, promiseConstructorResolveCodeGenerator(init.vm), init.owner));
         });
 
+    m_numberProtoToStringFunction.initLater(
+        [] (const Initializer<JSFunction>& init) {
+            init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 1, init.vm.propertyNames->toString.string(), numberProtoFuncToString, NumberPrototypeToStringIntrinsic));
+        });
+
     m_functionProtoHasInstanceSymbolFunction.set(vm, this, hasInstanceSymbolFunction);
     m_throwTypeErrorGetterSetter.initLater(
         [] (const Initializer<GetterSetter>& init) {
@@ -946,7 +976,6 @@
     m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::regExpBuiltinExec)].set(vm, this, jsCast<JSFunction*>(m_regExpPrototype->getDirect(vm, vm.propertyNames->exec)));
     m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::regExpPrototypeSymbolReplace)].set(vm, this, m_regExpPrototype->getDirect(vm, vm.propertyNames->replaceSymbol).asCell());
 
-    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::Set)].set(vm, this, setConstructor);
     m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::isArray)].set(vm, this, arrayConstructor->getDirect(vm, vm.propertyNames->isArray).asCell());
     m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::callFunction)].set(vm, this, callFunction);
     m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::applyFunction)].set(vm, this, applyFunction);
@@ -977,6 +1006,9 @@
     jsCast<JSObject*>(linkTimeConstant(LinkTimeConstant::SetIterator))->putDirect(vm, vm.propertyNames->prototype, setIteratorPrototype);
 
     // Map and Set helpers.
+    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::Set)].initLater([] (const Initializer<JSCell>& init) {
+            init.set(jsCast<JSGlobalObject*>(init.owner)->setConstructor());
+        });
     m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::mapBucketHead)].initLater([] (const Initializer<JSCell>& init) {
             init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 0, String(), mapPrivateFuncMapBucketHead, JSMapBucketHeadIntrinsic));
         });
@@ -1186,97 +1218,48 @@
 
 #undef CREATE_PROTOTYPE_FOR_LAZY_TYPE
 
-    auto setupAdaptiveWatchpoint = [&] (JSObject* base, const Identifier& ident) -> ObjectPropertyCondition {
-        // Performing these gets should not throw.
-        PropertySlot slot(base, PropertySlot::InternalMethodType::Get);
-        bool result = base->getOwnPropertySlot(base, this, ident, slot);
-        ASSERT_UNUSED(result, result);
-        catchScope.assertNoException();
-        RELEASE_ASSERT(slot.isCacheableValue());
-        JSValue functionValue = slot.getValue(this, ident);
-        catchScope.assertNoException();
-        ASSERT(jsDynamicCast<JSFunction*>(vm, functionValue));
-
-        ObjectPropertyCondition condition = generateConditionForSelfEquivalence(vm, nullptr, base, ident.impl());
-        RELEASE_ASSERT(condition.requiredValue() == functionValue);
-
-        bool isWatchable = condition.isWatchable(PropertyCondition::EnsureWatchability);
-        RELEASE_ASSERT(isWatchable); // We allow this to install the necessary watchpoints.
-
-        return condition;
-    };
-
     {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(arrayIteratorPrototype, vm.propertyNames->next);
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, arrayIteratorPrototype, vm.propertyNames->next);
         m_arrayIteratorPrototypeNext = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_arrayIteratorProtocolWatchpointSet);
         m_arrayIteratorPrototypeNext->install(vm);
     }
     {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this->arrayPrototype(), vm.propertyNames->iteratorSymbol);
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, this->arrayPrototype(), vm.propertyNames->iteratorSymbol);
         m_arrayPrototypeSymbolIteratorWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_arrayIteratorProtocolWatchpointSet);
         m_arrayPrototypeSymbolIteratorWatchpoint->install(vm);
     }
     {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this->arrayPrototype(), vm.propertyNames->join);
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, this->arrayPrototype(), vm.propertyNames->join);
         m_arrayPrototypeJoinWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_arrayJoinWatchpointSet);
         m_arrayPrototypeJoinWatchpoint->install(vm);
     }
 
     {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(mapIteratorPrototype, vm.propertyNames->next);
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, mapIteratorPrototype, vm.propertyNames->next);
         m_mapIteratorPrototypeNextWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_mapIteratorProtocolWatchpointSet);
         m_mapIteratorPrototypeNextWatchpoint->install(vm);
     }
     {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), vm.propertyNames->iteratorSymbol);
-        m_mapPrototypeSymbolIteratorWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_mapIteratorProtocolWatchpointSet);
-        m_mapPrototypeSymbolIteratorWatchpoint->install(vm);
-    }
-
-    {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(setIteratorPrototype, vm.propertyNames->next);
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, setIteratorPrototype, vm.propertyNames->next);
         m_setIteratorPrototypeNextWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_setIteratorProtocolWatchpointSet);
         m_setIteratorPrototypeNextWatchpoint->install(vm);
     }
     {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), vm.propertyNames->iteratorSymbol);
-        m_setPrototypeSymbolIteratorWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_setIteratorProtocolWatchpointSet);
-        m_setPrototypeSymbolIteratorWatchpoint->install(vm);
-    }
-
-    {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_stringIteratorPrototype.get(), vm.propertyNames->next);
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, m_stringIteratorPrototype.get(), vm.propertyNames->next);
         m_stringIteratorPrototypeNextWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_stringIteratorProtocolWatchpointSet);
         m_stringIteratorPrototypeNextWatchpoint->install(vm);
     }
     {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_stringPrototype.get(), vm.propertyNames->iteratorSymbol);
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, m_stringPrototype.get(), vm.propertyNames->iteratorSymbol);
         m_stringPrototypeSymbolIteratorWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_stringIteratorProtocolWatchpointSet);
         m_stringPrototypeSymbolIteratorWatchpoint->install(vm);
     }
 
-    {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), vm.propertyNames->set);
-        m_mapPrototypeSetWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_mapSetWatchpointSet);
-        m_mapPrototypeSetWatchpoint->install(vm);
-    }
-
-    {
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), vm.propertyNames->add);
-        m_setPrototypeAddWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_setAddWatchpointSet);
-        m_setPrototypeAddWatchpoint->install(vm);
-    }
-
     // Unfortunately, the prototype objects of the builtin objects can be touched from concurrent compilers. So eagerly initialize them only if we use JIT.
     if (VM::canUseJIT()) {
         this->booleanPrototype();
-        auto* numberPrototype = this->numberPrototype();
+        this->numberPrototype();
         this->symbolPrototype();
-
-        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(numberPrototype, vm.propertyNames->toString);
-        m_numberPrototypeToStringWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_numberToStringWatchpointSet);
-        m_numberPrototypeToStringWatchpoint->install(vm);
-        m_numberProtoToStringFunction.set(vm, this, jsCast<JSFunction*>(numberPrototype->getDirect(vm, vm.propertyNames->toString)));
     }
 
     fixupPrototypeChainWithObjectPrototype(vm);
@@ -1770,7 +1753,7 @@
     thisObject->m_iteratorProtocolFunction.visit(visitor);
     thisObject->m_promiseResolveFunction.visit(visitor);
     visitor.append(thisObject->m_objectProtoValueOfFunction);
-    visitor.append(thisObject->m_numberProtoToStringFunction);
+    thisObject->m_numberProtoToStringFunction.visit(visitor);
     visitor.append(thisObject->m_functionProtoHasInstanceSymbolFunction);
     thisObject->m_throwTypeErrorGetterSetter.visit(visitor);
     visitor.append(thisObject->m_regExpProtoSymbolReplace);
@@ -1945,12 +1928,12 @@
     jsCast<JSGlobalObject*>(cell)->m_rareData = nullptr;
 }
 
-void JSGlobalObject::tryInstallArraySpeciesWatchpoint(JSGlobalObject* globalObject)
+void JSGlobalObject::tryInstallArraySpeciesWatchpoint()
 {
     RELEASE_ASSERT(!m_arrayPrototypeConstructorWatchpoint);
     RELEASE_ASSERT(!m_arrayConstructorSpeciesWatchpoint);
 
-    VM& vm = globalObject->vm();
+    VM& vm = this->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     // First we need to make sure that the Array.prototype.constructor property points to Array
@@ -1970,11 +1953,11 @@
     };
 
     PropertySlot constructorSlot(arrayPrototype, PropertySlot::InternalMethodType::VMInquiry);
-    arrayPrototype->getOwnPropertySlot(arrayPrototype, globalObject, vm.propertyNames->constructor, constructorSlot);
+    arrayPrototype->getOwnPropertySlot(arrayPrototype, this, vm.propertyNames->constructor, constructorSlot);
     scope.assertNoException();
     if (constructorSlot.slotBase() != arrayPrototype
         || !constructorSlot.isCacheableValue()
-        || constructorSlot.getValue(globalObject, vm.propertyNames->constructor) != arrayConstructor) {
+        || constructorSlot.getValue(this, vm.propertyNames->constructor) != arrayConstructor) {
         invalidateWatchpoint();
         return;
     }
@@ -1984,7 +1967,7 @@
         constructorStructure = constructorStructure->flattenDictionaryStructure(vm, arrayConstructor);
 
     PropertySlot speciesSlot(arrayConstructor, PropertySlot::InternalMethodType::VMInquiry);
-    arrayConstructor->getOwnPropertySlot(arrayConstructor, globalObject, vm.propertyNames->speciesSymbol, speciesSlot);
+    arrayConstructor->getOwnPropertySlot(arrayConstructor, this, vm.propertyNames->speciesSymbol, speciesSlot);
     scope.assertNoException();
     if (speciesSlot.slotBase() != arrayConstructor
         || !speciesSlot.isCacheableGetter()
@@ -2016,6 +1999,43 @@
     m_arrayConstructorSpeciesWatchpoint->install(vm);
 }
 
+void JSGlobalObject::installNumberPrototypeWatchpoint(NumberPrototype* numberPrototype)
+{
+    VM& vm = this->vm();
+    ASSERT(m_numberToStringWatchpointSet.isStillValid());
+    ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, numberPrototype, vm.propertyNames->toString);
+    m_numberPrototypeToStringWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_numberToStringWatchpointSet);
+    m_numberPrototypeToStringWatchpoint->install(vm);
+}
+
+void JSGlobalObject::installMapPrototypeWatchpoint(MapPrototype* mapPrototype)
+{
+    VM& vm = this->vm();
+    if (m_mapIteratorProtocolWatchpointSet.isStillValid()) {
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, mapPrototype, vm.propertyNames->iteratorSymbol);
+        m_mapPrototypeSymbolIteratorWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_mapIteratorProtocolWatchpointSet);
+        m_mapPrototypeSymbolIteratorWatchpoint->install(vm);
+    }
+    ASSERT(m_mapSetWatchpointSet.isStillValid());
+    ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, mapPrototype, vm.propertyNames->set);
+    m_mapPrototypeSetWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_mapSetWatchpointSet);
+    m_mapPrototypeSetWatchpoint->install(vm);
+}
+
+void JSGlobalObject::installSetPrototypeWatchpoint(SetPrototype* setPrototype)
+{
+    VM& vm = this->vm();
+    if (m_setIteratorProtocolWatchpointSet.isStillValid()) {
+        ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, setPrototype, vm.propertyNames->iteratorSymbol);
+        m_setPrototypeSymbolIteratorWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_setIteratorProtocolWatchpointSet);
+        m_setPrototypeSymbolIteratorWatchpoint->install(vm);
+    }
+    ASSERT(m_setAddWatchpointSet.isStillValid());
+    ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this, setPrototype, vm.propertyNames->add);
+    m_setPrototypeAddWatchpoint = makeUnique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(this, condition, m_setAddWatchpointSet);
+    m_setPrototypeAddWatchpoint->install(vm);
+}
+
 void slowValidateCell(JSGlobalObject* globalObject)
 {
     RELEASE_ASSERT(globalObject->isGlobalObject());

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (252255 => 252256)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2019-11-08 21:11:25 UTC (rev 252256)
@@ -132,8 +132,6 @@
 
 #define FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
     macro(String, string, stringObject, StringObject, String, object, typeExposedByDefault) \
-    macro(Map, map, map, JSMap, Map, object, typeExposedByDefault) \
-    macro(Set, set, set, JSSet, Set, object, typeExposedByDefault) \
     macro(JSPromise, promise, promise, JSPromise, Promise, object, typeExposedByDefault) \
     macro(BigInt, bigInt, bigIntObject, BigIntObject, BigInt, object, Options::useBigInt()) \
     macro(WeakObjectRef, weakObjectRef, weakObjectRef, JSWeakObjectRef, WeakRef, object, Options::useWeakRefs()) \
@@ -149,7 +147,9 @@
     macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object, typeExposedByDefault) \
     macro(Date, date, date, DateInstance, Date, object, typeExposedByDefault) \
     macro(Error, error, error, ErrorInstance, Error, object, typeExposedByDefault) \
+    macro(Map, map, map, JSMap, Map, object, typeExposedByDefault) \
     macro(Number, number, numberObject, NumberObject, Number, object, typeExposedByDefault) \
+    macro(Set, set, set, JSSet, Set, object, typeExposedByDefault) \
     macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object, typeExposedByDefault) \
     DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \
     DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
@@ -302,8 +302,8 @@
     LazyProperty<JSGlobalObject, JSFunction> m_evalFunction;
     LazyProperty<JSGlobalObject, JSFunction> m_iteratorProtocolFunction;
     LazyProperty<JSGlobalObject, JSFunction> m_promiseResolveFunction;
+    LazyProperty<JSGlobalObject, JSFunction> m_numberProtoToStringFunction;
     WriteBarrier<JSFunction> m_objectProtoValueOfFunction;
-    WriteBarrier<JSFunction> m_numberProtoToStringFunction;
     WriteBarrier<JSFunction> m_functionProtoHasInstanceSymbolFunction;
     LazyProperty<JSGlobalObject, GetterSetter> m_throwTypeErrorGetterSetter;
     WriteBarrier<JSObject> m_regExpProtoSymbolReplace;
@@ -615,7 +615,7 @@
     JSFunction* rejectPromiseFunction() const;
     JSFunction* promiseProtoThenFunction() const;
     JSFunction* objectProtoValueOfFunction() const { return m_objectProtoValueOfFunction.get(); }
-    JSFunction* numberProtoToStringFunction() const { return m_numberProtoToStringFunction.get(); }
+    JSFunction* numberProtoToStringFunction() const { return m_numberProtoToStringFunction.getInitializedOnMainThread(this); }
     JSFunction* functionProtoHasInstanceSymbolFunction() const { return m_functionProtoHasInstanceSymbolFunction.get(); }
     JSFunction* regExpProtoExecFunction() const;
     JSObject* regExpProtoSymbolReplaceFunction() const { return m_regExpProtoSymbolReplace.get(); }
@@ -644,9 +644,9 @@
     GeneratorFunctionPrototype* generatorFunctionPrototype() const { return m_generatorFunctionPrototype.get(); }
     GeneratorPrototype* generatorPrototype() const { return m_generatorPrototype.get(); }
     AsyncFunctionPrototype* asyncFunctionPrototype() const { return m_asyncFunctionPrototype.get(); }
-    MapPrototype* mapPrototype() const { return m_mapPrototype.get(); }
+    JSObject* mapPrototype() const { return m_mapStructure.prototype(this); }
     // Workaround for the name conflict between JSCell::setPrototype.
-    SetPrototype* jsSetPrototype() const { return m_setPrototype.get(); }
+    JSObject* jsSetPrototype() const { return m_setStructure.prototype(this); }
     JSPromisePrototype* promisePrototype() const { return m_promisePrototype.get(); }
     AsyncGeneratorPrototype* asyncGeneratorPrototype() const { return m_asyncGeneratorPrototype.get(); }
     AsyncGeneratorFunctionPrototype* asyncGeneratorFunctionPrototype() const { return m_asyncGeneratorFunctionPrototype.get(); }
@@ -745,7 +745,6 @@
     Structure* nativeStdFunctionStructure() const { return m_nativeStdFunctionStructure.get(this); }
     PropertyOffset functionNameOffset() const { return m_functionNameOffset; }
     Structure* numberObjectStructure() const { return m_numberObjectStructure.get(this); }
-    Structure* mapStructure() const { return m_mapStructure.get(); }
     Structure* regExpStructure() const { return m_regExpStructure.get(); }
     Structure* generatorStructure() const { return m_generatorStructure.get(); }
     Structure* asyncGeneratorStructure() const { return m_asyncGeneratorStructure.get(); }
@@ -1012,7 +1011,10 @@
     void setWrapperMap(std::unique_ptr<WrapperMap>&&);
 #endif
 
-    void tryInstallArraySpeciesWatchpoint(JSGlobalObject*);
+    void tryInstallArraySpeciesWatchpoint();
+    void installNumberPrototypeWatchpoint(NumberPrototype*);
+    void installMapPrototypeWatchpoint(MapPrototype*);
+    void installSetPrototypeWatchpoint(SetPrototype*);
 
 protected:
     struct GlobalPropertyInfo {

Modified: trunk/Source/_javascript_Core/runtime/MapPrototype.cpp (252255 => 252256)


--- trunk/Source/_javascript_Core/runtime/MapPrototype.cpp	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/runtime/MapPrototype.cpp	2019-11-08 21:11:25 UTC (rev 252256)
@@ -76,6 +76,8 @@
     putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, "Map"), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
 
     JSC_NATIVE_GETTER_WITHOUT_TRANSITION(vm.propertyNames->size, mapProtoFuncSize, PropertyAttribute::DontEnum | PropertyAttribute::Accessor);
+
+    globalObject->installMapPrototypeWatchpoint(this);
 }
 
 ALWAYS_INLINE static JSMap* getMap(JSGlobalObject* globalObject, JSValue thisValue)

Modified: trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp (252255 => 252256)


--- trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp	2019-11-08 21:11:25 UTC (rev 252256)
@@ -44,7 +44,6 @@
 
 namespace JSC {
 
-static EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(JSGlobalObject*, CallFrame*);
 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToLocaleString(JSGlobalObject*, CallFrame*);
 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(JSGlobalObject*, CallFrame*);
 static EncodedJSValue JSC_HOST_CALL numberProtoFuncToExponential(JSGlobalObject*, CallFrame*);
@@ -79,9 +78,9 @@
 {
     Base::finishCreation(vm);
     setInternalValue(vm, jsNumber(0));
-
-    JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->toString, numberProtoFuncToString, static_cast<unsigned>(PropertyAttribute::DontEnum), 1, NumberPrototypeToStringIntrinsic);
+    putDirectWithoutTransition(vm, vm.propertyNames->toString, globalObject->numberProtoToStringFunction(), static_cast<unsigned>(PropertyAttribute::DontEnum));
     ASSERT(inherits(vm, info()));
+    globalObject->installNumberPrototypeWatchpoint(this);
 }
 
 // ------------------------------ Functions ---------------------------

Modified: trunk/Source/_javascript_Core/runtime/NumberPrototype.h (252255 => 252256)


--- trunk/Source/_javascript_Core/runtime/NumberPrototype.h	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/runtime/NumberPrototype.h	2019-11-08 21:11:25 UTC (rev 252256)
@@ -51,6 +51,7 @@
 };
 
 EncodedJSValue JSC_HOST_CALL numberProtoFuncValueOf(JSGlobalObject*, CallFrame*);
+EncodedJSValue JSC_HOST_CALL numberProtoFuncToString(JSGlobalObject*, CallFrame*);
 JSString* int32ToString(VM&, int32_t value, int32_t radix);
 JSString* int52ToString(VM&, int64_t value, int32_t radix);
 JSString* numberToString(VM&, double value, int32_t radix);

Modified: trunk/Source/_javascript_Core/runtime/SetPrototype.cpp (252255 => 252256)


--- trunk/Source/_javascript_Core/runtime/SetPrototype.cpp	2019-11-08 21:10:11 UTC (rev 252255)
+++ trunk/Source/_javascript_Core/runtime/SetPrototype.cpp	2019-11-08 21:11:25 UTC (rev 252256)
@@ -74,6 +74,8 @@
     putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, "Set"), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly);
 
     JSC_NATIVE_GETTER_WITHOUT_TRANSITION(vm.propertyNames->size, setProtoFuncSize, PropertyAttribute::DontEnum | PropertyAttribute::Accessor);
+
+    globalObject->installSetPrototypeWatchpoint(this);
 }
 
 ALWAYS_INLINE static JSSet* getSet(JSGlobalObject* globalObject, JSValue thisValue)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to