From f836b9837dda09c09c2ee3307300998ca5dff5c4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 4 Mar 2014 13:19:27 +0100 Subject: Remove the name member of FunctionObject The data is anyway stored in the name property of the FunctionObject, and is not performance critical. Change-Id: If1784b0ec6f368bc474c246bb9c2c50d5e56b689 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/qml/jsruntime/qv4functionobject.cpp') diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index f0002b3b4e..f0966492a9 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -91,22 +91,30 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo , protoCacheClass(0) , protoCacheIndex(UINT_MAX) { - // set the name to something here, so that a gc run a few lines below doesn't crash on it - this->name = scope->engine->id_undefined; - Scope s(scope); ScopedValue protectThis(s, this); ScopedString n(s, s.engine->newString(name)); init(n, createProto); } +FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name) + : Object(scope->engine->functionClass) + , scope(scope) + , function(0) + , protoCacheClass(0) + , protoCacheIndex(UINT_MAX) +{ + Scope s(scope); + ScopedValue protectThis(s, this); + ScopedString n(s, name); + init(n, false); +} + FunctionObject::FunctionObject(InternalClass *ic) : Object(ic) , scope(ic->engine->rootContext) , function(0) { - name = ic->engine->id_undefined; - needsActivation = false; strictMode = false; } @@ -119,8 +127,6 @@ FunctionObject::~FunctionObject() void FunctionObject::init(const StringRef n, bool createProto) { - name = n; - Scope s(internalClass->engine); ScopedValue protectThis(s, this); @@ -137,6 +143,12 @@ void FunctionObject::init(const StringRef n, bool createProto) defineReadonlyProperty(scope->engine->id_name, v); } +ReturnedValue FunctionObject::name() +{ + return get(scope->engine->id_name); +} + + ReturnedValue FunctionObject::newInstance() { Scope scope(internalClass->engine); @@ -163,8 +175,6 @@ ReturnedValue FunctionObject::call(Managed *, CallData *) void FunctionObject::markObjects(Managed *that, ExecutionEngine *e) { FunctionObject *o = static_cast(that); - if (o->name.managed()) - o->name->mark(e); o->scope->mark(e); Object::markObjects(that, e); -- cgit v1.2.3