marked = false;
this->engine = engine;
outer = function->scope;
+#ifndef QT_NO_DEBUG
+ assert(outer->next != (ExecutionContext *)0x1);
+#endif
exceptionVarName = 0;
exceptionValue = Value::undefinedValue();
/* Function *f, int argc */
#define requiredMemoryForExecutionContect(f, argc) \
sizeof(ExecutionContext) + sizeof(Value) * (f->varCount + qMax((uint)argc, f->formalParameterCount))
+#define stackContextSize (sizeof(ExecutionContext) + 32*sizeof(Value))
} // namespace VM
} // namespace QQmlJS
return current;
}
+ExecutionContext *ExecutionEngine::newCallContext(void *stackSpace, FunctionObject *f, const Value &thisObject, Value *args, int argc)
+{
+ ensureContextStackSize();
+ assert(contextStack[contextStackPosition + 1] == 0);
+
+ uint memory = requiredMemoryForExecutionContect(f, argc);
+ if (f->needsActivation || memory > stackContextSize) {
+ current = memoryManager->allocContext(memory);
+ } else {
+ current = (ExecutionContext *)stackSpace;
+#ifndef QT_NO_DEBUG
+ current->next = (ExecutionContext *)0x1;
+#endif
+ }
+
+ contextStack[++contextStackPosition] = current;
+
+ current->function = f;
+ current->thisObject = thisObject;
+ current->arguments = args;
+ current->argumentCount = argc;
+ current->initCallContext(this);
+
+ return current;
+}
+
+
ExecutionContext *ExecutionEngine::pushGlobalContext()
{
ensureContextStackSize();
ExecutionContext *newWithContext(Object *with);
ExecutionContext *newCatchContext(String* exceptionVarName, const QQmlJS::VM::Value &exceptionValue);
ExecutionContext *newCallContext(FunctionObject *f, const QQmlJS::VM::Value &thisObject, QQmlJS::VM::Value *args, int argc);
+ ExecutionContext *newCallContext(void *stackSpace, FunctionObject *f, const QQmlJS::VM::Value &thisObject, QQmlJS::VM::Value *args, int argc);
ExecutionContext *pushGlobalContext();
ExecutionContext *popContext();
needsActivation = true;
usesArgumentsObject = false;
strictMode = false;
+#ifndef QT_NO_DEBUG
+ assert(scope->next != (ExecutionContext *)0x1);
+#endif
}
bool FunctionObject::hasInstance(Managed *that, ExecutionContext *ctx, const Value &value)
if (proto.isObject())
obj->prototype = proto.objectValue();
- ExecutionContext *ctx = context->engine->newCallContext(f, Value::fromObject(obj), args, argc);
+ quintptr stackSpace[stackContextSize/sizeof(quintptr)];
+ ExecutionContext *ctx = context->engine->newCallContext(stackSpace, f, Value::fromObject(obj), args, argc);
Value result = Value::undefinedValue();
try {
{
ScriptFunction *f = static_cast<ScriptFunction *>(that);
assert(f->function->code);
- ExecutionContext *ctx = context->engine->newCallContext(f, thisObject, args, argc);
+ quintptr stackSpace[stackContextSize/sizeof(quintptr)];
+ ExecutionContext *ctx = context->engine->newCallContext(stackSpace, f, thisObject, args, argc);
if (!f->strictMode && !thisObject.isObject()) {
if (thisObject.isUndefined() || thisObject.isNull()) {