X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..93a3786624b2768d89bfa27e46598dc64e2fb70a:/runtime/GCActivityCallback.h diff --git a/runtime/GCActivityCallback.h b/runtime/GCActivityCallback.h index f40ebee..80edaa7 100644 --- a/runtime/GCActivityCallback.h +++ b/runtime/GCActivityCallback.h @@ -29,6 +29,7 @@ #ifndef GCActivityCallback_h #define GCActivityCallback_h +#include "HeapTimer.h" #include #include @@ -40,41 +41,90 @@ namespace JSC { class Heap; -class GCActivityCallback { +class GCActivityCallback : public HeapTimer { + WTF_MAKE_FAST_ALLOCATED; public: - virtual ~GCActivityCallback() {} - virtual void operator()() {} - virtual void synchronize() {} + virtual void didAllocate(size_t) { } + virtual void willCollect() { } + virtual void cancel() { } + bool isEnabled() const { return m_enabled; } + void setEnabled(bool enabled) { m_enabled = enabled; } + +#if PLATFORM(IOS) + static bool s_shouldCreateGCTimer; +#endif // PLATFORM(IOS) protected: - GCActivityCallback() {} -}; +#if USE(CF) + GCActivityCallback(VM* vm, CFRunLoopRef runLoop) + : HeapTimer(vm, runLoop) + , m_enabled(true) + { + } +#elif PLATFORM(EFL) + GCActivityCallback(VM* vm, bool flag) + : HeapTimer(vm) + , m_enabled(flag) + { + } +#else + GCActivityCallback(VM* vm) + : HeapTimer(vm) + , m_enabled(true) + { + } +#endif -struct DefaultGCActivityCallbackPlatformData; + bool m_enabled; +}; class DefaultGCActivityCallback : public GCActivityCallback { public: static PassOwnPtr create(Heap*); DefaultGCActivityCallback(Heap*); - ~DefaultGCActivityCallback(); - - void operator()(); - void synchronize(); +#if PLATFORM(IOS) + JS_EXPORT_PRIVATE virtual void didAllocate(size_t); + JS_EXPORT_PRIVATE virtual void willCollect(); + JS_EXPORT_PRIVATE virtual void cancel(); + + JS_EXPORT_PRIVATE virtual void doWork(); +#else + virtual void didAllocate(size_t); + virtual void willCollect(); + virtual void cancel(); + + virtual void doWork(); +#endif #if USE(CF) protected: +#if PLATFORM(IOS) + JS_EXPORT_PRIVATE DefaultGCActivityCallback(Heap*, CFRunLoopRef); +#else DefaultGCActivityCallback(Heap*, CFRunLoopRef); - void commonConstructor(Heap*, CFRunLoopRef); +#endif // PLATFORM(IOS) #endif +#if USE(CF) || PLATFORM(QT) || PLATFORM(EFL) +protected: + void cancelTimer(); + void scheduleTimer(double); private: - OwnPtr d; + double m_delay; +#endif }; inline PassOwnPtr DefaultGCActivityCallback::create(Heap* heap) { +#if PLATFORM(IOS) + // Big hack. + if (GCActivityCallback::s_shouldCreateGCTimer) + return adoptPtr(new DefaultGCActivityCallback(heap)); + return nullptr; +#else return adoptPtr(new DefaultGCActivityCallback(heap)); +#endif // PLATFORM(IOS) } }