diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/v4/qv4argumentsobject.cpp | 2 | ||||
-rw-r--r-- | src/v4/qv4argumentsobject.h | 2 | ||||
-rw-r--r-- | src/v4/qv4context.cpp | 39 | ||||
-rw-r--r-- | src/v4/qv4context.h | 7 | ||||
-rw-r--r-- | src/v4/qv4engine.cpp | 7 | ||||
-rw-r--r-- | src/v4/qv4v8.cpp | 12 |
6 files changed, 29 insertions, 40 deletions
diff --git a/src/v4/qv4argumentsobject.cpp b/src/v4/qv4argumentsobject.cpp index b891d029ec..4fb0e1afe9 100644 --- a/src/v4/qv4argumentsobject.cpp +++ b/src/v4/qv4argumentsobject.cpp @@ -52,7 +52,7 @@ static Value throwTypeError(ExecutionContext *ctx) DEFINE_MANAGED_VTABLE(ArgumentsObject); -ArgumentsObject::ArgumentsObject(ExecutionContext *context, int formalParameterCount, int actualParameterCount) +ArgumentsObject::ArgumentsObject(CallContext *context, int formalParameterCount, int actualParameterCount) : Object(context->engine), context(context) { vtbl = &static_vtbl; diff --git a/src/v4/qv4argumentsobject.h b/src/v4/qv4argumentsobject.h index 13f6b4080b..144cb35e59 100644 --- a/src/v4/qv4argumentsobject.h +++ b/src/v4/qv4argumentsobject.h @@ -79,7 +79,7 @@ protected: struct ArgumentsObject: Object { ExecutionContext *context; QVector<Value> mappedArguments; - ArgumentsObject(ExecutionContext *context, int formalParameterCount, int actualParameterCount); + ArgumentsObject(CallContext *context, int formalParameterCount, int actualParameterCount); ~ArgumentsObject() {} bool defineOwnProperty(ExecutionContext *ctx, uint index, const PropertyDescriptor *desc); diff --git a/src/v4/qv4context.cpp b/src/v4/qv4context.cpp index c34dcc00bb..0fac836858 100644 --- a/src/v4/qv4context.cpp +++ b/src/v4/qv4context.cpp @@ -155,7 +155,6 @@ void GlobalContext::init(ExecutionEngine *eng) arguments = 0; argumentCount = 0; activation = 0; - function = 0; } void WithContext::init(ExecutionContext *p, Object *with) @@ -174,7 +173,6 @@ void WithContext::init(ExecutionContext *p, Object *with) arguments = 0; argumentCount = 0; activation = 0; - function = 0; } void CatchContext::init(ExecutionContext *p, String *exceptionVarName, const Value &exceptionValue) @@ -194,7 +192,6 @@ void CatchContext::init(ExecutionContext *p, String *exceptionVarName, const Val arguments = 0; argumentCount = 0; activation = 0; - function = 0; } void CallContext::initCallContext(ExecutionEngine *engine) @@ -262,7 +259,8 @@ bool ExecutionContext::deleteProperty(String *name) return false; } if (ctx->type == Type_CallContext) { - FunctionObject *f = ctx->function; + CallContext *c = static_cast<CallContext *>(ctx); + FunctionObject *f = c->function; if (f->needsActivation || hasWith) { for (unsigned int i = 0; i < f->varCount; ++i) if (f->varList[i]->isEqualTo(name)) @@ -278,9 +276,9 @@ bool ExecutionContext::deleteProperty(String *name) return true; } -bool ExecutionContext::needsOwnArguments() const +bool CallContext::needsOwnArguments() const { - return function && (function->needsActivation || argumentCount < function->formalParameterCount); + return function->needsActivation || argumentCount < function->formalParameterCount; } void ExecutionContext::mark() @@ -293,8 +291,6 @@ void ExecutionContext::mark() outer->mark(); thisObject.mark(); - if (function) - function->mark(); for (unsigned arg = 0, lastArg = argumentCount; arg < lastArg; ++arg) arguments[arg].mark(); @@ -302,6 +298,7 @@ void ExecutionContext::mark() VM::CallContext *c = static_cast<CallContext *>(this); for (unsigned local = 0, lastLocal = c->variableCount(); local < lastLocal; ++local) c->locals[local].mark(); + c->function->mark(); } if (activation) @@ -387,10 +384,11 @@ Value ExecutionContext::getProperty(String *name) return v; } if (ctx->type == Type_CallContext) { - FunctionObject *f = ctx->function; + CallContext *c = static_cast<CallContext *>(ctx); + FunctionObject *f = c->function; if (f->function && f->function->isNamedExpression && name->isEqualTo(f->function->name)) - return Value::fromObject(ctx->function); + return Value::fromObject(c->function); } } throwReferenceError(Value::fromString(name)); @@ -444,10 +442,11 @@ Value ExecutionContext::getPropertyNoThrow(String *name) return v; } if (ctx->type == Type_CallContext) { - FunctionObject *f = ctx->function; + CallContext *c = static_cast<CallContext *>(ctx); + FunctionObject *f = c->function; if (f->function && f->function->isNamedExpression && name->isEqualTo(f->function->name)) - return Value::fromObject(ctx->function); + return Value::fromObject(c->function); } } return Value::undefinedValue(); @@ -502,10 +501,11 @@ Value ExecutionContext::getPropertyAndBase(String *name, Object **base) return v; } if (ctx->type == Type_CallContext) { - FunctionObject *f = ctx->function; + CallContext *c = static_cast<CallContext *>(ctx); + FunctionObject *f = c->function; if (f->function && f->function->isNamedExpression && name->isEqualTo(f->function->name)) - return Value::fromObject(ctx->function); + return Value::fromObject(c->function); } } throwReferenceError(Value::fromString(name)); @@ -568,16 +568,5 @@ void ExecutionContext::throwURIError(Value msg) throwError(Value::fromObject(engine->newURIErrorObject(this, msg))); } -void ExecutionContext::wireUpPrototype() -{ - assert(thisObject.isObject()); - - Value proto = function->get(this, engine->id_prototype); - if (proto.isObject()) - thisObject.objectValue()->prototype = proto.objectValue(); - else - thisObject.objectValue()->prototype = engine->objectPrototype; -} - } // namespace VM } // namespace QQmlJS diff --git a/src/v4/qv4context.h b/src/v4/qv4context.h index ff375fea18..7e6156a6ff 100644 --- a/src/v4/qv4context.h +++ b/src/v4/qv4context.h @@ -101,7 +101,6 @@ struct ExecutionContext Value *arguments; unsigned int argumentCount; Object *activation; - FunctionObject *function; String * const *formals() const; unsigned int formalCount() const; @@ -111,8 +110,6 @@ struct ExecutionContext void createMutableBinding(String *name, bool deletable); bool setMutableBinding(ExecutionContext *scope, String *name, const Value &value); - void wireUpPrototype(); - void Q_NORETURN throwError(const Value &value); void Q_NORETURN throwError(const QString &message); void Q_NORETURN throwSyntaxError(DiagnosticMessage *message); @@ -131,8 +128,6 @@ struct ExecutionContext inline Value argument(unsigned int index = 0); - bool needsOwnArguments() const; - void mark(); inline CallContext *asCallContext(); @@ -141,7 +136,9 @@ struct ExecutionContext struct CallContext : public ExecutionContext { void initCallContext(QQmlJS::VM::ExecutionEngine *engine); + bool needsOwnArguments() const; + FunctionObject *function; Value *locals; }; diff --git a/src/v4/qv4engine.cpp b/src/v4/qv4engine.cpp index 44b57244d5..105dd6ce59 100644 --- a/src/v4/qv4engine.cpp +++ b/src/v4/qv4engine.cpp @@ -367,9 +367,10 @@ ExecutionContext *ExecutionEngine::popContext() if (debugger) debugger->justLeft(current); - if (!current->needsOwnArguments()) { - current->arguments = 0; - current->argumentCount = 0; + CallContext *c = current->asCallContext(); + if (c && !c->needsOwnArguments()) { + c->arguments = 0; + c->argumentCount = 0; } contextStack[contextStackPosition] = 0; diff --git a/src/v4/qv4v8.cpp b/src/v4/qv4v8.cpp index ce66109535..10de8c7327 100644 --- a/src/v4/qv4v8.cpp +++ b/src/v4/qv4v8.cpp @@ -337,11 +337,13 @@ Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, StackTrace::Sta VM::ExecutionContext **root = engine->contextStack; VM::ExecutionContext **current = root + engine->contextStackPosition; while (current >= root && frame_limit) { - StackFrame *frame = new StackFrame(Value::fromVmValue(VM::Value::fromString(engine->id_null)), - Value::fromVmValue(VM::Value::fromString((*current)->function ? (*current)->function->name : engine->id_null)), - 0, 0); - trace->frames.append(frame); - --frame_limit; + if (CallContext *c = (*current)->asCallContext()) { + StackFrame *frame = new StackFrame(Value::fromVmValue(VM::Value::fromString(engine->id_null)), + Value::fromVmValue(VM::Value::fromString(c->function->name)), + 0, 0); + trace->frames.append(frame); + --frame_limit; + } --current; } |