aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-08-24 15:31:46 +0200
committerLars Knoll <lars.knoll@theqtcompany.com>2015-09-15 07:37:16 +0000
commit3a8d6123d1947d18db15bf8b30f59cdea7e31380 (patch)
tree7ad4ca820c395099e938fd9dacffbe27728d24d7 /src/qml/jsruntime/qv4engine_p.h
parentfb059f697a128f87ceecf5ddff1dd735ae78db20 (diff)
Store the stack of executioncontext's on the JS stack
This saves one pointer per allocated execution context. Now every execution context that is pushed, allocates two Values on the js stack. One contains the context itself, the other one the offset to the parent context. Things are a bit tricky for with and catch scopes, as those are called from the generated code, and can't open a Scope anymore. In addition, all methods iterating over the js stack frames need to work with ExecutionContext pointers, not ScopedContext's. Change-Id: I6f3013749d4e73d2fac37973b976ba6029686b82 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4engine_p.h')
-rw-r--r--src/qml/jsruntime/qv4engine_p.h36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 968c9d5df0..e9d505c858 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -88,6 +88,7 @@ public:
ExecutableAllocator *regExpAllocator;
QScopedPointer<EvalISelFactory> iselFactory;
+ ExecutionContext *currentExecutionContext;
Value *jsStackLimit;
quintptr cStackLimit;
@@ -128,6 +129,7 @@ public:
enum JSObjects {
RootContect,
+ IntegerNull, // Has to come after the RootContext to make the context stack safe
ObjectProto,
ArrayProto,
StringProto,
@@ -351,6 +353,7 @@ public:
void pushContext(Heap::ExecutionContext *context);
void pushContext(CallContext *context);
Heap::ExecutionContext *popContext();
+ ExecutionContext *parentContext(ExecutionContext *context) const;
Heap::Object *newObject();
Heap::Object *newObject(InternalClass *internalClass, Object *prototype);
@@ -444,9 +447,12 @@ public:
inline void ExecutionEngine::pushContext(Heap::ExecutionContext *context)
{
- Q_ASSERT(current && context);
- context->parent = current;
- current = context;
+ Q_ASSERT(currentExecutionContext && context);
+ Value *v = jsAlloca(2);
+ v[0] = Encode(context);
+ v[1] = Encode((int)(v - static_cast<Value *>(currentExecutionContext)));
+ currentExecutionContext = static_cast<ExecutionContext *>(v);
+ current = currentExecutionContext->d();
}
inline void ExecutionEngine::pushContext(CallContext *context)
@@ -457,27 +463,17 @@ inline void ExecutionEngine::pushContext(CallContext *context)
inline Heap::ExecutionContext *ExecutionEngine::popContext()
{
- Q_ASSERT(current->parent);
- current = current->parent;
- Q_ASSERT(current);
+ Q_ASSERT(jsStackTop > currentExecutionContext);
+ QV4::Value *offset = (currentExecutionContext + 1);
+ Q_ASSERT(offset->isInteger());
+ int o = offset->integerValue();
+ Q_ASSERT(o);
+ currentExecutionContext -= o;
+ current = currentExecutionContext->d();
return current;
}
inline
-Heap::ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t)
- : engine(engine)
- , parent(engine->currentContext())
- , outer(0)
- , lookups(0)
- , compilationUnit(0)
- , type(t)
- , strictMode(false)
- , lineNumber(-1)
-{
-}
-
-
-inline
void Heap::Base::mark(QV4::ExecutionEngine *engine)
{
Q_ASSERT(inUse());