From 7cc351c2ca6b0caad04cab411e91d8050cb284c8 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 18 Nov 2014 17:35:48 +0100 Subject: [PATCH] Cleanup header inclusion order Change-Id: I6f7973370c4468e7d1686a147efca66bfbfdd5b1 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4context_p.h | 79 +++++++--------------------- src/qml/jsruntime/qv4engine_p.h | 50 ++++++++++++++++++ src/qml/jsruntime/qv4scopedvalue_p.h | 28 ++++------ 3 files changed, 77 insertions(+), 80 deletions(-) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index bb45bf4b7d..39456b202f 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -34,9 +34,7 @@ #define QMLJS_ENVIRONMENT_H #include "qv4global_p.h" -#include "qv4scopedvalue_p.h" #include "qv4managed_p.h" -#include "qv4engine_p.h" QT_BEGIN_NAMESPACE @@ -51,6 +49,24 @@ struct CallContext; struct CatchContext; struct WithContext; +struct CallData +{ + // below is to be compatible with Value. Initialize tag to 0 +#if Q_BYTE_ORDER != Q_LITTLE_ENDIAN + uint tag; +#endif + int argc; +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + uint tag; +#endif + inline ReturnedValue argument(int i) { + return i < argc ? args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); + } + + Value thisObject; + Value args[1]; +}; + namespace Heap { struct ExecutionContext : Base { @@ -142,23 +158,6 @@ struct Q_QML_EXPORT ExecutionContext : public Managed static void markObjects(Heap::Base *m, ExecutionEngine *e); }; -inline -Heap::ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t) - : Heap::Base(engine->executionContextClass) - , type(t) - , strictMode(false) - , engine(engine) - , parent(engine->currentContext()->d()) - , outer(0) - , lookups(0) - , compilationUnit(0) - , lineNumber(-1) -{ - // ### GC - engine->current = reinterpret_cast(this); -} - - struct CallContext : public ExecutionContext { V4_MANAGED(CallContext, ExecutionContext) @@ -203,48 +202,6 @@ inline const CallContext *ExecutionContext::asCallContext() const return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast(this) : 0; } - -inline void ExecutionEngine::pushContext(CallContext *context) -{ - Q_ASSERT(current && current->d() && context && context->d()); - context->d()->parent = current->d(); - current = context; -} - -inline ExecutionContext *ExecutionEngine::popContext() -{ - Q_ASSERT(current->d()->parent); - // ### GC - current = reinterpret_cast(current->d()->parent); - Q_ASSERT(current && current->d()); - return current; -} - -struct ExecutionContextSaver -{ - ExecutionEngine *engine; - ExecutionContext *savedContext; - - ExecutionContextSaver(ExecutionContext *context) - : engine(context->d()->engine) - , savedContext(context) - { - } - ~ExecutionContextSaver() - { - engine->current = savedContext; - } -}; - -inline Scope::Scope(ExecutionContext *ctx) - : engine(ctx->d()->engine) -#ifndef QT_NO_DEBUG - , size(0) -#endif -{ - mark = engine->jsStackTop; -} - /* Function *f, int argc */ #define requiredMemoryForExecutionContect(f, argc) \ ((sizeof(CallContext::Data) + 7) & ~7) + sizeof(Value) * (f->varCount() + qMax((uint)argc, f->formalParameterCount())) + sizeof(CallData) diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 60e6b2c285..f07448b4a2 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -36,6 +36,7 @@ #include "qv4global_p.h" #include "private/qv4isel_p.h" #include "qv4managed_p.h" +#include "qv4context_p.h" #include namespace WTF { @@ -338,6 +339,55 @@ private: QmlExtensions *m_qmlExtensions; }; +struct ExecutionContextSaver +{ + ExecutionEngine *engine; + ExecutionContext *savedContext; + + ExecutionContextSaver(ExecutionContext *context) + : engine(context->d()->engine) + , savedContext(context) + { + } + ~ExecutionContextSaver() + { + engine->current = savedContext; + } +}; + +inline void ExecutionEngine::pushContext(CallContext *context) +{ + Q_ASSERT(current && current->d() && context && context->d()); + context->d()->parent = current->d(); + current = context; +} + +inline ExecutionContext *ExecutionEngine::popContext() +{ + Q_ASSERT(current->d()->parent); + // ### GC + current = reinterpret_cast(current->d()->parent); + Q_ASSERT(current && current->d()); + return current; +} + +inline +Heap::ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t) + : Heap::Base(engine->executionContextClass) + , type(t) + , strictMode(false) + , engine(engine) + , parent(engine->currentContext()->d()) + , outer(0) + , lookups(0) + , compilationUnit(0) + , lineNumber(-1) +{ + // ### GC + engine->current = reinterpret_cast(this); +} + + // ### Remove me inline void Managed::mark(QV4::ExecutionEngine *engine) diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index e239e6f91d..f9a21d706a 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -48,7 +48,15 @@ namespace QV4 { struct ScopedValue; struct Scope { - inline explicit Scope(ExecutionContext *ctx); + inline Scope(ExecutionContext *ctx) + : engine(ctx->d()->engine) + #ifndef QT_NO_DEBUG + , size(0) + #endif + { + mark = engine->jsStackTop; + } + explicit Scope(ExecutionEngine *e) : engine(e) #ifndef QT_NO_DEBUG @@ -353,24 +361,6 @@ struct Scoped Value *ptr; }; -struct CallData -{ - // below is to be compatible with Value. Initialize tag to 0 -#if Q_BYTE_ORDER != Q_LITTLE_ENDIAN - uint tag; -#endif - int argc; -#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - uint tag; -#endif - inline ReturnedValue argument(int i) { - return i < argc ? args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); - } - - Value thisObject; - Value args[1]; -}; - struct ScopedCallData { ScopedCallData(Scope &scope, int argc) {