Title: [290416] trunk/Source/_javascript_Core
- Revision
- 290416
- Author
- ysuz...@apple.com
- Date
- 2022-02-24 00:56:54 -0800 (Thu, 24 Feb 2022)
Log Message
[JSC] WeakMapImpl do not need to take cellLock in visitOutputConstraints and main thread
https://bugs.webkit.org/show_bug.cgi?id=200195
Reviewed by Mark Lam.
WeakMapImpl::visitOutputConstraints is called in the constraint solver, so the main thread is stopped.
WeakMapImpl::rehash can destroy the buffer, but it is only called on either the main thread or GC finalizer. As a result,
it never happens that destroying the buffer while touching it in visitOutputConstraints. We can remove the lock guarding
this buffer.
* runtime/WeakMapImpl.cpp:
(JSC::WeakMapImpl<BucketType>::visitOutputConstraints):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::WeakMapImpl):
(JSC::WeakMapImpl::makeAndSetNewBuffer):
(JSC::WeakMapImpl::finishCreation): Deleted.
* runtime/WeakMapImplInlines.h:
(JSC::WeakMapImpl<WeakMapBucket>::rehash):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (290415 => 290416)
--- trunk/Source/_javascript_Core/ChangeLog 2022-02-24 08:55:39 UTC (rev 290415)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-02-24 08:56:54 UTC (rev 290416)
@@ -1,5 +1,26 @@
2022-02-23 Yusuke Suzuki <ysuz...@apple.com>
+ [JSC] WeakMapImpl do not need to take cellLock in visitOutputConstraints and main thread
+ https://bugs.webkit.org/show_bug.cgi?id=200195
+
+ Reviewed by Mark Lam.
+
+ WeakMapImpl::visitOutputConstraints is called in the constraint solver, so the main thread is stopped.
+ WeakMapImpl::rehash can destroy the buffer, but it is only called on either the main thread or GC finalizer. As a result,
+ it never happens that destroying the buffer while touching it in visitOutputConstraints. We can remove the lock guarding
+ this buffer.
+
+ * runtime/WeakMapImpl.cpp:
+ (JSC::WeakMapImpl<BucketType>::visitOutputConstraints):
+ * runtime/WeakMapImpl.h:
+ (JSC::WeakMapImpl::WeakMapImpl):
+ (JSC::WeakMapImpl::makeAndSetNewBuffer):
+ (JSC::WeakMapImpl::finishCreation): Deleted.
+ * runtime/WeakMapImplInlines.h:
+ (JSC::WeakMapImpl<WeakMapBucket>::rehash):
+
+2022-02-23 Yusuke Suzuki <ysuz...@apple.com>
+
[JSC] Adjust thread number for GC throughput
https://bugs.webkit.org/show_bug.cgi?id=237122
Modified: trunk/Source/_javascript_Core/runtime/WeakMapImpl.cpp (290415 => 290416)
--- trunk/Source/_javascript_Core/runtime/WeakMapImpl.cpp 2022-02-24 08:55:39 UTC (rev 290415)
+++ trunk/Source/_javascript_Core/runtime/WeakMapImpl.cpp 2022-02-24 08:56:54 UTC (rev 290416)
@@ -80,7 +80,6 @@
static_assert(std::is_same<BucketType, WeakMapBucket<WeakMapBucketDataKeyValue>>::value);
auto* thisObject = jsCast<WeakMapImpl*>(cell);
- Locker locker { thisObject->cellLock() };
auto* buffer = thisObject->buffer();
for (uint32_t index = 0; index < thisObject->m_capacity; ++index) {
auto* bucket = buffer + index;
Modified: trunk/Source/_javascript_Core/runtime/WeakMapImpl.h (290415 => 290416)
--- trunk/Source/_javascript_Core/runtime/WeakMapImpl.h 2022-02-24 08:55:39 UTC (rev 290415)
+++ trunk/Source/_javascript_Core/runtime/WeakMapImpl.h 2022-02-24 08:56:54 UTC (rev 290416)
@@ -197,21 +197,13 @@
static size_t estimatedSize(JSCell*, VM&);
+ static constexpr uint32_t initialCapacity = 4;
+
WeakMapImpl(VM& vm, Structure* structure)
: Base(vm, structure)
{
- }
-
- static constexpr uint32_t initialCapacity = 4;
-
- void finishCreation(VM& vm)
- {
ASSERT_WITH_MESSAGE(WeakMapBucket<WeakMapBucketDataKey>::offsetOfKey() == WeakMapBucket<WeakMapBucketDataKeyValue>::offsetOfKey(), "We assume this to be true in the DFG and FTL JIT.");
-
- Base::finishCreation(vm);
-
- Locker locker { cellLock() };
- makeAndSetNewBuffer(locker, initialCapacity);
+ makeAndSetNewBuffer(initialCapacity);
}
// WeakMap operations must not cause GC. We model operations in DFG based on this guarantee.
@@ -395,7 +387,7 @@
}
}
- void makeAndSetNewBuffer(const AbstractLocker&, uint32_t capacity)
+ void makeAndSetNewBuffer(uint32_t capacity)
{
ASSERT(!(capacity & (capacity - 1)));
Modified: trunk/Source/_javascript_Core/runtime/WeakMapImplInlines.h (290415 => 290416)
--- trunk/Source/_javascript_Core/runtime/WeakMapImplInlines.h 2022-02-24 08:55:39 UTC (rev 290415)
+++ trunk/Source/_javascript_Core/runtime/WeakMapImplInlines.h 2022-02-24 08:56:54 UTC (rev 290416)
@@ -90,10 +90,6 @@
// function must not touch any GC related features. This is why we do not allocate WeakMapBuffer
// in auxiliary buffer.
- // This rehash modifies m_buffer which is not GC-managed buffer. But m_buffer can be touched in
- // visitOutputConstraints. Thus, we should guard it with cellLock.
- Locker locker { cellLock() };
-
uint32_t oldCapacity = m_capacity;
MallocPtr<WeakMapBufferType, JSValueMalloc> oldBuffer = WTFMove(m_buffer);
@@ -103,7 +99,7 @@
capacity = nextCapacityAfterBatchRemoval(capacity, m_keyCount);
} else
capacity = nextCapacity(capacity, m_keyCount);
- makeAndSetNewBuffer(locker, capacity);
+ makeAndSetNewBuffer(capacity);
auto* buffer = this->buffer();
const uint32_t mask = m_capacity - 1;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes