diff options
author | Lars Knoll <[email protected]> | 2014-03-04 13:19:27 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2014-03-07 16:55:12 +0100 |
commit | f836b9837dda09c09c2ee3307300998ca5dff5c4 (patch) | |
tree | 0f49f84a9e6912dbef18c7b58d8c9442c5387180 /src | |
parent | 48251fd737447710775727f55e7334ec1c6af1f4 (diff) |
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 28 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 |
5 files changed, 30 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 6aedc5ffd8..6b2d1e657b 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -670,6 +670,8 @@ Returned<Object> *ExecutionEngine::qmlContextObject() const QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const { + Scope scope(this->currentContext()); + ScopedString name(scope); QVector<StackFrame> stack; QV4::ExecutionContext *c = currentContext(); @@ -679,7 +681,8 @@ QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const StackFrame frame; if (callCtx->function->function) frame.source = callCtx->function->function->sourceFile(); - frame.function = callCtx->function->name->toQString(); + name = callCtx->function->name(); + frame.function = name->toQString(); frame.line = -1; frame.column = -1; 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<FunctionObject *>(that); - if (o->name.managed()) - o->name->mark(e); o->scope->mark(e); Object::markObjects(that, e); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index ac7fe5daba..3f432c2f26 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -112,7 +112,7 @@ struct Q_QML_EXPORT FunctionObject: Object { }; ExecutionContext *scope; - StringValue name; + ReturnedValue name(); unsigned int formalParameterCount() { return function ? function->compiledFunction->nFormals : 0; } unsigned int varCount() { return function ? function->compiledFunction->nLocals : 0; } Function *function; @@ -123,6 +123,7 @@ struct Q_QML_EXPORT FunctionObject: Object { FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto = false); FunctionObject(ExecutionContext *scope, const QString &name = QString(), bool createProto = false); + FunctionObject(ExecutionContext *scope, const ReturnedValue name); ~FunctionObject(); void init(const StringRef name, bool createProto); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index cd19520f9f..4ebfcd01cd 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -776,8 +776,10 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase if (scope.hasException() && v4->v8Engine) { if (QQmlEngine *qmlEngine = v4->v8Engine->engine()) { QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx); - if (error.description().isEmpty()) - error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(f->name->toQString())); + if (error.description().isEmpty()) { + QV4::ScopedString name(scope, f->name()); + error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(name->toQString())); + } QQmlEnginePrivate::get(qmlEngine)->warning(error); } } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 8692be6b7b..82af1c3fb8 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1181,7 +1181,7 @@ struct BindingFunction : public QV4::FunctionObject { V4_OBJECT BindingFunction(FunctionObject *originalFunction) - : QV4::FunctionObject(originalFunction->scope, originalFunction->name) + : QV4::FunctionObject(originalFunction->scope, originalFunction->name()) , originalFunction(originalFunction) { setVTable(staticVTable()); |