aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-11-15 16:36:13 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-04 09:45:33 +0100
commit0fa9cf218bdd3054585f23abfb2b707e26ce987a (patch)
tree346592c0d570d138278c659dbbbbda23ec1d148d /src/qml/jsruntime/qv4functionobject.cpp
parent608a9600142878574a509964941413bb15c91201 (diff)
Use an internalClass to represent formals and locals in CallContexts
formals and locals in a CallContext where so far accessed through a linear search in ExecutionContext::getProperty. Fix this by introducing an internalClass for the Function used by the call context. Change-Id: I1141efa12b19d6de4a354bfd6e769c5ffcb8898b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 194320528c..b9859d20e5 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -76,8 +76,6 @@ DEFINE_MANAGED_VTABLE(FunctionObject);
FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto)
: Object(createProto ? scope->engine->functionWithProtoClass : scope->engine->functionClass)
, scope(scope)
- , formalParameterList(0)
- , varList(0)
, formalParameterCount(0)
, varCount(0)
, function(0)
@@ -90,8 +88,6 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bo
FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
: Object(createProto ? scope->engine->functionWithProtoClass : scope->engine->functionClass)
, scope(scope)
- , formalParameterList(0)
- , varList(0)
, formalParameterCount(0)
, varCount(0)
, function(0)
@@ -110,8 +106,6 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo
FunctionObject::FunctionObject(InternalClass *ic)
: Object(ic)
, scope(ic->engine->rootContext)
- , formalParameterList(0)
- , varList(0)
, formalParameterCount(0)
, varCount(0)
, function(0)
@@ -410,12 +404,10 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
needsActivation = function->needsActivation();
strictMode = function->isStrict();
- formalParameterCount = function->formals.size();
- formalParameterList = function->formals.constData();
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
+ formalParameterCount = function->nArguments;
+ varCount = function->internalClass->size - function->nArguments;
- varCount = function->locals.size();
- varList = function->locals.constData();
+ defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
if (scope->strictMode) {
Property pd = Property::fromAccessor(v4->thrower, v4->thrower);
@@ -497,12 +489,10 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu
needsActivation = function->needsActivation();
strictMode = function->isStrict();
- formalParameterCount = function->formals.size();
- formalParameterList = function->formals.constData();
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
+ formalParameterCount = function->nArguments;
+ varCount = function->internalClass->size - function->nArguments;
- varCount = function->locals.size();
- varList = function->locals.constData();
+ defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
if (scope->strictMode) {
Property pd = Property::fromAccessor(v4->thrower, v4->thrower);
@@ -537,7 +527,7 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData)
ctx.compilationUnit = f->function->compilationUnit;
ctx.lookups = ctx.compilationUnit->runtimeLookups;
ctx.outer = f->scope;
- ctx.locals = v4->stackPush(f->function->locals.size());
+ ctx.locals = v4->stackPush(f->varCount);
while (callData->argc < (int)f->formalParameterCount) {
callData->args[callData->argc] = Encode::undefined();
++callData->argc;
@@ -575,7 +565,7 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData)
ctx.compilationUnit = f->function->compilationUnit;
ctx.lookups = ctx.compilationUnit->runtimeLookups;
ctx.outer = f->scope;
- ctx.locals = v4->stackPush(f->function->locals.size());
+ ctx.locals = v4->stackPush(f->varCount);
while (callData->argc < (int)f->formalParameterCount) {
callData->args[callData->argc] = Encode::undefined();
++callData->argc;