Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (253239 => 253240)
--- trunk/Source/_javascript_Core/ChangeLog 2019-12-07 05:16:00 UTC (rev 253239)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-12-07 05:48:08 UTC (rev 253240)
@@ -1,5 +1,27 @@
2019-12-06 Yusuke Suzuki <[email protected]>
+ [JSC] Put JSModuleNamespaceObject in IsoSubspace
+ https://bugs.webkit.org/show_bug.cgi?id=204973
+
+ Reviewed by Mark Lam.
+
+ We found that we do not need to embed AbstractModuleRecord vector inside JSModuleNamespaceObject: we can just put it
+ in ExportEntry. So we can make it non-variable-sized cell. Further, this patch puts it in IsoSubspace.
+
+ * runtime/CellSize.h:
+ (JSC::isDynamicallySizedType):
+ (JSC::cellSize):
+ * runtime/JSModuleNamespaceObject.cpp:
+ (JSC::JSModuleNamespaceObject::finishCreation):
+ (JSC::JSModuleNamespaceObject::visitChildren):
+ (JSC::JSModuleNamespaceObject::getOwnPropertySlotCommon):
+ * runtime/JSModuleNamespaceObject.h:
+ * runtime/VM.cpp:
+ (JSC::VM::VM):
+ * runtime/VM.h:
+
+2019-12-06 Yusuke Suzuki <[email protected]>
+
[JSC] Put ModuleRecords in IsoSubspace
https://bugs.webkit.org/show_bug.cgi?id=204972
Modified: trunk/Source/_javascript_Core/runtime/CellSize.h (253239 => 253240)
--- trunk/Source/_javascript_Core/runtime/CellSize.h 2019-12-07 05:16:00 UTC (rev 253239)
+++ trunk/Source/_javascript_Core/runtime/CellSize.h 2019-12-07 05:48:08 UTC (rev 253240)
@@ -29,7 +29,6 @@
#include "JSBigInt.h"
#include "JSLexicalEnvironment.h"
#include "JSModuleEnvironment.h"
-#include "JSModuleNamespaceObject.h"
namespace JSC {
@@ -38,8 +37,7 @@
if (type == DirectArgumentsType
|| type == FinalObjectType
|| type == LexicalEnvironmentType
- || type == ModuleEnvironmentType
- || type == ModuleNamespaceObjectType)
+ || type == ModuleEnvironmentType)
return true;
return false;
}
@@ -66,10 +64,6 @@
auto* env = jsCast<JSModuleEnvironment*>(cell);
return JSModuleEnvironment::allocationSize(env->symbolTable());
}
- case ModuleNamespaceObjectType: {
- auto* obj = jsCast<JSModuleNamespaceObject*>(cell);
- return JSModuleNamespaceObject::allocationSize(obj->m_names.capacity());
- }
default:
RELEASE_ASSERT_NOT_REACHED();
}
Modified: trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp (253239 => 253240)
--- trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp 2019-12-07 05:16:00 UTC (rev 253239)
+++ trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.cpp 2019-12-07 05:48:08 UTC (rev 253240)
@@ -59,17 +59,14 @@
});
m_moduleRecord.set(vm, this, moduleRecord);
+ m_names.reserveCapacity(resolutions.size());
{
- unsigned moduleRecordOffset = 0;
- m_names.reserveCapacity(resolutions.size());
+ auto locker = holdLock(cellLock());
for (const auto& pair : resolutions) {
- moduleRecordAt(moduleRecordOffset).set(vm, this, pair.second.moduleRecord);
m_names.append(pair.first);
- m_exports.add(pair.first.impl(), ExportEntry {
- pair.second.localName,
- moduleRecordOffset
- });
- ++moduleRecordOffset;
+ auto addResult = m_exports.add(pair.first.impl(), ExportEntry());
+ addResult.iterator->value.localName = pair.second.localName;
+ addResult.iterator->value.moduleRecord.set(vm, this, pair.second.moduleRecord);
}
}
@@ -95,8 +92,11 @@
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
visitor.append(thisObject->m_moduleRecord);
- for (unsigned i = 0; i < thisObject->m_names.size(); ++i)
- visitor.appendHidden(thisObject->moduleRecordAt(i));
+ {
+ auto locker = holdLock(thisObject->cellLock());
+ for (auto& pair : thisObject->m_exports)
+ visitor.appendHidden(pair.value.moduleRecord);
+ }
}
static JSValue getValue(JSModuleEnvironment* environment, PropertyName localName, ScopeOffset& scopeOffset)
@@ -136,7 +136,7 @@
switch (slot.internalMethodType()) {
case PropertySlot::InternalMethodType::GetOwnProperty:
case PropertySlot::InternalMethodType::Get: {
- JSModuleEnvironment* environment = moduleRecordAt(exportEntry.moduleRecordOffset)->moduleEnvironment();
+ JSModuleEnvironment* environment = exportEntry.moduleRecord->moduleEnvironment();
ScopeOffset scopeOffset;
JSValue value = getValue(environment, exportEntry.localName, scopeOffset);
// If the value is filled with TDZ value, throw a reference error.
Modified: trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.h (253239 => 253240)
--- trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.h 2019-12-07 05:16:00 UTC (rev 253239)
+++ trunk/Source/_javascript_Core/runtime/JSModuleNamespaceObject.h 2019-12-07 05:48:08 UTC (rev 253240)
@@ -30,19 +30,24 @@
namespace JSC {
-class JSModuleNamespaceObject final : public JSDestructibleObject {
+class JSModuleNamespaceObject final : public JSNonFinalObject {
public:
- typedef JSDestructibleObject Base;
+ using Base = JSNonFinalObject;
static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | OverridesGetPropertyNames | GetOwnPropertySlotIsImpureForPropertyAbsence | IsImmutablePrototypeExoticObject;
+ static constexpr bool needsDestruction = true;
+ static void destroy(JSCell*);
+
+ template<typename CellType, SubspaceAccess mode>
+ static IsoSubspace* subspaceFor(VM& vm)
+ {
+ return vm.moduleNamespaceObjectSpace<mode>();
+ }
+
static JSModuleNamespaceObject* create(JSGlobalObject* globalObject, Structure* structure, AbstractModuleRecord* moduleRecord, Vector<std::pair<Identifier, AbstractModuleRecord::Resolution>>&& resolutions)
{
VM& vm = getVM(globalObject);
- JSModuleNamespaceObject* object =
- new (
- NotNull,
- allocateCell<JSModuleNamespaceObject>(vm.heap, JSModuleNamespaceObject::allocationSize(resolutions.size())))
- JSModuleNamespaceObject(vm, structure);
+ JSModuleNamespaceObject* object = new (NotNull, allocateCell<JSModuleNamespaceObject>(vm.heap)) JSModuleNamespaceObject(vm, structure);
object->finishCreation(globalObject, moduleRecord, WTFMove(resolutions));
return object;
}
@@ -69,33 +74,12 @@
JS_EXPORT_PRIVATE JSModuleNamespaceObject(VM&, Structure*);
private:
- static void destroy(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
bool getOwnPropertySlotCommon(JSGlobalObject*, PropertyName, PropertySlot&);
- WriteBarrierBase<AbstractModuleRecord>& moduleRecordAt(unsigned offset)
- {
- return moduleRecords()[offset];
- }
-
- WriteBarrierBase<AbstractModuleRecord>* moduleRecords()
- {
- return bitwise_cast<WriteBarrierBase<AbstractModuleRecord>*>(bitwise_cast<char*>(this) + offsetOfModuleRecords());
- }
-
- static size_t offsetOfModuleRecords()
- {
- return WTF::roundUpToMultipleOf<sizeof(WriteBarrier<AbstractModuleRecord>)>(sizeof(JSModuleNamespaceObject));
- }
-
- static size_t allocationSize(Checked<size_t> moduleRecords)
- {
- return (offsetOfModuleRecords() + moduleRecords * sizeof(WriteBarrier<AbstractModuleRecord>)).unsafeGet();
- }
-
struct ExportEntry {
Identifier localName;
- unsigned moduleRecordOffset;
+ WriteBarrier<AbstractModuleRecord> moduleRecord;
};
typedef HashMap<RefPtr<UniquedStringImpl>, ExportEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>> ExportMap;
Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (253239 => 253240)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2019-12-07 05:16:00 UTC (rev 253239)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2019-12-07 05:48:08 UTC (rev 253240)
@@ -95,6 +95,7 @@
#include "JSLock.h"
#include "JSMap.h"
#include "JSMapIterator.h"
+#include "JSModuleNamespaceObject.h"
#include "JSModuleRecord.h"
#include "JSPromise.h"
#include "JSPropertyNameEnumerator.h"
@@ -289,6 +290,7 @@
, dateInstanceHeapCellType(makeUnique<IsoHeapCellType<DateInstance>>())
, errorInstanceHeapCellType(makeUnique<IsoHeapCellType<ErrorInstance>>())
, jsModuleRecordHeapCellType(makeUnique<IsoHeapCellType<JSModuleRecord>>())
+ , moduleNamespaceObjectHeapCellType(makeUnique<IsoHeapCellType<JSModuleNamespaceObject>>())
, stringHeapCellType(makeUnique<IsoHeapCellType<JSString>>())
, weakMapHeapCellType(makeUnique<IsoHeapCellType<JSWeakMap>>())
, weakSetHeapCellType(makeUnique<IsoHeapCellType<JSWeakSet>>())
@@ -1365,6 +1367,7 @@
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(int16ArraySpace, cellHeapCellType.get(), JSInt16Array)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(int32ArraySpace, cellHeapCellType.get(), JSInt32Array)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(mapSpace, cellHeapCellType.get(), JSMap)
+DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(moduleNamespaceObjectSpace, moduleNamespaceObjectHeapCellType.get(), JSModuleNamespaceObject)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(nativeStdFunctionSpace, cellHeapCellType.get(), JSNativeStdFunction) // Hash:0x70ed61e4
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(proxyObjectSpace, cellHeapCellType.get(), ProxyObject)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(proxyRevokeSpace, cellHeapCellType.get(), ProxyRevoke) // Hash:0xb506a939
Modified: trunk/Source/_javascript_Core/runtime/VM.h (253239 => 253240)
--- trunk/Source/_javascript_Core/runtime/VM.h 2019-12-07 05:16:00 UTC (rev 253239)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2019-12-07 05:48:08 UTC (rev 253240)
@@ -130,6 +130,7 @@
class JSCustomGetterSetterFunction;
class JSDestructibleObjectHeapCellType;
class JSGlobalObject;
+class JSModuleNamespaceObject;
class JSModuleRecord;
class JSObject;
class JSPromise;
@@ -360,6 +361,7 @@
std::unique_ptr<IsoHeapCellType<DateInstance>> dateInstanceHeapCellType;
std::unique_ptr<IsoHeapCellType<ErrorInstance>> errorInstanceHeapCellType;
std::unique_ptr<IsoHeapCellType<JSModuleRecord>> jsModuleRecordHeapCellType;
+ std::unique_ptr<IsoHeapCellType<JSModuleNamespaceObject>> moduleNamespaceObjectHeapCellType;
std::unique_ptr<IsoHeapCellType<JSString>> stringHeapCellType;
std::unique_ptr<IsoHeapCellType<JSWeakMap>> weakMapHeapCellType;
std::unique_ptr<IsoHeapCellType<JSWeakSet>> weakSetHeapCellType;
@@ -471,6 +473,7 @@
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(int32ArraySpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(jsModuleRecordSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(mapSpace)
+ DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(moduleNamespaceObjectSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(nativeStdFunctionSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(proxyObjectSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(proxyRevokeSpace)