aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <[email protected]>2014-03-03 21:00:30 +0100
committerThe Qt Project <[email protected]>2014-03-07 16:55:12 +0100
commit48251fd737447710775727f55e7334ec1c6af1f4 (patch)
treecf9fe657bf65c6c6a984ab73f2dc0785f07d45b5 /src/qml/jsruntime/qv4functionobject.cpp
parentf5f4c3c47c8ee4141f8355f2bce95ef3ef1890bf (diff)
Reduce memory consumption of FunctionObject
Remove varCount and formalParameterCount members in FunctionObject and retrieve them from the CompiledFunction instead. Change-Id: I8a6cdc6d354b0f33da9d67a4c3dbfe8a7cc96176 Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index e8a442faca..f0002b3b4e 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -77,8 +77,6 @@ DEFINE_OBJECT_VTABLE(FunctionObject);
FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto)
: Object(createProto ? scope->engine->functionWithProtoClass : scope->engine->functionClass)
, scope(scope)
- , formalParameterCount(0)
- , varCount(0)
, function(0)
, protoCacheClass(0)
, protoCacheIndex(UINT_MAX)
@@ -89,8 +87,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)
- , formalParameterCount(0)
- , varCount(0)
, function(0)
, protoCacheClass(0)
, protoCacheIndex(UINT_MAX)
@@ -107,8 +103,6 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo
FunctionObject::FunctionObject(InternalClass *ic)
: Object(ic)
, scope(ic->engine->rootContext)
- , formalParameterCount(0)
- , varCount(0)
, function(0)
{
name = ic->engine->id_undefined;
@@ -171,11 +165,6 @@ void FunctionObject::markObjects(Managed *that, ExecutionEngine *e)
FunctionObject *o = static_cast<FunctionObject *>(that);
if (o->name.managed())
o->name->mark(e);
- // these are marked in VM::Function:
-// for (uint i = 0; i < formalParameterCount; ++i)
-// formalParameterList[i]->mark();
-// for (uint i = 0; i < varCount; ++i)
-// varList[i]->mark();
o->scope->mark(e);
Object::markObjects(that, e);
@@ -416,10 +405,8 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
needsActivation = function->needsActivation();
strictMode = function->isStrict();
- formalParameterCount = function->compiledFunction->nFormals;
- varCount = function->internalClass->size - function->compiledFunction->nFormals;
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
+ defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount()));
if (scope->strictMode) {
Property pd = Property::fromAccessor(v4->thrower, v4->thrower);
@@ -501,10 +488,8 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu
needsActivation = function->needsActivation();
strictMode = function->isStrict();
- formalParameterCount = function->compiledFunction->nFormals;
- varCount = function->internalClass->size - function->compiledFunction->nFormals;
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
+ defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount()));
if (scope->strictMode) {
Property pd = Property::fromAccessor(v4->thrower, v4->thrower);
@@ -536,8 +521,8 @@ 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->varCount);
- while (callData->argc < (int)f->formalParameterCount) {
+ ctx.locals = v4->stackPush(f->varCount());
+ while (callData->argc < (int)f->formalParameterCount()) {
callData->args[callData->argc] = Encode::undefined();
++callData->argc;
}
@@ -573,8 +558,8 @@ 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->varCount);
- while (callData->argc < (int)f->formalParameterCount) {
+ ctx.locals = v4->stackPush(f->varCount());
+ while (callData->argc < (int)f->formalParameterCount()) {
callData->args[callData->argc] = Encode::undefined();
++callData->argc;
}