diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-08 21:55:06 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-10 08:19:34 +0000 |
commit | d5cacaf6b2adb269b9e24b518e1496bca935bc34 (patch) | |
tree | e95631610e46956f24aa6284526645a25b86ab9a /src | |
parent | 7c0dbaa3db649fb348af533820ac0550bc144d96 (diff) |
Remove stuff related to simple call contexts
Those are not being used anymore.
Change-Id: Ia33dd7c3c7ea7828caef0fbf397253249580a4e1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 15 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 11 | ||||
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 47 | ||||
-rw-r--r-- | src/qml/memory/qv4mm_p.h | 59 |
4 files changed, 10 insertions, 122 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index f82ea74227..0bcc864b85 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -65,7 +65,7 @@ Heap::CallContext *ExecutionContext::newCallContext(Heap::ExecutionContext *oute ExecutionEngine *v4 = outer->internalClass->engine; Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory, function->internalClass); - c->init(Heap::ExecutionContext::Type_CallContext); + c->init(); c->v4Function = function; @@ -118,7 +118,6 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) while (ctx) { switch (ctx->d()->type) { case Heap::ExecutionContext::Type_CallContext: - case Heap::ExecutionContext::Type_SimpleCallContext: if (!activation) { Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d()); if (!c->activation) @@ -209,8 +208,7 @@ bool ExecutionContext::deleteProperty(String *name) Q_FALLTHROUGH(); } case Heap::ExecutionContext::Type_WithContext: - case Heap::ExecutionContext::Type_GlobalContext: - case Heap::ExecutionContext::Type_SimpleCallContext: { + case Heap::ExecutionContext::Type_GlobalContext: { if (ctx->activation) { Scope scope(this); ScopedObject object(scope, ctx->activation); @@ -281,8 +279,7 @@ bool ExecutionContext::setProperty(String *name, const Value &value) return w->put(name, value); break; } - case Heap::ExecutionContext::Type_CallContext: - case Heap::ExecutionContext::Type_SimpleCallContext: { + case Heap::ExecutionContext::Type_CallContext: { Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx); if (c->v4Function) { uint index = c->internalClass->find(id); @@ -357,8 +354,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) } case Heap::ExecutionContext::Type_WithContext: case Heap::ExecutionContext::Type_GlobalContext: - case Heap::ExecutionContext::Type_QmlContext: - case Heap::ExecutionContext::Type_SimpleCallContext: { + case Heap::ExecutionContext::Type_QmlContext: { if (ctx->activation) { Scope scope(this); ScopedObject activation(scope, ctx->activation); @@ -406,8 +402,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) } Q_FALLTHROUGH(); } - case Heap::ExecutionContext::Type_GlobalContext: - case Heap::ExecutionContext::Type_SimpleCallContext: { + case Heap::ExecutionContext::Type_GlobalContext: { if (ctx->activation) { Scope scope(this); ScopedObject activation(scope, ctx->activation); diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 1f62c64a23..8c533f775c 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -116,8 +116,7 @@ DECLARE_HEAP_OBJECT(ExecutionContext, Base) { Type_CatchContext = 0x2, Type_WithContext = 0x3, Type_QmlContext = 0x4, - Type_SimpleCallContext = 0x5, - Type_CallContext = 0x6 + Type_CallContext = 0x5 }; void init(ContextType t) @@ -150,9 +149,9 @@ Q_STATIC_ASSERT(offsetof(ExecutionContextData, v4Function) == offsetof(Execution DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) { DECLARE_MARK_TABLE(CallContext); - void init(ContextType t = Type_SimpleCallContext) + void init() { - ExecutionContext::init(t); + ExecutionContext::init(Type_CallContext); } inline unsigned int formalParameterCount() const; @@ -250,12 +249,12 @@ struct CatchContext : public ExecutionContext inline CallContext *ExecutionContext::asCallContext() { - return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<CallContext *>(this) : 0; + return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<CallContext *>(this) : 0; } inline const CallContext *ExecutionContext::asCallContext() const { - return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<const CallContext *>(this) : 0; + return d()->type == Heap::ExecutionContext::Type_CallContext ? static_cast<const CallContext *>(this) : 0; } } // namespace QV4 diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index de97918fb0..b9bc2c34a3 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -553,51 +553,6 @@ void Chunk::sortIntoBins(HeapItem **bins, uint nBins) #endif } - -template<typename T> -StackAllocator<T>::StackAllocator(ChunkAllocator *chunkAlloc) - : chunkAllocator(chunkAlloc) -{ - chunks.push_back(chunkAllocator->allocate()); - firstInChunk = chunks.back()->first(); - nextFree = firstInChunk; - lastInChunk = firstInChunk + (Chunk::AvailableSlots - 1)/requiredSlots*requiredSlots; -} - -template<typename T> -void StackAllocator<T>::freeAll() -{ - for (auto c : chunks) - chunkAllocator->free(c); -} - -template<typename T> -void StackAllocator<T>::nextChunk() { - Q_ASSERT(nextFree == lastInChunk); - ++currentChunk; - if (currentChunk >= chunks.size()) { - Chunk *newChunk = chunkAllocator->allocate(); - chunks.push_back(newChunk); - } - firstInChunk = chunks.at(currentChunk)->first(); - nextFree = firstInChunk; - lastInChunk = firstInChunk + (Chunk::AvailableSlots - 1)/requiredSlots*requiredSlots; -} - -template<typename T> -void QV4::StackAllocator<T>::prevChunk() { - Q_ASSERT(nextFree == firstInChunk); - Q_ASSERT(chunks.at(currentChunk) == nextFree->chunk()); - Q_ASSERT(currentChunk > 0); - --currentChunk; - firstInChunk = chunks.at(currentChunk)->first(); - lastInChunk = firstInChunk + (Chunk::AvailableSlots - 1)/requiredSlots*requiredSlots; - nextFree = lastInChunk; -} - -template struct StackAllocator<Heap::CallContext>; - - HeapItem *BlockAllocator::allocate(size_t size, bool forceAllocation) { Q_ASSERT((size % Chunk::SlotSize) == 0); size_t slotsRequired = size >> Chunk::SlotSizeShift; @@ -836,7 +791,6 @@ void HugeItemAllocator::freeAll() MemoryManager::MemoryManager(ExecutionEngine *engine) : engine(engine) , chunkAllocator(new ChunkAllocator) - , stackAllocator(chunkAllocator) , blockAllocator(chunkAllocator) , hugeItemAllocator(chunkAllocator) , m_persistentValues(new PersistentValueStorage(engine)) @@ -1261,7 +1215,6 @@ MemoryManager::~MemoryManager() sweep(/*lastSweep*/true); blockAllocator.freeAll(); hugeItemAllocator.freeAll(); - stackAllocator.freeAll(); delete m_weakValues; #ifdef V4_USE_VALGRIND diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index b4f2d0492c..921fea3956 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -72,51 +72,6 @@ namespace QV4 { struct ChunkAllocator; -template<typename T> -struct StackAllocator { - Q_STATIC_ASSERT(sizeof(T) < Chunk::DataSize); - static const uint requiredSlots = (sizeof(T) + sizeof(HeapItem) - 1)/sizeof(HeapItem); - - StackAllocator(ChunkAllocator *chunkAlloc); - - T *allocate() { - HeapItem *m = nextFree; - if (Q_UNLIKELY(nextFree == lastInChunk)) { - nextChunk(); - } else { - nextFree += requiredSlots; - } -#if MM_DEBUG || !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS) - Chunk *c = m->chunk(); - Chunk::setBit(c->objectBitmap, m - c->realBase()); -#endif - return m->as<T>(); - } - void free() { - if (Q_UNLIKELY(nextFree == firstInChunk)) { - prevChunk(); - } else { - nextFree -= requiredSlots; - } -#if MM_DEBUG || !defined(QT_NO_DEBUG) || defined(QT_FORCE_ASSERTS) - Chunk *c = nextFree->chunk(); - Chunk::clearBit(c->objectBitmap, nextFree - c->realBase()); -#endif - } - - void nextChunk(); - void prevChunk(); - - void freeAll(); - - ChunkAllocator *chunkAllocator; - HeapItem *nextFree = 0; - HeapItem *firstInChunk = 0; - HeapItem *lastInChunk = 0; - std::vector<Chunk *> chunks; - uint currentChunk = 0; -}; - struct BlockAllocator { BlockAllocator(ChunkAllocator *chunkAllocator) : chunkAllocator(chunkAllocator) @@ -211,19 +166,6 @@ public: Q_DECL_CONSTEXPR static inline std::size_t align(std::size_t size) { return (size + Chunk::SlotSize - 1) & ~(Chunk::SlotSize - 1); } - QV4::Heap::CallContext *allocSimpleCallContext() - { - Heap::CallContext *ctxt = stackAllocator.allocate(); - memset(ctxt, 0, sizeof(Heap::CallContext)); - ctxt->internalClass = CallContext::defaultInternalClass(engine); - Q_ASSERT(ctxt->internalClass && ctxt->internalClass->vtable); - ctxt->init(); - return ctxt; - - } - void freeSimpleCallContext() - { stackAllocator.free(); } - template<typename ManagedType> inline typename ManagedType::Data *allocManaged(std::size_t size) { @@ -477,7 +419,6 @@ private: public: QV4::ExecutionEngine *engine; ChunkAllocator *chunkAllocator; - StackAllocator<Heap::CallContext> stackAllocator; BlockAllocator blockAllocator; HugeItemAllocator hugeItemAllocator; PersistentValueStorage *m_persistentValues; |