#pragma once namespace WebCore { class ExtendedDOMClientIsoSubspaces; class ExtendedDOMIsoSubspaces; class DOMWrapperWorld; } #include "root.h" #include "ExtendedDOMClientIsoSubspaces.h" #include "ExtendedDOMIsoSubspaces.h" #include "DOMIsoSubspaces.h" // #include "DOMWrapperWorld.h" #include "BunBuiltinNames.h" // #include "WebCoreJSBuiltins.h" // #include "WorkerThreadType.h" #include "wtf/Function.h" #include "wtf/HashSet.h" #include "wtf/RefPtr.h" #include "JavaScriptCore/WeakHandleOwner.h" #include "JavaScriptCore/WeakInlines.h" #include "JavaScriptCore/IsoSubspacePerVM.h" namespace WebCore { using namespace JSC; using namespace Zig; enum class UseCustomHeapCellType { Yes, No }; class JSHeapData { WTF_MAKE_NONCOPYABLE(JSHeapData); WTF_MAKE_FAST_ALLOCATED; friend class JSVMClientData; public: JSHeapData(JSC::Heap&); static JSHeapData* ensureHeapData(JSC::Heap&); Lock& lock() { return m_lock; } ExtendedDOMIsoSubspaces& subspaces() { return *m_subspaces.get(); } Vector& outputConstraintSpaces() { return m_outputConstraintSpaces; } template void forEachOutputConstraintSpace(const Func& func) { for (auto* space : m_outputConstraintSpaces) func(*space); } // JSC::IsoSubspace m_domNamespaceObjectSpace; private: Lock m_lock; private: std::unique_ptr m_subspaces; JSC::IsoSubspace m_domConstructorSpace; Vector m_outputConstraintSpaces; }; class JSVMClientData : public JSC::VM::ClientData { WTF_MAKE_NONCOPYABLE(JSVMClientData); WTF_MAKE_FAST_ALLOCATED; public: explicit JSVMClientData(JSC::VM&); virtual ~JSVMClientData(); static void create(JSC::VM*); JSHeapData& heapData() { return *m_heapData; } BunBuiltinNames& builtinNames() { return m_builtinNames; } WebCore::DOMWrapperWorld& normalWorld() { return *m_normalWorld; } JSC::GCClient::IsoSubspace& domConstructorSpace() { return m_domConstructorSpace; } ExtendedDOMClientIsoSubspaces& clientSubspaces() { return *m_clientSubspaces.get(); } Vector& outputConstraintSpaces() { return m_outputConstraintSpaces; } template void forEachOutputConstraintSpace(const Func& func) { for (auto* space : m_outputConstraintSpaces) func(*space); } private: BunBuiltinNames m_builtinNames; JSHeapData* m_heapData; RefPtr m_normalWorld; JSC::GCClient::IsoSubspace m_domConstructorSpace; // JSC::IsoSubspace m_domNamespaceObjectSpace; std::unique_ptr m_clientSubspaces; Vector m_outputConstraintSpaces; }; template ALWAYS_INLINE JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm, GetClient getClient, SetClient setClient, GetServer getServer, SetServer setServer, JSC::HeapCellType& (*getCustomHeapCellType)(JSHeapData&) = nullptr) { auto& clientData = *static_cast(vm.clientData); auto& clientSubspaces = clientData.clientSubspaces(); if (auto* clientSpace = getClient(clientSubspaces)) return clientSpace; auto& heapData = clientData.heapData(); Locker locker { heapData.lock() }; auto& subspaces = heapData.subspaces(); JSC::IsoSubspace* space = getServer(subspaces); if (!space) { JSC::Heap& heap = vm.heap; std::unique_ptr uniqueSubspace; static_assert(useCustomHeapCellType == UseCustomHeapCellType::Yes || std::is_base_of_v || !T::needsDestruction); if constexpr (useCustomHeapCellType == UseCustomHeapCellType::Yes) uniqueSubspace = makeUnique ISO_SUBSPACE_INIT(heap, getCustomHeapCellType(heapData), T); else { if constexpr (std::is_base_of_v) uniqueSubspace = makeUnique ISO_SUBSPACE_INIT(heap, heap.destructibleObjectHeapCellType, T); else uniqueSubspace = makeUnique ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, T); } space = uniqueSubspace.get(); setServer(subspaces, uniqueSubspace); IGNORE_WARNINGS_BEGIN("unreachable-code") IGNORE_WARNINGS_BEGIN("tautological-compare") void (*myVisitOutputConstraint)(JSC::JSCell*, JSC::SlotVisitor&) = T::visitOutputConstraints; void (*jsCellVisitOutputConstraint)(JSC::JSCell*, JSC::SlotVisitor&) = JSC::JSCell::visitOutputConstraints; if (myVisitOutputConstraint != jsCellVisitOutputConstraint) heapData.outputConstraintSpaces().append(space); IGNORE_WARNINGS_END IGNORE_WARNINGS_END } auto uniqueClientSubspace = makeUnique(*space); auto* clientSpace = uniqueClientSubspace.get(); setClient(clientSubspaces, uniqueClientSubspace); return clientSpace; } // template // ALWAYS_INLINE JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm, GetClient getClient, SetClient setClient, GetServer getServer, SetServer setServer, JSC::HeapCellType& (*getCustomHeapCellType)(JSHeapData&) = nullptr) // { // static NeverDestroyed perVM([](JSC::Heap& heap) { // return ISO_SUBSPACE_PARAMETERS(heap.destructibleObjectHeapCellType, T); // }); // return &perVM.get().clientIsoSubspaceforVM(vm); // } static JSVMClientData* clientData(JSC::VM& vm) { return static_cast(vm.clientData); } } // namespace WebCore namespace WebCore { using JSVMClientData = WebCore::JSVMClientData; using JSHeapData = WebCore::JSHeapData; }stantin Mochalov 1-1/+1 2019-12-03Update migration guide to include the enabling of the the DWT peripheral. Als...Gravatar Scott Mabin 1-1/+9 2019-11-19Fixed link to API referenceGravatar Emil Fresk 1-1/+1 2019-11-19Preparation for v0.5.1Gravatar Emil Fresk 1-3/+7 2019-11-19TimerQueue.dequeue: don't set SYST reload to 0Gravatar Maciej Pasternacki 1-0/+7 2019-11-18Bumped version to 0.5.1, cyccntr bugfixGravatar Per Lindgren 1-1/+1 2019-11-18Fixed internal overflow on subtraiton in elapsed and durationGravatar Per Lindgren 2-2/+9 2019-11-14fix CIGravatar Jorge Aparicio 1-4/+8 2019-11-14remove references to 'beta' from the docsGravatar Jorge Aparicio 3-5/+2 2019-11-14CI: fix caching mechanismGravatar Jorge Aparicio 1-1/+1 2019-11-14v0.5.0 final releaseGravatar Jorge Aparicio 3-7/+8 2019-11-13Minor docs update to monotonicGravatar Emil Fresk 1-2/+4 2019-11-07Added struct de-structure-ing example in tips & tricksGravatar Emil Fresk 2-0/+56 2019-11-06fix bash comparisonGravatar Jorge Aparicio 1-1/+1 2019-11-06run cfail tests only when rustc --version == $MSRVGravatar Jorge Aparicio 2-3/+6 2019-11-06CI: replace compiletest-rs with trybuildGravatar Jorge Aparicio 12-47/+23 2019-11-06fix CI: use an older nightly on the x86_64 buildGravatar Jorge Aparicio 1-1/+2 2019-10-25CI: build 0.4 docs from the v0.4.x branchGravatar Jorge Aparicio 1-1/+1 2019-10-23Fixed peripherals -> device typoGravatar Emil Fresk 1-2/+2 2019-10-21do not zero late resource memory on bootGravatar Jorge Aparicio 1-2/+10 2019-10-17version v0.5 is still betav0.5.0-beta.1Gravatar Jorge Aparicio 1-1/+1 2019-10-16ARMv7-M+Gravatar Jorge Aparicio 1-1/+1 2019-10-16add migration guideGravatar Jorge Aparicio 2-0/+226 2019-10-16Update book/en/src/by-example/timer-queue.mdGravatar Jorge Aparicio 1-1/+1 2019-10-15cyccnt::Instant: simplify the Send / Sync implGravatar Jorge Aparicio 1-13/+2 2019-10-15document the limitations of cyccnt::{Instant,Duration}Gravatar Jorge Aparicio 1-5/+19 2019-10-15more monotonic timer docsGravatar Jorge Aparicio 6-5/+33 2019-10-15v0.5.0 beta releaseGravatar Jorge Aparicio 7-27/+31 2019-10-11Fix matrix.to web link for the static room view.Gravatar Tim Small 1-1/+1 2019-10-10critical sections: each task gets its own contextGravatar chrysn 1-1/+1 2019-09-17fix linkchecker warningGravatar Jorge Aparicio 1-1/+1 2019-09-17fix more linksGravatar Jorge Aparicio 8-15/+15 2019-09-17update the CHANGELOGGravatar Jorge Aparicio 2-3/+38 2019-09-17www: fix book placementGravatar Jorge Aparicio 1-4/+3 2019-09-17www: prefix latest docs with the minor versionGravatar Jorge Aparicio 1-3/+6 2019-09-15remove reference from README to CONTRIBUTINGGravatar nils-grepit 1-1/+1 2019-09-15turn git deps into crates.io depsGravatar Jorge Aparicio 2-4/+2 2019-09-15add CONTRIBUTING.md and link to Matrix roomGravatar nils-grepit 2-0/+26 2019-09-15Revert "Fixed install script"Gravatar Emil Fresk 1-2/+2 2019-09-15Fixed install scriptGravatar Emil Fresk 1-2/+2 2019-09-15fix install scriptGravatar Jorge Aparicio 1-1/+1 2019-09-15Book fixGravatar Emil Fresk 1-1/+1 2019-09-150.4: don't cross compile docsGravatar Jorge Aparicio 1-0/+1 2019-09-15One more place updatedGravatar Emil Fresk 1-1/+1 2019-09-15faster doc builds and fix redirect on 0.4Gravatar Jorge Aparicio 2-12/+16 2019-09-15fix redirects and CNAMEGravatar Jorge Aparicio 2-4/+11 2019-09-15Updated links in README for rtfm.rsGravatar Emil Fresk 2-3/+3 2019-09-15link to older docs from the bookGravatar Jorge Aparicio 1-1/+4