aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-03-03 11:51:17 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-03 20:23:24 +0100
commit292fdc90865e8603e11bbbe3f2870004caeb0e35 (patch)
tree964cfe2ea959c1159618356ce8d99c6f1db03ff1 /src/qml/jsruntime
parentfd8981d835f298306a39c5d32b1050bf8f9b5653 (diff)
Remove nArguments and name from QV4::Function
Saves 12 bytes per Function Change-Id: I9a495805f9201eb6162a520ff5c2defeb73dc37a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4context.cpp6
-rw-r--r--src/qml/jsruntime/qv4engine.cpp5
-rw-r--r--src/qml/jsruntime/qv4function.cpp9
-rw-r--r--src/qml/jsruntime/qv4function_p.h8
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp14
-rw-r--r--src/qml/jsruntime/qv4profiling.cpp2
6 files changed, 14 insertions, 30 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index cec42e87aa..8a78b18df1 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -153,7 +153,7 @@ String * const *ExecutionContext::variables() const
if (type < Type_SimpleCallContext)
return 0;
QV4::FunctionObject *f = static_cast<const CallContext *>(this)->function;
- return (f && f->function) ? f->function->internalClass->nameMap.constData() + f->function->nArguments : 0;
+ return (f && f->function) ? f->function->internalClass->nameMap.constData() + f->function->compiledFunction->nFormals : 0;
}
unsigned int ExecutionContext::variableCount() const
@@ -392,7 +392,7 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name)
return v.asReturnedValue();
}
if (f->function && f->function->isNamedExpression()
- && name->equals(f->function->name))
+ && name->equals(f->function->name()))
return f.asReturnedValue();
}
@@ -461,7 +461,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR
}
}
if (f->function && f->function->isNamedExpression()
- && name->equals(f->function->name))
+ && name->equals(f->function->name()))
return c->function->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 56ca31c85d..4bf6c89f26 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -719,7 +719,7 @@ QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const
if (frameLimit && globalCode) {
StackFrame frame;
frame.source = globalCode->sourceFile();
- frame.function = globalCode->name->toQString();
+ frame.function = globalCode->name()->toQString();
frame.line = -1;
frame.column = -1;
@@ -828,9 +828,6 @@ void ExecutionEngine::markObjects()
globalObject->mark(this);
- if (globalCode)
- globalCode->mark(this);
-
for (int i = 0; i < argumentsAccessors.size(); ++i) {
const Property &pd = argumentsAccessors.at(i);
if (FunctionObject *getter = pd.getter())
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 811b445f9e..550c359772 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -60,10 +60,6 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
{
Q_UNUSED(engine);
- name = compilationUnit->runtimeStrings[compiledFunction->nameIndex].asString();
-
- nArguments = compiledFunction->nFormals;
-
internalClass = engine->emptyClass;
const quint32 *formalsIndices = compiledFunction->formalsTable();
// iterate backwards, so we get the right ordering for duplicate names
@@ -92,11 +88,6 @@ Function::~Function()
}
-void Function::mark(ExecutionEngine *e)
-{
- name.mark(e);
-}
-
namespace QV4 {
template <int field, typename SearchType>
struct LineNumberMappingHelper
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index 377b45bfa3..530d67e3c8 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -81,8 +81,6 @@ struct InternalClass;
struct Lookup;
struct Function {
- StringValue name;
-
const CompiledData::Function *compiledFunction;
CompiledData::CompilationUnit *compilationUnit;
@@ -91,13 +89,15 @@ struct Function {
quint32 codeSize;
// first nArguments names in internalClass are the actual arguments
- int nArguments;
InternalClass *internalClass;
Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
ReturnedValue (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize);
~Function();
+ inline StringRef name() {
+ return compilationUnit->runtimeStrings[compiledFunction->nameIndex];
+ }
inline QString sourceFile() const { return compilationUnit->fileName(); }
inline bool usesArgumentsObject() const { return compiledFunction->flags & CompiledData::Function::UsesArgumentsObject; }
@@ -107,8 +107,6 @@ struct Function {
inline bool needsActivation() const
{ return compiledFunction->nInnerFunctions > 0 || (compiledFunction->flags & (CompiledData::Function::HasDirectEval | CompiledData::Function::UsesArgumentsObject)); }
- void mark(ExecutionEngine *e);
-
int lineNumberForProgramCounter(qptrdiff offset) const;
QList<qptrdiff> programCountersForAllLines() const;
};
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 66e956e43c..e8a442faca 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -177,8 +177,6 @@ void FunctionObject::markObjects(Managed *that, ExecutionEngine *e)
// for (uint i = 0; i < varCount; ++i)
// varList[i]->mark();
o->scope->mark(e);
- if (o->function)
- o->function->mark(e);
Object::markObjects(that, e);
}
@@ -398,7 +396,7 @@ ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
DEFINE_OBJECT_VTABLE(ScriptFunction);
ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
- : FunctionObject(scope, function->name, true)
+ : FunctionObject(scope, function->name(), true)
{
setVTable(staticVTable());
@@ -418,8 +416,8 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
needsActivation = function->needsActivation();
strictMode = function->isStrict();
- formalParameterCount = function->nArguments;
- varCount = function->internalClass->size - function->nArguments;
+ formalParameterCount = function->compiledFunction->nFormals;
+ varCount = function->internalClass->size - function->compiledFunction->nFormals;
defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
@@ -483,7 +481,7 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData)
DEFINE_OBJECT_VTABLE(SimpleScriptFunction);
SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *function, bool createProto)
- : FunctionObject(scope, function->name, createProto)
+ : FunctionObject(scope, function->name(), createProto)
{
setVTable(staticVTable());
@@ -503,8 +501,8 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu
needsActivation = function->needsActivation();
strictMode = function->isStrict();
- formalParameterCount = function->nArguments;
- varCount = function->internalClass->size - function->nArguments;
+ formalParameterCount = function->compiledFunction->nFormals;
+ varCount = function->internalClass->size - function->compiledFunction->nFormals;
defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount));
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp
index 69efbfdee3..8a0cc56448 100644
--- a/src/qml/jsruntime/qv4profiling.cpp
+++ b/src/qml/jsruntime/qv4profiling.cpp
@@ -51,7 +51,7 @@ FunctionCallProperties FunctionCall::resolve() const
FunctionCallProperties props = {
m_start,
m_end,
- m_function->name.toQString(),
+ m_function->name()->toQString(),
m_function->compilationUnit->fileName(),
m_function->compiledFunction->location.line,
m_function->compiledFunction->location.column