Get rid of flags in QV4::Function and use CompiledFunction::flags instead
Change-Id: Iffe72ff6dd0311d7548d1ea41164a400fd3a7600 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
0d1e37e9f5
commit
83a975ae1c
|
@ -100,9 +100,16 @@ struct Unit
|
|||
|
||||
struct Function
|
||||
{
|
||||
enum Flags {
|
||||
HasDirectEval = 0x1,
|
||||
UsesArgumentsObject = 0x2,
|
||||
IsStrict = 0x4,
|
||||
IsNamedExpression = 0x8
|
||||
};
|
||||
|
||||
QV4::Value (*code)(ExecutionContext *, const uchar *);
|
||||
quint32 nameIndex;
|
||||
qint64 flags; // strict, etc.
|
||||
qint64 flags;
|
||||
quint32 nFormals;
|
||||
quint32 formalsOffset;
|
||||
quint32 nLocals;
|
||||
|
|
|
@ -143,7 +143,15 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QQmlJS::V4IR::Functi
|
|||
{
|
||||
QV4::CompiledData::Function *function = (QV4::CompiledData::Function *)f;
|
||||
function->nameIndex = getStringId(*irFunction->name);
|
||||
function->flags = 0; // ###
|
||||
function->flags = 0;
|
||||
if (irFunction->hasDirectEval)
|
||||
function->flags |= CompiledData::Function::HasDirectEval;
|
||||
if (irFunction->usesArgumentsObject)
|
||||
function->flags |= CompiledData::Function::UsesArgumentsObject;
|
||||
if (irFunction->isStrict)
|
||||
function->flags |= CompiledData::Function::IsStrict;
|
||||
if (irFunction->isNamedExpression)
|
||||
function->flags |= CompiledData::Function::IsNamedExpression;
|
||||
function->nFormals = irFunction->formals.size();
|
||||
function->formalsOffset = sizeof(QV4::CompiledData::Function);
|
||||
function->nLocals = irFunction->locals.size();
|
||||
|
|
|
@ -84,11 +84,6 @@ QV4::Function *EvalInstructionSelection::createFunctionMapping(QV4::Function *ou
|
|||
QV4::Function *vmFunction = _engine->newFunction(irFunction->name ? *irFunction->name : QString());
|
||||
_irToVM.insert(irFunction, vmFunction);
|
||||
|
||||
vmFunction->hasDirectEval = irFunction->hasDirectEval;
|
||||
vmFunction->usesArgumentsObject = irFunction->usesArgumentsObject;
|
||||
vmFunction->hasNestedFunctions = !irFunction->nestedFunctions.isEmpty();
|
||||
vmFunction->isStrict = irFunction->isStrict;
|
||||
vmFunction->isNamedExpression = irFunction->isNamedExpression;
|
||||
vmFunction->sourceFile = irFunction->sourceFile;
|
||||
|
||||
if (outer)
|
||||
|
|
|
@ -393,7 +393,7 @@ Value ExecutionContext::getProperty(String *name)
|
|||
if (hasProperty)
|
||||
return v;
|
||||
}
|
||||
if (f->function && f->function->isNamedExpression
|
||||
if (f->function && f->function->isNamedExpression()
|
||||
&& name->isEqualTo(f->function->name))
|
||||
return Value::fromObject(c->function);
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ Value ExecutionContext::getPropertyNoThrow(String *name)
|
|||
if (hasProperty)
|
||||
return v;
|
||||
}
|
||||
if (f->function && f->function->isNamedExpression
|
||||
if (f->function && f->function->isNamedExpression()
|
||||
&& name->isEqualTo(f->function->name))
|
||||
return Value::fromObject(c->function);
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ Value ExecutionContext::getPropertyAndBase(String *name, Object **base)
|
|||
return v;
|
||||
}
|
||||
}
|
||||
if (f->function && f->function->isNamedExpression
|
||||
if (f->function && f->function->isNamedExpression()
|
||||
&& name->isEqualTo(f->function->name))
|
||||
return Value::fromObject(c->function);
|
||||
}
|
||||
|
|
|
@ -106,12 +106,6 @@ struct Function {
|
|||
|
||||
Lookup *lookups;
|
||||
|
||||
bool hasNestedFunctions;
|
||||
bool hasDirectEval;
|
||||
bool usesArgumentsObject;
|
||||
bool isStrict;
|
||||
bool isNamedExpression;
|
||||
|
||||
QString sourceFile;
|
||||
QVector<LineNumberMapping> lineNumberMappings;
|
||||
|
||||
|
@ -126,11 +120,6 @@ struct Function {
|
|||
, codeData(0)
|
||||
, codeSize(0)
|
||||
, lookups(0)
|
||||
, hasNestedFunctions(0)
|
||||
, hasDirectEval(false)
|
||||
, usesArgumentsObject(false)
|
||||
, isStrict(false)
|
||||
, isNamedExpression(false)
|
||||
, engine(engine)
|
||||
{}
|
||||
~Function();
|
||||
|
@ -144,7 +133,12 @@ struct Function {
|
|||
nestedFunctions.append(f);
|
||||
}
|
||||
|
||||
inline bool needsActivation() const { return hasNestedFunctions || hasDirectEval || usesArgumentsObject; }
|
||||
inline bool usesArgumentsObject() const { return compiledFunction->flags & CompiledData::Function::UsesArgumentsObject; }
|
||||
inline bool isStrict() const { return compiledFunction->flags & CompiledData::Function::IsStrict; }
|
||||
inline bool isNamedExpression() const { return compiledFunction->flags & CompiledData::Function::IsNamedExpression; }
|
||||
|
||||
inline bool needsActivation() const
|
||||
{ return compiledFunction->nInnerFunctions > 0 || (compiledFunction->flags & (CompiledData::Function::HasDirectEval | CompiledData::Function::UsesArgumentsObject)); }
|
||||
|
||||
void mark();
|
||||
|
||||
|
|
|
@ -336,8 +336,8 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
|
|||
MemoryManager::GCBlocker gcBlocker(scope->engine->memoryManager);
|
||||
|
||||
needsActivation = function->needsActivation();
|
||||
usesArgumentsObject = function->usesArgumentsObject;
|
||||
strictMode = function->isStrict;
|
||||
usesArgumentsObject = function->usesArgumentsObject();
|
||||
strictMode = function->isStrict();
|
||||
formalParameterCount = function->formals.size();
|
||||
formalParameterList = function->formals.constData();
|
||||
defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(formalParameterCount));
|
||||
|
|
|
@ -383,9 +383,9 @@ Value EvalFunction::evalCall(Value /*thisObject*/, Value *args, int argc, bool d
|
|||
if (!function)
|
||||
return Value::undefinedValue();
|
||||
|
||||
strictMode = function->isStrict || (ctx->strictMode);
|
||||
strictMode = function->isStrict() || (ctx->strictMode);
|
||||
|
||||
usesArgumentsObject = function->usesArgumentsObject;
|
||||
usesArgumentsObject = function->usesArgumentsObject();
|
||||
needsActivation = function->needsActivation();
|
||||
|
||||
if (strictMode) {
|
||||
|
|
|
@ -124,30 +124,6 @@ void __qmljs_init_closure(ExecutionContext *ctx, Value *result, Function *clos)
|
|||
*result = Value::fromObject(ctx->engine->newScriptFunction(ctx, clos));
|
||||
}
|
||||
|
||||
Function *__qmljs_register_function(ExecutionContext *ctx, String *name,
|
||||
bool hasDirectEval,
|
||||
bool usesArgumentsObject, bool isStrict,
|
||||
bool hasNestedFunctions,
|
||||
String **formals, unsigned formalCount,
|
||||
String **locals, unsigned localCount)
|
||||
{
|
||||
Function *f = ctx->engine->newFunction(name ? name->toQString() : QString());
|
||||
|
||||
f->hasDirectEval = hasDirectEval;
|
||||
f->usesArgumentsObject = usesArgumentsObject;
|
||||
f->isStrict = isStrict;
|
||||
f->hasNestedFunctions = hasNestedFunctions;
|
||||
|
||||
for (unsigned i = 0; i < formalCount; ++i)
|
||||
if (formals[i])
|
||||
f->formals.append(formals[i]);
|
||||
for (unsigned i = 0; i < localCount; ++i)
|
||||
if (locals[i])
|
||||
f->locals.append(locals[i]);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void __qmljs_delete_subscript(ExecutionContext *ctx, Value *result, const Value &base, const Value &index)
|
||||
{
|
||||
if (Object *o = base.asObject()) {
|
||||
|
|
|
@ -131,12 +131,6 @@ void __qmljs_resolve_string_as_value(QV4::ExecutionContext *ctx, QV4::Value *res
|
|||
|
||||
// constructors
|
||||
void __qmljs_init_closure(QV4::ExecutionContext *ctx, QV4::Value *result, QV4::Function *clos);
|
||||
QV4::Function *__qmljs_register_function(QV4::ExecutionContext *ctx, QV4::String *name,
|
||||
bool hasDirectEval,
|
||||
bool usesArgumentsObject, bool isStrict,
|
||||
bool hasNestedFunctions,
|
||||
QV4::String **formals, unsigned formalCount,
|
||||
QV4::String **locals, unsigned localCount);
|
||||
|
||||
// strings
|
||||
Q_QML_EXPORT double __qmljs_string_to_number(const QString &s);
|
||||
|
|
|
@ -68,7 +68,7 @@ struct QmlBindingWrapper : FunctionObject
|
|||
vtbl = &static_vtbl;
|
||||
function = f;
|
||||
function->ref();
|
||||
usesArgumentsObject = function->usesArgumentsObject;
|
||||
usesArgumentsObject = function->usesArgumentsObject();
|
||||
needsActivation = function->needsActivation();
|
||||
defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1));
|
||||
|
||||
|
@ -203,7 +203,7 @@ Value Script::run()
|
|||
bool strict = scope->strictMode;
|
||||
Lookup *lookups = scope->lookups;
|
||||
|
||||
scope->strictMode = vmFunction->isStrict;
|
||||
scope->strictMode = vmFunction->isStrict();
|
||||
scope->lookups = vmFunction->lookups;
|
||||
|
||||
QV4::Value result;
|
||||
|
|
Loading…
Reference in New Issue