return false; \
}
-void QmlObject::init(MemoryPool *pool, int typeNameIndex, int id, const AST::SourceLocation &loc)
+void QmlObject::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int id, const QQmlJS::AST::SourceLocation &loc)
{
inheritedTypeNameIndex = typeNameIndex;
out << "}" << endl;
}
-QString QmlObject::sanityCheckFunctionNames(const QList<CompiledFunctionOrExpression> &allFunctions, const QSet<QString> &illegalNames, AST::SourceLocation *errorLocation)
+QString QmlObject::sanityCheckFunctionNames(const QList<CompiledFunctionOrExpression> &allFunctions, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation)
{
QSet<int> functionNames;
for (Function *f = functions->first; f; f = f->next) {
- AST::FunctionDeclaration *function = AST::cast<AST::FunctionDeclaration*>(allFunctions.at(f->index).node);
+ QQmlJS::AST::FunctionDeclaration *function = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(allFunctions.at(f->index).node);
Q_ASSERT(function);
*errorLocation = function->identifierToken;
QString name = function->name.toString();
return QString(); // no error
}
-QString QmlObject::appendProperty(QmlProperty *prop, const QString &propertyName, bool isDefaultProperty, const AST::SourceLocation &defaultToken, AST::SourceLocation *errorLocation)
+QString QmlObject::appendProperty(QmlProperty *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation)
{
QmlObject *target = declarationsOverride;
if (!target)
return QString(); // no error
}
-void QmlObject::appendFunction(Function *f)
+void QmlObject::appendFunction(QtQml::Function *f)
{
QmlObject *target = declarationsOverride;
if (!target)
bool QQmlCodeGenerator::generateFromQml(const QString &code, const QUrl &url, const QString &urlString, ParsedQML *output)
{
this->url = url;
- AST::UiProgram *program = 0;
+ QQmlJS::AST::UiProgram *program = 0;
{
QQmlJS::Lexer lexer(&output->jsParserEngine);
lexer.setCode(code, /*line = */ 1);
if (! parser.parse() || !parser.diagnosticMessages().isEmpty()) {
// Extract errors from the parser
- foreach (const DiagnosticMessage &m, parser.diagnosticMessages()) {
+ foreach (const QQmlJS::DiagnosticMessage &m, parser.diagnosticMessages()) {
if (m.isWarning()) {
qWarning("%s:%d : %s", qPrintable(urlString), m.loc.startLine, qPrintable(m.message));
if (program->members->next) {
QQmlError error;
error.setDescription(QCoreApplication::translate("QQmlParser", "Unexpected object definition"));
- AST::SourceLocation loc = program->members->next->firstSourceLocation();
+ QQmlJS::AST::SourceLocation loc = program->members->next->firstSourceLocation();
error.setLine(loc.startLine);
error.setColumn(loc.startColumn);
errors << error;
return false;
}
- AST::UiObjectDefinition *rootObject = AST::cast<AST::UiObjectDefinition*>(program->members->member);
+ QQmlJS::AST::UiObjectDefinition *rootObject = QQmlJS::AST::cast<QQmlJS::AST::UiObjectDefinition*>(program->members->member);
Q_ASSERT(rootObject);
output->indexOfRootObject = defineQMLObject(rootObject);
return false; // consists solely of underscores - invalid.
}
-bool QQmlCodeGenerator::visit(AST::UiArrayMemberList *ast)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiArrayMemberList *ast)
{
- return AST::Visitor::visit(ast);
+ return QQmlJS::AST::Visitor::visit(ast);
}
-bool QQmlCodeGenerator::visit(AST::UiProgram *)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiProgram *)
{
Q_ASSERT(!"should not happen");
return false;
}
-bool QQmlCodeGenerator::visit(AST::UiObjectDefinition *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiObjectDefinition *node)
{
// The grammar can't distinguish between two different definitions here:
// Item { ... }
// and the latter is a binding to the font property with no type name but
// only initializer.
- AST::UiQualifiedId *lastId = node->qualifiedTypeNameId;
+ QQmlJS::AST::UiQualifiedId *lastId = node->qualifiedTypeNameId;
while (lastId->next)
lastId = lastId->next;
bool isType = lastId->name.unicode()->isUpper();
return false;
}
-bool QQmlCodeGenerator::visit(AST::UiObjectBinding *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiObjectBinding *node)
{
int idx = defineQMLObject(node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer);
appendBinding(node->qualifiedId, idx, node->hasOnToken);
return false;
}
-bool QQmlCodeGenerator::visit(AST::UiScriptBinding *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiScriptBinding *node)
{
appendBinding(node->qualifiedId, node->statement);
return false;
}
-bool QQmlCodeGenerator::visit(AST::UiArrayBinding *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiArrayBinding *node)
{
QmlObject *object = 0;
- AST::UiQualifiedId *name = node->qualifiedId;
+ QQmlJS::AST::UiQualifiedId *name = node->qualifiedId;
if (!resolveQualifiedId(&name, &object))
return false;
qSwap(_object, object);
- AST::UiArrayMemberList *member = node->members;
+ QQmlJS::AST::UiArrayMemberList *member = node->members;
while (member) {
- AST::UiObjectDefinition *def = AST::cast<AST::UiObjectDefinition*>(member->member);
+ QQmlJS::AST::UiObjectDefinition *def = QQmlJS::AST::cast<QQmlJS::AST::UiObjectDefinition*>(member->member);
int idx = defineQMLObject(def);
appendBinding(name->identifierToken, registerString(name->name.toString()), idx, /*isListItem*/ true);
return false;
}
-bool QQmlCodeGenerator::visit(AST::UiHeaderItemList *list)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiHeaderItemList *list)
{
- return AST::Visitor::visit(list);
+ return QQmlJS::AST::Visitor::visit(list);
}
-bool QQmlCodeGenerator::visit(AST::UiObjectInitializer *ast)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiObjectInitializer *ast)
{
- return AST::Visitor::visit(ast);
+ return QQmlJS::AST::Visitor::visit(ast);
}
-bool QQmlCodeGenerator::visit(AST::UiObjectMemberList *ast)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiObjectMemberList *ast)
{
- return AST::Visitor::visit(ast);
+ return QQmlJS::AST::Visitor::visit(ast);
}
-bool QQmlCodeGenerator::visit(AST::UiParameterList *ast)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiParameterList *ast)
{
- return AST::Visitor::visit(ast);
+ return QQmlJS::AST::Visitor::visit(ast);
}
-bool QQmlCodeGenerator::visit(AST::UiQualifiedId *id)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiQualifiedId *id)
{
- return AST::Visitor::visit(id);
+ return QQmlJS::AST::Visitor::visit(id);
}
-void QQmlCodeGenerator::accept(AST::Node *node)
+void QQmlCodeGenerator::accept(QQmlJS::AST::Node *node)
{
- AST::Node::acceptChild(node, this);
+ QQmlJS::AST::Node::acceptChild(node, this);
}
-int QQmlCodeGenerator::defineQMLObject(AST::UiQualifiedId *qualifiedTypeNameId, const AST::SourceLocation &location, AST::UiObjectInitializer *initializer, QmlObject *declarationsOverride)
+int QQmlCodeGenerator::defineQMLObject(QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, QmlObject *declarationsOverride)
{
QmlObject *obj = New<QmlObject>();
_objects.append(obj);
qSwap(_object, obj);
- AST::SourceLocation loc;
+ QQmlJS::AST::SourceLocation loc;
QString error = obj->sanityCheckFunctionNames(_functions, illegalNames, &loc);
if (!error.isEmpty())
recordError(loc, error);
return objectIndex;
}
-bool QQmlCodeGenerator::visit(AST::UiImport *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiImport *node)
{
QString uri;
QV4::CompiledData::Import *import = New<QV4::CompiledData::Import>();
return false;
}
-bool QQmlCodeGenerator::visit(AST::UiPragma *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiPragma *node)
{
Pragma *pragma = New<Pragma>();
return QStringList();
}
-bool QQmlCodeGenerator::visit(AST::UiPublicMember *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiPublicMember *node)
{
static const struct TypeNameToType {
const char *name;
static const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) /
sizeof(propTypeNameToTypes[0]);
- if (node->type == AST::UiPublicMember::Signal) {
+ if (node->type == QQmlJS::AST::UiPublicMember::Signal) {
Signal *signal = New<Signal>();
QString signalName = node->name.toString();
signal->nameIndex = registerString(signalName);
- AST::SourceLocation loc = node->typeToken;
+ QQmlJS::AST::SourceLocation loc = node->typeToken;
signal->location.line = loc.startLine;
signal->location.column = loc.startColumn;
signal->parameters = New<PoolList<SignalParameter> >();
- AST::UiParameterList *p = node->parameters;
+ QQmlJS::AST::UiParameterList *p = node->parameters;
while (p) {
const QStringRef &memberType = p->type;
const QString propName = name.toString();
property->nameIndex = registerString(propName);
- AST::SourceLocation loc = node->firstSourceLocation();
+ QQmlJS::AST::SourceLocation loc = node->firstSourceLocation();
property->location.line = loc.startLine;
property->location.column = loc.startColumn;
if (!node->statement && !node->binding)
COMPILE_EXCEPTION(loc, tr("No property alias location"));
- AST::SourceLocation rhsLoc;
+ QQmlJS::AST::SourceLocation rhsLoc;
if (node->binding)
rhsLoc = node->binding->firstSourceLocation();
else if (node->statement)
QStringList alias;
- if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement*>(node->statement)) {
+ if (QQmlJS::AST::ExpressionStatement *stmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement*>(node->statement)) {
alias = astNodeToStringList(stmt->expression);
if (alias.isEmpty()) {
if (isStatementNodeScript(node->statement)) {
qSwap(_propertyDeclaration, property);
}
- AST::SourceLocation errorLocation;
+ QQmlJS::AST::SourceLocation errorLocation;
QString error;
if (illegalNames.contains(propName))
if (node->binding) {
qSwap(_propertyDeclaration, property);
// process QML-like initializers (e.g. property Object o: Object {})
- AST::Node::accept(node->binding, this);
+ QQmlJS::AST::Node::accept(node->binding, this);
qSwap(_propertyDeclaration, property);
}
}
return false;
}
-bool QQmlCodeGenerator::visit(AST::UiSourceElement *node)
+bool QQmlCodeGenerator::visit(QQmlJS::AST::UiSourceElement *node)
{
- if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
+ if (QQmlJS::AST::FunctionDeclaration *funDecl = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration *>(node->sourceElement)) {
_functions << funDecl;
Function *f = New<Function>();
f->functionDeclaration = funDecl;
- AST::SourceLocation loc = funDecl->identifierToken;
+ QQmlJS::AST::SourceLocation loc = funDecl->identifierToken;
f->location.line = loc.startLine;
f->location.column = loc.startColumn;
f->index = _functions.size() - 1;
return false;
}
-QString QQmlCodeGenerator::asString(AST::UiQualifiedId *node)
+QString QQmlCodeGenerator::asString(QQmlJS::AST::UiQualifiedId *node)
{
QString s;
- for (AST::UiQualifiedId *it = node; it; it = it->next) {
+ for (QQmlJS::AST::UiQualifiedId *it = node; it; it = it->next) {
s.append(it->name);
if (it->next)
return s;
}
-QStringRef QQmlCodeGenerator::asStringRef(AST::Node *node)
+QStringRef QQmlCodeGenerator::asStringRef(QQmlJS::AST::Node *node)
{
if (!node)
return QStringRef();
}
}
-QStringRef QQmlCodeGenerator::textRefAt(const AST::SourceLocation &first, const AST::SourceLocation &last) const
+QStringRef QQmlCodeGenerator::textRefAt(const QQmlJS::AST::SourceLocation &first, const QQmlJS::AST::SourceLocation &last) const
{
return QStringRef(&sourceCode, first.offset, last.offset + last.length - first.offset);
}
-void QQmlCodeGenerator::setBindingValue(QV4::CompiledData::Binding *binding, AST::Statement *statement)
+void QQmlCodeGenerator::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement)
{
- AST::SourceLocation loc = statement->firstSourceLocation();
+ QQmlJS::AST::SourceLocation loc = statement->firstSourceLocation();
binding->valueLocation.line = loc.startLine;
binding->valueLocation.column = loc.startColumn;
binding->type = QV4::CompiledData::Binding::Type_Invalid;
if (_propertyDeclaration && (_propertyDeclaration->flags & QV4::CompiledData::Property::IsReadOnly))
binding->flags |= QV4::CompiledData::Binding::InitializerForReadOnlyDeclaration;
- if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(statement)) {
- AST::ExpressionNode *expr = stmt->expression;
- if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(expr)) {
+ if (QQmlJS::AST::ExpressionStatement *stmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(statement)) {
+ QQmlJS::AST::ExpressionNode *expr = stmt->expression;
+ if (QQmlJS::AST::StringLiteral *lit = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expr)) {
binding->type = QV4::CompiledData::Binding::Type_String;
binding->stringIndex = registerString(lit->value.toString());
- } else if (expr->kind == AST::Node::Kind_TrueLiteral) {
+ } else if (expr->kind == QQmlJS::AST::Node::Kind_TrueLiteral) {
binding->type = QV4::CompiledData::Binding::Type_Boolean;
binding->value.b = true;
- } else if (expr->kind == AST::Node::Kind_FalseLiteral) {
+ } else if (expr->kind == QQmlJS::AST::Node::Kind_FalseLiteral) {
binding->type = QV4::CompiledData::Binding::Type_Boolean;
binding->value.b = false;
- } else if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) {
+ } else if (QQmlJS::AST::NumericLiteral *lit = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(expr)) {
binding->type = QV4::CompiledData::Binding::Type_Number;
binding->value.d = lit->value;
} else {
- if (AST::UnaryMinusExpression *unaryMinus = AST::cast<AST::UnaryMinusExpression *>(expr)) {
- if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(unaryMinus->expression)) {
+ if (QQmlJS::AST::UnaryMinusExpression *unaryMinus = QQmlJS::AST::cast<QQmlJS::AST::UnaryMinusExpression *>(expr)) {
+ if (QQmlJS::AST::NumericLiteral *lit = QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(unaryMinus->expression)) {
binding->type = QV4::CompiledData::Binding::Type_Number;
binding->value.d = -lit->value;
}
}
}
-void QQmlCodeGenerator::appendBinding(AST::UiQualifiedId *name, AST::Statement *value)
+void QQmlCodeGenerator::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value)
{
QmlObject *object = 0;
if (!resolveQualifiedId(&name, &object))
qSwap(_object, object);
}
-void QQmlCodeGenerator::appendBinding(AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment)
+void QQmlCodeGenerator::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment)
{
QmlObject *object = 0;
if (!resolveQualifiedId(&name, &object))
qSwap(_object, object);
}
-void QQmlCodeGenerator::appendBinding(const AST::SourceLocation &nameLocation, quint32 propertyNameIndex, AST::Statement *value)
+void QQmlCodeGenerator::appendBinding(const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value)
{
if (stringAt(propertyNameIndex) == QStringLiteral("id")) {
setId(nameLocation, value);
}
}
-void QQmlCodeGenerator::appendBinding(const AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment)
+void QQmlCodeGenerator::appendBinding(const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment)
{
if (stringAt(propertyNameIndex) == QStringLiteral("id")) {
recordError(nameLocation, tr("Invalid component id specification"));
return _object;
}
-bool QQmlCodeGenerator::setId(const AST::SourceLocation &idLocation, AST::Statement *value)
+bool QQmlCodeGenerator::setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
{
- AST::SourceLocation loc = value->firstSourceLocation();
+ QQmlJS::AST::SourceLocation loc = value->firstSourceLocation();
QStringRef str;
- AST::Node *node = value;
- if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node)) {
- if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(stmt->expression)) {
+ QQmlJS::AST::Node *node = value;
+ if (QQmlJS::AST::ExpressionStatement *stmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(node)) {
+ if (QQmlJS::AST::StringLiteral *lit = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(stmt->expression)) {
str = lit->value;
node = 0;
} else
return true;
}
-bool QQmlCodeGenerator::resolveQualifiedId(AST::UiQualifiedId **nameToResolve, QmlObject **object)
+bool QQmlCodeGenerator::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, QmlObject **object)
{
- AST::UiQualifiedId *qualifiedIdElement = *nameToResolve;
+ QQmlJS::AST::UiQualifiedId *qualifiedIdElement = *nameToResolve;
if (qualifiedIdElement->name == QStringLiteral("id") && qualifiedIdElement->next)
COMPILE_EXCEPTION(qualifiedIdElement->identifierToken, tr( "Invalid use of id property"));
else
binding->type = QV4::CompiledData::Binding::Type_GroupProperty;
- int objIndex = defineQMLObject(0, AST::SourceLocation(), 0, 0);
+ int objIndex = defineQMLObject(0, QQmlJS::AST::SourceLocation(), 0, 0);
binding->value.objectIndex = objIndex;
QString error = (*object)->appendBinding(binding, /*isListBinding*/false);
return true;
}
-void QQmlCodeGenerator::recordError(const AST::SourceLocation &location, const QString &description)
+void QQmlCodeGenerator::recordError(const QQmlJS::AST::SourceLocation &location, const QString &description)
{
QQmlError error;
error.setUrl(url);
}
}
-QQmlScript::LocationSpan QQmlCodeGenerator::location(AST::SourceLocation start, AST::SourceLocation end)
+QQmlScript::LocationSpan QQmlCodeGenerator::location(QQmlJS::AST::SourceLocation start, QQmlJS::AST::SourceLocation end)
{
QQmlScript::LocationSpan rv;
rv.start.line = start.startLine;
return rv;
}
-bool QQmlCodeGenerator::isStatementNodeScript(AST::Statement *statement)
+bool QQmlCodeGenerator::isStatementNodeScript(QQmlJS::AST::Statement *statement)
{
- if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(statement)) {
- AST::ExpressionNode *expr = stmt->expression;
- if (AST::cast<AST::StringLiteral *>(expr))
+ if (QQmlJS::AST::ExpressionStatement *stmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(statement)) {
+ QQmlJS::AST::ExpressionNode *expr = stmt->expression;
+ if (QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expr))
return false;
- else if (expr->kind == AST::Node::Kind_TrueLiteral)
+ else if (expr->kind == QQmlJS::AST::Node::Kind_TrueLiteral)
return false;
- else if (expr->kind == AST::Node::Kind_FalseLiteral)
+ else if (expr->kind == QQmlJS::AST::Node::Kind_FalseLiteral)
return false;
- else if (AST::cast<AST::NumericLiteral *>(expr))
+ else if (QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(expr))
return false;
else {
- if (AST::UnaryMinusExpression *unaryMinus = AST::cast<AST::UnaryMinusExpression *>(expr)) {
- if (AST::cast<AST::NumericLiteral *>(unaryMinus->expression)) {
+ if (QQmlJS::AST::UnaryMinusExpression *unaryMinus = QQmlJS::AST::cast<QQmlJS::AST::UnaryMinusExpression *>(expr)) {
+ if (QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(unaryMinus->expression)) {
return false;
}
}
return jsUnitGenerator->getStringId(str);
}
-JSCodeGen::JSCodeGen(const QString &fileName, const QString &sourceCode, V4IR::Module *jsModule, Engine *jsEngine, AST::UiProgram *qmlRoot, QQmlTypeNameCache *imports)
+JSCodeGen::JSCodeGen(const QString &fileName, const QString &sourceCode, IR::Module *jsModule, QQmlJS::Engine *jsEngine,
+ QQmlJS::AST::UiProgram *qmlRoot, QQmlTypeNameCache *imports)
: QQmlJS::Codegen(/*strict mode*/false)
, sourceCode(sourceCode)
, jsEngine(jsEngine)
scan.enterQmlScope(qmlRoot, QStringLiteral("context scope"));
foreach (const CompiledFunctionOrExpression &f, functions) {
Q_ASSERT(f.node != qmlRoot);
- AST::FunctionDeclaration *function = AST::cast<AST::FunctionDeclaration*>(f.node);
+ QQmlJS::AST::FunctionDeclaration *function = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(f.node);
if (function)
scan.enterQmlFunction(function);
for (int i = 0; i < functions.count(); ++i) {
const CompiledFunctionOrExpression &qmlFunction = functions.at(i);
- AST::Node *node = qmlFunction.node;
+ QQmlJS::AST::Node *node = qmlFunction.node;
Q_ASSERT(node != qmlRoot);
- AST::FunctionDeclaration *function = AST::cast<AST::FunctionDeclaration*>(node);
+ QQmlJS::AST::FunctionDeclaration *function = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(node);
QString name;
if (function)
else
name = QStringLiteral("%qml-expression-entry");
- AST::SourceElements *body;
+ QQmlJS::AST::SourceElements *body;
if (function)
body = function->body ? function->body->elements : 0;
else {
// Synthesize source elements.
QQmlJS::MemoryPool *pool = jsEngine->pool();
- AST::Statement *stmt = node->statementCast();
+ QQmlJS::AST::Statement *stmt = node->statementCast();
if (!stmt) {
Q_ASSERT(node->expressionCast());
- AST::ExpressionNode *expr = node->expressionCast();
- stmt = new (pool) AST::ExpressionStatement(expr);
+ QQmlJS::AST::ExpressionNode *expr = node->expressionCast();
+ stmt = new (pool) QQmlJS::AST::ExpressionStatement(expr);
}
- AST::SourceElement *element = new (pool) AST::StatementSourceElement(stmt);
- body = new (pool) AST::SourceElements(element);
+ QQmlJS::AST::SourceElement *element = new (pool) QQmlJS::AST::StatementSourceElement(stmt);
+ body = new (pool) QQmlJS::AST::SourceElements(element);
body = body->finish();
}
return pd;
}
-static void initMetaObjectResolver(V4IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject);
+static void initMetaObjectResolver(IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject);
enum MetaObjectResolverFlags {
AllPropertiesAreFinal = 0x1,
ResolveTypeInformationOnly = 0x8
};
-static void initMetaObjectResolver(V4IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject);
+static void initMetaObjectResolver(IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject);
-static V4IR::Type resolveQmlType(QQmlEnginePrivate *qmlEngine, V4IR::MemberExpressionResolver *resolver, V4IR::Member *member)
+static IR::Type resolveQmlType(QQmlEnginePrivate *qmlEngine, IR::MemberExpressionResolver *resolver, IR::Member *member)
{
- V4IR::Type result = V4IR::VarType;
+ IR::Type result = IR::VarType;
QQmlType *type = static_cast<QQmlType*>(resolver->data);
if (ok) {
member->setEnumValue(value);
resolver->clear();
- return V4IR::SInt32Type;
+ return IR::SInt32Type;
}
}
return result;
}
-static void initQmlTypeResolver(V4IR::MemberExpressionResolver *resolver, QQmlType *qmlType)
+static void initQmlTypeResolver(IR::MemberExpressionResolver *resolver, QQmlType *qmlType)
{
resolver->resolveMember = &resolveQmlType;
resolver->data = qmlType;
resolver->flags = 0;
}
-static V4IR::Type resolveImportNamespace(QQmlEnginePrivate *, V4IR::MemberExpressionResolver *resolver, V4IR::Member *member)
+static IR::Type resolveImportNamespace(QQmlEnginePrivate *, IR::MemberExpressionResolver *resolver, IR::Member *member)
{
- V4IR::Type result = V4IR::VarType;
+ IR::Type result = IR::VarType;
QQmlTypeNameCache *typeNamespace = static_cast<QQmlTypeNameCache*>(resolver->extraData);
void *importNamespace = resolver->data;
member->freeOfSideEffects = true;
if (r.scriptIndex != -1) {
// TODO: remember the index and replace with subscript later.
- result = V4IR::VarType;
+ result = IR::VarType;
} else if (r.type) {
// TODO: Propagate singleton information, so that it is loaded
// through the singleton getter in the run-time. Until then we
// can't accelerate access :(
if (!r.type->isSingleton()) {
initQmlTypeResolver(resolver, r.type);
- return V4IR::QObjectType;
+ return IR::QObjectType;
}
} else {
Q_ASSERT(false); // How can this happen?
return result;
}
-static void initImportNamespaceResolver(V4IR::MemberExpressionResolver *resolver, QQmlTypeNameCache *imports, const void *importNamespace)
+static void initImportNamespaceResolver(IR::MemberExpressionResolver *resolver, QQmlTypeNameCache *imports, const void *importNamespace)
{
resolver->resolveMember = &resolveImportNamespace;
resolver->data = const_cast<void*>(importNamespace);
resolver->flags = 0;
}
-static V4IR::Type resolveMetaObjectProperty(QQmlEnginePrivate *qmlEngine, V4IR::MemberExpressionResolver *resolver, V4IR::Member *member)
+static IR::Type resolveMetaObjectProperty(QQmlEnginePrivate *qmlEngine, IR::MemberExpressionResolver *resolver, IR::Member *member)
{
- V4IR::Type result = V4IR::VarType;
+ IR::Type result = IR::VarType;
QQmlPropertyCache *metaObject = static_cast<QQmlPropertyCache*>(resolver->data);
if (member->name->constData()->isUpper() && (resolver->flags & LookupsIncludeEnums)) {
if (ok) {
member->setEnumValue(value);
resolver->clear();
- return V4IR::SInt32Type;
+ return IR::SInt32Type;
}
}
}
// Enums cannot be mapped to IR types, they need to go through the run-time handling
// of accepting strings that will then be converted to the right values.
if (property->isEnum())
- return V4IR::VarType;
+ return IR::VarType;
switch (property->propType) {
- case QMetaType::Bool: result = V4IR::BoolType; break;
- case QMetaType::Int: result = V4IR::SInt32Type; break;
- case QMetaType::Double: result = V4IR::DoubleType; break;
- case QMetaType::QString: result = V4IR::StringType; break;
+ case QMetaType::Bool: result = IR::BoolType; break;
+ case QMetaType::Int: result = IR::SInt32Type; break;
+ case QMetaType::Double: result = IR::DoubleType; break;
+ case QMetaType::QString: result = IR::StringType; break;
default:
if (property->isQObject()) {
if (QQmlPropertyCache *cache = qmlEngine->propertyCacheForType(property->propType)) {
initMetaObjectResolver(resolver, cache);
- return V4IR::QObjectType;
+ return IR::QObjectType;
}
} else if (QQmlValueType *valueType = QQmlValueTypeFactory::valueType(property->propType)) {
if (QQmlPropertyCache *cache = qmlEngine->cache(valueType->metaObject())) {
initMetaObjectResolver(resolver, cache);
resolver->flags |= ResolveTypeInformationOnly;
- return V4IR::QObjectType;
+ return IR::QObjectType;
}
}
break;
return result;
}
-static void initMetaObjectResolver(V4IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject)
+static void initMetaObjectResolver(IR::MemberExpressionResolver *resolver, QQmlPropertyCache *metaObject)
{
resolver->resolveMember = &resolveMetaObjectProperty;
resolver->data = metaObject;
_importedScriptsTemp = _block->newTemp();
_idArrayTemp = _block->newTemp();
- V4IR::Temp *temp = _block->TEMP(_contextObjectTemp);
+ IR::Temp *temp = _block->TEMP(_contextObjectTemp);
initMetaObjectResolver(&temp->memberResolver, _contextObject);
- move(temp, _block->NAME(V4IR::Name::builtin_qml_context_object, 0, 0));
+ move(temp, _block->NAME(IR::Name::builtin_qml_context_object, 0, 0));
temp = _block->TEMP(_scopeObjectTemp);
initMetaObjectResolver(&temp->memberResolver, _scopeObject);
- move(temp, _block->NAME(V4IR::Name::builtin_qml_scope_object, 0, 0));
+ move(temp, _block->NAME(IR::Name::builtin_qml_scope_object, 0, 0));
- move(_block->TEMP(_importedScriptsTemp), _block->NAME(V4IR::Name::builtin_qml_imported_scripts_object, 0, 0));
- move(_block->TEMP(_idArrayTemp), _block->NAME(V4IR::Name::builtin_qml_id_array, 0, 0));
+ move(_block->TEMP(_importedScriptsTemp), _block->NAME(IR::Name::builtin_qml_imported_scripts_object, 0, 0));
+ move(_block->TEMP(_idArrayTemp), _block->NAME(IR::Name::builtin_qml_id_array, 0, 0));
}
-V4IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int col)
+IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int col)
{
if (_disableAcceleratedLookups)
return 0;
foreach (const IdMapping &mapping, _idObjects)
if (name == mapping.name) {
_function->idObjectDependencies.insert(mapping.idIndex);
- V4IR::Expr *s = subscript(_block->TEMP(_idArrayTemp), _block->CONST(V4IR::SInt32Type, mapping.idIndex));
- V4IR::Temp *result = _block->TEMP(_block->newTemp());
+ IR::Expr *s = subscript(_block->TEMP(_idArrayTemp), _block->CONST(IR::SInt32Type, mapping.idIndex));
+ IR::Temp *result = _block->TEMP(_block->newTemp());
_block->MOVE(result, s);
result = _block->TEMP(result->index);
if (mapping.type) {
QQmlTypeNameCache::Result r = imports->query(name);
if (r.isValid()) {
if (r.scriptIndex != -1) {
- return subscript(_block->TEMP(_importedScriptsTemp), _block->CONST(V4IR::SInt32Type, r.scriptIndex));
+ return subscript(_block->TEMP(_importedScriptsTemp), _block->CONST(IR::SInt32Type, r.scriptIndex));
} else if (r.type) {
- V4IR::Name *typeName = _block->NAME(name, line, col);
+ IR::Name *typeName = _block->NAME(name, line, col);
// Make sure the run-time loads this through the more efficient singleton getter.
typeName->qmlSingleton = r.type->isCompositeSingleton();
typeName->freeOfSideEffects = true;
- V4IR::Temp *result = _block->TEMP(_block->newTemp());
+ IR::Temp *result = _block->TEMP(_block->newTemp());
_block->MOVE(result, typeName);
result = _block->TEMP(result->index);
return result;
} else {
Q_ASSERT(r.importNamespace);
- V4IR::Name *namespaceName = _block->NAME(name, line, col);
+ IR::Name *namespaceName = _block->NAME(name, line, col);
namespaceName->freeOfSideEffects = true;
- V4IR::Temp *result = _block->TEMP(_block->newTemp());
+ IR::Temp *result = _block->TEMP(_block->newTemp());
initImportNamespaceResolver(&result->memberResolver, imports, r.importNamespace);
_block->MOVE(result, namespaceName);
if (propertyExistsButForceNameLookup)
return 0;
if (pd) {
- V4IR::Temp *base = _block->TEMP(_scopeObjectTemp);
+ IR::Temp *base = _block->TEMP(_scopeObjectTemp);
initMetaObjectResolver(&base->memberResolver, _scopeObject);
- return _block->MEMBER(base, _function->newString(name), pd, V4IR::Member::MemberOfQmlScopeObject);
+ return _block->MEMBER(base, _function->newString(name), pd, IR::Member::MemberOfQmlScopeObject);
}
}
if (propertyExistsButForceNameLookup)
return 0;
if (pd) {
- V4IR::Temp *base = _block->TEMP(_contextObjectTemp);
+ IR::Temp *base = _block->TEMP(_contextObjectTemp);
initMetaObjectResolver(&base->memberResolver, _contextObject);
- return _block->MEMBER(base, _function->newString(name), pd, V4IR::Member::MemberOfQmlContextObject);
+ return _block->MEMBER(base, _function->newString(name), pd, IR::Member::MemberOfQmlContextObject);
}
}
QQmlJS::Engine &jsEngine = parsedQML->jsParserEngine;
QQmlJS::MemoryPool *pool = jsEngine.pool();
- AST::FormalParameterList *paramList = 0;
+ QQmlJS::AST::FormalParameterList *paramList = 0;
foreach (const QString ¶m, parameters) {
QStringRef paramNameRef = jsEngine.newStringRef(param);
if (paramList)
- paramList = new (pool) AST::FormalParameterList(paramList, paramNameRef);
+ paramList = new (pool) QQmlJS::AST::FormalParameterList(paramList, paramNameRef);
else
- paramList = new (pool) AST::FormalParameterList(paramNameRef);
+ paramList = new (pool) QQmlJS::AST::FormalParameterList(paramNameRef);
}
if (paramList)
paramList = paramList->finish();
- AST::Statement *statement = static_cast<AST::Statement*>(parsedQML->functions[binding->value.compiledScriptIndex].node);
- AST::SourceElement *sourceElement = new (pool) AST::StatementSourceElement(statement);
- AST::SourceElements *elements = new (pool) AST::SourceElements(sourceElement);
+ QQmlJS::AST::Statement *statement = static_cast<QQmlJS::AST::Statement*>(parsedQML->functions[binding->value.compiledScriptIndex].node);
+ QQmlJS::AST::SourceElement *sourceElement = new (pool) QQmlJS::AST::StatementSourceElement(statement);
+ QQmlJS::AST::SourceElements *elements = new (pool) QQmlJS::AST::SourceElements(sourceElement);
elements = elements->finish();
- AST::FunctionBody *body = new (pool) AST::FunctionBody(elements);
+ QQmlJS::AST::FunctionBody *body = new (pool) QQmlJS::AST::FunctionBody(elements);
- AST::FunctionDeclaration *functionDeclaration = new (pool) AST::FunctionDeclaration(jsEngine.newStringRef(propertyName), paramList, body);
+ QQmlJS::AST::FunctionDeclaration *functionDeclaration = new (pool) QQmlJS::AST::FunctionDeclaration(jsEngine.newStringRef(propertyName), paramList, body);
parsedQML->functions[binding->value.compiledScriptIndex] = functionDeclaration;
binding->flags |= QV4::CompiledData::Binding::IsSignalHandlerExpression;
namespace QtQml {
-using namespace QQmlJS;
+using namespace QV4;
struct DebugStream
{
struct Function
{
- AST::FunctionDeclaration *functionDeclaration;
+ QQmlJS::AST::FunctionDeclaration *functionDeclaration;
QV4::CompiledData::Location location;
int nameIndex;
int index; // index in parsedQML::functions
: node(0)
, disableAcceleratedLookups(false)
{}
- CompiledFunctionOrExpression(AST::Node *n)
+ CompiledFunctionOrExpression(QQmlJS::AST::Node *n)
: node(n)
, disableAcceleratedLookups(false)
{}
- AST::Node *node; // FunctionDeclaration, Statement or Expression
+ QQmlJS::AST::Node *node; // FunctionDeclaration, Statement or Expression
QString name;
bool disableAcceleratedLookups;
};
// specified object. Used for declarations inside group properties.
QmlObject *declarationsOverride;
- void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int id, const AST::SourceLocation &location = AST::SourceLocation());
+ void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int id, const QQmlJS::AST::SourceLocation &location = QQmlJS::AST::SourceLocation());
void dump(DebugStream &out);
- QString sanityCheckFunctionNames(const QList<CompiledFunctionOrExpression> &allFunctions, const QSet<QString> &illegalNames, AST::SourceLocation *errorLocation);
+ QString sanityCheckFunctionNames(const QList<CompiledFunctionOrExpression> &allFunctions, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation);
QString appendSignal(Signal *signal);
- QString appendProperty(QmlProperty *prop, const QString &propertyName, bool isDefaultProperty, const AST::SourceLocation &defaultToken, AST::SourceLocation *errorLocation);
- void appendFunction(Function *f);
+ QString appendProperty(QmlProperty *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation);
+ void appendFunction(QtQml::Function *f);
QString appendBinding(Binding *b, bool isListBinding);
{}
QString code;
QQmlJS::Engine jsParserEngine;
- V4IR::Module jsModule;
+ QV4::IR::Module jsModule;
QList<QV4::CompiledData::Import*> imports;
QList<Pragma*> pragmas;
- AST::UiProgram *program;
+ QQmlJS::AST::UiProgram *program;
int indexOfRootObject;
QList<QmlObject*> objects;
QList<CompiledFunctionOrExpression> functions;
};
// Doesn't really generate code per-se, but more the data structure
-struct Q_QML_EXPORT QQmlCodeGenerator : public AST::Visitor
+struct Q_QML_EXPORT QQmlCodeGenerator : public QQmlJS::AST::Visitor
{
Q_DECLARE_TR_FUNCTIONS(QQmlCodeGenerator)
public:
static bool isSignalPropertyName(const QString &name);
- using AST::Visitor::visit;
- using AST::Visitor::endVisit;
-
- virtual bool visit(AST::UiArrayMemberList *ast);
- virtual bool visit(AST::UiImport *ast);
- virtual bool visit(AST::UiPragma *ast);
- virtual bool visit(AST::UiHeaderItemList *ast);
- virtual bool visit(AST::UiObjectInitializer *ast);
- virtual bool visit(AST::UiObjectMemberList *ast);
- virtual bool visit(AST::UiParameterList *ast);
- virtual bool visit(AST::UiProgram *);
- virtual bool visit(AST::UiQualifiedId *ast);
- virtual bool visit(AST::UiArrayBinding *ast);
- virtual bool visit(AST::UiObjectBinding *ast);
- virtual bool visit(AST::UiObjectDefinition *ast);
- virtual bool visit(AST::UiPublicMember *ast);
- virtual bool visit(AST::UiScriptBinding *ast);
- virtual bool visit(AST::UiSourceElement *ast);
-
- void accept(AST::Node *node);
+ using QQmlJS::AST::Visitor::visit;
+ using QQmlJS::AST::Visitor::endVisit;
+
+ virtual bool visit(QQmlJS::AST::UiArrayMemberList *ast);
+ virtual bool visit(QQmlJS::AST::UiImport *ast);
+ virtual bool visit(QQmlJS::AST::UiPragma *ast);
+ virtual bool visit(QQmlJS::AST::UiHeaderItemList *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectInitializer *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectMemberList *ast);
+ virtual bool visit(QQmlJS::AST::UiParameterList *ast);
+ virtual bool visit(QQmlJS::AST::UiProgram *);
+ virtual bool visit(QQmlJS::AST::UiQualifiedId *ast);
+ virtual bool visit(QQmlJS::AST::UiArrayBinding *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectBinding *ast);
+ virtual bool visit(QQmlJS::AST::UiObjectDefinition *ast);
+ virtual bool visit(QQmlJS::AST::UiPublicMember *ast);
+ virtual bool visit(QQmlJS::AST::UiScriptBinding *ast);
+ virtual bool visit(QQmlJS::AST::UiSourceElement *ast);
+
+ void accept(QQmlJS::AST::Node *node);
// returns index in _objects
- int defineQMLObject(AST::UiQualifiedId *qualifiedTypeNameId, const AST::SourceLocation &location, AST::UiObjectInitializer *initializer, QmlObject *declarationsOverride = 0);
- int defineQMLObject(AST::UiObjectDefinition *node, QmlObject *declarationsOverride = 0)
+ int defineQMLObject(QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, QmlObject *declarationsOverride = 0);
+ int defineQMLObject(QQmlJS::AST::UiObjectDefinition *node, QmlObject *declarationsOverride = 0)
{ return defineQMLObject(node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer, declarationsOverride); }
- static QString asString(AST::UiQualifiedId *node);
- QStringRef asStringRef(AST::Node *node);
+ static QString asString(QQmlJS::AST::UiQualifiedId *node);
+ QStringRef asStringRef(QQmlJS::AST::Node *node);
static void extractVersion(QStringRef string, int *maj, int *min);
- QStringRef textRefAt(const AST::SourceLocation &loc) const
+ QStringRef textRefAt(const QQmlJS::AST::SourceLocation &loc) const
{ return QStringRef(&sourceCode, loc.offset, loc.length); }
- QStringRef textRefAt(const AST::SourceLocation &first,
- const AST::SourceLocation &last) const;
- static QQmlScript::LocationSpan location(AST::UiQualifiedId *id)
+ QStringRef textRefAt(const QQmlJS::AST::SourceLocation &first,
+ const QQmlJS::AST::SourceLocation &last) const;
+ static QQmlScript::LocationSpan location(QQmlJS::AST::UiQualifiedId *id)
{
return location(id->identifierToken, id->identifierToken);
}
- void setBindingValue(QV4::CompiledData::Binding *binding, AST::Statement *statement);
+ void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement);
- void appendBinding(AST::UiQualifiedId *name, AST::Statement *value);
- void appendBinding(AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false);
- void appendBinding(const AST::SourceLocation &nameLocation, quint32 propertyNameIndex, AST::Statement *value);
- void appendBinding(const AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem = false, bool isOnAssignment = false);
+ void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value);
+ void appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false);
+ void appendBinding(const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value);
+ void appendBinding(const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem = false, bool isOnAssignment = false);
QmlObject *bindingsTarget() const;
- bool setId(const AST::SourceLocation &idLocation, AST::Statement *value);
+ bool setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value);
// resolves qualified name (font.pixelSize for example) and returns the last name along
// with the object any right-hand-side of a binding should apply to.
- bool resolveQualifiedId(AST::UiQualifiedId **nameToResolve, QmlObject **object);
+ bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, QmlObject **object);
- void recordError(const AST::SourceLocation &location, const QString &description);
+ void recordError(const QQmlJS::AST::SourceLocation &location, const QString &description);
void collectTypeReferences();
- static QQmlScript::LocationSpan location(AST::SourceLocation start, AST::SourceLocation end);
+ static QQmlScript::LocationSpan location(QQmlJS::AST::SourceLocation start, QQmlJS::AST::SourceLocation end);
quint32 registerString(const QString &str) const { return jsGenerator->registerString(str); }
template <typename _Tp> _Tp *New() { return pool->New<_Tp>(); }
QString stringAt(int index) const { return jsGenerator->strings.at(index); }
- static bool isStatementNodeScript(AST::Statement *statement);
+ static bool isStatementNodeScript(QQmlJS::AST::Statement *statement);
QList<QQmlError> errors;
struct Q_QML_EXPORT JSCodeGen : public QQmlJS::Codegen
{
- JSCodeGen(const QString &fileName, const QString &sourceCode, V4IR::Module *jsModule,
- QQmlJS::Engine *jsEngine, AST::UiProgram *qmlRoot, QQmlTypeNameCache *imports);
+ JSCodeGen(const QString &fileName, const QString &sourceCode, IR::Module *jsModule,
+ QQmlJS::Engine *jsEngine, QQmlJS::AST::UiProgram *qmlRoot, QQmlTypeNameCache *imports);
struct IdMapping
{
void beginContextScope(const ObjectIdMapping &objectIds, QQmlPropertyCache *contextObject);
void beginObjectScope(QQmlPropertyCache *scopeObject);
- // Returns mapping from input functions to index in V4IR::Module::functions / compiledData->runtimeFunctions
+ // Returns mapping from input functions to index in IR::Module::functions / compiledData->runtimeFunctions
QVector<int> generateJSCodeForFunctionsAndBindings(const QList<CompiledFunctionOrExpression> &functions);
protected:
virtual void beginFunctionBodyHook();
- virtual V4IR::Expr *fallbackNameLookup(const QString &name, int line, int col);
+ virtual IR::Expr *fallbackNameLookup(const QString &name, int line, int col);
private:
QQmlPropertyData *lookupQmlCompliantProperty(QQmlPropertyCache *cache, const QString &name, bool *propertyExistsButForceNameLookup = 0);
QString sourceCode;
QQmlJS::Engine *jsEngine; // needed for memory pool
- AST::UiProgram *qmlRoot;
+ QQmlJS::AST::UiProgram *qmlRoot;
QQmlTypeNameCache *imports;
bool _disableAcceleratedLookups;
QV4::ExecutionEngine *v4 = engine->v4engine();
- QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(engine, v4->executableAllocator, &parsedQML->jsModule, &parsedQML->jsGenerator));
+ QScopedPointer<EvalInstructionSelection> isel(v4->iselFactory->create(engine, v4->executableAllocator, &parsedQML->jsModule, &parsedQML->jsGenerator));
isel->setUseFastLookups(false);
QV4::CompiledData::CompilationUnit *jsUnit = isel->compile(/*generated unit data*/false);
return &compiledData->customParserData;
}
-MemoryPool *QQmlTypeCompiler::memoryPool()
+QQmlJS::MemoryPool *QQmlTypeCompiler::memoryPool()
{
return parsedQML->jsParserEngine.pool();
}
// Dynamic slots
for (const QtQml::Function *s = obj->firstFunction(); s; s = s->next) {
- AST::FunctionDeclaration *astFunction = s->functionDeclaration;
+ QQmlJS::AST::FunctionDeclaration *astFunction = s->functionDeclaration;
quint32 flags = QQmlPropertyData::IsFunction | QQmlPropertyData::IsVMEFunction;
// protect against overriding change signals or methods with properties.
QList<QByteArray> parameterNames;
- AST::FormalParameterList *param = astFunction->formals;
+ QQmlJS::AST::FormalParameterList *param = astFunction->formals;
while (param) {
parameterNames << param->name.toUtf8();
param = param->next;
// Dynamic slot data - comes after the property data
for (const QtQml::Function *s = obj->firstFunction(); s; s = s->next) {
- AST::FunctionDeclaration *astFunction = s->functionDeclaration;
+ QQmlJS::AST::FunctionDeclaration *astFunction = s->functionDeclaration;
int formalsCount = 0;
- AST::FormalParameterList *param = astFunction->formals;
+ QQmlJS::AST::FormalParameterList *param = astFunction->formals;
while (param) {
formalsCount++;
param = param->next;
return *compiler->imports();
}
-AST::Node *QQmlPropertyValidator::astForBinding(int scriptIndex) const
+QQmlJS::AST::Node *QQmlPropertyValidator::astForBinding(int scriptIndex) const
{
// ####
int reverseIndex = runtimeFunctionIndices.indexOf(scriptIndex);
#undef CONST
#endif
+using namespace QV4;
using namespace QQmlJS;
using namespace AST;
void Codegen::generateFromProgram(const QString &fileName,
const QString &sourceCode,
Program *node,
- V4IR::Module *module,
+ QV4::IR::Module *module,
CompilationMode mode,
const QStringList &inheritedLocals)
{
void Codegen::generateFromFunctionExpression(const QString &fileName,
const QString &sourceCode,
AST::FunctionExpression *ast,
- V4IR::Module *module)
+ QV4::IR::Module *module)
{
_module = module;
_module->setFileName(fileName);
_env = _env->parent;
}
-void Codegen::enterLoop(Statement *node, V4IR::BasicBlock *startBlock, V4IR::BasicBlock *breakBlock, V4IR::BasicBlock *continueBlock)
+void Codegen::enterLoop(Statement *node, IR::BasicBlock *startBlock, IR::BasicBlock *breakBlock, IR::BasicBlock *continueBlock)
{
if (startBlock)
startBlock->markAsGroupStart();
delete current;
}
-V4IR::Expr *Codegen::member(V4IR::Expr *base, const QString *name)
+IR::Expr *Codegen::member(IR::Expr *base, const QString *name)
{
if (hasError)
return 0;
}
}
-V4IR::Expr *Codegen::subscript(V4IR::Expr *base, V4IR::Expr *index)
+IR::Expr *Codegen::subscript(IR::Expr *base, IR::Expr *index)
{
if (hasError)
return 0;
return _block->SUBSCRIPT(base->asTemp(), index->asTemp());
}
-V4IR::Expr *Codegen::argument(V4IR::Expr *expr)
+IR::Expr *Codegen::argument(IR::Expr *expr)
{
if (expr && ! expr->asTemp()) {
const unsigned t = _block->newTemp();
}
// keeps references alive, converts other expressions to temps
-V4IR::Expr *Codegen::reference(V4IR::Expr *expr)
+IR::Expr *Codegen::reference(IR::Expr *expr)
{
if (hasError)
return 0;
return expr;
}
-V4IR::Expr *Codegen::unop(V4IR::AluOp op, V4IR::Expr *expr)
+IR::Expr *Codegen::unop(IR::AluOp op, IR::Expr *expr)
{
if (hasError)
return 0;
- Q_ASSERT(op != V4IR::OpIncrement);
- Q_ASSERT(op != V4IR::OpDecrement);
+ Q_ASSERT(op != IR::OpIncrement);
+ Q_ASSERT(op != IR::OpDecrement);
- if (V4IR::Const *c = expr->asConst()) {
- if (c->type == V4IR::NumberType) {
+ if (IR::Const *c = expr->asConst()) {
+ if (c->type == IR::NumberType) {
switch (op) {
- case V4IR::OpNot:
- return _block->CONST(V4IR::BoolType, !c->value);
- case V4IR::OpUMinus:
- return _block->CONST(V4IR::NumberType, -c->value);
- case V4IR::OpUPlus:
+ case IR::OpNot:
+ return _block->CONST(IR::BoolType, !c->value);
+ case IR::OpUMinus:
+ return _block->CONST(IR::NumberType, -c->value);
+ case IR::OpUPlus:
return expr;
- case V4IR::OpCompl:
- return _block->CONST(V4IR::NumberType, ~QV4::Primitive::toInt32(c->value));
- case V4IR::OpIncrement:
- return _block->CONST(V4IR::NumberType, c->value + 1);
- case V4IR::OpDecrement:
- return _block->CONST(V4IR::NumberType, c->value - 1);
+ case IR::OpCompl:
+ return _block->CONST(IR::NumberType, ~QV4::Primitive::toInt32(c->value));
+ case IR::OpIncrement:
+ return _block->CONST(IR::NumberType, c->value + 1);
+ case IR::OpDecrement:
+ return _block->CONST(IR::NumberType, c->value - 1);
default:
break;
}
return _block->UNOP(op, expr->asTemp());
}
-V4IR::Expr *Codegen::binop(V4IR::AluOp op, V4IR::Expr *left, V4IR::Expr *right)
+IR::Expr *Codegen::binop(IR::AluOp op, IR::Expr *left, IR::Expr *right)
{
if (hasError)
return 0;
- if (V4IR::Const *c1 = left->asConst()) {
- if (V4IR::Const *c2 = right->asConst()) {
- if (c1->type == V4IR::NumberType && c2->type == V4IR::NumberType) {
+ if (IR::Const *c1 = left->asConst()) {
+ if (IR::Const *c2 = right->asConst()) {
+ if (c1->type == IR::NumberType && c2->type == IR::NumberType) {
switch (op) {
- case V4IR::OpAdd: return _block->CONST(V4IR::NumberType, c1->value + c2->value);
- case V4IR::OpAnd: return _block->CONST(V4IR::BoolType, c1->value ? c2->value : 0);
- case V4IR::OpBitAnd: return _block->CONST(V4IR::NumberType, int(c1->value) & int(c2->value));
- case V4IR::OpBitOr: return _block->CONST(V4IR::NumberType, int(c1->value) | int(c2->value));
- case V4IR::OpBitXor: return _block->CONST(V4IR::NumberType, int(c1->value) ^ int(c2->value));
- case V4IR::OpDiv: return _block->CONST(V4IR::NumberType, c1->value / c2->value);
- case V4IR::OpEqual: return _block->CONST(V4IR::BoolType, c1->value == c2->value);
- case V4IR::OpNotEqual: return _block->CONST(V4IR::BoolType, c1->value != c2->value);
- case V4IR::OpStrictEqual: return _block->CONST(V4IR::BoolType, c1->value == c2->value);
- case V4IR::OpStrictNotEqual: return _block->CONST(V4IR::BoolType, c1->value != c2->value);
- case V4IR::OpGe: return _block->CONST(V4IR::BoolType, c1->value >= c2->value);
- case V4IR::OpGt: return _block->CONST(V4IR::BoolType, c1->value > c2->value);
- case V4IR::OpLe: return _block->CONST(V4IR::BoolType, c1->value <= c2->value);
- case V4IR::OpLt: return _block->CONST(V4IR::BoolType, c1->value < c2->value);
- case V4IR::OpLShift: return _block->CONST(V4IR::NumberType, QV4::Primitive::toInt32(c1->value) << (QV4::Primitive::toUInt32(c2->value) & 0x1f));
- case V4IR::OpMod: return _block->CONST(V4IR::NumberType, std::fmod(c1->value, c2->value));
- case V4IR::OpMul: return _block->CONST(V4IR::NumberType, c1->value * c2->value);
- case V4IR::OpOr: return _block->CONST(V4IR::NumberType, c1->value ? c1->value : c2->value);
- case V4IR::OpRShift: return _block->CONST(V4IR::NumberType, QV4::Primitive::toInt32(c1->value) >> (QV4::Primitive::toUInt32(c2->value) & 0x1f));
- case V4IR::OpSub: return _block->CONST(V4IR::NumberType, c1->value - c2->value);
- case V4IR::OpURShift: return _block->CONST(V4IR::NumberType,QV4::Primitive::toUInt32(c1->value) >> (QV4::Primitive::toUInt32(c2->value) & 0x1f));
-
- case V4IR::OpInstanceof:
- case V4IR::OpIn:
+ case IR::OpAdd: return _block->CONST(IR::NumberType, c1->value + c2->value);
+ case IR::OpAnd: return _block->CONST(IR::BoolType, c1->value ? c2->value : 0);
+ case IR::OpBitAnd: return _block->CONST(IR::NumberType, int(c1->value) & int(c2->value));
+ case IR::OpBitOr: return _block->CONST(IR::NumberType, int(c1->value) | int(c2->value));
+ case IR::OpBitXor: return _block->CONST(IR::NumberType, int(c1->value) ^ int(c2->value));
+ case IR::OpDiv: return _block->CONST(IR::NumberType, c1->value / c2->value);
+ case IR::OpEqual: return _block->CONST(IR::BoolType, c1->value == c2->value);
+ case IR::OpNotEqual: return _block->CONST(IR::BoolType, c1->value != c2->value);
+ case IR::OpStrictEqual: return _block->CONST(IR::BoolType, c1->value == c2->value);
+ case IR::OpStrictNotEqual: return _block->CONST(IR::BoolType, c1->value != c2->value);
+ case IR::OpGe: return _block->CONST(IR::BoolType, c1->value >= c2->value);
+ case IR::OpGt: return _block->CONST(IR::BoolType, c1->value > c2->value);
+ case IR::OpLe: return _block->CONST(IR::BoolType, c1->value <= c2->value);
+ case IR::OpLt: return _block->CONST(IR::BoolType, c1->value < c2->value);
+ case IR::OpLShift: return _block->CONST(IR::NumberType, QV4::Primitive::toInt32(c1->value) << (QV4::Primitive::toUInt32(c2->value) & 0x1f));
+ case IR::OpMod: return _block->CONST(IR::NumberType, std::fmod(c1->value, c2->value));
+ case IR::OpMul: return _block->CONST(IR::NumberType, c1->value * c2->value);
+ case IR::OpOr: return _block->CONST(IR::NumberType, c1->value ? c1->value : c2->value);
+ case IR::OpRShift: return _block->CONST(IR::NumberType, QV4::Primitive::toInt32(c1->value) >> (QV4::Primitive::toUInt32(c2->value) & 0x1f));
+ case IR::OpSub: return _block->CONST(IR::NumberType, c1->value - c2->value);
+ case IR::OpURShift: return _block->CONST(IR::NumberType,QV4::Primitive::toUInt32(c1->value) >> (QV4::Primitive::toUInt32(c2->value) & 0x1f));
+
+ case IR::OpInstanceof:
+ case IR::OpIn:
break;
- case V4IR::OpIfTrue: // unary ops
- case V4IR::OpNot:
- case V4IR::OpUMinus:
- case V4IR::OpUPlus:
- case V4IR::OpCompl:
- case V4IR::OpIncrement:
- case V4IR::OpDecrement:
- case V4IR::OpInvalid:
+ case IR::OpIfTrue: // unary ops
+ case IR::OpNot:
+ case IR::OpUMinus:
+ case IR::OpUPlus:
+ case IR::OpCompl:
+ case IR::OpIncrement:
+ case IR::OpDecrement:
+ case IR::OpInvalid:
break;
}
}
}
- } else if (op == V4IR::OpAdd) {
- if (V4IR::String *s1 = left->asString()) {
- if (V4IR::String *s2 = right->asString()) {
+ } else if (op == IR::OpAdd) {
+ if (IR::String *s1 = left->asString()) {
+ if (IR::String *s2 = right->asString()) {
return _block->STRING(_function->newString(*s1->value + *s2->value));
}
}
return _block->BINOP(op, left, right);
}
-V4IR::Expr *Codegen::call(V4IR::Expr *base, V4IR::ExprList *args)
+IR::Expr *Codegen::call(IR::Expr *base, IR::ExprList *args)
{
if (hasError)
return 0;
return _block->CALL(base, args);
}
-void Codegen::move(V4IR::Expr *target, V4IR::Expr *source, V4IR::AluOp op)
+void Codegen::move(IR::Expr *target, IR::Expr *source, IR::AluOp op)
{
if (hasError)
return;
Q_ASSERT(target->isLValue());
- if (op != V4IR::OpInvalid) {
+ if (op != IR::OpInvalid) {
move(target, binop(op, target, source));
return;
}
_block->MOVE(target, source);
}
-void Codegen::cjump(V4IR::Expr *cond, V4IR::BasicBlock *iftrue, V4IR::BasicBlock *iffalse)
+void Codegen::cjump(IR::Expr *cond, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
{
if (hasError)
return;
}
}
-void Codegen::condition(ExpressionNode *ast, V4IR::BasicBlock *iftrue, V4IR::BasicBlock *iffalse)
+void Codegen::condition(ExpressionNode *ast, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
{
if (ast) {
Result r(iftrue, iffalse);
void Codegen::variableDeclaration(VariableDeclaration *ast)
{
- V4IR::Expr *initializer = 0;
+ IR::Expr *initializer = 0;
if (!ast->expression)
return;
Result expr = expression(ast->expression);
if (hasError)
return false;
- V4IR::ExprList *args = 0;
- V4IR::ExprList *current = 0;
+ IR::ExprList *args = 0;
+ IR::ExprList *current = 0;
for (ElementList *it = ast->elements; it; it = it->next) {
for (Elision *elision = it->elision; elision; elision = elision->next) {
- V4IR::ExprList *arg = _function->New<V4IR::ExprList>();
+ IR::ExprList *arg = _function->New<IR::ExprList>();
if (!current) {
args = arg;
} else {
current->next = arg;
}
current = arg;
- current->expr = _block->CONST(V4IR::MissingType, 0);
+ current->expr = _block->CONST(IR::MissingType, 0);
}
Result expr = expression(it->expression);
- V4IR::ExprList *arg = _function->New<V4IR::ExprList>();
+ IR::ExprList *arg = _function->New<IR::ExprList>();
if (!current) {
args = arg;
} else {
}
current = arg;
- V4IR::Expr *exp = *expr;
+ IR::Expr *exp = *expr;
if (exp->asTemp() || exp->asConst()) {
current->expr = exp;
} else {
}
}
for (Elision *elision = ast->elision; elision; elision = elision->next) {
- V4IR::ExprList *arg = _function->New<V4IR::ExprList>();
+ IR::ExprList *arg = _function->New<IR::ExprList>();
if (!current) {
args = arg;
} else {
current->next = arg;
}
current = arg;
- current->expr = _block->CONST(V4IR::MissingType, 0);
+ current->expr = _block->CONST(IR::MissingType, 0);
}
const unsigned t = _block->newTemp();
- move(_block->TEMP(t), _block->CALL(_block->NAME(V4IR::Name::builtin_define_array, 0, 0), args));
+ move(_block->TEMP(t), _block->CALL(_block->NAME(IR::Name::builtin_define_array, 0, 0), args));
_expr.code = _block->TEMP(t);
return false;
}
return false;
}
-static V4IR::AluOp baseOp(int op)
+static IR::AluOp baseOp(int op)
{
switch ((QSOperator::Op) op) {
- case QSOperator::InplaceAnd: return V4IR::OpBitAnd;
- case QSOperator::InplaceSub: return V4IR::OpSub;
- case QSOperator::InplaceDiv: return V4IR::OpDiv;
- case QSOperator::InplaceAdd: return V4IR::OpAdd;
- case QSOperator::InplaceLeftShift: return V4IR::OpLShift;
- case QSOperator::InplaceMod: return V4IR::OpMod;
- case QSOperator::InplaceMul: return V4IR::OpMul;
- case QSOperator::InplaceOr: return V4IR::OpBitOr;
- case QSOperator::InplaceRightShift: return V4IR::OpRShift;
- case QSOperator::InplaceURightShift: return V4IR::OpURShift;
- case QSOperator::InplaceXor: return V4IR::OpBitXor;
- default: return V4IR::OpInvalid;
+ case QSOperator::InplaceAnd: return IR::OpBitAnd;
+ case QSOperator::InplaceSub: return IR::OpSub;
+ case QSOperator::InplaceDiv: return IR::OpDiv;
+ case QSOperator::InplaceAdd: return IR::OpAdd;
+ case QSOperator::InplaceLeftShift: return IR::OpLShift;
+ case QSOperator::InplaceMod: return IR::OpMod;
+ case QSOperator::InplaceMul: return IR::OpMul;
+ case QSOperator::InplaceOr: return IR::OpBitOr;
+ case QSOperator::InplaceRightShift: return IR::OpRShift;
+ case QSOperator::InplaceURightShift: return IR::OpURShift;
+ case QSOperator::InplaceXor: return IR::OpBitXor;
+ default: return IR::OpInvalid;
}
}
if (ast->op == QSOperator::And) {
if (_expr.accept(cx)) {
- V4IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
condition(ast->left, iftrue, _expr.iffalse);
_block = iftrue;
condition(ast->right, _expr.iftrue, _expr.iffalse);
} else {
- V4IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
const unsigned r = _block->newTemp();
return false;
} else if (ast->op == QSOperator::Or) {
if (_expr.accept(cx)) {
- V4IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
condition(ast->left, _expr.iftrue, iffalse);
_block = iffalse;
condition(ast->right, _expr.iftrue, _expr.iffalse);
} else {
- V4IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
const unsigned r = _block->newTemp();
move(_block->TEMP(r), *expression(ast->left));
return false;
}
- V4IR::Expr* left = *expression(ast->left);
+ IR::Expr* left = *expression(ast->left);
switch (ast->op) {
case QSOperator::Or:
case QSOperator::Assign: {
if (throwSyntaxErrorOnEvalOrArgumentsInStrictMode(left, ast->left->lastSourceLocation()))
return false;
- V4IR::Expr* right = *expression(ast->right);
+ IR::Expr* right = *expression(ast->right);
if (!left->isLValue()) {
throwReferenceError(ast->operatorToken, QStringLiteral("left-hand side of assignment operator is not an lvalue"));
return false;
case QSOperator::InplaceXor: {
if (throwSyntaxErrorOnEvalOrArgumentsInStrictMode(left, ast->left->lastSourceLocation()))
return false;
- V4IR::Expr* right = *expression(ast->right);
+ IR::Expr* right = *expression(ast->right);
if (!left->isLValue()) {
throwSyntaxError(ast->operatorToken, QStringLiteral("left-hand side of inplace operator is not an lvalue"));
return false;
left = _block->TEMP(t);
}
- V4IR::Expr* right = *expression(ast->right);
+ IR::Expr* right = *expression(ast->right);
if (_expr.accept(cx)) {
- cjump(binop(V4IR::binaryOperator(ast->op), left, right), _expr.iftrue, _expr.iffalse);
+ cjump(binop(IR::binaryOperator(ast->op), left, right), _expr.iftrue, _expr.iffalse);
} else {
- V4IR::Expr *e = binop(V4IR::binaryOperator(ast->op), left, right);
+ IR::Expr *e = binop(IR::binaryOperator(ast->op), left, right);
if (e->asConst() || e->asString())
_expr.code = e;
else {
left = _block->TEMP(t);
}
- V4IR::Expr* right = *expression(ast->right);
+ IR::Expr* right = *expression(ast->right);
- V4IR::Expr *e = binop(V4IR::binaryOperator(ast->op), left, right);
+ IR::Expr *e = binop(IR::binaryOperator(ast->op), left, right);
if (e->asConst() || e->asString())
_expr.code = e;
else {
return false;
Result base = expression(ast->base);
- V4IR::ExprList *args = 0, **args_it = &args;
+ IR::ExprList *args = 0, **args_it = &args;
for (ArgumentList *it = ast->arguments; it; it = it->next) {
Result arg = expression(it->expression);
- V4IR::Expr *actual = argument(*arg);
- *args_it = _function->New<V4IR::ExprList>();
+ IR::Expr *actual = argument(*arg);
+ *args_it = _function->New<IR::ExprList>();
(*args_it)->init(actual);
args_it = &(*args_it)->next;
}
if (hasError)
return true;
- V4IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
const unsigned t = _block->newTemp();
if (hasError)
return false;
- V4IR::Expr* expr = *expression(ast->expression);
+ IR::Expr* expr = *expression(ast->expression);
// Temporaries cannot be deleted
- V4IR::Temp *t = expr->asTemp();
+ IR::Temp *t = expr->asTemp();
if (t && t->index < static_cast<unsigned>(_env->members.size())) {
// Trying to delete a function argument might throw.
if (_function->isStrict) {
throwSyntaxError(ast->deleteToken, QStringLiteral("Delete of an unqualified identifier in strict mode."));
return false;
}
- _expr.code = _block->CONST(V4IR::BoolType, 0);
+ _expr.code = _block->CONST(IR::BoolType, 0);
return false;
}
if (_function->isStrict && expr->asName()) {
// [[11.4.1]] Return true if it's not a reference
if (expr->asConst() || expr->asString()) {
- _expr.code = _block->CONST(V4IR::BoolType, 1);
+ _expr.code = _block->CONST(IR::BoolType, 1);
return false;
}
// perform the call to allow for side effects.
if (expr->asCall()) {
_block->EXP(expr);
- _expr.code = _block->CONST(V4IR::BoolType, 1);
+ _expr.code = _block->CONST(IR::BoolType, 1);
return false;
}
if (expr->asTemp() && expr->asTemp()->index >= static_cast<unsigned>(_env->members.size())) {
- _expr.code = _block->CONST(V4IR::BoolType, 1);
+ _expr.code = _block->CONST(IR::BoolType, 1);
return false;
}
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
+ IR::ExprList *args = _function->New<IR::ExprList>();
args->init(reference(expr));
- _expr.code = call(_block->NAME(V4IR::Name::builtin_delete, ast->deleteToken.startLine, ast->deleteToken.startColumn), args);
+ _expr.code = call(_block->NAME(IR::Name::builtin_delete, ast->deleteToken.startLine, ast->deleteToken.startColumn), args);
return false;
}
if (_expr.accept(cx)) {
_block->JUMP(_expr.iffalse);
} else {
- _expr.code = _block->CONST(V4IR::BoolType, 0);
+ _expr.code = _block->CONST(IR::BoolType, 0);
}
return false;
}
return false;
}
-V4IR::Expr *Codegen::identifier(const QString &name, int line, int col)
+IR::Expr *Codegen::identifier(const QString &name, int line, int col)
{
if (hasError)
return 0;
uint scope = 0;
Environment *e = _env;
- V4IR::Function *f = _function;
+ IR::Function *f = _function;
while (f && e->parent) {
if (f->insideWithOrCatch || (f->isNamedExpression && f->name == name))
int index = e->findMember(name);
Q_ASSERT (index < e->members.size());
if (index != -1) {
- V4IR::Temp *t = _block->LOCAL(index, scope);
+ IR::Temp *t = _block->LOCAL(index, scope);
if (name == QStringLiteral("arguments") || name == QStringLiteral("eval"))
t->isArgumentsOrEval = true;
return t;
}
// This hook allows implementing QML lookup semantics
- if (V4IR::Expr *fallback = fallbackNameLookup(name, line, col))
+ if (IR::Expr *fallback = fallbackNameLookup(name, line, col))
return fallback;
if (!e->parent && (!f || !f->insideWithOrCatch) && _env->compilationMode != EvalCode && e->compilationMode != QmlBinding)
}
-V4IR::Expr *Codegen::fallbackNameLookup(const QString &name, int line, int col)
+IR::Expr *Codegen::fallbackNameLookup(const QString &name, int line, int col)
{
Q_UNUSED(name)
Q_UNUSED(line)
return false;
Result base = expression(ast->expression);
- V4IR::Expr *expr = *base;
+ IR::Expr *expr = *base;
if (expr && !expr->asTemp() && !expr->asName() && !expr->asMember()) {
const unsigned t = _block->newTemp();
move(_block->TEMP(t), expr);
return false;
Result base = expression(ast->base);
- V4IR::Expr *expr = *base;
+ IR::Expr *expr = *base;
if (expr && !expr->asTemp() && !expr->asName() && !expr->asMember()) {
const unsigned t = _block->newTemp();
move(_block->TEMP(t), expr);
expr = _block->TEMP(t);
}
- V4IR::ExprList *args = 0, **args_it = &args;
+ IR::ExprList *args = 0, **args_it = &args;
for (ArgumentList *it = ast->arguments; it; it = it->next) {
Result arg = expression(it->expression);
- V4IR::Expr *actual = argument(*arg);
- *args_it = _function->New<V4IR::ExprList>();
+ IR::Expr *actual = argument(*arg);
+ *args_it = _function->New<IR::ExprList>();
(*args_it)->init(actual);
args_it = &(*args_it)->next;
}
Result expr = expression(ast->expression);
const unsigned r = _block->newTemp();
- move(_block->TEMP(r), unop(V4IR::OpNot, *expr));
+ move(_block->TEMP(r), unop(IR::OpNot, *expr));
_expr.code = _block->TEMP(r);
return false;
}
return false;
if (_expr.accept(cx)) _block->JUMP(_expr.iffalse);
- else _expr.code = _block->CONST(V4IR::NullType, 0);
+ else _expr.code = _block->CONST(IR::NullType, 0);
return false;
}
if (ast->value) _block->JUMP(_expr.iftrue);
else _block->JUMP(_expr.iffalse);
} else {
- _expr.code = _block->CONST(V4IR::NumberType, ast->value);
+ _expr.code = _block->CONST(IR::NumberType, ast->value);
}
return false;
}
, setter(-1)
{}
- V4IR::Expr *value;
+ IR::Expr *value;
int getter; // index in _module->functions or -1 if not set
int setter;
}
}
- V4IR::ExprList *args = 0;
+ IR::ExprList *args = 0;
if (!valueMap.isEmpty()) {
- V4IR::ExprList *current;
+ IR::ExprList *current;
for (QMap<QString, ObjectPropertyValue>::iterator it = valueMap.begin(); it != valueMap.end(); ) {
if (QV4::String::toArrayIndex(it.key()) != UINT_MAX) {
++it;
}
if (!args) {
- args = _function->New<V4IR::ExprList>();
+ args = _function->New<IR::ExprList>();
current = args;
} else {
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
}
current->expr = _block->NAME(it.key(), 0, 0);
if (it->value) {
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
- current->expr = _block->CONST(V4IR::BoolType, true);
+ current->expr = _block->CONST(IR::BoolType, true);
unsigned value = _block->newTemp();
move(_block->TEMP(value), it->value);
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
current->expr = _block->TEMP(value);
} else {
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
- current->expr = _block->CONST(V4IR::BoolType, false);
+ current->expr = _block->CONST(IR::BoolType, false);
unsigned getter = _block->newTemp();
unsigned setter = _block->newTemp();
- move(_block->TEMP(getter), it->hasGetter() ? _block->CLOSURE(it->getter) : _block->CONST(V4IR::UndefinedType, 0));
- move(_block->TEMP(setter), it->hasSetter() ? _block->CLOSURE(it->setter) : _block->CONST(V4IR::UndefinedType, 0));
+ move(_block->TEMP(getter), it->hasGetter() ? _block->CLOSURE(it->getter) : _block->CONST(IR::UndefinedType, 0));
+ move(_block->TEMP(setter), it->hasSetter() ? _block->CLOSURE(it->setter) : _block->CONST(IR::UndefinedType, 0));
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
current->expr = _block->TEMP(getter);
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
current->expr = _block->TEMP(setter);
}
}
const unsigned t = _block->newTemp();
- move(_block->TEMP(t), _block->CALL(_block->NAME(V4IR::Name::builtin_define_object_literal,
+ move(_block->TEMP(t), _block->CALL(_block->NAME(IR::Name::builtin_define_object_literal,
ast->firstSourceLocation().startLine, ast->firstSourceLocation().startColumn), args));
// What's left are array entries
unsigned getter = 0;
unsigned setter = 0;
for (QMap<QString, ObjectPropertyValue>::const_iterator it = valueMap.constBegin(); it != valueMap.constEnd(); ++it) {
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
- V4IR::ExprList *current = args;
+ IR::ExprList *args = _function->New<IR::ExprList>();
+ IR::ExprList *current = args;
current->expr = _block->TEMP(t);
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
current->expr = _block->NAME(it.key(), 0, 0);
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
if (it->value) {
move(_block->TEMP(value), it->value);
// __qmljs_builtin_define_property(Value object, String *name, Value val, ExecutionContext *ctx)
current->expr = _block->TEMP(value);
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_define_property, 0, 0), args));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_define_property, 0, 0), args));
} else {
if (!getter) {
getter = _block->newTemp();
setter = _block->newTemp();
}
- move(_block->TEMP(getter), it->hasGetter() ? _block->CLOSURE(it->getter) : _block->CONST(V4IR::UndefinedType, 0));
- move(_block->TEMP(setter), it->hasSetter() ? _block->CLOSURE(it->setter) : _block->CONST(V4IR::UndefinedType, 0));
+ move(_block->TEMP(getter), it->hasGetter() ? _block->CLOSURE(it->getter) : _block->CONST(IR::UndefinedType, 0));
+ move(_block->TEMP(setter), it->hasSetter() ? _block->CLOSURE(it->setter) : _block->CONST(IR::UndefinedType, 0));
// __qmljs_builtin_define_getter_setter(Value object, String *name, Value getter, Value setter, ExecutionContext *ctx);
current->expr = _block->TEMP(getter);
- current->next = _function->New<V4IR::ExprList>();
+ current->next = _function->New<IR::ExprList>();
current = current->next;
current->expr = _block->TEMP(setter);
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_define_getter_setter, 0, 0), args));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_define_getter_setter, 0, 0), args));
}
}
}
return false;
const unsigned oldValue = _block->newTemp();
- move(_block->TEMP(oldValue), unop(V4IR::OpUPlus, *expr));
+ move(_block->TEMP(oldValue), unop(IR::OpUPlus, *expr));
const unsigned newValue = _block->newTemp();
- move(_block->TEMP(newValue), binop(V4IR::OpSub, _block->TEMP(oldValue), _block->CONST(V4IR::NumberType, 1)));
+ move(_block->TEMP(newValue), binop(IR::OpSub, _block->TEMP(oldValue), _block->CONST(IR::NumberType, 1)));
move(*expr, _block->TEMP(newValue));
if (!_expr.accept(nx))
return false;
const unsigned oldValue = _block->newTemp();
- move(_block->TEMP(oldValue), unop(V4IR::OpUPlus, *expr));
+ move(_block->TEMP(oldValue), unop(IR::OpUPlus, *expr));
const unsigned newValue = _block->newTemp();
- move(_block->TEMP(newValue), binop(V4IR::OpAdd, _block->TEMP(oldValue), _block->CONST(V4IR::NumberType, 1)));
+ move(_block->TEMP(newValue), binop(IR::OpAdd, _block->TEMP(oldValue), _block->CONST(IR::NumberType, 1)));
move(*expr, _block->TEMP(newValue));
if (!_expr.accept(nx))
if (throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->decrementToken))
return false;
- V4IR::Expr *op = binop(V4IR::OpSub, *expr, _block->CONST(V4IR::NumberType, 1));
+ IR::Expr *op = binop(IR::OpSub, *expr, _block->CONST(IR::NumberType, 1));
if (_expr.accept(nx)) {
move(*expr, op);
} else {
if (throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->incrementToken))
return false;
- V4IR::Expr *op = binop(V4IR::OpAdd, unop(V4IR::OpUPlus, *expr), _block->CONST(V4IR::NumberType, 1));
+ IR::Expr *op = binop(IR::OpAdd, unop(IR::OpUPlus, *expr), _block->CONST(IR::NumberType, 1));
if (_expr.accept(nx)) {
move(*expr, op);
} else {
Result expr = expression(ast->expression);
const unsigned t = _block->newTemp();
- move(_block->TEMP(t), unop(V4IR::OpCompl, *expr));
+ move(_block->TEMP(t), unop(IR::OpCompl, *expr));
_expr.code = _block->TEMP(t);
return false;
}
if (_expr.accept(cx)) {
_block->JUMP(_expr.iftrue);
} else {
- _expr.code = _block->CONST(V4IR::BoolType, 1);
+ _expr.code = _block->CONST(IR::BoolType, 1);
}
return false;
}
return false;
Result expr = expression(ast->expression);
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
+ IR::ExprList *args = _function->New<IR::ExprList>();
args->init(reference(*expr));
- _expr.code = call(_block->NAME(V4IR::Name::builtin_typeof, ast->typeofToken.startLine, ast->typeofToken.startColumn), args);
+ _expr.code = call(_block->NAME(IR::Name::builtin_typeof, ast->typeofToken.startLine, ast->typeofToken.startColumn), args);
return false;
}
Result expr = expression(ast->expression);
const unsigned t = _block->newTemp();
- move(_block->TEMP(t), unop(V4IR::OpUMinus, *expr));
+ move(_block->TEMP(t), unop(IR::OpUMinus, *expr));
_expr.code = _block->TEMP(t);
return false;
}
Result expr = expression(ast->expression);
const unsigned t = _block->newTemp();
- move(_block->TEMP(t), unop(V4IR::OpUPlus, *expr));
+ move(_block->TEMP(t), unop(IR::OpUPlus, *expr));
_expr.code = _block->TEMP(t);
return false;
}
return false;
statement(ast->expression);
- _expr.code = _block->CONST(V4IR::UndefinedType, 0);
+ _expr.code = _block->CONST(IR::UndefinedType, 0);
return false;
}
{
Loop *loop = 0;
qSwap(_loop, loop);
- QStack<V4IR::BasicBlock *> exceptionHandlers;
+ QStack<IR::BasicBlock *> exceptionHandlers;
qSwap(_exceptionHandlers, exceptionHandlers);
ScopeAndFinally *scopeAndFinally = 0;
enterEnvironment(ast);
- V4IR::Function *function = _module->newFunction(name, _function);
+ IR::Function *function = _module->newFunction(name, _function);
int functionIndex = _module->functions.count() - 1;
- V4IR::BasicBlock *entryBlock = function->newBasicBlock(groupStartBlock(), 0);
- V4IR::BasicBlock *exitBlock = function->newBasicBlock(groupStartBlock(), 0, V4IR::Function::DontInsertBlock);
+ IR::BasicBlock *entryBlock = function->newBasicBlock(groupStartBlock(), 0);
+ IR::BasicBlock *exitBlock = function->newBasicBlock(groupStartBlock(), 0, IR::Function::DontInsertBlock);
function->hasDirectEval = _env->hasDirectEval || _env->compilationMode == EvalCode;
function->usesArgumentsObject = _env->parent && (_env->usesArgumentsObject == Environment::ArgumentsObjectUsed);
function->usesThis = _env->usesThis;
const QString &local = it.key();
function->LOCAL(local);
(*it).index = t;
- entryBlock->MOVE(entryBlock->LOCAL(t, 0), entryBlock->CONST(V4IR::UndefinedType, 0));
+ entryBlock->MOVE(entryBlock->LOCAL(t, 0), entryBlock->CONST(IR::UndefinedType, 0));
++t;
}
} else {
}
}
- V4IR::ExprList *args = 0;
+ IR::ExprList *args = 0;
for (Environment::MemberMap::const_iterator it = _env->members.constBegin(); it != _env->members.constEnd(); ++it) {
const QString &local = it.key();
- V4IR::ExprList *next = function->New<V4IR::ExprList>();
+ IR::ExprList *next = function->New<IR::ExprList>();
next->expr = entryBlock->NAME(local, 0, 0);
next->next = args;
args = next;
}
if (args) {
- V4IR::ExprList *next = function->New<V4IR::ExprList>();
- next->expr = entryBlock->CONST(V4IR::BoolType, false); // ### Investigate removal of bool deletable
+ IR::ExprList *next = function->New<IR::ExprList>();
+ next->expr = entryBlock->CONST(IR::BoolType, false); // ### Investigate removal of bool deletable
next->next = args;
args = next;
- entryBlock->EXP(entryBlock->CALL(entryBlock->NAME(V4IR::Name::builtin_declare_vars, 0, 0), args));
+ entryBlock->EXP(entryBlock->CALL(entryBlock->NAME(IR::Name::builtin_declare_vars, 0, 0), args));
}
}
unsigned returnAddress = entryBlock->newTemp();
- entryBlock->MOVE(entryBlock->TEMP(returnAddress), entryBlock->CONST(V4IR::UndefinedType, 0));
+ entryBlock->MOVE(entryBlock->TEMP(returnAddress), entryBlock->CONST(IR::UndefinedType, 0));
exitBlock->RET(exitBlock->TEMP(returnAddress));
qSwap(_function, function);
}
if (_function->usesArgumentsObject) {
move(identifier(QStringLiteral("arguments"), ast->firstSourceLocation().startLine, ast->firstSourceLocation().startColumn),
- _block->CALL(_block->NAME(V4IR::Name::builtin_setup_argument_object,
+ _block->CALL(_block->NAME(IR::Name::builtin_setup_argument_object,
ast->firstSourceLocation().startLine, ast->firstSourceLocation().startColumn), 0));
}
if (_function->usesThis && !_function->isStrict) {
// make sure we convert this to an object
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_convert_this_to_object,
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_convert_this_to_object,
ast->firstSourceLocation().startLine, ast->firstSourceLocation().startColumn), 0));
}
if (hasError)
return true;
- V4IR::BasicBlock *loopbody = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *loopcond = _function->newBasicBlock(loopbody, exceptionHandler());
- V4IR::BasicBlock *loopend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *loopbody = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *loopcond = _function->newBasicBlock(loopbody, exceptionHandler());
+ IR::BasicBlock *loopend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
enterLoop(ast, loopbody, loopend, loopcond);
if (hasError)
return true;
- V4IR::BasicBlock *foreachin = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *foreachbody = _function->newBasicBlock(foreachin, exceptionHandler());
- V4IR::BasicBlock *foreachend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *foreachin = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *foreachbody = _function->newBasicBlock(foreachin, exceptionHandler());
+ IR::BasicBlock *foreachend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
enterLoop(ast, foreachin, foreachend, foreachin);
int objectToIterateOn = _block->newTemp();
move(_block->TEMP(objectToIterateOn), *expression(ast->expression));
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
+ IR::ExprList *args = _function->New<IR::ExprList>();
args->init(_block->TEMP(objectToIterateOn));
int iterator = _block->newTemp();
- move(_block->TEMP(iterator), _block->CALL(_block->NAME(V4IR::Name::builtin_foreach_iterator_object, 0, 0), args));
+ move(_block->TEMP(iterator), _block->CALL(_block->NAME(IR::Name::builtin_foreach_iterator_object, 0, 0), args));
_block->JUMP(foreachin);
_block = foreachin;
- args = _function->New<V4IR::ExprList>();
+ args = _function->New<IR::ExprList>();
args->init(_block->TEMP(iterator));
- move(_block->TEMP(temp), _block->CALL(_block->NAME(V4IR::Name::builtin_foreach_next_property_name, 0, 0), args));
+ move(_block->TEMP(temp), _block->CALL(_block->NAME(IR::Name::builtin_foreach_next_property_name, 0, 0), args));
int null = _block->newTemp();
- move(_block->TEMP(null), _block->CONST(V4IR::NullType, 0));
- cjump(_block->BINOP(V4IR::OpStrictNotEqual, _block->TEMP(temp), _block->TEMP(null)), foreachbody, foreachend);
+ move(_block->TEMP(null), _block->CONST(IR::NullType, 0));
+ cjump(_block->BINOP(IR::OpStrictNotEqual, _block->TEMP(temp), _block->TEMP(null)), foreachbody, foreachend);
_block = foreachend;
leaveLoop();
if (hasError)
return true;
- V4IR::BasicBlock *forcond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *forbody = _function->newBasicBlock(forcond, exceptionHandler());
- V4IR::BasicBlock *forstep = _function->newBasicBlock(forcond, exceptionHandler());
- V4IR::BasicBlock *forend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *forcond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *forbody = _function->newBasicBlock(forcond, exceptionHandler());
+ IR::BasicBlock *forstep = _function->newBasicBlock(forcond, exceptionHandler());
+ IR::BasicBlock *forend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
statement(ast->initialiser);
_block->JUMP(forcond);
if (hasError)
return true;
- V4IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *iffalse = ast->ko ? _function->newBasicBlock(groupStartBlock(), exceptionHandler()) : 0;
- V4IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iftrue = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *iffalse = ast->ko ? _function->newBasicBlock(groupStartBlock(), exceptionHandler()) : 0;
+ IR::BasicBlock *endif = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
condition(ast->expression, iftrue, ast->ko ? iffalse : endif);
AST::cast<AST::LocalForEachStatement *>(ast->statement)) {
statement(ast->statement); // labelledStatement will be associated with the ast->statement's loop.
} else {
- V4IR::BasicBlock *breakBlock = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *breakBlock = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
enterLoop(ast->statement, 0, breakBlock, /*continueBlock*/ 0);
statement(ast->statement);
_block->JUMP(breakBlock);
if (hasError)
return true;
- V4IR::BasicBlock *foreachin = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *foreachbody = _function->newBasicBlock(foreachin, exceptionHandler());
- V4IR::BasicBlock *foreachend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *foreachin = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *foreachbody = _function->newBasicBlock(foreachin, exceptionHandler());
+ IR::BasicBlock *foreachend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
enterLoop(ast, foreachin, foreachend, foreachin);
int iterator = _block->newTemp();
move(_block->TEMP(iterator), *expression(ast->expression));
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
+ IR::ExprList *args = _function->New<IR::ExprList>();
args->init(_block->TEMP(iterator));
- move(_block->TEMP(iterator), _block->CALL(_block->NAME(V4IR::Name::builtin_foreach_iterator_object, 0, 0), args));
+ move(_block->TEMP(iterator), _block->CALL(_block->NAME(IR::Name::builtin_foreach_iterator_object, 0, 0), args));
_block->JUMP(foreachin);
_block = foreachin;
- args = _function->New<V4IR::ExprList>();
+ args = _function->New<IR::ExprList>();
args->init(_block->TEMP(iterator));
- move(_block->TEMP(temp), _block->CALL(_block->NAME(V4IR::Name::builtin_foreach_next_property_name, 0, 0), args));
+ move(_block->TEMP(temp), _block->CALL(_block->NAME(IR::Name::builtin_foreach_next_property_name, 0, 0), args));
int null = _block->newTemp();
- move(_block->TEMP(null), _block->CONST(V4IR::NullType, 0));
- cjump(_block->BINOP(V4IR::OpStrictNotEqual, _block->TEMP(temp), _block->TEMP(null)), foreachbody, foreachend);
+ move(_block->TEMP(null), _block->CONST(IR::NullType, 0));
+ cjump(_block->BINOP(IR::OpStrictNotEqual, _block->TEMP(temp), _block->TEMP(null)), foreachbody, foreachend);
_block = foreachend;
leaveLoop();
if (hasError)
return true;
- V4IR::BasicBlock *forcond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *forbody = _function->newBasicBlock(forcond, exceptionHandler());
- V4IR::BasicBlock *forstep = _function->newBasicBlock(forcond, exceptionHandler());
- V4IR::BasicBlock *forend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *forcond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *forbody = _function->newBasicBlock(forcond, exceptionHandler());
+ IR::BasicBlock *forstep = _function->newBasicBlock(forcond, exceptionHandler());
+ IR::BasicBlock *forend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
variableDeclarationList(ast->declarations);
_block->JUMP(forcond);
if (hasError)
return true;
- V4IR::BasicBlock *switchend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *switchend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
if (ast->block) {
Result lhs = expression(ast->expression);
- V4IR::BasicBlock *switchcond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *switchcond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
_block->JUMP(switchcond);
- V4IR::BasicBlock *previousBlock = 0;
+ IR::BasicBlock *previousBlock = 0;
- QHash<Node *, V4IR::BasicBlock *> blockMap;
+ QHash<Node *, IR::BasicBlock *> blockMap;
enterLoop(ast, 0, switchend, 0);
for (CaseClauses *it = ast->block->clauses; it; it = it->next) {
CaseClause *clause = it->clause;
Result rhs = expression(clause->expression);
- V4IR::BasicBlock *iftrue = blockMap[clause];
- V4IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- cjump(binop(V4IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse);
+ IR::BasicBlock *iftrue = blockMap[clause];
+ IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ cjump(binop(IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse);
_block = iffalse;
}
for (CaseClauses *it = ast->block->moreClauses; it; it = it->next) {
CaseClause *clause = it->clause;
Result rhs = expression(clause->expression);
- V4IR::BasicBlock *iftrue = blockMap[clause];
- V4IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- cjump(binop(V4IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse);
+ IR::BasicBlock *iftrue = blockMap[clause];
+ IR::BasicBlock *iffalse = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ cjump(binop(IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse);
_block = iffalse;
}
Result expr = expression(ast->expression);
move(_block->TEMP(_returnAddress), *expr);
- V4IR::ExprList *throwArgs = _function->New<V4IR::ExprList>();
+ IR::ExprList *throwArgs = _function->New<IR::ExprList>();
throwArgs->expr = _block->TEMP(_returnAddress);
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_throw, /*line*/0, /*column*/0), throwArgs));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_throw, /*line*/0, /*column*/0), throwArgs));
return false;
}
return false;
}
- V4IR::BasicBlock *surroundingExceptionHandler = exceptionHandler();
+ IR::BasicBlock *surroundingExceptionHandler = exceptionHandler();
// We always need a finally body to clean up the exception handler
// exceptions thrown in finally get catched by the surrounding catch block
- V4IR::BasicBlock *finallyBody = 0;
- V4IR::BasicBlock *catchBody = 0;
- V4IR::BasicBlock *catchExceptionHandler = 0;
- V4IR::BasicBlock *end = _function->newBasicBlock(groupStartBlock(), surroundingExceptionHandler, V4IR::Function::DontInsertBlock);
+ IR::BasicBlock *finallyBody = 0;
+ IR::BasicBlock *catchBody = 0;
+ IR::BasicBlock *catchExceptionHandler = 0;
+ IR::BasicBlock *end = _function->newBasicBlock(groupStartBlock(), surroundingExceptionHandler, IR::Function::DontInsertBlock);
if (ast->finallyExpression)
- finallyBody = _function->newBasicBlock(groupStartBlock(), surroundingExceptionHandler, V4IR::Function::DontInsertBlock);
+ finallyBody = _function->newBasicBlock(groupStartBlock(), surroundingExceptionHandler, IR::Function::DontInsertBlock);
if (ast->catchExpression) {
// exception handler for the catch body
- catchExceptionHandler = _function->newBasicBlock(groupStartBlock(), 0, V4IR::Function::DontInsertBlock);
+ catchExceptionHandler = _function->newBasicBlock(groupStartBlock(), 0, IR::Function::DontInsertBlock);
pushExceptionHandler(catchExceptionHandler);
- catchBody = _function->newBasicBlock(groupStartBlock(), catchExceptionHandler, V4IR::Function::DontInsertBlock);
+ catchBody = _function->newBasicBlock(groupStartBlock(), catchExceptionHandler, IR::Function::DontInsertBlock);
popExceptionHandler();
pushExceptionHandler(catchBody);
} else {
pushExceptionHandler(finallyBody);
}
- V4IR::BasicBlock *tryBody = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *tryBody = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
_block->JUMP(tryBody);
ScopeAndFinally tcf(_scopeAndFinally, ast->finallyExpression);
_block = catchBody;
++_function->insideWithOrCatch;
- V4IR::ExprList *catchArgs = _function->New<V4IR::ExprList>();
+ IR::ExprList *catchArgs = _function->New<IR::ExprList>();
catchArgs->init(_block->STRING(_function->newString(ast->catchExpression->name.toString())));
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_push_catch_scope, 0, 0), catchArgs));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_push_catch_scope, 0, 0), catchArgs));
{
ScopeAndFinally scope(_scopeAndFinally, ScopeAndFinally::CatchScope);
_scopeAndFinally = &scope;
statement(ast->catchExpression->statement);
_scopeAndFinally = scope.parent;
}
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_pop_scope, 0, 0), 0));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_pop_scope, 0, 0), 0));
--_function->insideWithOrCatch;
_block->JUMP(finallyBody ? finallyBody : end);
popExceptionHandler();
_function->insertBasicBlock(catchExceptionHandler);
- catchExceptionHandler->EXP(catchExceptionHandler->CALL(catchExceptionHandler->NAME(V4IR::Name::builtin_pop_scope, 0, 0), 0));
+ catchExceptionHandler->EXP(catchExceptionHandler->CALL(catchExceptionHandler->NAME(IR::Name::builtin_pop_scope, 0, 0), 0));
if (finallyBody || surroundingExceptionHandler)
catchExceptionHandler->JUMP(finallyBody ? finallyBody : surroundingExceptionHandler);
else
- catchExceptionHandler->EXP(catchExceptionHandler->CALL(catchExceptionHandler->NAME(V4IR::Name::builtin_rethrow, 0, 0), 0));
+ catchExceptionHandler->EXP(catchExceptionHandler->CALL(catchExceptionHandler->NAME(IR::Name::builtin_rethrow, 0, 0), 0));
}
_scopeAndFinally = tcf.parent;
_block = finallyBody;
int hasException = _block->newTemp();
- move(_block->TEMP(hasException), _block->CALL(_block->NAME(V4IR::Name::builtin_unwind_exception, /*line*/0, /*column*/0), 0));
+ move(_block->TEMP(hasException), _block->CALL(_block->NAME(IR::Name::builtin_unwind_exception, /*line*/0, /*column*/0), 0));
if (ast->finallyExpression && ast->finallyExpression->statement)
statement(ast->finallyExpression->statement);
- V4IR::ExprList *arg = _function->New<V4IR::ExprList>();
+ IR::ExprList *arg = _function->New<IR::ExprList>();
arg->expr = _block->TEMP(hasException);
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_throw, /*line*/0, /*column*/0), arg));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_throw, /*line*/0, /*column*/0), arg));
_block->JUMP(end);
}
case ScopeAndFinally::WithScope:
// fall through
case ScopeAndFinally::CatchScope:
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_pop_scope, 0, 0)));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_pop_scope, 0, 0)));
_scopeAndFinally = _scopeAndFinally->parent;
--_function->insideWithOrCatch;
break;
if (hasError)
return true;
- V4IR::BasicBlock *whilecond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- V4IR::BasicBlock *whilebody = _function->newBasicBlock(whilecond, exceptionHandler());
- V4IR::BasicBlock *whileend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *whilecond = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *whilebody = _function->newBasicBlock(whilecond, exceptionHandler());
+ IR::BasicBlock *whileend = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
enterLoop(ast, whilecond, whileend, whilecond);
_function->hasWith = true;
// need an exception handler for with to cleanup the with scope
- V4IR::BasicBlock *withExceptionHandler = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
- withExceptionHandler->EXP(withExceptionHandler->CALL(withExceptionHandler->NAME(V4IR::Name::builtin_pop_scope, 0, 0), 0));
+ IR::BasicBlock *withExceptionHandler = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ withExceptionHandler->EXP(withExceptionHandler->CALL(withExceptionHandler->NAME(IR::Name::builtin_pop_scope, 0, 0), 0));
if (!exceptionHandler())
- withExceptionHandler->EXP(withExceptionHandler->CALL(withExceptionHandler->NAME(V4IR::Name::builtin_rethrow, 0, 0), 0));
+ withExceptionHandler->EXP(withExceptionHandler->CALL(withExceptionHandler->NAME(IR::Name::builtin_rethrow, 0, 0), 0));
else
withExceptionHandler->JUMP(exceptionHandler());
pushExceptionHandler(withExceptionHandler);
- V4IR::BasicBlock *withBlock = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *withBlock = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
_block->JUMP(withBlock);
_block = withBlock;
int withObject = _block->newTemp();
_block->MOVE(_block->TEMP(withObject), *expression(ast->expression));
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
+ IR::ExprList *args = _function->New<IR::ExprList>();
args->init(_block->TEMP(withObject));
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_push_with_scope, 0, 0), args));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_push_with_scope, 0, 0), args));
++_function->insideWithOrCatch;
{
_scopeAndFinally = scope.parent;
}
--_function->insideWithOrCatch;
- _block->EXP(_block->CALL(_block->NAME(V4IR::Name::builtin_pop_scope, 0, 0), 0));
+ _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_pop_scope, 0, 0), 0));
popExceptionHandler();
- V4IR::BasicBlock *next = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
+ IR::BasicBlock *next = _function->newBasicBlock(groupStartBlock(), exceptionHandler());
_block->JUMP(next);
_block = next;
return false;
}
-bool Codegen::throwSyntaxErrorOnEvalOrArgumentsInStrictMode(V4IR::Expr *expr, const SourceLocation& loc)
+bool Codegen::throwSyntaxErrorOnEvalOrArgumentsInStrictMode(IR::Expr *expr, const SourceLocation& loc)
{
if (!_env->isStrict)
return false;
- if (V4IR::Name *n = expr->asName()) {
+ if (IR::Name *n = expr->asName()) {
if (*n->id != QLatin1String("eval") && *n->id != QLatin1String("arguments"))
return false;
- } else if (V4IR::Temp *t = expr->asTemp()) {
+ } else if (IR::Temp *t = expr->asTemp()) {
if (!t->isArgumentsOrEval)
return false;
} else {
void generateFromProgram(const QString &fileName,
const QString &sourceCode,
AST::Program *ast,
- V4IR::Module *module,
+ QV4::IR::Module *module,
CompilationMode mode = GlobalCode,
const QStringList &inheritedLocals = QStringList());
void generateFromFunctionExpression(const QString &fileName,
const QString &sourceCode,
AST::FunctionExpression *ast,
- V4IR::Module *module);
+ QV4::IR::Module *module);
protected:
enum Format { ex, cx, nx };
struct Result {
- V4IR::Expr *code;
- V4IR::BasicBlock *iftrue;
- V4IR::BasicBlock *iffalse;
+ QV4::IR::Expr *code;
+ QV4::IR::BasicBlock *iftrue;
+ QV4::IR::BasicBlock *iffalse;
Format format;
Format requested;
, format(ex)
, requested(requested) {}
- explicit Result(V4IR::BasicBlock *iftrue, V4IR::BasicBlock *iffalse)
+ explicit Result(QV4::IR::BasicBlock *iftrue, QV4::IR::BasicBlock *iffalse)
: code(0)
, iftrue(iftrue)
, iffalse(iffalse)
, format(ex)
, requested(cx) {}
- inline V4IR::Expr *operator*() const { Q_ASSERT(format == ex); return code; }
- inline V4IR::Expr *operator->() const { Q_ASSERT(format == ex); return code; }
+ inline QV4::IR::Expr *operator*() const { Q_ASSERT(format == ex); return code; }
+ inline QV4::IR::Expr *operator->() const { Q_ASSERT(format == ex); return code; }
bool accept(Format f)
{
struct Loop {
AST::LabelledStatement *labelledStatement;
AST::Statement *node;
- V4IR::BasicBlock *groupStartBlock;
- V4IR::BasicBlock *breakBlock;
- V4IR::BasicBlock *continueBlock;
+ QV4::IR::BasicBlock *groupStartBlock;
+ QV4::IR::BasicBlock *breakBlock;
+ QV4::IR::BasicBlock *continueBlock;
Loop *parent;
ScopeAndFinally *scopeAndFinally;
- Loop(AST::Statement *node, V4IR::BasicBlock *groupStartBlock, V4IR::BasicBlock *breakBlock, V4IR::BasicBlock *continueBlock, Loop *parent)
+ Loop(AST::Statement *node, QV4::IR::BasicBlock *groupStartBlock, QV4::IR::BasicBlock *breakBlock, QV4::IR::BasicBlock *continueBlock, Loop *parent)
: labelledStatement(0), node(node), groupStartBlock(groupStartBlock), breakBlock(breakBlock), continueBlock(continueBlock), parent(parent) {}
};
void enterEnvironment(AST::Node *node);
void leaveEnvironment();
- void enterLoop(AST::Statement *node, V4IR::BasicBlock *startBlock, V4IR::BasicBlock *breakBlock, V4IR::BasicBlock *continueBlock);
+ void enterLoop(AST::Statement *node, QV4::IR::BasicBlock *startBlock, QV4::IR::BasicBlock *breakBlock, QV4::IR::BasicBlock *continueBlock);
void leaveLoop();
- V4IR::BasicBlock *groupStartBlock() const
+ QV4::IR::BasicBlock *groupStartBlock() const
{
for (Loop *it = _loop; it; it = it->parent)
if (it->groupStartBlock)
return it->groupStartBlock;
return 0;
}
- V4IR::BasicBlock *exceptionHandler() const
+ QV4::IR::BasicBlock *exceptionHandler() const
{
if (_exceptionHandlers.isEmpty())
return 0;
return _exceptionHandlers.top();
}
- void pushExceptionHandler(V4IR::BasicBlock *handler)
+ void pushExceptionHandler(QV4::IR::BasicBlock *handler)
{
handler->isExceptionHandler = true;
_exceptionHandlers.push(handler);
_exceptionHandlers.pop();
}
- V4IR::Expr *member(V4IR::Expr *base, const QString *name);
- V4IR::Expr *subscript(V4IR::Expr *base, V4IR::Expr *index);
- V4IR::Expr *argument(V4IR::Expr *expr);
- V4IR::Expr *reference(V4IR::Expr *expr);
- V4IR::Expr *unop(V4IR::AluOp op, V4IR::Expr *expr);
- V4IR::Expr *binop(V4IR::AluOp op, V4IR::Expr *left, V4IR::Expr *right);
- V4IR::Expr *call(V4IR::Expr *base, V4IR::ExprList *args);
- void move(V4IR::Expr *target, V4IR::Expr *source, V4IR::AluOp op = V4IR::OpInvalid);
- void cjump(V4IR::Expr *cond, V4IR::BasicBlock *iftrue, V4IR::BasicBlock *iffalse);
+ QV4::IR::Expr *member(QV4::IR::Expr *base, const QString *name);
+ QV4::IR::Expr *subscript(QV4::IR::Expr *base, QV4::IR::Expr *index);
+ QV4::IR::Expr *argument(QV4::IR::Expr *expr);
+ QV4::IR::Expr *reference(QV4::IR::Expr *expr);
+ QV4::IR::Expr *unop(QV4::IR::AluOp op, QV4::IR::Expr *expr);
+ QV4::IR::Expr *binop(QV4::IR::AluOp op, QV4::IR::Expr *left, QV4::IR::Expr *right);
+ QV4::IR::Expr *call(QV4::IR::Expr *base, QV4::IR::ExprList *args);
+ void move(QV4::IR::Expr *target, QV4::IR::Expr *source, QV4::IR::AluOp op = QV4::IR::OpInvalid);
+ void cjump(QV4::IR::Expr *cond, QV4::IR::BasicBlock *iftrue, QV4::IR::BasicBlock *iffalse);
// Returns index in _module->functions
int defineFunction(const QString &name, AST::Node *ast,
void statement(AST::Statement *ast);
void statement(AST::ExpressionNode *ast);
- void condition(AST::ExpressionNode *ast, V4IR::BasicBlock *iftrue, V4IR::BasicBlock *iffalse);
+ void condition(AST::ExpressionNode *ast, QV4::IR::BasicBlock *iftrue, QV4::IR::BasicBlock *iffalse);
Result expression(AST::ExpressionNode *ast);
QString propertyName(AST::PropertyName *ast);
Result sourceElement(AST::SourceElement *ast);
void variableDeclaration(AST::VariableDeclaration *ast);
void variableDeclarationList(AST::VariableDeclarationList *ast);
- V4IR::Expr *identifier(const QString &name, int line = 0, int col = 0);
+ QV4::IR::Expr *identifier(const QString &name, int line = 0, int col = 0);
// Hook provided to implement QML lookup semantics
- virtual V4IR::Expr *fallbackNameLookup(const QString &name, int line, int col);
+ virtual QV4::IR::Expr *fallbackNameLookup(const QString &name, int line, int col);
virtual void beginFunctionBodyHook() {}
// nodes
virtual bool visit(AST::UiScriptBinding *ast);
virtual bool visit(AST::UiSourceElement *ast);
- bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(V4IR::Expr* expr, const AST::SourceLocation &loc);
+ bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(QV4::IR::Expr* expr, const AST::SourceLocation &loc);
virtual void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail);
virtual void throwReferenceError(const AST::SourceLocation &loc, const QString &detail);
Result _expr;
QString _property;
UiMember _uiMember;
- V4IR::Module *_module;
- V4IR::Function *_function;
- V4IR::BasicBlock *_block;
- V4IR::BasicBlock *_exitBlock;
+ QV4::IR::Module *_module;
+ QV4::IR::Function *_function;
+ QV4::IR::BasicBlock *_block;
+ QV4::IR::BasicBlock *_exitBlock;
unsigned _returnAddress;
Environment *_env;
Loop *_loop;
ScopeAndFinally *_scopeAndFinally;
QHash<AST::Node *, Environment *> _envMap;
QHash<AST::FunctionExpression *, int> _functionMap;
- QStack<V4IR::BasicBlock *> _exceptionHandlers;
+ QStack<QV4::IR::BasicBlock *> _exceptionHandlers;
bool _strictMode;
bool _fileNameIsUrl;
const CompiledData::RegExp *re = data->regexpAt(i);
int flags = 0;
if (re->flags & CompiledData::RegExp::RegExp_Global)
- flags |= QQmlJS::V4IR::RegExp::RegExp_Global;
+ flags |= IR::RegExp::RegExp_Global;
if (re->flags & CompiledData::RegExp::RegExp_IgnoreCase)
- flags |= QQmlJS::V4IR::RegExp::RegExp_IgnoreCase;
+ flags |= IR::RegExp::RegExp_IgnoreCase;
if (re->flags & CompiledData::RegExp::RegExp_Multiline)
- flags |= QQmlJS::V4IR::RegExp::RegExp_Multiline;
+ flags |= IR::RegExp::RegExp_Multiline;
runtimeRegularExpressions[i] = engine->newRegExpObject(data->stringAt(re->stringIndex), flags);
}
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
-namespace V4IR {
+namespace QV4 {
+namespace IR {
struct Function;
}
-}
-
-namespace QV4 {
struct Function;
struct ExecutionContext;
#include <qv4engine_p.h>
#include <private/qqmlpropertycache_p.h>
-QV4::Compiler::JSUnitGenerator::JSUnitGenerator(QQmlJS::V4IR::Module *module, int headerSize)
+QV4::Compiler::JSUnitGenerator::JSUnitGenerator(QV4::IR::Module *module, int headerSize)
: irModule(module)
, stringDataSize(0)
, jsClassDataSize(0)
return lookups.size() - 1;
}
-int QV4::Compiler::JSUnitGenerator::registerRegExp(QQmlJS::V4IR::RegExp *regexp)
+int QV4::Compiler::JSUnitGenerator::registerRegExp(QV4::IR::RegExp *regexp)
{
CompiledData::RegExp re;
re.stringIndex = registerString(*regexp->value);
re.flags = 0;
- if (regexp->flags & QQmlJS::V4IR::RegExp::RegExp_Global)
+ if (regexp->flags & QV4::IR::RegExp::RegExp_Global)
re.flags |= CompiledData::RegExp::RegExp_Global;
- if (regexp->flags & QQmlJS::V4IR::RegExp::RegExp_IgnoreCase)
+ if (regexp->flags & QV4::IR::RegExp::RegExp_IgnoreCase)
re.flags |= CompiledData::RegExp::RegExp_IgnoreCase;
- if (regexp->flags & QQmlJS::V4IR::RegExp::RegExp_Multiline)
+ if (regexp->flags & QV4::IR::RegExp::RegExp_Multiline)
re.flags |= CompiledData::RegExp::RegExp_Multiline;
regexps.append(re);
return constants.size() - 1;
}
-void QV4::Compiler::JSUnitGenerator::registerLineNumberMapping(QQmlJS::V4IR::Function *function, const QVector<uint> &mappings)
+void QV4::Compiler::JSUnitGenerator::registerLineNumberMapping(QV4::IR::Function *function, const QVector<uint> &mappings)
{
lineNumberMappingsPerFunction.insert(function, mappings);
}
-int QV4::Compiler::JSUnitGenerator::registerJSClass(QQmlJS::V4IR::ExprList *args)
+int QV4::Compiler::JSUnitGenerator::registerJSClass(QV4::IR::ExprList *args)
{
// ### re-use existing class definitions.
QList<CompiledData::JSClassMember> members;
- QQmlJS::V4IR::ExprList *it = args;
+ QV4::IR::ExprList *it = args;
while (it) {
CompiledData::JSClassMember member;
- QQmlJS::V4IR::Name *name = it->expr->asName();
+ QV4::IR::Name *name = it->expr->asName();
it = it->next;
const bool isData = it->expr->asConst()->value;
QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(int *totalUnitSize)
{
registerString(irModule->fileName);
- foreach (QQmlJS::V4IR::Function *f, irModule->functions) {
+ foreach (QV4::IR::Function *f, irModule->functions) {
registerString(*f->name);
for (int i = 0; i < f->formals.size(); ++i)
registerString(*f->formals.at(i));
uint functionDataSize = 0;
for (int i = 0; i < irModule->functions.size(); ++i) {
- QQmlJS::V4IR::Function *f = irModule->functions.at(i);
+ QV4::IR::Function *f = irModule->functions.at(i);
functionOffsets.insert(f, functionDataSize + unitSize + stringDataSize);
int lineNumberMappingCount = 0;
- QHash<QQmlJS::V4IR::Function *, QVector<uint> >::ConstIterator lineNumberMapping = lineNumberMappingsPerFunction.find(f);
+ QHash<QV4::IR::Function *, QVector<uint> >::ConstIterator lineNumberMapping = lineNumberMappingsPerFunction.find(f);
if (lineNumberMapping != lineNumberMappingsPerFunction.constEnd())
lineNumberMappingCount = lineNumberMapping->count() / 2;
char *f = data + unitSize + stringDataSize;
for (int i = 0; i < irModule->functions.size(); ++i) {
- QQmlJS::V4IR::Function *function = irModule->functions.at(i);
+ QV4::IR::Function *function = irModule->functions.at(i);
if (function == irModule->rootFunction)
unit->indexOfRootFunction = i;
return unit;
}
-int QV4::Compiler::JSUnitGenerator::writeFunction(char *f, int index, QQmlJS::V4IR::Function *irFunction)
+int QV4::Compiler::JSUnitGenerator::writeFunction(char *f, int index, QV4::IR::Function *irFunction)
{
QV4::CompiledData::Function *function = (QV4::CompiledData::Function *)f;
currentOffset += function->nLocals * sizeof(quint32);
function->nLineNumberMappingEntries = 0;
- QHash<QQmlJS::V4IR::Function *, QVector<uint> >::ConstIterator lineNumberMapping = lineNumberMappingsPerFunction.find(irFunction);
+ QHash<QV4::IR::Function *, QVector<uint> >::ConstIterator lineNumberMapping = lineNumberMappingsPerFunction.find(irFunction);
if (lineNumberMapping != lineNumberMappingsPerFunction.constEnd()) {
function->nLineNumberMappingEntries = lineNumberMapping->count() / 2;
}
*writtenDeps++ = id;
writtenDeps = (quint32 *)(f + function->dependingContextPropertiesOffset);
- for (QQmlJS::V4IR::PropertyDependencyMap::ConstIterator property = irFunction->contextObjectPropertyDependencies.constBegin(), end = irFunction->contextObjectPropertyDependencies.constEnd();
+ for (QV4::IR::PropertyDependencyMap::ConstIterator property = irFunction->contextObjectPropertyDependencies.constBegin(), end = irFunction->contextObjectPropertyDependencies.constEnd();
property != end; ++property) {
*writtenDeps++ = property.key(); // property index
*writtenDeps++ = property.value(); // notify index
}
writtenDeps = (quint32 *)(f + function->dependingScopePropertiesOffset);
- for (QQmlJS::V4IR::PropertyDependencyMap::ConstIterator property = irFunction->scopeObjectPropertyDependencies.constBegin(), end = irFunction->scopeObjectPropertyDependencies.constEnd();
+ for (QV4::IR::PropertyDependencyMap::ConstIterator property = irFunction->scopeObjectPropertyDependencies.constBegin(), end = irFunction->scopeObjectPropertyDependencies.constEnd();
property != end; ++property) {
*writtenDeps++ = property.key(); // property index
*writtenDeps++ = property.value(); // notify index
namespace Compiler {
struct Q_QML_EXPORT JSUnitGenerator {
- JSUnitGenerator(QQmlJS::V4IR::Module *module, int headerSize = -1);
+ JSUnitGenerator(IR::Module *module, int headerSize = -1);
- QQmlJS::V4IR::Module *irModule;
+ IR::Module *irModule;
int registerString(const QString &str);
int getStringId(const QString &string) const;
uint registerIndexedGetterLookup();
uint registerIndexedSetterLookup();
- int registerRegExp(QQmlJS::V4IR::RegExp *regexp);
+ int registerRegExp(IR::RegExp *regexp);
int registerConstant(ReturnedValue v);
- void registerLineNumberMapping(QQmlJS::V4IR::Function *function, const QVector<uint> &mappings);
+ void registerLineNumberMapping(IR::Function *function, const QVector<uint> &mappings);
- int registerJSClass(QQmlJS::V4IR::ExprList *args);
+ int registerJSClass(IR::ExprList *args);
QV4::CompiledData::Unit *generateUnit(int *totalUnitSize = 0);
// Returns bytes written
- int writeFunction(char *f, int index, QQmlJS::V4IR::Function *irFunction);
+ int writeFunction(char *f, int index, IR::Function *irFunction);
QHash<QString, int> stringToId;
QStringList strings;
uint stringDataSize;
- QHash<QQmlJS::V4IR::Function *, uint> functionOffsets;
+ QHash<IR::Function *, uint> functionOffsets;
QList<CompiledData::Lookup> lookups;
QVector<CompiledData::RegExp> regexps;
QVector<ReturnedValue> constants;
- QHash<QQmlJS::V4IR::Function *, QVector<uint> > lineNumberMappingsPerFunction;
+ QHash<IR::Function *, QVector<uint> > lineNumberMappingsPerFunction;
QList<QList<CompiledData::JSClassMember> > jsClasses;
uint jsClassDataSize;
uint headerSize;
#include "qv4instr_moth_p.h"
-using namespace QQmlJS;
-using namespace QQmlJS::Moth;
+using namespace QV4;
+using namespace QV4::Moth;
int Instr::size(Type type)
{
# define MOTH_THREADED_INTERPRETER
#endif
-#define MOTH_INSTR_ALIGN_MASK (Q_ALIGNOF(QQmlJS::Moth::Instr) - 1)
+#define MOTH_INSTR_ALIGN_MASK (Q_ALIGNOF(QV4::Moth::Instr) - 1)
#ifdef MOTH_THREADED_INTERPRETER
# define MOTH_INSTR_HEADER void *code;
#endif
#define MOTH_INSTR_ENUM(I, FMT) I,
-#define MOTH_INSTR_SIZE(I, FMT) ((sizeof(QQmlJS::Moth::Instr::instr_##FMT) + MOTH_INSTR_ALIGN_MASK) & ~MOTH_INSTR_ALIGN_MASK)
+#define MOTH_INSTR_SIZE(I, FMT) ((sizeof(QV4::Moth::Instr::instr_##FMT) + MOTH_INSTR_ALIGN_MASK) & ~MOTH_INSTR_ALIGN_MASK)
-namespace QQmlJS {
+namespace QV4 {
namespace Moth {
struct Param {
};
} // namespace Moth
-} // namespace QQmlJS
+} // namespace QV4
QT_END_NAMESPACE
#undef USE_TYPE_INFO
-using namespace QQmlJS;
-using namespace QQmlJS::Moth;
+using namespace QV4;
+using namespace QV4::Moth;
namespace {
-inline QV4::BinOp aluOpFunction(V4IR::AluOp op)
+inline QV4::BinOp aluOpFunction(IR::AluOp op)
{
switch (op) {
- case V4IR::OpInvalid:
+ case IR::OpInvalid:
return 0;
- case V4IR::OpIfTrue:
+ case IR::OpIfTrue:
return 0;
- case V4IR::OpNot:
+ case IR::OpNot:
return 0;
- case V4IR::OpUMinus:
+ case IR::OpUMinus:
return 0;
- case V4IR::OpUPlus:
+ case IR::OpUPlus:
return 0;
- case V4IR::OpCompl:
+ case IR::OpCompl:
return 0;
- case V4IR::OpBitAnd:
+ case IR::OpBitAnd:
return QV4::__qmljs_bit_and;
- case V4IR::OpBitOr:
+ case IR::OpBitOr:
return QV4::__qmljs_bit_or;
- case V4IR::OpBitXor:
+ case IR::OpBitXor:
return QV4::__qmljs_bit_xor;
- case V4IR::OpAdd:
+ case IR::OpAdd:
return 0;
- case V4IR::OpSub:
+ case IR::OpSub:
return QV4::__qmljs_sub;
- case V4IR::OpMul:
+ case IR::OpMul:
return QV4::__qmljs_mul;
- case V4IR::OpDiv:
+ case IR::OpDiv:
return QV4::__qmljs_div;
- case V4IR::OpMod:
+ case IR::OpMod:
return QV4::__qmljs_mod;
- case V4IR::OpLShift:
+ case IR::OpLShift:
return QV4::__qmljs_shl;
- case V4IR::OpRShift:
+ case IR::OpRShift:
return QV4::__qmljs_shr;
- case V4IR::OpURShift:
+ case IR::OpURShift:
return QV4::__qmljs_ushr;
- case V4IR::OpGt:
+ case IR::OpGt:
return QV4::__qmljs_gt;
- case V4IR::OpLt:
+ case IR::OpLt:
return QV4::__qmljs_lt;
- case V4IR::OpGe:
+ case IR::OpGe:
return QV4::__qmljs_ge;
- case V4IR::OpLe:
+ case IR::OpLe:
return QV4::__qmljs_le;
- case V4IR::OpEqual:
+ case IR::OpEqual:
return QV4::__qmljs_eq;
- case V4IR::OpNotEqual:
+ case IR::OpNotEqual:
return QV4::__qmljs_ne;
- case V4IR::OpStrictEqual:
+ case IR::OpStrictEqual:
return QV4::__qmljs_se;
- case V4IR::OpStrictNotEqual:
+ case IR::OpStrictNotEqual:
return QV4::__qmljs_sne;
- case V4IR::OpInstanceof:
+ case IR::OpInstanceof:
return 0;
- case V4IR::OpIn:
+ case IR::OpIn:
return 0;
- case V4IR::OpAnd:
+ case IR::OpAnd:
return 0;
- case V4IR::OpOr:
+ case IR::OpOr:
return 0;
default:
assert(!"Unknown AluOp");
}
};
-inline bool isNumberType(V4IR::Expr *e)
+inline bool isNumberType(IR::Expr *e)
{
switch (e->type) {
- case V4IR::SInt32Type:
- case V4IR::UInt32Type:
- case V4IR::DoubleType:
+ case IR::SInt32Type:
+ case IR::UInt32Type:
+ case IR::DoubleType:
return true;
default:
return false;
}
}
-inline bool isIntegerType(V4IR::Expr *e)
+inline bool isIntegerType(IR::Expr *e)
{
switch (e->type) {
- case V4IR::SInt32Type:
- case V4IR::UInt32Type:
+ case IR::SInt32Type:
+ case IR::UInt32Type:
return true;
default:
return false;
}
}
-inline bool isBoolType(V4IR::Expr *e)
+inline bool isBoolType(IR::Expr *e)
{
- return (e->type == V4IR::BoolType);
+ return (e->type == IR::BoolType);
}
/*
*/
class AllocateStackSlots: protected ConvertTemps
{
- const QVector<V4IR::LifeTimeInterval> _intervals;
- QVector<const V4IR::LifeTimeInterval *> _unhandled;
- QVector<const V4IR::LifeTimeInterval *> _live;
+ const QVector<IR::LifeTimeInterval> _intervals;
+ QVector<const IR::LifeTimeInterval *> _unhandled;
+ QVector<const IR::LifeTimeInterval *> _live;
QBitArray _slotIsInUse;
- V4IR::Function *_function;
+ IR::Function *_function;
public:
- AllocateStackSlots(const QVector<V4IR::LifeTimeInterval> &intervals)
+ AllocateStackSlots(const QVector<IR::LifeTimeInterval> &intervals)
: _intervals(intervals)
, _slotIsInUse(intervals.size(), false)
, _function(0)
_unhandled.append(&_intervals.at(i));
}
- void forFunction(V4IR::Function *function)
+ void forFunction(IR::Function *function)
{
- V4IR::Optimizer::showMeTheCode(function);
+ IR::Optimizer::showMeTheCode(function);
_function = function;
toStackSlots(function);
return -1;
}
- virtual void process(V4IR::Stmt *s)
+ virtual void process(IR::Stmt *s)
{
Q_ASSERT(s->id > 0);
// qDebug("L%d statement %d:", _currentBasicBlock->index, s->id);
- if (V4IR::Phi *phi = s->asPhi()) {
+ if (IR::Phi *phi = s->asPhi()) {
visitPhi(phi);
} else {
// purge ranges no longer alive:
for (int i = 0; i < _live.size(); ) {
- const V4IR::LifeTimeInterval *lti = _live.at(i);
+ const IR::LifeTimeInterval *lti = _live.at(i);
if (lti->end() < s->id) {
// qDebug() << "\t - moving temp" << lti->temp().index << "to handled, freeing slot" << _stackSlotForTemp[lti->temp().index];
_live.remove(i);
// active new ranges:
while (!_unhandled.isEmpty()) {
- const V4IR::LifeTimeInterval *lti = _unhandled.last();
+ const IR::LifeTimeInterval *lti = _unhandled.last();
if (lti->start() > s->id)
break; // we're done
Q_ASSERT(!_stackSlotForTemp.contains(lti->temp().index));
s->accept(this);
}
- if (V4IR::Jump *jump = s->asJump()) {
- V4IR::MoveMapping moves;
- foreach (V4IR::Stmt *succStmt, jump->target->statements) {
- if (V4IR::Phi *phi = succStmt->asPhi()) {
+ if (IR::Jump *jump = s->asJump()) {
+ IR::MoveMapping moves;
+ foreach (IR::Stmt *succStmt, jump->target->statements) {
+ if (IR::Phi *phi = succStmt->asPhi()) {
forceActivation(*phi->targetTemp);
for (int i = 0, ei = phi->d->incoming.size(); i != ei; ++i) {
- V4IR::Expr *e = phi->d->incoming[i];
- if (V4IR::Temp *t = e->asTemp()) {
+ IR::Expr *e = phi->d->incoming[i];
+ if (IR::Temp *t = e->asTemp()) {
forceActivation(*t);
}
if (jump->target->in[i] == _currentBasicBlock)
}
}
moves.order();
- QList<V4IR::Move *> newMoves = moves.insertMoves(_currentBasicBlock, _function, true);
- foreach (V4IR::Move *move, newMoves)
+ QList<IR::Move *> newMoves = moves.insertMoves(_currentBasicBlock, _function, true);
+ foreach (IR::Move *move, newMoves)
move->accept(this);
}
}
- void forceActivation(const V4IR::Temp &t)
+ void forceActivation(const IR::Temp &t)
{
if (_stackSlotForTemp.contains(t.index))
return;
int i = _unhandled.size() - 1;
for (; i >= 0; --i) {
- const V4IR::LifeTimeInterval *lti = _unhandled[i];
+ const IR::LifeTimeInterval *lti = _unhandled[i];
if (lti->temp() == t) {
_live.append(lti);
_unhandled.remove(i);
// qDebug() << "\t - force activating temp" << t.index << "on slot" << _stackSlotForTemp[t.index];
}
- virtual void visitPhi(V4IR::Phi *phi)
+ virtual void visitPhi(IR::Phi *phi)
{
Q_UNUSED(phi);
#if !defined(QT_NO_DEBUG)
Q_ASSERT(_stackSlotForTemp.contains(phi->targetTemp->index));
Q_ASSERT(_slotIsInUse[_stackSlotForTemp[phi->targetTemp->index]]);
- foreach (V4IR::Expr *e, phi->d->incoming) {
- if (V4IR::Temp *t = e->asTemp())
+ foreach (IR::Expr *e, phi->d->incoming) {
+ if (IR::Temp *t = e->asTemp())
Q_ASSERT(_stackSlotForTemp.contains(t->index));
}
#endif // defined(QT_NO_DEBUG)
};
} // anonymous namespace
-InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
+InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
: EvalInstructionSelection(execAllocator, module, jsGenerator)
, qmlEngine(qmlEngine)
, _block(0)
void InstructionSelection::run(int functionIndex)
{
- V4IR::Function *function = irModule->functions[functionIndex];
- V4IR::BasicBlock *block = 0, *nextBlock = 0;
+ IR::Function *function = irModule->functions[functionIndex];
+ IR::BasicBlock *block = 0, *nextBlock = 0;
- QHash<V4IR::BasicBlock *, QVector<ptrdiff_t> > patches;
- QHash<V4IR::BasicBlock *, ptrdiff_t> addrs;
+ QHash<IR::BasicBlock *, QVector<ptrdiff_t> > patches;
+ QHash<IR::BasicBlock *, ptrdiff_t> addrs;
int codeSize = 4096;
uchar *codeStart = new uchar[codeSize];
qSwap(codeNext, _codeNext);
qSwap(codeEnd, _codeEnd);
- V4IR::Optimizer opt(_function);
+ IR::Optimizer opt(_function);
opt.run(qmlEngine);
if (opt.isInSSA()) {
static const bool doStackSlotAllocation =
ConvertTemps().toStackSlots(_function);
}
- QSet<V4IR::Jump *> removableJumps = opt.calculateOptionalJumps();
+ QSet<IR::Jump *> removableJumps = opt.calculateOptionalJumps();
qSwap(_removableJumps, removableJumps);
- V4IR::Stmt *cs = 0;
+ IR::Stmt *cs = 0;
qSwap(_currentStatement, cs);
int locals = frameSize();
assert(locals >= 0);
- V4IR::BasicBlock *exceptionHandler = 0;
+ IR::BasicBlock *exceptionHandler = 0;
Instruction::Push push;
push.value = quint32(locals);
exceptionHandler = _block->catchBlock;
}
- foreach (V4IR::Stmt *s, _block->statements) {
+ foreach (IR::Stmt *s, _block->statements) {
_currentStatement = s;
if (s->location.isValid()) {
{
compilationUnit->codeRefs.resize(irModule->functions.size());
int i = 0;
- foreach (V4IR::Function *irFunction, irModule->functions)
+ foreach (IR::Function *irFunction, irModule->functions)
compilationUnit->codeRefs[i++] = codeRefs[irFunction];
return compilationUnit;
}
-void InstructionSelection::callValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result)
{
Instruction::CallValue call;
prepareCallArgs(args, call.argc);
addInstruction(call);
}
-void InstructionSelection::callProperty(V4IR::Expr *base, const QString &name, V4IR::ExprList *args,
- V4IR::Temp *result)
+void InstructionSelection::callProperty(IR::Expr *base, const QString &name, IR::ExprList *args,
+ IR::Temp *result)
{
if (useFastLookups) {
Instruction::CallPropertyLookup call;
}
}
-void InstructionSelection::callSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::ExprList *args,
- V4IR::Temp *result)
+void InstructionSelection::callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args,
+ IR::Temp *result)
{
// call the property on the loaded base
Instruction::CallElement call;
addInstruction(call);
}
-void InstructionSelection::convertType(V4IR::Temp *source, V4IR::Temp *target)
+void InstructionSelection::convertType(IR::Temp *source, IR::Temp *target)
{
// FIXME: do something more useful with this info
- if (target->type & V4IR::NumberType && !(source->type & V4IR::NumberType))
- unop(V4IR::OpUPlus, source, target);
+ if (target->type & IR::NumberType && !(source->type & IR::NumberType))
+ unop(IR::OpUPlus, source, target);
else
copyValue(source, target);
}
-void InstructionSelection::constructActivationProperty(V4IR::Name *func,
- V4IR::ExprList *args,
- V4IR::Temp *result)
+void InstructionSelection::constructActivationProperty(IR::Name *func,
+ IR::ExprList *args,
+ IR::Temp *result)
{
if (useFastLookups && func->global) {
Instruction::ConstructGlobalLookup call;
addInstruction(create);
}
-void InstructionSelection::constructProperty(V4IR::Temp *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::constructProperty(IR::Temp *base, const QString &name, IR::ExprList *args, IR::Temp *result)
{
if (useFastLookups) {
Instruction::ConstructPropertyLookup call;
addInstruction(create);
}
-void InstructionSelection::constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::constructValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result)
{
Instruction::CreateValue create;
create.func = getParam(value);
addInstruction(create);
}
-void InstructionSelection::loadThisObject(V4IR::Temp *temp)
+void InstructionSelection::loadThisObject(IR::Temp *temp)
{
Instruction::LoadThis load;
load.result = getResultParam(temp);
addInstruction(load);
}
-void InstructionSelection::loadQmlIdArray(V4IR::Temp *temp)
+void InstructionSelection::loadQmlIdArray(IR::Temp *temp)
{
Instruction::LoadQmlIdArray load;
load.result = getResultParam(temp);
addInstruction(load);
}
-void InstructionSelection::loadQmlImportedScripts(V4IR::Temp *temp)
+void InstructionSelection::loadQmlImportedScripts(IR::Temp *temp)
{
Instruction::LoadQmlImportedScripts load;
load.result = getResultParam(temp);
addInstruction(load);
}
-void InstructionSelection::loadQmlContextObject(V4IR::Temp *temp)
+void InstructionSelection::loadQmlContextObject(IR::Temp *temp)
{
Instruction::LoadQmlContextObject load;
load.result = getResultParam(temp);
addInstruction(load);
}
-void InstructionSelection::loadQmlScopeObject(V4IR::Temp *temp)
+void InstructionSelection::loadQmlScopeObject(IR::Temp *temp)
{
Instruction::LoadQmlScopeObject load;
load.result = getResultParam(temp);
addInstruction(load);
}
-void InstructionSelection::loadQmlSingleton(const QString &name, V4IR::Temp *temp)
+void InstructionSelection::loadQmlSingleton(const QString &name, IR::Temp *temp)
{
Instruction::LoadQmlSingleton load;
load.result = getResultParam(temp);
addInstruction(load);
}
-void InstructionSelection::loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp)
+void InstructionSelection::loadConst(IR::Const *sourceConst, IR::Temp *targetTemp)
{
assert(sourceConst);
addInstruction(move);
}
-void InstructionSelection::loadString(const QString &str, V4IR::Temp *targetTemp)
+void InstructionSelection::loadString(const QString &str, IR::Temp *targetTemp)
{
Instruction::LoadRuntimeString load;
load.stringId = registerString(str);
addInstruction(load);
}
-void InstructionSelection::loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *targetTemp)
+void InstructionSelection::loadRegexp(IR::RegExp *sourceRegexp, IR::Temp *targetTemp)
{
Instruction::LoadRegExp load;
load.regExpId = registerRegExp(sourceRegexp);
addInstruction(load);
}
-void InstructionSelection::getActivationProperty(const V4IR::Name *name, V4IR::Temp *temp)
+void InstructionSelection::getActivationProperty(const IR::Name *name, IR::Temp *temp)
{
if (useFastLookups && name->global) {
Instruction::GetGlobalLookup load;
addInstruction(load);
}
-void InstructionSelection::setActivationProperty(V4IR::Expr *source, const QString &targetName)
+void InstructionSelection::setActivationProperty(IR::Expr *source, const QString &targetName)
{
Instruction::StoreName store;
store.source = getParam(source);
addInstruction(store);
}
-void InstructionSelection::initClosure(V4IR::Closure *closure, V4IR::Temp *target)
+void InstructionSelection::initClosure(IR::Closure *closure, IR::Temp *target)
{
int id = closure->value;
Instruction::LoadClosure load;
addInstruction(load);
}
-void InstructionSelection::getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target)
+void InstructionSelection::getProperty(IR::Expr *base, const QString &name, IR::Temp *target)
{
if (useFastLookups) {
Instruction::GetLookup load;
addInstruction(load);
}
-void InstructionSelection::setProperty(V4IR::Expr *source, V4IR::Expr *targetBase,
+void InstructionSelection::setProperty(IR::Expr *source, IR::Expr *targetBase,
const QString &targetName)
{
if (useFastLookups) {
addInstruction(store);
}
-void InstructionSelection::setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex)
+void InstructionSelection::setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex)
{
Instruction::StoreQObjectProperty store;
store.base = getParam(targetBase);
addInstruction(store);
}
-void InstructionSelection::getQObjectProperty(V4IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, V4IR::Temp *target)
+void InstructionSelection::getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, IR::Temp *target)
{
if (attachedPropertiesId != 0) {
Instruction::LoadAttachedQObjectProperty load;
}
}
-void InstructionSelection::getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target)
+void InstructionSelection::getElement(IR::Expr *base, IR::Expr *index, IR::Temp *target)
{
if (useFastLookups) {
Instruction::LoadElementLookup load;
addInstruction(load);
}
-void InstructionSelection::setElement(V4IR::Expr *source, V4IR::Expr *targetBase,
- V4IR::Expr *targetIndex)
+void InstructionSelection::setElement(IR::Expr *source, IR::Expr *targetBase,
+ IR::Expr *targetIndex)
{
if (useFastLookups) {
Instruction::StoreElementLookup store;
addInstruction(store);
}
-void InstructionSelection::copyValue(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp)
+void InstructionSelection::copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
Instruction::Move move;
move.source = getParam(sourceTemp);
addInstruction(move);
}
-void InstructionSelection::swapValues(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp)
+void InstructionSelection::swapValues(IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
Instruction::SwapTemps swap;
swap.left = getParam(sourceTemp);
addInstruction(swap);
}
-void InstructionSelection::unop(V4IR::AluOp oper, V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp)
+void InstructionSelection::unop(IR::AluOp oper, IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
switch (oper) {
- case V4IR::OpIfTrue:
+ case IR::OpIfTrue:
Q_ASSERT(!"unreachable"); break;
- case V4IR::OpNot: {
+ case IR::OpNot: {
// ### enabling this fails in some cases, where apparently the value is not a bool at runtime
if (0 && isBoolType(sourceTemp)) {
Instruction::UNotBool unot;
addInstruction(unot);
return;
}
- case V4IR::OpUMinus: {
+ case IR::OpUMinus: {
Instruction::UMinus uminus;
uminus.source = getParam(sourceTemp);
uminus.result = getResultParam(targetTemp);
addInstruction(uminus);
return;
}
- case V4IR::OpUPlus: {
+ case IR::OpUPlus: {
if (isNumberType(sourceTemp)) {
// use a move
Instruction::Move move;
addInstruction(uplus);
return;
}
- case V4IR::OpCompl: {
+ case IR::OpCompl: {
// ### enabling this fails in some cases, where apparently the value is not a int at runtime
if (0 && isIntegerType(sourceTemp)) {
Instruction::UComplInt unot;
addInstruction(ucompl);
return;
}
- case V4IR::OpIncrement: {
+ case IR::OpIncrement: {
Instruction::Increment inc;
inc.source = getParam(sourceTemp);
inc.result = getResultParam(targetTemp);
addInstruction(inc);
return;
}
- case V4IR::OpDecrement: {
+ case IR::OpDecrement: {
Instruction::Decrement dec;
dec.source = getParam(sourceTemp);
dec.result = getResultParam(targetTemp);
Q_ASSERT(!"unreachable");
}
-void InstructionSelection::binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
+void InstructionSelection::binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target)
{
binopHelper(oper, leftSource, rightSource, target);
}
-Param InstructionSelection::binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
+Param InstructionSelection::binopHelper(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target)
{
- if (oper == V4IR::OpAdd) {
+ if (oper == IR::OpAdd) {
Instruction::Add add;
add.lhs = getParam(leftSource);
add.rhs = getParam(rightSource);
addInstruction(add);
return add.result;
}
- if (oper == V4IR::OpSub) {
+ if (oper == IR::OpSub) {
Instruction::Sub sub;
sub.lhs = getParam(leftSource);
sub.rhs = getParam(rightSource);
addInstruction(sub);
return sub.result;
}
- if (oper == V4IR::OpMul) {
+ if (oper == IR::OpMul) {
Instruction::Mul mul;
mul.lhs = getParam(leftSource);
mul.rhs = getParam(rightSource);
addInstruction(mul);
return mul.result;
}
- if (oper == V4IR::OpBitAnd) {
+ if (oper == IR::OpBitAnd) {
if (leftSource->asConst())
qSwap(leftSource, rightSource);
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (IR::Const *c = rightSource->asConst()) {
Instruction::BitAndConst bitAnd;
bitAnd.lhs = getParam(leftSource);
bitAnd.rhs = convertToValue(c).Value::toInt32();
addInstruction(bitAnd);
return bitAnd.result;
}
- if (oper == V4IR::OpBitOr) {
+ if (oper == IR::OpBitOr) {
if (leftSource->asConst())
qSwap(leftSource, rightSource);
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (IR::Const *c = rightSource->asConst()) {
Instruction::BitOrConst bitOr;
bitOr.lhs = getParam(leftSource);
bitOr.rhs = convertToValue(c).Value::toInt32();
addInstruction(bitOr);
return bitOr.result;
}
- if (oper == V4IR::OpBitXor) {
+ if (oper == IR::OpBitXor) {
if (leftSource->asConst())
qSwap(leftSource, rightSource);
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (IR::Const *c = rightSource->asConst()) {
Instruction::BitXorConst bitXor;
bitXor.lhs = getParam(leftSource);
bitXor.rhs = convertToValue(c).Value::toInt32();
addInstruction(bitXor);
return bitXor.result;
}
- if (oper == V4IR::OpRShift) {
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (oper == IR::OpRShift) {
+ if (IR::Const *c = rightSource->asConst()) {
Instruction::ShrConst shr;
shr.lhs = getParam(leftSource);
shr.rhs = convertToValue(c).Value::toInt32() & 0x1f;
addInstruction(shr);
return shr.result;
}
- if (oper == V4IR::OpLShift) {
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (oper == IR::OpLShift) {
+ if (IR::Const *c = rightSource->asConst()) {
Instruction::ShlConst shl;
shl.lhs = getParam(leftSource);
shl.rhs = convertToValue(c).Value::toInt32() & 0x1f;
return shl.result;
}
- if (oper == V4IR::OpInstanceof || oper == V4IR::OpIn || oper == V4IR::OpAdd) {
+ if (oper == IR::OpInstanceof || oper == IR::OpIn || oper == IR::OpAdd) {
Instruction::BinopContext binop;
- if (oper == V4IR::OpInstanceof)
+ if (oper == IR::OpInstanceof)
binop.alu = QV4::__qmljs_instanceof;
- else if (oper == V4IR::OpIn)
+ else if (oper == IR::OpIn)
binop.alu = QV4::__qmljs_in;
else
binop.alu = QV4::__qmljs_add;
}
}
-void InstructionSelection::prepareCallArgs(V4IR::ExprList *e, quint32 &argc, quint32 *args)
+void InstructionSelection::prepareCallArgs(IR::ExprList *e, quint32 &argc, quint32 *args)
{
int argLocation = outgoingArgumentTempStart();
argc = 0;
// We need to move all the temps into the function arg array
assert(argLocation >= 0);
while (e) {
- if (V4IR::Const *c = e->expr->asConst()) {
+ if (IR::Const *c = e->expr->asConst()) {
Instruction::MoveConst move;
move.source = convertToValue(c).asReturnedValue();
move.result = Param::createTemp(argLocation);
}
}
-void InstructionSelection::visitJump(V4IR::Jump *s)
+void InstructionSelection::visitJump(IR::Jump *s)
{
if (s->target == _nextBlock)
return;
_patches[s->target].append(loc);
}
-void InstructionSelection::visitCJump(V4IR::CJump *s)
+void InstructionSelection::visitCJump(IR::CJump *s)
{
Param condition;
- if (V4IR::Temp *t = s->cond->asTemp()) {
+ if (IR::Temp *t = s->cond->asTemp()) {
condition = getResultParam(t);
- } else if (V4IR::Binop *b = s->cond->asBinop()) {
+ } else if (IR::Binop *b = s->cond->asBinop()) {
condition = binopHelper(b->op, b->left, b->right, /*target*/0);
} else {
Q_UNIMPLEMENTED();
}
}
-void InstructionSelection::visitRet(V4IR::Ret *s)
+void InstructionSelection::visitRet(IR::Ret *s)
{
Instruction::Ret ret;
ret.result = getParam(s->expr);
addInstruction(ret);
}
-void InstructionSelection::callBuiltinInvalid(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Temp *result)
{
if (useFastLookups && func->global) {
Instruction::CallGlobalLookup call;
addInstruction(call);
}
-void InstructionSelection::callBuiltinTypeofMember(V4IR::Expr *base, const QString &name,
- V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofMember(IR::Expr *base, const QString &name,
+ IR::Temp *result)
{
Instruction::CallBuiltinTypeofMember call;
call.base = getParam(base);
addInstruction(call);
}
-void InstructionSelection::callBuiltinTypeofSubscript(V4IR::Expr *base, V4IR::Expr *index,
- V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index,
+ IR::Temp *result)
{
Instruction::CallBuiltinTypeofSubscript call;
call.base = getParam(base);
addInstruction(call);
}
-void InstructionSelection::callBuiltinTypeofName(const QString &name, V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofName(const QString &name, IR::Temp *result)
{
Instruction::CallBuiltinTypeofName call;
call.name = registerString(name);
addInstruction(call);
}
-void InstructionSelection::callBuiltinTypeofValue(V4IR::Expr *value, V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofValue(IR::Expr *value, IR::Temp *result)
{
Instruction::CallBuiltinTypeofValue call;
call.value = getParam(value);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDeleteMember(V4IR::Temp *base, const QString &name, V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteMember(IR::Temp *base, const QString &name, IR::Temp *result)
{
Instruction::CallBuiltinDeleteMember call;
call.base = getParam(base);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDeleteSubscript(V4IR::Temp *base, V4IR::Expr *index,
- V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteSubscript(IR::Temp *base, IR::Expr *index,
+ IR::Temp *result)
{
Instruction::CallBuiltinDeleteSubscript call;
call.base = getParam(base);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDeleteName(const QString &name, V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteName(const QString &name, IR::Temp *result)
{
Instruction::CallBuiltinDeleteName call;
call.name = registerString(name);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDeleteValue(V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteValue(IR::Temp *result)
{
Instruction::MoveConst move;
move.source = QV4::Encode(false);
addInstruction(move);
}
-void InstructionSelection::callBuiltinThrow(V4IR::Expr *arg)
+void InstructionSelection::callBuiltinThrow(IR::Expr *arg)
{
Instruction::CallBuiltinThrow call;
call.arg = getParam(arg);
}
}
-void InstructionSelection::callBuiltinUnwindException(V4IR::Temp *result)
+void InstructionSelection::callBuiltinUnwindException(IR::Temp *result)
{
Instruction::CallBuiltinUnwindException call;
call.result = getResultParam(result);
addInstruction(call);
}
-void InstructionSelection::callBuiltinForeachIteratorObject(V4IR::Temp *arg, V4IR::Temp *result)
+void InstructionSelection::callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result)
{
Instruction::CallBuiltinForeachIteratorObject call;
call.arg = getParam(arg);
addInstruction(call);
}
-void InstructionSelection::callBuiltinForeachNextPropertyname(V4IR::Temp *arg, V4IR::Temp *result)
+void InstructionSelection::callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result)
{
Instruction::CallBuiltinForeachNextPropertyName call;
call.arg = getParam(arg);
addInstruction(call);
}
-void InstructionSelection::callBuiltinPushWithScope(V4IR::Temp *arg)
+void InstructionSelection::callBuiltinPushWithScope(IR::Temp *arg)
{
Instruction::CallBuiltinPushScope call;
call.arg = getParam(arg);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDefineGetterSetter(V4IR::Temp *object, const QString &name, V4IR::Temp *getter, V4IR::Temp *setter)
+void InstructionSelection::callBuiltinDefineGetterSetter(IR::Temp *object, const QString &name, IR::Temp *getter, IR::Temp *setter)
{
Instruction::CallBuiltinDefineGetterSetter call;
call.object = getParam(object);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDefineProperty(V4IR::Temp *object, const QString &name,
- V4IR::Expr *value)
+void InstructionSelection::callBuiltinDefineProperty(IR::Temp *object, const QString &name,
+ IR::Expr *value)
{
Instruction::CallBuiltinDefineProperty call;
call.object = getParam(object);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDefineArray(V4IR::Temp *result, V4IR::ExprList *args)
+void InstructionSelection::callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args)
{
Instruction::CallBuiltinDefineArray call;
prepareCallArgs(args, call.argc, &call.args);
addInstruction(call);
}
-void InstructionSelection::callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4IR::ExprList *args)
+void InstructionSelection::callBuiltinDefineObjectLiteral(IR::Temp *result, IR::ExprList *args)
{
int argLocation = outgoingArgumentTempStart();
const int classId = registerJSClass(args);
- V4IR::ExprList *it = args;
+ IR::ExprList *it = args;
while (it) {
it = it->next;
bool isData = it->expr->asConst()->value;
it = it->next;
- if (V4IR::Const *c = it->expr->asConst()) {
+ if (IR::Const *c = it->expr->asConst()) {
Instruction::MoveConst move;
move.source = convertToValue(c).asReturnedValue();
move.result = Param::createTemp(argLocation);
addInstruction(call);
}
-void InstructionSelection::callBuiltinSetupArgumentObject(V4IR::Temp *result)
+void InstructionSelection::callBuiltinSetupArgumentObject(IR::Temp *result)
{
Instruction::CallBuiltinSetupArgumentsObject call;
call.result = getResultParam(result);
}
-void QQmlJS::Moth::InstructionSelection::callBuiltinConvertThisToObject()
+void QV4::Moth::InstructionSelection::callBuiltinConvertThisToObject()
{
Instruction::CallBuiltinConvertThisToObject call;
addInstruction(call);
void InstructionSelection::patchJumpAddresses()
{
- typedef QHash<V4IR::BasicBlock *, QVector<ptrdiff_t> >::ConstIterator PatchIt;
+ typedef QHash<IR::BasicBlock *, QVector<ptrdiff_t> >::ConstIterator PatchIt;
for (PatchIt i = _patches.begin(), ei = _patches.end(); i != ei; ++i) {
Q_ASSERT(_addrs.contains(i.key()));
ptrdiff_t target = _addrs.value(i.key());
return squeezed;
}
-Param InstructionSelection::getParam(V4IR::Expr *e) {
+Param InstructionSelection::getParam(IR::Expr *e) {
assert(e);
- if (V4IR::Const *c = e->asConst()) {
+ if (IR::Const *c = e->asConst()) {
int idx = jsUnitGenerator()->registerConstant(convertToValue(c).asReturnedValue());
return Param::createConstant(idx);
- } else if (V4IR::Temp *t = e->asTemp()) {
+ } else if (IR::Temp *t = e->asTemp()) {
switch (t->kind) {
- case V4IR::Temp::Formal:
- case V4IR::Temp::ScopedFormal: return Param::createArgument(t->index, t->scope);
- case V4IR::Temp::Local: return Param::createLocal(t->index);
- case V4IR::Temp::ScopedLocal: return Param::createScopedLocal(t->index, t->scope);
- case V4IR::Temp::StackSlot:
+ case IR::Temp::Formal:
+ case IR::Temp::ScopedFormal: return Param::createArgument(t->index, t->scope);
+ case IR::Temp::Local: return Param::createLocal(t->index);
+ case IR::Temp::ScopedLocal: return Param::createScopedLocal(t->index, t->scope);
+ case IR::Temp::StackSlot:
return Param::createTemp(t->index);
default:
Q_UNREACHABLE();
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
+namespace QV4 {
namespace Moth {
struct CompilationUnit : public QV4::CompiledData::CompilationUnit
};
class Q_QML_EXPORT InstructionSelection:
- public V4IR::IRDecoder,
+ public IR::IRDecoder,
public EvalInstructionSelection
{
public:
- InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator);
+ InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator);
~InstructionSelection();
virtual void run(int functionIndex);
protected:
virtual QV4::CompiledData::CompilationUnit *backendCompileStep();
- virtual void visitJump(V4IR::Jump *);
- virtual void visitCJump(V4IR::CJump *);
- virtual void visitRet(V4IR::Ret *);
-
- virtual void callBuiltinInvalid(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void callBuiltinTypeofMember(V4IR::Expr *base, const QString &name, V4IR::Temp *result);
- virtual void callBuiltinTypeofSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *result);
- virtual void callBuiltinTypeofName(const QString &name, V4IR::Temp *result);
- virtual void callBuiltinTypeofValue(V4IR::Expr *value, V4IR::Temp *result);
- virtual void callBuiltinDeleteMember(V4IR::Temp *base, const QString &name, V4IR::Temp *result);
- virtual void callBuiltinDeleteSubscript(V4IR::Temp *base, V4IR::Expr *index, V4IR::Temp *result);
- virtual void callBuiltinDeleteName(const QString &name, V4IR::Temp *result);
- virtual void callBuiltinDeleteValue(V4IR::Temp *result);
- virtual void callBuiltinThrow(V4IR::Expr *arg);
+ virtual void visitJump(IR::Jump *);
+ virtual void visitCJump(IR::CJump *);
+ virtual void visitRet(IR::Ret *);
+
+ virtual void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Temp *result);
+ virtual void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Temp *result);
+ virtual void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Temp *result);
+ virtual void callBuiltinTypeofName(const QString &name, IR::Temp *result);
+ virtual void callBuiltinTypeofValue(IR::Expr *value, IR::Temp *result);
+ virtual void callBuiltinDeleteMember(IR::Temp *base, const QString &name, IR::Temp *result);
+ virtual void callBuiltinDeleteSubscript(IR::Temp *base, IR::Expr *index, IR::Temp *result);
+ virtual void callBuiltinDeleteName(const QString &name, IR::Temp *result);
+ virtual void callBuiltinDeleteValue(IR::Temp *result);
+ virtual void callBuiltinThrow(IR::Expr *arg);
virtual void callBuiltinReThrow();
- virtual void callBuiltinUnwindException(V4IR::Temp *);
+ virtual void callBuiltinUnwindException(IR::Temp *);
virtual void callBuiltinPushCatchScope(const QString &exceptionName);
- virtual void callBuiltinForeachIteratorObject(V4IR::Temp *arg, V4IR::Temp *result);
- virtual void callBuiltinForeachNextPropertyname(V4IR::Temp *arg, V4IR::Temp *result);
- virtual void callBuiltinPushWithScope(V4IR::Temp *arg);
+ virtual void callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result);
+ virtual void callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result);
+ virtual void callBuiltinPushWithScope(IR::Temp *arg);
virtual void callBuiltinPopScope();
virtual void callBuiltinDeclareVar(bool deletable, const QString &name);
- virtual void callBuiltinDefineGetterSetter(V4IR::Temp *object, const QString &name, V4IR::Temp *getter, V4IR::Temp *setter);
- virtual void callBuiltinDefineProperty(V4IR::Temp *object, const QString &name, V4IR::Expr *value);
- virtual void callBuiltinDefineArray(V4IR::Temp *result, V4IR::ExprList *args);
- virtual void callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4IR::ExprList *args);
- virtual void callBuiltinSetupArgumentObject(V4IR::Temp *result);
+ virtual void callBuiltinDefineGetterSetter(IR::Temp *object, const QString &name, IR::Temp *getter, IR::Temp *setter);
+ virtual void callBuiltinDefineProperty(IR::Temp *object, const QString &name, IR::Expr *value);
+ virtual void callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args);
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, IR::ExprList *args);
+ virtual void callBuiltinSetupArgumentObject(IR::Temp *result);
virtual void callBuiltinConvertThisToObject();
- virtual void callValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void callProperty(V4IR::Expr *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void callSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void convertType(V4IR::Temp *source, V4IR::Temp *target);
- virtual void constructActivationProperty(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void constructProperty(V4IR::Temp *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void loadThisObject(V4IR::Temp *temp);
- virtual void loadQmlIdArray(V4IR::Temp *temp);
- virtual void loadQmlImportedScripts(V4IR::Temp *temp);
- virtual void loadQmlContextObject(V4IR::Temp *temp);
- virtual void loadQmlScopeObject(V4IR::Temp *temp);
- virtual void loadQmlSingleton(const QString &name, V4IR::Temp *temp);
- virtual void loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp);
- virtual void loadString(const QString &str, V4IR::Temp *targetTemp);
- virtual void loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *targetTemp);
- virtual void getActivationProperty(const V4IR::Name *name, V4IR::Temp *temp);
- virtual void setActivationProperty(V4IR::Expr *source, const QString &targetName);
- virtual void initClosure(V4IR::Closure *closure, V4IR::Temp *target);
- virtual void getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target);
- virtual void setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &targetName);
- virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex);
- virtual void getQObjectProperty(V4IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, V4IR::Temp *target);
- virtual void getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target);
- virtual void setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex);
- virtual void copyValue(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp);
- virtual void swapValues(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp);
- virtual void unop(V4IR::AluOp oper, V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp);
- virtual void binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target);
+ virtual void callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result);
+ virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Temp *result);
+ virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Temp *result);
+ virtual void convertType(IR::Temp *source, IR::Temp *target);
+ virtual void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Temp *result);
+ virtual void constructProperty(IR::Temp *base, const QString &name, IR::ExprList *args, IR::Temp *result);
+ virtual void constructValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result);
+ virtual void loadThisObject(IR::Temp *temp);
+ virtual void loadQmlIdArray(IR::Temp *temp);
+ virtual void loadQmlImportedScripts(IR::Temp *temp);
+ virtual void loadQmlContextObject(IR::Temp *temp);
+ virtual void loadQmlScopeObject(IR::Temp *temp);
+ virtual void loadQmlSingleton(const QString &name, IR::Temp *temp);
+ virtual void loadConst(IR::Const *sourceConst, IR::Temp *targetTemp);
+ virtual void loadString(const QString &str, IR::Temp *targetTemp);
+ virtual void loadRegexp(IR::RegExp *sourceRegexp, IR::Temp *targetTemp);
+ virtual void getActivationProperty(const IR::Name *name, IR::Temp *temp);
+ virtual void setActivationProperty(IR::Expr *source, const QString &targetName);
+ virtual void initClosure(IR::Closure *closure, IR::Temp *target);
+ virtual void getProperty(IR::Expr *base, const QString &name, IR::Temp *target);
+ virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName);
+ virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex);
+ virtual void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, IR::Temp *target);
+ virtual void getElement(IR::Expr *base, IR::Expr *index, IR::Temp *target);
+ virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex);
+ virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp);
+ virtual void swapValues(IR::Temp *sourceTemp, IR::Temp *targetTemp);
+ virtual void unop(IR::AluOp oper, IR::Temp *sourceTemp, IR::Temp *targetTemp);
+ virtual void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target);
private:
- Param binopHelper(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target);
+ Param binopHelper(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target);
struct Instruction {
#define MOTH_INSTR_DATA_TYPEDEF(I, FMT) typedef InstrData<Instr::I> I;
Instruction();
};
- Param getParam(V4IR::Expr *e);
+ Param getParam(IR::Expr *e);
- Param getResultParam(V4IR::Temp *result)
+ Param getResultParam(IR::Temp *result)
{
if (result)
return getParam(result);
return Param::createTemp(scratchTempIndex());
}
- void simpleMove(V4IR::Move *);
- void prepareCallArgs(V4IR::ExprList *, quint32 &, quint32 * = 0);
+ void simpleMove(IR::Move *);
+ void prepareCallArgs(IR::ExprList *, quint32 &, quint32 * = 0);
int scratchTempIndex() const { return _function->tempCount; }
int callDataStart() const { return scratchTempIndex() + 1; }
QQmlEnginePrivate *qmlEngine;
- V4IR::BasicBlock *_block;
- V4IR::BasicBlock *_nextBlock;
+ IR::BasicBlock *_block;
+ IR::BasicBlock *_nextBlock;
- QHash<V4IR::BasicBlock *, QVector<ptrdiff_t> > _patches;
- QHash<V4IR::BasicBlock *, ptrdiff_t> _addrs;
+ QHash<IR::BasicBlock *, QVector<ptrdiff_t> > _patches;
+ QHash<IR::BasicBlock *, ptrdiff_t> _addrs;
uchar *_codeStart;
uchar *_codeNext;
uchar *_codeEnd;
- QSet<V4IR::Jump *> _removableJumps;
- V4IR::Stmt *_currentStatement;
+ QSet<IR::Jump *> _removableJumps;
+ IR::Stmt *_currentStatement;
CompilationUnit *compilationUnit;
- QHash<V4IR::Function *, QByteArray> codeRefs;
+ QHash<IR::Function *, QByteArray> codeRefs;
};
class Q_QML_EXPORT ISelFactory: public EvalISelFactory
{
public:
virtual ~ISelFactory() {}
- virtual EvalInstructionSelection *create(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
+ virtual EvalInstructionSelection *create(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
{ return new InstructionSelection(qmlEngine, execAllocator, module, jsGenerator); }
virtual bool jitCompileRegexps() const
{ return false; }
}
} // namespace Moth
-} // namespace QQmlJS
+} // namespace QV4
QT_END_NAMESPACE
#define qout *qout()
} // anonymous namespace
-using namespace QQmlJS;
-using namespace QQmlJS::V4IR;
+using namespace QV4;
+using namespace QV4::IR;
EvalInstructionSelection::EvalInstructionSelection(QV4::ExecutableAllocator *execAllocator, Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
: useFastLookups(true)
return unit;
}
-void IRDecoder::visitMove(V4IR::Move *s)
+void IRDecoder::visitMove(IR::Move *s)
{
- if (V4IR::Name *n = s->target->asName()) {
+ if (IR::Name *n = s->target->asName()) {
if (s->source->asTemp() || s->source->asConst()) {
setActivationProperty(s->source, *n->id);
return;
}
- } else if (V4IR::Temp *t = s->target->asTemp()) {
- if (V4IR::Name *n = s->source->asName()) {
+ } else if (IR::Temp *t = s->target->asTemp()) {
+ if (IR::Name *n = s->source->asName()) {
if (n->id && *n->id == QStringLiteral("this")) // TODO: `this' should be a builtin.
loadThisObject(t);
- else if (n->builtin == V4IR::Name::builtin_qml_id_array)
+ else if (n->builtin == IR::Name::builtin_qml_id_array)
loadQmlIdArray(t);
- else if (n->builtin == V4IR::Name::builtin_qml_context_object)
+ else if (n->builtin == IR::Name::builtin_qml_context_object)
loadQmlContextObject(t);
- else if (n->builtin == V4IR::Name::builtin_qml_scope_object)
+ else if (n->builtin == IR::Name::builtin_qml_scope_object)
loadQmlScopeObject(t);
- else if (n->builtin == V4IR::Name::builtin_qml_imported_scripts_object)
+ else if (n->builtin == IR::Name::builtin_qml_imported_scripts_object)
loadQmlImportedScripts(t);
else if (n->qmlSingleton)
loadQmlSingleton(*n->id, t);
else
getActivationProperty(n, t);
return;
- } else if (V4IR::Const *c = s->source->asConst()) {
+ } else if (IR::Const *c = s->source->asConst()) {
loadConst(c, t);
return;
- } else if (V4IR::Temp *t2 = s->source->asTemp()) {
+ } else if (IR::Temp *t2 = s->source->asTemp()) {
if (s->swap)
swapValues(t2, t);
else
copyValue(t2, t);
return;
- } else if (V4IR::String *str = s->source->asString()) {
+ } else if (IR::String *str = s->source->asString()) {
loadString(*str->value, t);
return;
- } else if (V4IR::RegExp *re = s->source->asRegExp()) {
+ } else if (IR::RegExp *re = s->source->asRegExp()) {
loadRegexp(re, t);
return;
- } else if (V4IR::Closure *clos = s->source->asClosure()) {
+ } else if (IR::Closure *clos = s->source->asClosure()) {
initClosure(clos, t);
return;
- } else if (V4IR::New *ctor = s->source->asNew()) {
+ } else if (IR::New *ctor = s->source->asNew()) {
if (Name *func = ctor->base->asName()) {
constructActivationProperty(func, ctor->args, t);
return;
- } else if (V4IR::Member *member = ctor->base->asMember()) {
+ } else if (IR::Member *member = ctor->base->asMember()) {
constructProperty(member->base->asTemp(), *member->name, ctor->args, t);
return;
- } else if (V4IR::Temp *value = ctor->base->asTemp()) {
+ } else if (IR::Temp *value = ctor->base->asTemp()) {
constructValue(value, ctor->args, t);
return;
}
- } else if (V4IR::Member *m = s->source->asMember()) {
+ } else if (IR::Member *m = s->source->asMember()) {
if (m->property) {
bool captureRequired = true;
- Q_ASSERT(m->kind != V4IR::Member::MemberOfEnum);
+ Q_ASSERT(m->kind != IR::Member::MemberOfEnum);
const int attachedPropertiesId = m->attachedPropertiesIdOrEnumValue;
if (_function && attachedPropertiesId == 0 && !m->property->isConstant()) {
- if (m->kind == V4IR::Member::MemberOfQmlContextObject) {
+ if (m->kind == IR::Member::MemberOfQmlContextObject) {
_function->contextObjectPropertyDependencies.insert(m->property->coreIndex, m->property->notifyIndex);
captureRequired = false;
- } else if (m->kind == V4IR::Member::MemberOfQmlScopeObject) {
+ } else if (m->kind == IR::Member::MemberOfQmlScopeObject) {
_function->scopeObjectPropertyDependencies.insert(m->property->coreIndex, m->property->notifyIndex);
captureRequired = false;
}
getProperty(m->base, *m->name, t);
return;
}
- } else if (V4IR::Subscript *ss = s->source->asSubscript()) {
+ } else if (IR::Subscript *ss = s->source->asSubscript()) {
getElement(ss->base->asTemp(), ss->index, t);
return;
- } else if (V4IR::Unop *u = s->source->asUnop()) {
- if (V4IR::Temp *e = u->expr->asTemp()) {
+ } else if (IR::Unop *u = s->source->asUnop()) {
+ if (IR::Temp *e = u->expr->asTemp()) {
unop(u->op, e, t);
return;
}
- } else if (V4IR::Binop *b = s->source->asBinop()) {
+ } else if (IR::Binop *b = s->source->asBinop()) {
binop(b->op, b->left, b->right, t);
return;
- } else if (V4IR::Call *c = s->source->asCall()) {
+ } else if (IR::Call *c = s->source->asCall()) {
if (c->base->asName()) {
callBuiltin(c, t);
return;
} else if (Subscript *ss = c->base->asSubscript()) {
callSubscript(ss->base, ss->index, c->args, t);
return;
- } else if (V4IR::Temp *value = c->base->asTemp()) {
+ } else if (IR::Temp *value = c->base->asTemp()) {
callValue(value, c->args, t);
return;
}
- } else if (V4IR::Convert *c = s->source->asConvert()) {
+ } else if (IR::Convert *c = s->source->asConvert()) {
Q_ASSERT(c->expr->asTemp());
convertType(c->expr->asTemp(), t);
return;
}
- } else if (V4IR::Member *m = s->target->asMember()) {
+ } else if (IR::Member *m = s->target->asMember()) {
if (m->base->asTemp() || m->base->asConst()) {
if (s->source->asTemp() || s->source->asConst()) {
- Q_ASSERT(m->kind != V4IR::Member::MemberOfEnum);
+ Q_ASSERT(m->kind != IR::Member::MemberOfEnum);
const int attachedPropertiesId = m->attachedPropertiesIdOrEnumValue;
if (m->property && attachedPropertiesId == 0) {
setQObjectProperty(s->source, m->base, m->property->coreIndex);
}
}
}
- } else if (V4IR::Subscript *ss = s->target->asSubscript()) {
+ } else if (IR::Subscript *ss = s->target->asSubscript()) {
if (s->source->asTemp() || s->source->asConst()) {
setElement(s->source, ss->base, ss->index);
return;
// For anything else...:
Q_UNIMPLEMENTED();
- s->dump(qout, V4IR::Stmt::MIR);
+ s->dump(qout, IR::Stmt::MIR);
qout << endl;
assert(!"TODO");
}
{
}
-void IRDecoder::visitExp(V4IR::Exp *s)
+void IRDecoder::visitExp(IR::Exp *s)
{
- if (V4IR::Call *c = s->expr->asCall()) {
+ if (IR::Call *c = s->expr->asCall()) {
// These are calls where the result is ignored.
if (c->base->asName()) {
callBuiltin(c, 0);
}
}
-void IRDecoder::callBuiltin(V4IR::Call *call, V4IR::Temp *result)
+void IRDecoder::callBuiltin(IR::Call *call, IR::Temp *result)
{
- V4IR::Name *baseName = call->base->asName();
+ IR::Name *baseName = call->base->asName();
assert(baseName != 0);
switch (baseName->builtin) {
- case V4IR::Name::builtin_invalid:
+ case IR::Name::builtin_invalid:
callBuiltinInvalid(baseName, call->args, result);
return;
- case V4IR::Name::builtin_typeof: {
- if (V4IR::Member *m = call->args->expr->asMember()) {
+ case IR::Name::builtin_typeof: {
+ if (IR::Member *m = call->args->expr->asMember()) {
callBuiltinTypeofMember(m->base, *m->name, result);
return;
- } else if (V4IR::Subscript *ss = call->args->expr->asSubscript()) {
+ } else if (IR::Subscript *ss = call->args->expr->asSubscript()) {
callBuiltinTypeofSubscript(ss->base, ss->index, result);
return;
- } else if (V4IR::Name *n = call->args->expr->asName()) {
+ } else if (IR::Name *n = call->args->expr->asName()) {
callBuiltinTypeofName(*n->id, result);
return;
} else if (call->args->expr->asTemp() || call->args->expr->asConst()){
}
} break;
- case V4IR::Name::builtin_delete: {
- if (V4IR::Member *m = call->args->expr->asMember()) {
+ case IR::Name::builtin_delete: {
+ if (IR::Member *m = call->args->expr->asMember()) {
callBuiltinDeleteMember(m->base->asTemp(), *m->name, result);
return;
- } else if (V4IR::Subscript *ss = call->args->expr->asSubscript()) {
+ } else if (IR::Subscript *ss = call->args->expr->asSubscript()) {
callBuiltinDeleteSubscript(ss->base->asTemp(), ss->index, result);
return;
- } else if (V4IR::Name *n = call->args->expr->asName()) {
+ } else if (IR::Name *n = call->args->expr->asName()) {
callBuiltinDeleteName(*n->id, result);
return;
} else if (call->args->expr->asTemp()){
}
} break;
- case V4IR::Name::builtin_throw: {
- V4IR::Expr *arg = call->args->expr;
+ case IR::Name::builtin_throw: {
+ IR::Expr *arg = call->args->expr;
assert(arg->asTemp() || arg->asConst());
callBuiltinThrow(arg);
} return;
- case V4IR::Name::builtin_rethrow: {
+ case IR::Name::builtin_rethrow: {
callBuiltinReThrow();
} return;
- case V4IR::Name::builtin_unwind_exception: {
+ case IR::Name::builtin_unwind_exception: {
callBuiltinUnwindException(result);
} return;
- case V4IR::Name::builtin_push_catch_scope: {
- V4IR::String *s = call->args->expr->asString();
+ case IR::Name::builtin_push_catch_scope: {
+ IR::String *s = call->args->expr->asString();
Q_ASSERT(s);
callBuiltinPushCatchScope(*s->value);
} return;
- case V4IR::Name::builtin_foreach_iterator_object: {
- V4IR::Temp *arg = call->args->expr->asTemp();
+ case IR::Name::builtin_foreach_iterator_object: {
+ IR::Temp *arg = call->args->expr->asTemp();
assert(arg != 0);
callBuiltinForeachIteratorObject(arg, result);
} return;
- case V4IR::Name::builtin_foreach_next_property_name: {
- V4IR::Temp *arg = call->args->expr->asTemp();
+ case IR::Name::builtin_foreach_next_property_name: {
+ IR::Temp *arg = call->args->expr->asTemp();
assert(arg != 0);
callBuiltinForeachNextPropertyname(arg, result);
} return;
- case V4IR::Name::builtin_push_with_scope: {
- V4IR::Temp *arg = call->args->expr->asTemp();
+ case IR::Name::builtin_push_with_scope: {
+ IR::Temp *arg = call->args->expr->asTemp();
assert(arg != 0);
callBuiltinPushWithScope(arg);
} return;
- case V4IR::Name::builtin_pop_scope:
+ case IR::Name::builtin_pop_scope:
callBuiltinPopScope();
return;
- case V4IR::Name::builtin_declare_vars: {
+ case IR::Name::builtin_declare_vars: {
if (!call->args)
return;
- V4IR::Const *deletable = call->args->expr->asConst();
- assert(deletable->type == V4IR::BoolType);
- for (V4IR::ExprList *it = call->args->next; it; it = it->next) {
- V4IR::Name *arg = it->expr->asName();
+ IR::Const *deletable = call->args->expr->asConst();
+ assert(deletable->type == IR::BoolType);
+ for (IR::ExprList *it = call->args->next; it; it = it->next) {
+ IR::Name *arg = it->expr->asName();
assert(arg != 0);
callBuiltinDeclareVar(deletable->value != 0, *arg->id);
}
} return;
- case V4IR::Name::builtin_define_getter_setter: {
+ case IR::Name::builtin_define_getter_setter: {
if (!call->args)
return;
- V4IR::ExprList *args = call->args;
- V4IR::Temp *object = args->expr->asTemp();
+ IR::ExprList *args = call->args;
+ IR::Temp *object = args->expr->asTemp();
assert(object);
args = args->next;
assert(args);
- V4IR::Name *name = args->expr->asName();
+ IR::Name *name = args->expr->asName();
args = args->next;
assert(args);
- V4IR::Temp *getter = args->expr->asTemp();
+ IR::Temp *getter = args->expr->asTemp();
args = args->next;
assert(args);
- V4IR::Temp *setter = args->expr->asTemp();
+ IR::Temp *setter = args->expr->asTemp();
callBuiltinDefineGetterSetter(object, *name->id, getter, setter);
} return;
- case V4IR::Name::builtin_define_property: {
+ case IR::Name::builtin_define_property: {
if (!call->args)
return;
- V4IR::ExprList *args = call->args;
- V4IR::Temp *object = args->expr->asTemp();
+ IR::ExprList *args = call->args;
+ IR::Temp *object = args->expr->asTemp();
assert(object);
args = args->next;
assert(args);
- V4IR::Name *name = args->expr->asName();
+ IR::Name *name = args->expr->asName();
args = args->next;
assert(args);
- V4IR::Expr *value = args->expr;
+ IR::Expr *value = args->expr;
callBuiltinDefineProperty(object, *name->id, value);
} return;
- case V4IR::Name::builtin_define_array:
+ case IR::Name::builtin_define_array:
callBuiltinDefineArray(result, call->args);
return;
- case V4IR::Name::builtin_define_object_literal:
+ case IR::Name::builtin_define_object_literal:
callBuiltinDefineObjectLiteral(result, call->args);
return;
- case V4IR::Name::builtin_setup_argument_object:
+ case IR::Name::builtin_setup_argument_object:
callBuiltinSetupArgumentObject(result);
return;
- case V4IR::Name::builtin_convert_this_to_object:
+ case IR::Name::builtin_convert_this_to_object:
callBuiltinConvertThisToObject();
return;
class QQmlEnginePrivate;
namespace QV4 {
+
class ExecutableAllocator;
struct Function;
-}
-
-namespace QQmlJS {
class Q_QML_EXPORT EvalInstructionSelection
{
public:
- EvalInstructionSelection(QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator);
+ EvalInstructionSelection(QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator);
virtual ~EvalInstructionSelection() = 0;
QV4::CompiledData::CompilationUnit *compile(bool generateUnitData = true);
uint registerGetterLookup(const QString &name) { return jsGenerator->registerGetterLookup(name); }
uint registerSetterLookup(const QString &name) { return jsGenerator->registerSetterLookup(name); }
uint registerGlobalGetterLookup(const QString &name) { return jsGenerator->registerGlobalGetterLookup(name); }
- int registerRegExp(QQmlJS::V4IR::RegExp *regexp) { return jsGenerator->registerRegExp(regexp); }
- int registerJSClass(QQmlJS::V4IR::ExprList *args) { return jsGenerator->registerJSClass(args); }
+ int registerRegExp(IR::RegExp *regexp) { return jsGenerator->registerRegExp(regexp); }
+ int registerJSClass(IR::ExprList *args) { return jsGenerator->registerJSClass(args); }
QV4::Compiler::JSUnitGenerator *jsUnitGenerator() const { return jsGenerator; }
protected:
QV4::ExecutableAllocator *executableAllocator;
QV4::Compiler::JSUnitGenerator *jsGenerator;
QScopedPointer<QV4::Compiler::JSUnitGenerator> ownJSGenerator;
- V4IR::Module *irModule;
+ IR::Module *irModule;
};
class Q_QML_EXPORT EvalISelFactory
{
public:
virtual ~EvalISelFactory() = 0;
- virtual EvalInstructionSelection *create(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator) = 0;
+ virtual EvalInstructionSelection *create(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator) = 0;
virtual bool jitCompileRegexps() const = 0;
};
-namespace V4IR {
-class Q_QML_EXPORT IRDecoder: protected V4IR::StmtVisitor
+namespace IR {
+class Q_QML_EXPORT IRDecoder: protected IR::StmtVisitor
{
public:
IRDecoder() : _function(0) {}
virtual ~IRDecoder() = 0;
- virtual void visitPhi(V4IR::Phi *) {}
+ virtual void visitPhi(IR::Phi *) {}
public: // visitor methods for StmtVisitor:
- virtual void visitMove(V4IR::Move *s);
- virtual void visitExp(V4IR::Exp *s);
+ virtual void visitMove(IR::Move *s);
+ virtual void visitExp(IR::Exp *s);
public: // to implement by subclasses:
- virtual void callBuiltinInvalid(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result) = 0;
- virtual void callBuiltinTypeofMember(V4IR::Expr *base, const QString &name, V4IR::Temp *result) = 0;
- virtual void callBuiltinTypeofSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *result) = 0;
- virtual void callBuiltinTypeofName(const QString &name, V4IR::Temp *result) = 0;
- virtual void callBuiltinTypeofValue(V4IR::Expr *value, V4IR::Temp *result) = 0;
- virtual void callBuiltinDeleteMember(V4IR::Temp *base, const QString &name, V4IR::Temp *result) = 0;
- virtual void callBuiltinDeleteSubscript(V4IR::Temp *base, V4IR::Expr *index, V4IR::Temp *result) = 0;
- virtual void callBuiltinDeleteName(const QString &name, V4IR::Temp *result) = 0;
- virtual void callBuiltinDeleteValue(V4IR::Temp *result) = 0;
- virtual void callBuiltinThrow(V4IR::Expr *arg) = 0;
+ virtual void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Temp *result) = 0;
+ virtual void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Temp *result) = 0;
+ virtual void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Temp *result) = 0;
+ virtual void callBuiltinTypeofName(const QString &name, IR::Temp *result) = 0;
+ virtual void callBuiltinTypeofValue(IR::Expr *value, IR::Temp *result) = 0;
+ virtual void callBuiltinDeleteMember(IR::Temp *base, const QString &name, IR::Temp *result) = 0;
+ virtual void callBuiltinDeleteSubscript(IR::Temp *base, IR::Expr *index, IR::Temp *result) = 0;
+ virtual void callBuiltinDeleteName(const QString &name, IR::Temp *result) = 0;
+ virtual void callBuiltinDeleteValue(IR::Temp *result) = 0;
+ virtual void callBuiltinThrow(IR::Expr *arg) = 0;
virtual void callBuiltinReThrow() = 0;
- virtual void callBuiltinUnwindException(V4IR::Temp *) = 0;
+ virtual void callBuiltinUnwindException(IR::Temp *) = 0;
virtual void callBuiltinPushCatchScope(const QString &exceptionName) = 0;
- virtual void callBuiltinForeachIteratorObject(V4IR::Temp *arg, V4IR::Temp *result) = 0;
- virtual void callBuiltinForeachNextPropertyname(V4IR::Temp *arg, V4IR::Temp *result) = 0;
- virtual void callBuiltinPushWithScope(V4IR::Temp *arg) = 0;
+ virtual void callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result) = 0;
+ virtual void callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result) = 0;
+ virtual void callBuiltinPushWithScope(IR::Temp *arg) = 0;
virtual void callBuiltinPopScope() = 0;
virtual void callBuiltinDeclareVar(bool deletable, const QString &name) = 0;
- virtual void callBuiltinDefineGetterSetter(V4IR::Temp *object, const QString &name, V4IR::Temp *getter, V4IR::Temp *setter) = 0;
- virtual void callBuiltinDefineProperty(V4IR::Temp *object, const QString &name, V4IR::Expr *value) = 0;
- virtual void callBuiltinDefineArray(V4IR::Temp *result, V4IR::ExprList *args) = 0;
- virtual void callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4IR::ExprList *args) = 0;
- virtual void callBuiltinSetupArgumentObject(V4IR::Temp *result) = 0;
+ virtual void callBuiltinDefineGetterSetter(IR::Temp *object, const QString &name, IR::Temp *getter, IR::Temp *setter) = 0;
+ virtual void callBuiltinDefineProperty(IR::Temp *object, const QString &name, IR::Expr *value) = 0;
+ virtual void callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args) = 0;
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, IR::ExprList *args) = 0;
+ virtual void callBuiltinSetupArgumentObject(IR::Temp *result) = 0;
virtual void callBuiltinConvertThisToObject() = 0;
- virtual void callValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result) = 0;
- virtual void callProperty(V4IR::Expr *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result) = 0;
- virtual void callSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::ExprList *args, V4IR::Temp *result) = 0;
- virtual void convertType(V4IR::Temp *source, V4IR::Temp *target) = 0;
- virtual void constructActivationProperty(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result) = 0;
- virtual void constructProperty(V4IR::Temp *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result) = 0;
- virtual void constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result) = 0;
- virtual void loadThisObject(V4IR::Temp *temp) = 0;
- virtual void loadQmlIdArray(V4IR::Temp *temp) = 0;
- virtual void loadQmlImportedScripts(V4IR::Temp *temp) = 0;
- virtual void loadQmlContextObject(V4IR::Temp *temp) = 0;
- virtual void loadQmlScopeObject(V4IR::Temp *temp) = 0;
- virtual void loadQmlSingleton(const QString &name, V4IR::Temp *temp) = 0;
- virtual void loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp) = 0;
- virtual void loadString(const QString &str, V4IR::Temp *targetTemp) = 0;
- virtual void loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *targetTemp) = 0;
- virtual void getActivationProperty(const V4IR::Name *name, V4IR::Temp *temp) = 0;
- virtual void setActivationProperty(V4IR::Expr *source, const QString &targetName) = 0;
- virtual void initClosure(V4IR::Closure *closure, V4IR::Temp *target) = 0;
- virtual void getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target) = 0;
- virtual void getQObjectProperty(V4IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, V4IR::Temp *targetTemp) = 0;
- virtual void setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &targetName) = 0;
- virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex) = 0;
- virtual void getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target) = 0;
- virtual void setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex) = 0;
- virtual void copyValue(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp) = 0;
- virtual void swapValues(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp) = 0;
- virtual void unop(V4IR::AluOp oper, V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp) = 0;
- virtual void binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target) = 0;
+ virtual void callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result) = 0;
+ virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Temp *result) = 0;
+ virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Temp *result) = 0;
+ virtual void convertType(IR::Temp *source, IR::Temp *target) = 0;
+ virtual void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Temp *result) = 0;
+ virtual void constructProperty(IR::Temp *base, const QString &name, IR::ExprList *args, IR::Temp *result) = 0;
+ virtual void constructValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result) = 0;
+ virtual void loadThisObject(IR::Temp *temp) = 0;
+ virtual void loadQmlIdArray(IR::Temp *temp) = 0;
+ virtual void loadQmlImportedScripts(IR::Temp *temp) = 0;
+ virtual void loadQmlContextObject(IR::Temp *temp) = 0;
+ virtual void loadQmlScopeObject(IR::Temp *temp) = 0;
+ virtual void loadQmlSingleton(const QString &name, IR::Temp *temp) = 0;
+ virtual void loadConst(IR::Const *sourceConst, IR::Temp *targetTemp) = 0;
+ virtual void loadString(const QString &str, IR::Temp *targetTemp) = 0;
+ virtual void loadRegexp(IR::RegExp *sourceRegexp, IR::Temp *targetTemp) = 0;
+ virtual void getActivationProperty(const IR::Name *name, IR::Temp *temp) = 0;
+ virtual void setActivationProperty(IR::Expr *source, const QString &targetName) = 0;
+ virtual void initClosure(IR::Closure *closure, IR::Temp *target) = 0;
+ virtual void getProperty(IR::Expr *base, const QString &name, IR::Temp *target) = 0;
+ virtual void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, IR::Temp *targetTemp) = 0;
+ virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName) = 0;
+ virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex) = 0;
+ virtual void getElement(IR::Expr *base, IR::Expr *index, IR::Temp *target) = 0;
+ virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex) = 0;
+ virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp) = 0;
+ virtual void swapValues(IR::Temp *sourceTemp, IR::Temp *targetTemp) = 0;
+ virtual void unop(IR::AluOp oper, IR::Temp *sourceTemp, IR::Temp *targetTemp) = 0;
+ virtual void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target) = 0;
protected:
- virtual void callBuiltin(V4IR::Call *c, V4IR::Temp *result);
+ virtual void callBuiltin(IR::Call *c, IR::Temp *result);
- V4IR::Function *_function; // subclass needs to set
+ IR::Function *_function; // subclass needs to set
};
} // namespace IR
-} // namespace QQmlJS
+} // namespace QV4
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
+namespace QV4 {
inline bool canConvertToSignedInteger(double value)
{
return uval == value && !(value == 0 && isNegative(value));
}
-inline QV4::Primitive convertToValue(V4IR::Const *c)
+inline Primitive convertToValue(IR::Const *c)
{
switch (c->type) {
- case V4IR::MissingType:
- return QV4::Primitive::emptyValue();
- case V4IR::NullType:
- return QV4::Primitive::nullValue();
- case V4IR::UndefinedType:
- return QV4::Primitive::undefinedValue();
- case V4IR::BoolType:
- return QV4::Primitive::fromBoolean(c->value != 0);
- case V4IR::SInt32Type:
- return QV4::Primitive::fromInt32(int(c->value));
- case V4IR::UInt32Type:
- return QV4::Primitive::fromUInt32(unsigned(c->value));
- case V4IR::DoubleType:
- return QV4::Primitive::fromDouble(c->value);
- case V4IR::NumberType: {
+ case IR::MissingType:
+ return Primitive::emptyValue();
+ case IR::NullType:
+ return Primitive::nullValue();
+ case IR::UndefinedType:
+ return Primitive::undefinedValue();
+ case IR::BoolType:
+ return Primitive::fromBoolean(c->value != 0);
+ case IR::SInt32Type:
+ return Primitive::fromInt32(int(c->value));
+ case IR::UInt32Type:
+ return Primitive::fromUInt32(unsigned(c->value));
+ case IR::DoubleType:
+ return Primitive::fromDouble(c->value);
+ case IR::NumberType: {
int ival = (int)c->value;
if (canConvertToSignedInteger(c->value)) {
- return QV4::Primitive::fromInt32(ival);
+ return Primitive::fromInt32(ival);
} else {
- return QV4::Primitive::fromDouble(c->value);
+ return Primitive::fromDouble(c->value);
}
}
default:
Q_UNREACHABLE();
}
// unreachable, but the function must return something
- return QV4::Primitive::undefinedValue();
+ return Primitive::undefinedValue();
}
-class ConvertTemps: protected V4IR::StmtVisitor, protected V4IR::ExprVisitor
+class ConvertTemps: protected IR::StmtVisitor, protected IR::ExprVisitor
{
- void renumber(V4IR::Temp *t)
+ void renumber(IR::Temp *t)
{
- if (t->kind != V4IR::Temp::VirtualRegister)
+ if (t->kind != IR::Temp::VirtualRegister)
return;
int stackSlot = _stackSlotForTemp.value(t->index, -1);
_stackSlotForTemp[t->index] = stackSlot;
}
- t->kind = V4IR::Temp::StackSlot;
+ t->kind = IR::Temp::StackSlot;
t->index = stackSlot;
}
protected:
int _nextUnusedStackSlot;
QHash<int, int> _stackSlotForTemp;
- V4IR::BasicBlock *_currentBasicBlock;
+ IR::BasicBlock *_currentBasicBlock;
virtual int allocateFreeSlot()
{
return _nextUnusedStackSlot++;
}
- virtual void process(V4IR::Stmt *s)
+ virtual void process(IR::Stmt *s)
{
s->accept(this);
}
, _currentBasicBlock(0)
{}
- void toStackSlots(V4IR::Function *function)
+ void toStackSlots(IR::Function *function)
{
_stackSlotForTemp.reserve(function->tempCount);
- foreach (V4IR::BasicBlock *bb, function->basicBlocks) {
+ foreach (IR::BasicBlock *bb, function->basicBlocks) {
_currentBasicBlock = bb;
- foreach (V4IR::Stmt *s, bb->statements)
+ foreach (IR::Stmt *s, bb->statements)
process(s);
}
}
protected:
- virtual void visitConst(V4IR::Const *) {}
- virtual void visitString(V4IR::String *) {}
- virtual void visitRegExp(V4IR::RegExp *) {}
- virtual void visitName(V4IR::Name *) {}
- virtual void visitTemp(V4IR::Temp *e) { renumber(e); }
- virtual void visitClosure(V4IR::Closure *) {}
- virtual void visitConvert(V4IR::Convert *e) { e->expr->accept(this); }
- virtual void visitUnop(V4IR::Unop *e) { e->expr->accept(this); }
- virtual void visitBinop(V4IR::Binop *e) { e->left->accept(this); e->right->accept(this); }
- virtual void visitCall(V4IR::Call *e) {
+ virtual void visitConst(IR::Const *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
+ virtual void visitName(IR::Name *) {}
+ virtual void visitTemp(IR::Temp *e) { renumber(e); }
+ virtual void visitClosure(IR::Closure *) {}
+ virtual void visitConvert(IR::Convert *e) { e->expr->accept(this); }
+ virtual void visitUnop(IR::Unop *e) { e->expr->accept(this); }
+ virtual void visitBinop(IR::Binop *e) { e->left->accept(this); e->right->accept(this); }
+ virtual void visitCall(IR::Call *e) {
e->base->accept(this);
- for (V4IR::ExprList *it = e->args; it; it = it->next)
+ for (IR::ExprList *it = e->args; it; it = it->next)
it->expr->accept(this);
}
- virtual void visitNew(V4IR::New *e) {
+ virtual void visitNew(IR::New *e) {
e->base->accept(this);
- for (V4IR::ExprList *it = e->args; it; it = it->next)
+ for (IR::ExprList *it = e->args; it; it = it->next)
it->expr->accept(this);
}
- virtual void visitSubscript(V4IR::Subscript *e) { e->base->accept(this); e->index->accept(this); }
- virtual void visitMember(V4IR::Member *e) { e->base->accept(this); }
- virtual void visitExp(V4IR::Exp *s) { s->expr->accept(this); }
- virtual void visitMove(V4IR::Move *s) { s->target->accept(this); s->source->accept(this); }
- virtual void visitJump(V4IR::Jump *) {}
- virtual void visitCJump(V4IR::CJump *s) { s->cond->accept(this); }
- virtual void visitRet(V4IR::Ret *s) { s->expr->accept(this); }
- virtual void visitPhi(V4IR::Phi *) { Q_UNREACHABLE(); }
+ virtual void visitSubscript(IR::Subscript *e) { e->base->accept(this); e->index->accept(this); }
+ virtual void visitMember(IR::Member *e) { e->base->accept(this); }
+ virtual void visitExp(IR::Exp *s) { s->expr->accept(this); }
+ virtual void visitMove(IR::Move *s) { s->target->accept(this); s->source->accept(this); }
+ virtual void visitJump(IR::Jump *) {}
+ virtual void visitCJump(IR::CJump *s) { s->cond->accept(this); }
+ virtual void visitRet(IR::Ret *s) { s->expr->accept(this); }
+ virtual void visitPhi(IR::Phi *) { Q_UNREACHABLE(); }
};
-} // namespace QQmlJS
+} // namespace QV4
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
-namespace V4IR {
+namespace QV4 {
+namespace IR {
QString typeName(Type t)
{
}
}
-struct RemoveSharedExpressions: V4IR::StmtVisitor, V4IR::ExprVisitor
+struct RemoveSharedExpressions: IR::StmtVisitor, IR::ExprVisitor
{
CloneExpr clone;
QSet<Expr *> subexpressions; // contains all the non-cloned subexpressions in the given function
RemoveSharedExpressions(): uniqueExpr(0) {}
- void operator()(V4IR::Function *function)
+ void operator()(IR::Function *function)
{
subexpressions.clear();
}
subexpressions.insert(expr);
- V4IR::Expr *e = expr;
+ IR::Expr *e = expr;
qSwap(uniqueExpr, e);
expr->accept(this);
qSwap(uniqueExpr, e);
s->expr = cleanup(s->expr);
}
- virtual void visitPhi(V4IR::Phi *) { Q_UNIMPLEMENTED(); }
+ virtual void visitPhi(IR::Phi *) { Q_UNIMPLEMENTED(); }
// expressions
virtual void visitConst(Const *) {}
virtual void visitCall(Call *e)
{
e->base = cleanup(e->base);
- for (V4IR::ExprList *it = e->args; it; it = it->next)
+ for (IR::ExprList *it = e->args; it; it = it->next)
it->expr = cleanup(it->expr);
}
virtual void visitNew(New *e)
{
e->base = cleanup(e->base);
- for (V4IR::ExprList *it = e->args; it; it = it->next)
+ for (IR::ExprList *it = e->args; it; it = it->next)
it->expr = cleanup(it->expr);
}
if (type != UndefinedType && type != NullType)
out << dumpStart(this);
switch (type) {
- case QQmlJS::V4IR::UndefinedType:
+ case QV4::IR::UndefinedType:
out << "undefined";
break;
- case QQmlJS::V4IR::NullType:
+ case QV4::IR::NullType:
out << "null";
break;
- case QQmlJS::V4IR::BoolType:
+ case QV4::IR::BoolType:
out << (value ? "true" : "false");
break;
- case QQmlJS::V4IR::MissingType:
+ case QV4::IR::MissingType:
out << "missing";
break;
default:
return "builtin_unwind_exception";
case Name::builtin_push_catch_scope:
return "builtin_push_catch_scope";
- case V4IR::Name::builtin_foreach_iterator_object:
+ case IR::Name::builtin_foreach_iterator_object:
return "builtin_foreach_iterator_object";
- case V4IR::Name::builtin_foreach_next_property_name:
+ case IR::Name::builtin_foreach_next_property_name:
return "builtin_foreach_next_property_name";
- case V4IR::Name::builtin_push_with_scope:
+ case IR::Name::builtin_push_with_scope:
return "builtin_push_with_scope";
- case V4IR::Name::builtin_pop_scope:
+ case IR::Name::builtin_pop_scope:
return "builtin_pop_scope";
- case V4IR::Name::builtin_declare_vars:
+ case IR::Name::builtin_declare_vars:
return "builtin_declare_vars";
- case V4IR::Name::builtin_define_property:
+ case IR::Name::builtin_define_property:
return "builtin_define_property";
- case V4IR::Name::builtin_define_array:
+ case IR::Name::builtin_define_array:
return "builtin_define_array";
- case V4IR::Name::builtin_define_getter_setter:
+ case IR::Name::builtin_define_getter_setter:
return "builtin_define_getter_setter";
- case V4IR::Name::builtin_define_object_literal:
+ case IR::Name::builtin_define_object_literal:
return "builtin_define_object_literal";
- case V4IR::Name::builtin_setup_argument_object:
+ case IR::Name::builtin_setup_argument_object:
return "builtin_setup_argument_object";
- case V4IR::Name::builtin_convert_this_to_object:
+ case IR::Name::builtin_convert_this_to_object:
return "builtin_convert_this_to_object";
- case V4IR::Name::builtin_qml_id_array:
+ case IR::Name::builtin_qml_id_array:
return "builtin_qml_id_array";
- case V4IR::Name::builtin_qml_imported_scripts_object:
+ case IR::Name::builtin_qml_imported_scripts_object:
return "builtin_qml_imported_scripts_object";
- case V4IR::Name::builtin_qml_scope_object:
+ case IR::Name::builtin_qml_scope_object:
return "builtin_qml_scope_object";
- case V4IR::Name::builtin_qml_context_object:
+ case IR::Name::builtin_qml_context_object:
return "builtin_qml_context_object";
}
return "builtin_(###FIXME)";
{
// destroy the Stmt::Data blocks manually, because memory pool cleanup won't
// call the Stmt destructors.
- foreach (V4IR::BasicBlock *b, basicBlocks)
- foreach (V4IR::Stmt *s, b->statements)
+ foreach (IR::BasicBlock *b, basicBlocks)
+ foreach (IR::Stmt *s, b->statements)
s->destroyData();
qDeleteAll(basicBlocks);
if (! list)
return 0;
- ExprList *clonedList = block->function->New<V4IR::ExprList>();
+ ExprList *clonedList = block->function->New<IR::ExprList>();
clonedList->init(clone(list->expr), clone(list->next));
return clonedList;
}
}
} // end of namespace IR
-} // end of namespace QQmlJS
+} // end of namespace QV4
QT_END_NAMESPACE
struct ExecutionContext;
}
-namespace QQmlJS {
+namespace QV4 {
inline bool isNegative(double d)
{
}
-namespace V4IR {
+namespace IR {
struct BasicBlock;
struct Function;
LastAluOp = OpOr
};
AluOp binaryOperator(int op);
-const char *opname(V4IR::AluOp op);
+const char *opname(IR::AluOp op);
enum Type {
UnknownType = 0,
Data *d;
int id;
- AST::SourceLocation location;
+ QQmlJS::AST::SourceLocation location;
Stmt(): d(0), id(-1) {}
virtual ~Stmt()
};
struct Q_QML_EXPORT Module {
- MemoryPool pool;
+ QQmlJS::MemoryPool pool;
QVector<Function *> functions;
Function *rootFunction;
QString fileName;
struct Function {
Module *module;
- MemoryPool *pool;
+ QQmlJS::MemoryPool *pool;
const QString *name;
QVector<BasicBlock *> basicBlocks;
int tempCount;
QBitArray liveOut;
int index;
bool isExceptionHandler;
- AST::SourceLocation nextLocation;
+ QQmlJS::AST::SourceLocation nextLocation;
BasicBlock(Function *function, BasicBlock *containingLoop, BasicBlock *catcher)
: function(function)
bool _groupStart;
};
-class CloneExpr: protected V4IR::ExprVisitor
+class CloneExpr: protected IR::ExprVisitor
{
public:
- explicit CloneExpr(V4IR::BasicBlock *block = 0);
+ explicit CloneExpr(IR::BasicBlock *block = 0);
- void setBasicBlock(V4IR::BasicBlock *block);
+ void setBasicBlock(IR::BasicBlock *block);
template <typename _Expr>
_Expr *operator()(_Expr *expr)
}
protected:
- V4IR::ExprList *clone(V4IR::ExprList *list);
+ IR::ExprList *clone(IR::ExprList *list);
virtual void visitConst(Const *);
virtual void visitString(String *);
virtual void visitMember(Member *);
private:
- V4IR::BasicBlock *block;
- V4IR::Expr *cloned;
+ IR::BasicBlock *block;
+ IR::Expr *cloned;
};
} // end of namespace IR
-} // end of namespace QQmlJS
+} // end of namespace QV4
QT_END_NAMESPACE
QT_USE_NAMESPACE
-using namespace QQmlJS;
-using namespace V4IR;
+using namespace QV4;
+using namespace IR;
namespace {
Q_GLOBAL_STATIC_WITH_ARGS(QTextStream, qout, (stderr, QIODevice::WriteOnly));
#define qout *qout()
-void showMeTheCode(Function *function)
+void showMeTheCode(IR::Function *function)
{
static bool showCode = !qgetenv("QV4_SHOW_IR").isNull();
if (showCode) {
}
};
-inline bool unescapableTemp(Temp *t, Function *f)
+inline bool unescapableTemp(Temp *t, IR::Function *f)
{
switch (t->kind) {
case Temp::Formal:
}
}
-inline Temp *unescapableTemp(Expr *e, Function *f)
+inline Temp *unescapableTemp(Expr *e, IR::Function *f)
{
Temp *t = e->asTemp();
if (!t)
QSet<Temp> killed;
BasicBlock *currentBB;
- Function *function;
+ IR::Function *function;
bool isCollectable(Temp *t) const
{
Q_ASSERT(t->kind != Temp::PhysicalRegister && t->kind != Temp::StackSlot);
}
public:
- VariableCollector(Function *function)
+ VariableCollector(IR::Function *function)
: function(function)
{
_defsites.reserve(function->tempCount);
virtual void visitConvert(Convert *e) { e->expr->accept(this); };
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitClosure(Closure *) {}
virtual void visitUnop(Unop *e) { e->expr->accept(this); }
}
};
-void insertPhiNode(const Temp &a, BasicBlock *y, Function *f) {
+void insertPhiNode(const Temp &a, BasicBlock *y, IR::Function *f) {
#if defined(SHOW_SSA)
qout << "-> inserted phi node for variable ";
a.dump(qout);
// mapping[t] = c
class VariableRenamer: public StmtVisitor, public ExprVisitor
{
- Function *function;
+ IR::Function *function;
unsigned tempCount;
typedef QHash<unsigned, int> Mapping; // maps from existing/old temp number to the new and unique temp number.
QVector<TodoAction> todo;
public:
- VariableRenamer(Function *f)
+ VariableRenamer(IR::Function *f)
: function(f)
, tempCount(0)
, processed(f->basicBlocks)
virtual void visitRet(Ret *s) { s->expr->accept(this); }
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitClosure(Closure *) {}
virtual void visitUnop(Unop *e) { e->expr->accept(this); }
}
};
-void convertToSSA(Function *function, const DominatorTree &df)
+void convertToSSA(IR::Function *function, const DominatorTree &df)
{
#ifdef SHOW_SSA
qout << "Converting function ";
};
private:
- Function *function;
+ IR::Function *function;
QHash<UntypedTemp, DefUse> _defUses;
QHash<Stmt *, QList<Temp> > _usesPerStatement;
}
public:
- DefUsesCalculator(Function *function)
+ DefUsesCalculator(IR::Function *function)
: function(function)
{
foreach (BasicBlock *bb, function->basicBlocks) {
virtual void visitTemp(Temp *e) { addUse(e); }
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitClosure(Closure *) {}
virtual void visitConvert(Convert *e) { e->expr->accept(this); }
QHash<Stmt*,Stmt**> ref;
public:
- StatementWorklist(Function *function)
+ StatementWorklist(IR::Function *function)
{
QVector<Stmt *> w;
int stmtCount = 0;
*ref[oldStmt] = newStmt;
}
- void cleanup(Function *function)
+ void cleanup(IR::Function *function)
{
foreach (BasicBlock *bb, function->basicBlocks) {
for (int i = 0; i < bb->statements.size();) {
class EliminateDeadCode: public ExprVisitor {
DefUsesCalculator &_defUses;
StatementWorklist &_worklist;
- Function *function;
+ IR::Function *function;
bool _sideEffect;
QVector<Temp *> _collectedTemps;
public:
- EliminateDeadCode(DefUsesCalculator &defUses, StatementWorklist &worklist, Function *function)
+ EliminateDeadCode(DefUsesCalculator &defUses, StatementWorklist &worklist, IR::Function *function)
: _defUses(defUses)
, _worklist(worklist)
, function(function)
protected:
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *e)
{
protected:
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitTemp(Temp *e) {
if (theTemp == UntypedTemp(*e)) {
class TypeInference: public StmtVisitor, public ExprVisitor {
QQmlEnginePrivate *qmlEngine;
- Function *function;
+ IR::Function *function;
const DefUsesCalculator &_defUses;
QHash<Temp, DiscoveredType> _tempTypes;
QSet<Stmt *> _worklist;
, _ty(UnknownType)
{}
- void run(Function *f) {
+ void run(IR::Function *f) {
function = f;
// TODO: the worklist handling looks a bit inefficient... check if there is something better
} else
_ty = TypingResult(e->type);
}
- virtual void visitString(String *) { _ty = TypingResult(StringType); }
- virtual void visitRegExp(RegExp *) { _ty = TypingResult(VarType); }
+ virtual void visitString(IR::String *) { _ty = TypingResult(StringType); }
+ virtual void visitRegExp(IR::RegExp *) { _ty = TypingResult(VarType); }
virtual void visitName(Name *) { _ty = TypingResult(VarType); }
virtual void visitTemp(Temp *e) {
if (isAlwaysVar(e))
: _defUses(defUses)
{}
- void run(Function *f)
+ void run(IR::Function *f)
{
QVector<UntypedTemp> knownOk;
QList<UntypedTemp> candidates = _defUses.defsUntyped();
class TypePropagation: public StmtVisitor, public ExprVisitor {
DefUsesCalculator &_defUses;
Type _ty;
- Function *_f;
+ IR::Function *_f;
bool run(Expr *&e, Type requestedType = UnknownType, bool insertConversion = true) {
qSwap(_ty, requestedType);
public:
TypePropagation(DefUsesCalculator &defUses) : _defUses(defUses), _ty(UnknownType) {}
- void run(Function *f) {
+ void run(IR::Function *f) {
_f = f;
foreach (BasicBlock *bb, f->basicBlocks) {
_conversions.clear();
}
foreach (const Conversion &conversion, _conversions) {
- V4IR::Move *move = conversion.stmt->asMove();
+ IR::Move *move = conversion.stmt->asMove();
// Note: isel only supports move into member when source is a temp, so convert
// is not a supported source.
}
}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitTemp(Temp *) {}
virtual void visitClosure(Closure *) {}
}
};
-void splitCriticalEdges(Function *f, DominatorTree &df)
+void splitCriticalEdges(IR::Function *f, DominatorTree &df)
{
for (int i = 0, ei = f->basicBlocks.size(); i != ei; ++i) {
BasicBlock *bb = f->basicBlocks[i];
// the same reason.
class BlockScheduler
{
- Function *function;
+ IR::Function *function;
const DominatorTree &dominatorTree;
struct WorkForGroup
}
public:
- BlockScheduler(Function *function, const DominatorTree &dominatorTree)
+ BlockScheduler(IR::Function *function, const DominatorTree &dominatorTree)
: function(function)
, dominatorTree(dominatorTree)
, emitted(function->basicBlocks)
}
#endif
-void cleanupBasicBlocks(Function *function, bool renumber)
+void cleanupBasicBlocks(IR::Function *function, bool renumber)
{
showMeTheCode(function);
return 0;
}
-static Expr *clone(Expr *e, Function *function) {
+static Expr *clone(Expr *e, IR::Function *function) {
if (Temp *t = e->asTemp()) {
return CloneExpr::cloneTemp(t, function);
} else if (Const *c = e->asConst()) {
class ExprReplacer: public StmtVisitor, public ExprVisitor
{
DefUsesCalculator &_defUses;
- Function* _function;
+ IR::Function* _function;
Temp *_toReplace;
Expr *_replacement;
public:
- ExprReplacer(DefUsesCalculator &defUses, Function *function)
+ ExprReplacer(DefUsesCalculator &defUses, IR::Function *function)
: _defUses(defUses)
, _function(function)
, _toReplace(0)
protected:
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitTemp(Temp *) {}
virtual void visitClosure(Closure *) {}
/// and removes unreachable staements from the worklist, so that optimiseSSA won't consider them
/// anymore.
/// Important: this assumes that there are no critical edges in the control-flow graph!
-void purgeBB(BasicBlock *bb, Function *func, DefUsesCalculator &defUses, StatementWorklist &W,
+void purgeBB(BasicBlock *bb, IR::Function *func, DefUsesCalculator &defUses, StatementWorklist &W,
DominatorTree &df)
{
// TODO: change this to mark the block as deleted, but leave it alone so that other references
}
} // anonymous namespace
-void optimizeSSA(Function *function, DefUsesCalculator &defUses, DominatorTree &df)
+void optimizeSSA(IR::Function *function, DefUsesCalculator &defUses, DominatorTree &df)
{
StatementWorklist W(function);
ExprReplacer replaceUses(defUses, function);
}
class InputOutputCollector: protected StmtVisitor, protected ExprVisitor {
- Function *function;
+ IR::Function *function;
public:
QList<Temp> inputs;
QList<Temp> outputs;
- InputOutputCollector(Function *f): function(f) {}
+ InputOutputCollector(IR::Function *f): function(f) {}
void collect(Stmt *s) {
inputs.clear();
protected:
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitTemp(Temp *e) {
if (unescapableTemp(e, function))
QVector<LifeTimeInterval> _sortedRanges;
public:
- LifeRanges(Function *function, const QHash<BasicBlock *, BasicBlock *> &startEndLoops)
+ LifeRanges(IR::Function *function, const QHash<BasicBlock *, BasicBlock *> &startEndLoops)
{
int id = 0;
foreach (BasicBlock *bb, function->basicBlocks) {
}
private:
- void buildIntervals(BasicBlock *bb, BasicBlock *loopEnd, Function *function)
+ void buildIntervals(BasicBlock *bb, BasicBlock *loopEnd, IR::Function *function)
{
LiveRegs live;
foreach (BasicBlock *successor, bb->out) {
return optional;
}
-void Optimizer::showMeTheCode(Function *function)
+void Optimizer::showMeTheCode(IR::Function *function)
{
::showMeTheCode(function);
}
qSwap(_moves, output);
}
-QList<V4IR::Move *> MoveMapping::insertMoves(BasicBlock *bb, Function *function, bool atEnd) const
+QList<IR::Move *> MoveMapping::insertMoves(BasicBlock *bb, IR::Function *function, bool atEnd) const
{
- QList<V4IR::Move *> newMoves;
+ QList<IR::Move *> newMoves;
newMoves.reserve(_moves.size());
int insertionPoint = atEnd ? bb->statements.size() - 1 : 0;
foreach (const Move &m, _moves) {
- V4IR::Move *move = function->New<V4IR::Move>();
+ IR::Move *move = function->New<IR::Move>();
move->init(clone(m.to, function), clone(m.from, function));
move->swap = m.needsSwap;
bb->statements.insert(insertionPoint++, move);
class QTextStream;
class QQmlEnginePrivate;
-namespace QQmlJS {
-namespace V4IR {
+namespace QV4 {
+namespace IR {
class Q_AUTOTEST_EXPORT LifeTimeInterval {
public:
void setTemp(const Temp &temp) { this->_temp = temp; }
Temp temp() const { return _temp; }
- bool isFP() const { return _temp.type == V4IR::DoubleType; }
+ bool isFP() const { return _temp.type == IR::DoubleType; }
void setFrom(Stmt *from);
void addRange(int from, int to);
QVector<LifeTimeInterval> lifeRanges() const;
- QSet<V4IR::Jump *> calculateOptionalJumps();
+ QSet<IR::Jump *> calculateOptionalJumps();
static void showMeTheCode(Function *function);
public:
void add(Expr *from, Temp *to);
void order();
- QList<V4IR::Move *> insertMoves(BasicBlock *bb, Function *function, bool atEnd) const;
+ QList<IR::Move *> insertMoves(BasicBlock *bb, Function *function, bool atEnd) const;
void dump() const;
QList<Move> &swaps) const;
};
-} // V4IR namespace
-} // QQmlJS namespace
+} // IR namespace
+} // QV4 namespace
-Q_DECLARE_TYPEINFO(QQmlJS::V4IR::LifeTimeInterval, Q_MOVABLE_TYPE);
-Q_DECLARE_TYPEINFO(QQmlJS::V4IR::LifeTimeInterval::Range, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QV4::IR::LifeTimeInterval, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(QV4::IR::LifeTimeInterval::Range, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
# include <udis86.h>
#endif
-using namespace QQmlJS;
-using namespace QQmlJS::MASM;
using namespace QV4;
+using namespace QV4::JIT;
CompilationUnit::~CompilationUnit()
{
const Assembler::VoidType Assembler::Void;
-Assembler::Assembler(InstructionSelection *isel, V4IR::Function* function, QV4::ExecutableAllocator *executableAllocator,
+Assembler::Assembler(InstructionSelection *isel, IR::Function* function, QV4::ExecutableAllocator *executableAllocator,
int maxArgCountForBuiltins)
: _stackLayout(function, maxArgCountForBuiltins)
, _constTable(this)
{
}
-void Assembler::registerBlock(V4IR::BasicBlock* block, V4IR::BasicBlock *nextBlock)
+void Assembler::registerBlock(IR::BasicBlock* block, IR::BasicBlock *nextBlock)
{
_addrs[block] = label();
catchBlock = block->catchBlock;
_nextBlock = nextBlock;
}
-void Assembler::jumpToBlock(V4IR::BasicBlock* current, V4IR::BasicBlock *target)
+void Assembler::jumpToBlock(IR::BasicBlock* current, IR::BasicBlock *target)
{
Q_UNUSED(current);
_patches[target].append(jump());
}
-void Assembler::addPatch(V4IR::BasicBlock* targetBlock, Jump targetJump)
+void Assembler::addPatch(IR::BasicBlock* targetBlock, Jump targetJump)
{
_patches[targetBlock].append(targetJump);
}
_dataLabelPatches.append(p);
}
-void Assembler::addPatch(DataLabelPtr patch, V4IR::BasicBlock *target)
+void Assembler::addPatch(DataLabelPtr patch, IR::BasicBlock *target)
{
_labelPatches[target].append(patch);
}
-void Assembler::generateCJumpOnNonZero(RegisterID reg, V4IR::BasicBlock *currentBlock,
- V4IR::BasicBlock *trueBlock, V4IR::BasicBlock *falseBlock)
+void Assembler::generateCJumpOnNonZero(RegisterID reg, IR::BasicBlock *currentBlock,
+ IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock)
{
generateCJumpOnCompare(NotEqual, reg, TrustedImm32(0), currentBlock, trueBlock, falseBlock);
}
void Assembler::generateCJumpOnCompare(RelationalCondition cond, RegisterID left,TrustedImm32 right,
- V4IR::BasicBlock *currentBlock, V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock)
+ IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
if (trueBlock == _nextBlock) {
Jump target = branch32(invert(cond), left, right);
}
void Assembler::generateCJumpOnCompare(RelationalCondition cond, RegisterID left, RegisterID right,
- V4IR::BasicBlock *currentBlock, V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock)
+ IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
if (trueBlock == _nextBlock) {
Jump target = branch32(invert(cond), left, right);
}
}
-Assembler::Pointer Assembler::loadTempAddress(RegisterID baseReg, V4IR::Temp *t)
+Assembler::Pointer Assembler::loadTempAddress(RegisterID baseReg, IR::Temp *t)
{
int32_t offset = 0;
int scope = t->scope;
}
}
switch (t->kind) {
- case V4IR::Temp::Formal:
- case V4IR::Temp::ScopedFormal: {
+ case IR::Temp::Formal:
+ case IR::Temp::ScopedFormal: {
loadPtr(Address(context, qOffsetOf(ExecutionContext, callData)), baseReg);
offset = sizeof(CallData) + (t->index - 1) * sizeof(Value);
} break;
- case V4IR::Temp::Local:
- case V4IR::Temp::ScopedLocal: {
+ case IR::Temp::Local:
+ case IR::Temp::ScopedLocal: {
loadPtr(Address(context, qOffsetOf(CallContext, locals)), baseReg);
offset = t->index * sizeof(Value);
} break;
- case V4IR::Temp::StackSlot: {
+ case IR::Temp::StackSlot: {
return stackSlotPointer(t);
} break;
default:
addPtr(TrustedImmPtr(id * sizeof(QV4::StringValue)), reg);
}
-void Assembler::storeValue(QV4::Primitive value, V4IR::Temp* destination)
+void Assembler::storeValue(QV4::Primitive value, IR::Temp* destination)
{
Address addr = loadTempAddress(ScratchRegister, destination);
storeValue(value, addr);
#define NULL_OP \
{ 0, 0, 0, 0, 0 }
-const Assembler::BinaryOperationInfo Assembler::binaryOperations[QQmlJS::V4IR::LastAluOp + 1] = {
+const Assembler::BinaryOperationInfo Assembler::binaryOperations[IR::LastAluOp + 1] = {
NULL_OP, // OpInvalid
NULL_OP, // OpIfTrue
NULL_OP, // OpNot
// Try to load the source expression into the destination FP register. This assumes that two
// general purpose (integer) registers are available: the ScratchRegister and the
// ReturnValueRegister. It returns a Jump if no conversion can be performed.
-Assembler::Jump Assembler::genTryDoubleConversion(V4IR::Expr *src, Assembler::FPRegisterID dest)
+Assembler::Jump Assembler::genTryDoubleConversion(IR::Expr *src, Assembler::FPRegisterID dest)
{
switch (src->type) {
- case V4IR::DoubleType:
+ case IR::DoubleType:
moveDouble(toDoubleRegister(src, dest), dest);
return Assembler::Jump();
- case V4IR::SInt32Type:
+ case IR::SInt32Type:
convertInt32ToDouble(toInt32Register(src, Assembler::ScratchRegister),
dest);
return Assembler::Jump();
- case V4IR::UInt32Type:
+ case IR::UInt32Type:
convertUInt32ToDouble(toUInt32Register(src, Assembler::ScratchRegister),
dest, Assembler::ReturnValueRegister);
return Assembler::Jump();
- case V4IR::BoolType:
+ case IR::BoolType:
// TODO?
return jump();
default:
break;
}
- V4IR::Temp *sourceTemp = src->asTemp();
+ IR::Temp *sourceTemp = src->asTemp();
Q_ASSERT(sourceTemp);
// It's not a number type, so it cannot be in a register.
- Q_ASSERT(sourceTemp->kind != V4IR::Temp::PhysicalRegister || sourceTemp->type == V4IR::BoolType);
+ Q_ASSERT(sourceTemp->kind != IR::Temp::PhysicalRegister || sourceTemp->type == IR::BoolType);
Assembler::Pointer tagAddr = loadTempAddress(Assembler::ScratchRegister, sourceTemp);
tagAddr.offset += 4;
#ifndef QT_NO_DEBUG
namespace {
-inline bool isPregOrConst(V4IR::Expr *e)
+inline bool isPregOrConst(IR::Expr *e)
{
- if (V4IR::Temp *t = e->asTemp())
- return t->kind == V4IR::Temp::PhysicalRegister;
+ if (IR::Temp *t = e->asTemp())
+ return t->kind == IR::Temp::PhysicalRegister;
return e->asConst() != 0;
}
} // anonymous namespace
#endif
-Assembler::Jump Assembler::branchDouble(bool invertCondition, V4IR::AluOp op,
- V4IR::Expr *left, V4IR::Expr *right)
+Assembler::Jump Assembler::branchDouble(bool invertCondition, IR::AluOp op,
+ IR::Expr *left, IR::Expr *right)
{
Q_ASSERT(isPregOrConst(left));
Q_ASSERT(isPregOrConst(right));
Assembler::DoubleCondition cond;
switch (op) {
- case V4IR::OpGt: cond = Assembler::DoubleGreaterThan; break;
- case V4IR::OpLt: cond = Assembler::DoubleLessThan; break;
- case V4IR::OpGe: cond = Assembler::DoubleGreaterThanOrEqual; break;
- case V4IR::OpLe: cond = Assembler::DoubleLessThanOrEqual; break;
- case V4IR::OpEqual:
- case V4IR::OpStrictEqual: cond = Assembler::DoubleEqual; break;
- case V4IR::OpNotEqual:
- case V4IR::OpStrictNotEqual: cond = Assembler::DoubleNotEqualOrUnordered; break; // No, the inversion of DoubleEqual is NOT DoubleNotEqual.
+ case IR::OpGt: cond = Assembler::DoubleGreaterThan; break;
+ case IR::OpLt: cond = Assembler::DoubleLessThan; break;
+ case IR::OpGe: cond = Assembler::DoubleGreaterThanOrEqual; break;
+ case IR::OpLe: cond = Assembler::DoubleLessThanOrEqual; break;
+ case IR::OpEqual:
+ case IR::OpStrictEqual: cond = Assembler::DoubleEqual; break;
+ case IR::OpNotEqual:
+ case IR::OpStrictNotEqual: cond = Assembler::DoubleNotEqualOrUnordered; break; // No, the inversion of DoubleEqual is NOT DoubleNotEqual.
default:
Q_UNREACHABLE();
}
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
-namespace MASM {
+namespace QV4 {
+namespace JIT {
#define OP(op) \
{ isel_stringIfy(op), op, 0, 0, 0 }
class Assembler : public JSC::MacroAssembler
{
public:
- Assembler(InstructionSelection *isel, V4IR::Function* function, QV4::ExecutableAllocator *executableAllocator,
+ Assembler(InstructionSelection *isel, IR::Function* function, QV4::ExecutableAllocator *executableAllocator,
int maxArgCountForBuiltins);
#if CPU(X86)
class StackLayout
{
public:
- StackLayout(V4IR::Function *function, int maxArgCountForBuiltins)
+ StackLayout(IR::Function *function, int maxArgCountForBuiltins)
: calleeSavedRegCount(Assembler::calleeSavedRegisterCount + 1)
, maxOutgoingArgumentCount(function->maxNumberOfArguments)
, localCount(function->tempCount)
ConstantTable(Assembler *as): _as(as) {}
int add(const QV4::Primitive &v);
- ImplicitAddress loadValueAddress(V4IR::Const *c, RegisterID baseReg);
+ ImplicitAddress loadValueAddress(IR::Const *c, RegisterID baseReg);
ImplicitAddress loadValueAddress(const QV4::Primitive &v, RegisterID baseReg);
void finalize(JSC::LinkBuffer &linkBuffer, InstructionSelection *isel);
const char* functionName;
};
struct PointerToValue {
- PointerToValue(V4IR::Expr *value)
+ PointerToValue(IR::Expr *value)
: value(value)
{}
- V4IR::Expr *value;
+ IR::Expr *value;
};
struct PointerToString {
explicit PointerToString(const QString &string) : string(string) {}
QString string;
};
struct Reference {
- Reference(V4IR::Temp *value) : value(value) {}
- V4IR::Temp *value;
+ Reference(IR::Temp *value) : value(value) {}
+ IR::Temp *value;
};
struct ReentryBlock {
- ReentryBlock(V4IR::BasicBlock *b) : block(b) {}
- V4IR::BasicBlock *block;
+ ReentryBlock(IR::BasicBlock *b) : block(b) {}
+ IR::BasicBlock *block;
};
void callAbsolute(const char* functionName, FunctionPtr function) {
call(relativeCall.addr);
}
- void registerBlock(V4IR::BasicBlock*, V4IR::BasicBlock *nextBlock);
- V4IR::BasicBlock *nextBlock() const { return _nextBlock; }
- void jumpToBlock(V4IR::BasicBlock* current, V4IR::BasicBlock *target);
- void addPatch(V4IR::BasicBlock* targetBlock, Jump targetJump);
+ void registerBlock(IR::BasicBlock*, IR::BasicBlock *nextBlock);
+ IR::BasicBlock *nextBlock() const { return _nextBlock; }
+ void jumpToBlock(IR::BasicBlock* current, IR::BasicBlock *target);
+ void addPatch(IR::BasicBlock* targetBlock, Jump targetJump);
void addPatch(DataLabelPtr patch, Label target);
- void addPatch(DataLabelPtr patch, V4IR::BasicBlock *target);
- void generateCJumpOnNonZero(RegisterID reg, V4IR::BasicBlock *currentBlock,
- V4IR::BasicBlock *trueBlock, V4IR::BasicBlock *falseBlock);
+ void addPatch(DataLabelPtr patch, IR::BasicBlock *target);
+ void generateCJumpOnNonZero(RegisterID reg, IR::BasicBlock *currentBlock,
+ IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
void generateCJumpOnCompare(RelationalCondition cond, RegisterID left, TrustedImm32 right,
- V4IR::BasicBlock *currentBlock, V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock);
+ IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock);
void generateCJumpOnCompare(RelationalCondition cond, RegisterID left, RegisterID right,
- V4IR::BasicBlock *currentBlock, V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock);
- Jump genTryDoubleConversion(V4IR::Expr *src, Assembler::FPRegisterID dest);
- Assembler::Jump branchDouble(bool invertCondition, V4IR::AluOp op, V4IR::Expr *left, V4IR::Expr *right);
+ IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock);
+ Jump genTryDoubleConversion(IR::Expr *src, Assembler::FPRegisterID dest);
+ Assembler::Jump branchDouble(bool invertCondition, IR::AluOp op, IR::Expr *left, IR::Expr *right);
- Pointer loadTempAddress(RegisterID baseReg, V4IR::Temp *t);
+ Pointer loadTempAddress(RegisterID baseReg, IR::Temp *t);
Pointer loadStringAddress(RegisterID reg, const QString &string);
void loadStringRef(RegisterID reg, const QString &string);
- Pointer stackSlotPointer(V4IR::Temp *t) const
+ Pointer stackSlotPointer(IR::Temp *t) const
{
- Q_ASSERT(t->kind == V4IR::Temp::StackSlot);
+ Q_ASSERT(t->kind == IR::Temp::StackSlot);
Q_ASSERT(t->scope == 0);
return Pointer(_stackLayout.stackSlotPointer(t->index));
{
if (!arg.value)
return;
- if (V4IR::Temp *t = arg.value->asTemp()) {
- if (t->kind == V4IR::Temp::PhysicalRegister) {
+ if (IR::Temp *t = arg.value->asTemp()) {
+ if (t->kind == IR::Temp::PhysicalRegister) {
Pointer addr(_stackLayout.savedRegPointer(argumentNumber));
switch (t->type) {
- case V4IR::BoolType:
+ case IR::BoolType:
storeBool((RegisterID) t->index, addr);
break;
- case V4IR::SInt32Type:
+ case IR::SInt32Type:
storeInt32((RegisterID) t->index, addr);
break;
- case V4IR::UInt32Type:
+ case IR::UInt32Type:
storeUInt32((RegisterID) t->index, addr);
break;
- case V4IR::DoubleType:
+ case IR::DoubleType:
storeDouble((FPRegisterID) t->index, addr);
break;
default:
}
#ifdef VALUE_FITS_IN_REGISTER
- void loadArgumentInRegister(V4IR::Temp* temp, RegisterID dest, int argumentNumber)
+ void loadArgumentInRegister(IR::Temp* temp, RegisterID dest, int argumentNumber)
{
Q_UNUSED(argumentNumber);
}
}
- void loadArgumentInRegister(V4IR::Const* c, RegisterID dest, int argumentNumber)
+ void loadArgumentInRegister(IR::Const* c, RegisterID dest, int argumentNumber)
{
Q_UNUSED(argumentNumber);
move(TrustedImm64(v.val), dest);
}
- void loadArgumentInRegister(V4IR::Expr* expr, RegisterID dest, int argumentNumber)
+ void loadArgumentInRegister(IR::Expr* expr, RegisterID dest, int argumentNumber)
{
Q_UNUSED(argumentNumber);
}
}
#else
- void loadArgumentInRegister(V4IR::Expr*, RegisterID)
+ void loadArgumentInRegister(IR::Expr*, RegisterID)
{
assert(!"unimplemented: expression in loadArgument");
}
}
#endif
- void storeReturnValue(V4IR::Temp *temp)
+ void storeReturnValue(IR::Temp *temp)
{
if (!temp)
return;
- if (temp->kind == V4IR::Temp::PhysicalRegister) {
- if (temp->type == V4IR::DoubleType)
+ if (temp->kind == IR::Temp::PhysicalRegister) {
+ if (temp->type == IR::DoubleType)
storeReturnValue((FPRegisterID) temp->index);
- else if (temp->type == V4IR::UInt32Type)
+ else if (temp->type == IR::UInt32Type)
storeUInt32ReturnValue((RegisterID) temp->index);
else
storeReturnValue((RegisterID) temp->index);
poke(TrustedImmPtr(name), StackSlot);
}
- void loadDouble(V4IR::Temp* temp, FPRegisterID dest)
+ void loadDouble(IR::Temp* temp, FPRegisterID dest)
{
- if (temp->kind == V4IR::Temp::PhysicalRegister) {
+ if (temp->kind == IR::Temp::PhysicalRegister) {
moveDouble((FPRegisterID) temp->index, dest);
return;
}
loadDouble(ptr, dest);
}
- void storeDouble(FPRegisterID source, V4IR::Temp* temp)
+ void storeDouble(FPRegisterID source, IR::Temp* temp)
{
- if (temp->kind == V4IR::Temp::PhysicalRegister) {
+ if (temp->kind == IR::Temp::PhysicalRegister) {
moveDouble(source, (FPRegisterID) temp->index);
return;
}
template <typename Result, typename Source>
void copyValue(Result result, Source source);
template <typename Result>
- void copyValue(Result result, V4IR::Expr* source);
+ void copyValue(Result result, IR::Expr* source);
// The scratch register is used to calculate the temp address for the source.
- void memcopyValue(Pointer target, V4IR::Temp *sourceTemp, RegisterID scratchRegister)
+ void memcopyValue(Pointer target, IR::Temp *sourceTemp, RegisterID scratchRegister)
{
- Q_ASSERT(sourceTemp->kind != V4IR::Temp::PhysicalRegister);
+ Q_ASSERT(sourceTemp->kind != IR::Temp::PhysicalRegister);
Q_ASSERT(target.base != scratchRegister);
JSC::MacroAssembler::loadDouble(loadTempAddress(scratchRegister, sourceTemp), FPGpr0);
JSC::MacroAssembler::storeDouble(FPGpr0, target);
#endif
}
- void storeValue(QV4::Primitive value, V4IR::Temp* temp);
+ void storeValue(QV4::Primitive value, IR::Temp* temp);
void enterStandardStackFrame();
void leaveStandardStackFrame();
ImmRegBinOp inlineImmRegOp;
};
- static const BinaryOperationInfo binaryOperations[QQmlJS::V4IR::LastAluOp + 1];
- static const BinaryOperationInfo &binaryOperation(V4IR::AluOp operation)
+ static const BinaryOperationInfo binaryOperations[IR::LastAluOp + 1];
+ static const BinaryOperationInfo &binaryOperation(IR::AluOp operation)
{ return binaryOperations[operation]; }
Jump inline_add32(Address addr, RegisterID reg)
return Jump();
}
- Pointer toAddress(RegisterID tmpReg, V4IR::Expr *e, int offset)
+ Pointer toAddress(RegisterID tmpReg, IR::Expr *e, int offset)
{
- if (V4IR::Const *c = e->asConst()) {
+ if (IR::Const *c = e->asConst()) {
Address addr = _stackLayout.savedRegPointer(offset);
Address tagAddr = addr;
tagAddr.offset += 4;
return Pointer(addr);
}
- V4IR::Temp *t = e->asTemp();
+ IR::Temp *t = e->asTemp();
Q_ASSERT(t);
- if (t->kind != V4IR::Temp::PhysicalRegister)
+ if (t->kind != IR::Temp::PhysicalRegister)
return loadTempAddress(tmpReg, t);
move(src, dest);
}
- void storeBool(RegisterID reg, V4IR::Temp *target)
+ void storeBool(RegisterID reg, IR::Temp *target)
{
- if (target->kind == V4IR::Temp::PhysicalRegister) {
+ if (target->kind == IR::Temp::PhysicalRegister) {
move(reg, (RegisterID) target->index);
} else {
Pointer addr = loadTempAddress(ScratchRegister, target);
}
}
- void storeBool(bool value, V4IR::Temp *target) {
+ void storeBool(bool value, IR::Temp *target) {
TrustedImm32 trustedValue(value ? 1 : 0);
- if (target->kind == V4IR::Temp::PhysicalRegister) {
+ if (target->kind == IR::Temp::PhysicalRegister) {
move(trustedValue, (RegisterID) target->index);
} else {
move(trustedValue, ScratchRegister);
store32(TrustedImm32(QV4::Primitive::fromInt32(0).tag), addr);
}
- void storeInt32(RegisterID reg, V4IR::Temp *target)
+ void storeInt32(RegisterID reg, IR::Temp *target)
{
- if (target->kind == V4IR::Temp::PhysicalRegister) {
+ if (target->kind == IR::Temp::PhysicalRegister) {
move(reg, (RegisterID) target->index);
} else {
Pointer addr = loadTempAddress(ScratchRegister, target);
done.link(this);
}
- void storeUInt32(RegisterID reg, V4IR::Temp *target)
+ void storeUInt32(RegisterID reg, IR::Temp *target)
{
- if (target->kind == V4IR::Temp::PhysicalRegister) {
+ if (target->kind == IR::Temp::PhysicalRegister) {
move(reg, (RegisterID) target->index);
} else {
Pointer addr = loadTempAddress(ScratchRegister, target);
}
}
- FPRegisterID toDoubleRegister(V4IR::Expr *e, FPRegisterID target = FPGpr0)
+ FPRegisterID toDoubleRegister(IR::Expr *e, FPRegisterID target = FPGpr0)
{
- if (V4IR::Const *c = e->asConst()) {
+ if (IR::Const *c = e->asConst()) {
#if QT_POINTER_SIZE == 8
union {
double d;
return target;
}
- V4IR::Temp *t = e->asTemp();
+ IR::Temp *t = e->asTemp();
Q_ASSERT(t);
- if (t->kind == V4IR::Temp::PhysicalRegister)
+ if (t->kind == IR::Temp::PhysicalRegister)
return (FPRegisterID) t->index;
loadDouble(t, target);
return target;
}
- RegisterID toBoolRegister(V4IR::Expr *e, RegisterID scratchReg)
+ RegisterID toBoolRegister(IR::Expr *e, RegisterID scratchReg)
{
return toInt32Register(e, scratchReg);
}
- RegisterID toInt32Register(V4IR::Expr *e, RegisterID scratchReg)
+ RegisterID toInt32Register(IR::Expr *e, RegisterID scratchReg)
{
- if (V4IR::Const *c = e->asConst()) {
+ if (IR::Const *c = e->asConst()) {
move(TrustedImm32(convertToValue(c).int_32), scratchReg);
return scratchReg;
}
- V4IR::Temp *t = e->asTemp();
+ IR::Temp *t = e->asTemp();
Q_ASSERT(t);
- if (t->kind == V4IR::Temp::PhysicalRegister)
+ if (t->kind == IR::Temp::PhysicalRegister)
return (RegisterID) t->index;
return toInt32Register(loadTempAddress(scratchReg, t), scratchReg);
return scratchReg;
}
- RegisterID toUInt32Register(V4IR::Expr *e, RegisterID scratchReg)
+ RegisterID toUInt32Register(IR::Expr *e, RegisterID scratchReg)
{
- if (V4IR::Const *c = e->asConst()) {
+ if (IR::Const *c = e->asConst()) {
move(TrustedImm32(unsigned(c->value)), scratchReg);
return scratchReg;
}
- V4IR::Temp *t = e->asTemp();
+ IR::Temp *t = e->asTemp();
Q_ASSERT(t);
- if (t->kind == V4IR::Temp::PhysicalRegister)
+ if (t->kind == IR::Temp::PhysicalRegister)
return (RegisterID) t->index;
return toUInt32Register(loadTempAddress(scratchReg, t), scratchReg);
ConstantTable &constantTable() { return _constTable; }
Label exceptionReturnLabel;
- V4IR::BasicBlock * catchBlock;
+ IR::BasicBlock * catchBlock;
QVector<Jump> exceptionPropagationJumps;
private:
const StackLayout _stackLayout;
ConstantTable _constTable;
- V4IR::Function *_function;
- QHash<V4IR::BasicBlock *, Label> _addrs;
- QHash<V4IR::BasicBlock *, QVector<Jump> > _patches;
+ IR::Function *_function;
+ QHash<IR::BasicBlock *, Label> _addrs;
+ QHash<IR::BasicBlock *, QVector<Jump> > _patches;
QList<CallToLink> _callsToLink;
struct DataLabelPatch {
};
QList<DataLabelPatch> _dataLabelPatches;
- QHash<V4IR::BasicBlock *, QVector<DataLabelPtr> > _labelPatches;
- V4IR::BasicBlock *_nextBlock;
+ QHash<IR::BasicBlock *, QVector<DataLabelPtr> > _labelPatches;
+ IR::BasicBlock *_nextBlock;
QV4::ExecutableAllocator *_executableAllocator;
InstructionSelection *_isel;
}
template <typename Result>
-void Assembler::copyValue(Result result, V4IR::Expr* source)
+void Assembler::copyValue(Result result, IR::Expr* source)
{
- if (source->type == V4IR::BoolType) {
+ if (source->type == IR::BoolType) {
RegisterID reg = toInt32Register(source, ScratchRegister);
storeBool(reg, result);
- } else if (source->type == V4IR::SInt32Type) {
+ } else if (source->type == IR::SInt32Type) {
RegisterID reg = toInt32Register(source, ScratchRegister);
storeInt32(reg, result);
- } else if (source->type == V4IR::UInt32Type) {
+ } else if (source->type == IR::UInt32Type) {
RegisterID reg = toUInt32Register(source, ScratchRegister);
storeUInt32(reg, result);
- } else if (source->type == V4IR::DoubleType) {
+ } else if (source->type == IR::DoubleType) {
storeDouble(toDoubleRegister(source), result);
- } else if (V4IR::Temp *temp = source->asTemp()) {
+ } else if (IR::Temp *temp = source->asTemp()) {
#ifdef VALUE_FITS_IN_REGISTER
Q_UNUSED(temp);
loadDouble(temp, FPGpr0);
storeDouble(FPGpr0, result);
#endif
- } else if (V4IR::Const *c = source->asConst()) {
+ } else if (IR::Const *c = source->asConst()) {
QV4::Primitive v = convertToValue(c);
storeValue(v, result);
} else {
relativeCall.addr.base);
}
-} // end of namespace MASM
-} // end of namespace QQmlJS
+} // end of namespace JIT
+} // end of namespace QV4
QT_END_NAMESPACE
using namespace QV4;
using namespace JIT;
-using namespace QQmlJS;
-using namespace MASM;
-
namespace {
-inline bool isPregOrConst(V4IR::Expr *e)
+inline bool isPregOrConst(IR::Expr *e)
{
- if (V4IR::Temp *t = e->asTemp())
- return t->kind == V4IR::Temp::PhysicalRegister;
+ if (IR::Temp *t = e->asTemp())
+ return t->kind == IR::Temp::PhysicalRegister;
return e->asConst() != 0;
}
} // anonymous namespace
-void Binop::generate(V4IR::Expr *lhs, V4IR::Expr *rhs, V4IR::Temp *target)
+void Binop::generate(IR::Expr *lhs, IR::Expr *rhs, IR::Temp *target)
{
- if (op != V4IR::OpMod
- && lhs->type == V4IR::DoubleType && rhs->type == V4IR::DoubleType
+ if (op != IR::OpMod
+ && lhs->type == IR::DoubleType && rhs->type == IR::DoubleType
&& isPregOrConst(lhs) && isPregOrConst(rhs)) {
doubleBinop(lhs, rhs, target);
return;
}
- if (lhs->type == V4IR::SInt32Type && rhs->type == V4IR::SInt32Type) {
+ if (lhs->type == IR::SInt32Type && rhs->type == IR::SInt32Type) {
if (int32Binop(lhs, rhs, target))
return;
}
Assembler::Jump done;
- if (lhs->type != V4IR::StringType && rhs->type != V4IR::StringType)
+ if (lhs->type != IR::StringType && rhs->type != IR::StringType)
done = genInlineBinop(lhs, rhs, target);
// TODO: inline var===null and var!==null
Assembler::BinaryOperationInfo info = Assembler::binaryOperation(op);
- if (op == V4IR::OpAdd &&
- (lhs->type == V4IR::StringType || rhs->type == V4IR::StringType)) {
+ if (op == IR::OpAdd &&
+ (lhs->type == IR::StringType || rhs->type == IR::StringType)) {
const Assembler::BinaryOperationInfo stringAdd = OPCONTEXT(__qmljs_add_string);
info = stringAdd;
}
}
-void Binop::doubleBinop(V4IR::Expr *lhs, V4IR::Expr *rhs, V4IR::Temp *target)
+void Binop::doubleBinop(IR::Expr *lhs, IR::Expr *rhs, IR::Temp *target)
{
Q_ASSERT(lhs->asConst() == 0 || rhs->asConst() == 0);
Q_ASSERT(isPregOrConst(lhs));
Q_ASSERT(isPregOrConst(rhs));
Assembler::FPRegisterID targetReg;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
targetReg = (Assembler::FPRegisterID) target->index;
else
targetReg = Assembler::FPGpr0;
switch (op) {
- case V4IR::OpAdd:
+ case IR::OpAdd:
as->addDouble(as->toDoubleRegister(lhs), as->toDoubleRegister(rhs),
targetReg);
break;
- case V4IR::OpMul:
+ case IR::OpMul:
as->mulDouble(as->toDoubleRegister(lhs), as->toDoubleRegister(rhs),
targetReg);
break;
- case V4IR::OpSub:
+ case IR::OpSub:
#if CPU(X86) || CPU(X86_64)
- if (V4IR::Temp *rightTemp = rhs->asTemp()) {
- if (rightTemp->kind == V4IR::Temp::PhysicalRegister && rightTemp->index == targetReg) {
+ if (IR::Temp *rightTemp = rhs->asTemp()) {
+ if (rightTemp->kind == IR::Temp::PhysicalRegister && rightTemp->index == targetReg) {
as->moveDouble(targetReg, Assembler::FPGpr0);
as->moveDouble(as->toDoubleRegister(lhs, targetReg), targetReg);
as->subDouble(Assembler::FPGpr0, targetReg);
}
} else if (rhs->asConst() && targetReg == Assembler::FPGpr0) {
Q_ASSERT(lhs->asTemp());
- Q_ASSERT(lhs->asTemp()->kind == V4IR::Temp::PhysicalRegister);
+ Q_ASSERT(lhs->asTemp()->kind == IR::Temp::PhysicalRegister);
as->moveDouble(as->toDoubleRegister(lhs, targetReg), targetReg);
Assembler::FPRegisterID reg = (Assembler::FPRegisterID) lhs->asTemp()->index;
as->moveDouble(as->toDoubleRegister(rhs, reg), reg);
as->subDouble(as->toDoubleRegister(lhs), as->toDoubleRegister(rhs),
targetReg);
break;
- case V4IR::OpDiv:
+ case IR::OpDiv:
#if CPU(X86) || CPU(X86_64)
- if (V4IR::Temp *rightTemp = rhs->asTemp()) {
- if (rightTemp->kind == V4IR::Temp::PhysicalRegister && rightTemp->index == targetReg) {
+ if (IR::Temp *rightTemp = rhs->asTemp()) {
+ if (rightTemp->kind == IR::Temp::PhysicalRegister && rightTemp->index == targetReg) {
as->moveDouble(targetReg, Assembler::FPGpr0);
as->moveDouble(as->toDoubleRegister(lhs, targetReg), targetReg);
as->divDouble(Assembler::FPGpr0, targetReg);
}
} else if (rhs->asConst() && targetReg == Assembler::FPGpr0) {
Q_ASSERT(lhs->asTemp());
- Q_ASSERT(lhs->asTemp()->kind == V4IR::Temp::PhysicalRegister);
+ Q_ASSERT(lhs->asTemp()->kind == IR::Temp::PhysicalRegister);
as->moveDouble(as->toDoubleRegister(lhs, targetReg), targetReg);
Assembler::FPRegisterID reg = (Assembler::FPRegisterID) lhs->asTemp()->index;
as->moveDouble(as->toDoubleRegister(rhs, reg), reg);
targetReg);
break;
default: {
- Q_ASSERT(target->type == V4IR::BoolType);
+ Q_ASSERT(target->type == IR::BoolType);
Assembler::Jump trueCase = as->branchDouble(false, op, lhs, rhs);
as->storeBool(false, target);
Assembler::Jump done = as->jump();
} return;
}
- if (target->kind != V4IR::Temp::PhysicalRegister)
+ if (target->kind != IR::Temp::PhysicalRegister)
as->storeDouble(Assembler::FPGpr0, target);
}
-bool Binop::int32Binop(V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
+bool Binop::int32Binop(IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target)
{
- Q_ASSERT(leftSource->type == V4IR::SInt32Type);
+ Q_ASSERT(leftSource->type == IR::SInt32Type);
Assembler::RegisterID targetReg;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
targetReg = (Assembler::RegisterID) target->index;
else
targetReg = Assembler::ReturnValueRegister;
switch (op) {
- case V4IR::OpBitAnd: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
- if (rightSource->asTemp() && rightSource->asTemp()->kind == V4IR::Temp::PhysicalRegister
- && target->kind == V4IR::Temp::PhysicalRegister
+ case IR::OpBitAnd: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
+ if (rightSource->asTemp() && rightSource->asTemp()->kind == IR::Temp::PhysicalRegister
+ && target->kind == IR::Temp::PhysicalRegister
&& target->index == rightSource->asTemp()->index) {
as->and32(as->toInt32Register(leftSource, Assembler::ScratchRegister),
(Assembler::RegisterID) target->index);
targetReg);
as->storeInt32(targetReg, target);
} return true;
- case V4IR::OpBitOr: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
- if (rightSource->asTemp() && rightSource->asTemp()->kind == V4IR::Temp::PhysicalRegister
- && target->kind == V4IR::Temp::PhysicalRegister
+ case IR::OpBitOr: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
+ if (rightSource->asTemp() && rightSource->asTemp()->kind == IR::Temp::PhysicalRegister
+ && target->kind == IR::Temp::PhysicalRegister
&& target->index == rightSource->asTemp()->index) {
as->or32(as->toInt32Register(leftSource, Assembler::ScratchRegister),
(Assembler::RegisterID) target->index);
targetReg);
as->storeInt32(targetReg, target);
} return true;
- case V4IR::OpBitXor: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
- if (rightSource->asTemp() && rightSource->asTemp()->kind == V4IR::Temp::PhysicalRegister
- && target->kind == V4IR::Temp::PhysicalRegister
+ case IR::OpBitXor: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
+ if (rightSource->asTemp() && rightSource->asTemp()->kind == IR::Temp::PhysicalRegister
+ && target->kind == IR::Temp::PhysicalRegister
&& target->index == rightSource->asTemp()->index) {
as->xor32(as->toInt32Register(leftSource, Assembler::ScratchRegister),
(Assembler::RegisterID) target->index);
targetReg);
as->storeInt32(targetReg, target);
} return true;
- case V4IR::OpLShift: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
+ case IR::OpLShift: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (IR::Const *c = rightSource->asConst()) {
as->lshift32(as->toInt32Register(leftSource, Assembler::ReturnValueRegister),
Assembler::TrustedImm32(int(c->value) & 0x1f), targetReg);
} else {
}
as->storeInt32(targetReg, target);
} return true;
- case V4IR::OpRShift: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
+ case IR::OpRShift: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (IR::Const *c = rightSource->asConst()) {
as->rshift32(as->toInt32Register(leftSource, Assembler::ReturnValueRegister),
Assembler::TrustedImm32(int(c->value) & 0x1f), targetReg);
} else {
}
as->storeInt32(targetReg, target);
} return true;
- case V4IR::OpURShift:
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
+ case IR::OpURShift:
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
- if (V4IR::Const *c = rightSource->asConst()) {
+ if (IR::Const *c = rightSource->asConst()) {
as->urshift32(as->toInt32Register(leftSource, Assembler::ReturnValueRegister),
Assembler::TrustedImm32(int(c->value) & 0x1f), targetReg);
} else {
}
as->storeUInt32(targetReg, target);
return true;
- case V4IR::OpAdd: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
+ case IR::OpAdd: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
Assembler::RegisterID targetReg;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
targetReg = (Assembler::RegisterID) target->index;
else
targetReg = Assembler::ReturnValueRegister;
targetReg);
as->storeInt32(targetReg, target);
} return true;
- case V4IR::OpSub: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
+ case IR::OpSub: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
- if (rightSource->asTemp() && rightSource->asTemp()->kind == V4IR::Temp::PhysicalRegister
- && target->kind == V4IR::Temp::PhysicalRegister
+ if (rightSource->asTemp() && rightSource->asTemp()->kind == IR::Temp::PhysicalRegister
+ && target->kind == IR::Temp::PhysicalRegister
&& target->index == rightSource->asTemp()->index) {
Assembler::RegisterID targetReg = (Assembler::RegisterID) target->index;
as->move(targetReg, Assembler::ScratchRegister);
}
Assembler::RegisterID targetReg;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
targetReg = (Assembler::RegisterID) target->index;
else
targetReg = Assembler::ReturnValueRegister;
as->sub32(as->toInt32Register(rightSource, Assembler::ScratchRegister), targetReg);
as->storeInt32(targetReg, target);
} return true;
- case V4IR::OpMul: {
- Q_ASSERT(rightSource->type == V4IR::SInt32Type);
+ case IR::OpMul: {
+ Q_ASSERT(rightSource->type == IR::SInt32Type);
Assembler::RegisterID targetReg;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
targetReg = (Assembler::RegisterID) target->index;
else
targetReg = Assembler::ReturnValueRegister;
}
}
-static inline Assembler::FPRegisterID getFreeFPReg(V4IR::Expr *shouldNotOverlap, unsigned hint)
+static inline Assembler::FPRegisterID getFreeFPReg(IR::Expr *shouldNotOverlap, unsigned hint)
{
- if (V4IR::Temp *t = shouldNotOverlap->asTemp())
- if (t->type == V4IR::DoubleType)
- if (t->kind == V4IR::Temp::PhysicalRegister)
+ if (IR::Temp *t = shouldNotOverlap->asTemp())
+ if (t->type == IR::DoubleType)
+ if (t->kind == IR::Temp::PhysicalRegister)
if (t->index == hint)
return Assembler::FPRegisterID(hint + 1);
return Assembler::FPRegisterID(hint);
}
-Assembler::Jump Binop::genInlineBinop(V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
+Assembler::Jump Binop::genInlineBinop(IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target)
{
Assembler::Jump done;
// Note: FPGPr0 can still not be used, because uint32->double conversion uses it as a scratch
// register.
switch (op) {
- case V4IR::OpAdd: {
+ case IR::OpAdd: {
Assembler::FPRegisterID lReg = getFreeFPReg(rightSource, 2);
Assembler::FPRegisterID rReg = getFreeFPReg(leftSource, 4);
Assembler::Jump leftIsNoDbl = as->genTryDoubleConversion(leftSource, lReg);
if (rightIsNoDbl.isSet())
rightIsNoDbl.link(as);
} break;
- case V4IR::OpMul: {
+ case IR::OpMul: {
Assembler::FPRegisterID lReg = getFreeFPReg(rightSource, 2);
Assembler::FPRegisterID rReg = getFreeFPReg(leftSource, 4);
Assembler::Jump leftIsNoDbl = as->genTryDoubleConversion(leftSource, lReg);
if (rightIsNoDbl.isSet())
rightIsNoDbl.link(as);
} break;
- case V4IR::OpSub: {
+ case IR::OpSub: {
Assembler::FPRegisterID lReg = getFreeFPReg(rightSource, 2);
Assembler::FPRegisterID rReg = getFreeFPReg(leftSource, 4);
Assembler::Jump leftIsNoDbl = as->genTryDoubleConversion(leftSource, lReg);
if (rightIsNoDbl.isSet())
rightIsNoDbl.link(as);
} break;
- case V4IR::OpDiv: {
+ case IR::OpDiv: {
Assembler::FPRegisterID lReg = getFreeFPReg(rightSource, 2);
Assembler::FPRegisterID rReg = getFreeFPReg(leftSource, 4);
Assembler::Jump leftIsNoDbl = as->genTryDoubleConversion(leftSource, lReg);
namespace JIT {
struct Binop {
- Binop(QQmlJS::MASM::Assembler *assembler, QQmlJS::V4IR::AluOp operation)
+ Binop(Assembler *assembler, IR::AluOp operation)
: as(assembler)
, op(operation)
{}
- void generate(QQmlJS::V4IR::Expr *lhs, QQmlJS::V4IR::Expr *rhs, QQmlJS::V4IR::Temp *target);
- void doubleBinop(QQmlJS::V4IR::Expr *lhs, QQmlJS::V4IR::Expr *rhs, QQmlJS::V4IR::Temp *target);
- bool int32Binop(QQmlJS::V4IR::Expr *leftSource, QQmlJS::V4IR::Expr *rightSource, QQmlJS::V4IR::Temp *target);
- QQmlJS::MASM::Assembler::Jump genInlineBinop(QQmlJS::V4IR::Expr *leftSource, QQmlJS::V4IR::Expr *rightSource, QQmlJS::V4IR::Temp *target);
+ void generate(IR::Expr *lhs, IR::Expr *rhs, IR::Temp *target);
+ void doubleBinop(IR::Expr *lhs, IR::Expr *rhs, IR::Temp *target);
+ bool int32Binop(IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target);
+ Assembler::Jump genInlineBinop(IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target);
- QQmlJS::MASM::Assembler *as;
- QQmlJS::V4IR::AluOp op;
+ Assembler *as;
+ IR::AluOp op;
};
}
# include <udis86.h>
#endif
-using namespace QQmlJS;
-using namespace QQmlJS::MASM;
using namespace QV4;
+using namespace QV4::JIT;
namespace {
-inline bool isPregOrConst(V4IR::Expr *e)
+inline bool isPregOrConst(IR::Expr *e)
{
- if (V4IR::Temp *t = e->asTemp())
- return t->kind == V4IR::Temp::PhysicalRegister;
+ if (IR::Temp *t = e->asTemp())
+ return t->kind == IR::Temp::PhysicalRegister;
return e->asConst() != 0;
}
} // anonymous namespace
Label endOfCode = label();
{
- QHashIterator<V4IR::BasicBlock *, QVector<Jump> > it(_patches);
+ QHashIterator<IR::BasicBlock *, QVector<Jump> > it(_patches);
while (it.hasNext()) {
it.next();
- V4IR::BasicBlock *block = it.key();
+ IR::BasicBlock *block = it.key();
Label target = _addrs.value(block);
assert(target.isSet());
foreach (Jump jump, it.value())
linkBuffer.link(jump, linkBuffer.locationOf(exceptionReturnLabel));
{
- QHashIterator<V4IR::BasicBlock *, QVector<DataLabelPtr> > it(_labelPatches);
+ QHashIterator<IR::BasicBlock *, QVector<DataLabelPtr> > it(_labelPatches);
while (it.hasNext()) {
it.next();
- V4IR::BasicBlock *block = it.key();
+ IR::BasicBlock *block = it.key();
Label target = _addrs.value(block);
assert(target.isSet());
foreach (DataLabelPtr label, it.value())
return codeRef;
}
-InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, Compiler::JSUnitGenerator *jsGenerator)
+InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, Compiler::JSUnitGenerator *jsGenerator)
: EvalInstructionSelection(execAllocator, module, jsGenerator)
, _block(0)
, _as(0)
void InstructionSelection::run(int functionIndex)
{
- V4IR::Function *function = irModule->functions[functionIndex];
+ IR::Function *function = irModule->functions[functionIndex];
QVector<Lookup> lookups;
qSwap(_function, function);
- V4IR::Optimizer opt(_function);
+ IR::Optimizer opt(_function);
opt.run(qmlEngine);
#ifdef REGALLOC_IS_SUPPORTED
opt.convertOutOfSSA();
ConvertTemps().toStackSlots(_function);
}
- V4IR::Optimizer::showMeTheCode(_function);
- QSet<V4IR::Jump *> removableJumps = opt.calculateOptionalJumps();
+ IR::Optimizer::showMeTheCode(_function);
+ QSet<IR::Jump *> removableJumps = opt.calculateOptionalJumps();
qSwap(_removableJumps, removableJumps);
Assembler* oldAssembler = _as;
int lastLine = -1;
for (int i = 0, ei = _function->basicBlocks.size(); i != ei; ++i) {
- V4IR::BasicBlock *nextBlock = (i < ei - 1) ? _function->basicBlocks[i + 1] : 0;
+ IR::BasicBlock *nextBlock = (i < ei - 1) ? _function->basicBlocks[i + 1] : 0;
_block = _function->basicBlocks[i];
_as->registerBlock(_block, nextBlock);
- foreach (V4IR::Stmt *s, _block->statements) {
+ foreach (IR::Stmt *s, _block->statements) {
if (s->location.isValid()) {
if (int(s->location.startLine) != lastLine) {
Assembler::Address lineAddr(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, lineNumber));
return compilationUnit;
}
-void InstructionSelection::callBuiltinInvalid(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Temp *result)
{
prepareCallData(args, 0);
}
}
-void InstructionSelection::callBuiltinTypeofMember(V4IR::Expr *base, const QString &name,
- V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofMember(IR::Expr *base, const QString &name,
+ IR::Temp *result)
{
generateFunctionCall(result, __qmljs_builtin_typeof_member, Assembler::ContextRegister,
Assembler::PointerToValue(base), Assembler::PointerToString(name));
}
-void InstructionSelection::callBuiltinTypeofSubscript(V4IR::Expr *base, V4IR::Expr *index,
- V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index,
+ IR::Temp *result)
{
generateFunctionCall(result, __qmljs_builtin_typeof_element,
Assembler::ContextRegister,
Assembler::PointerToValue(base), Assembler::PointerToValue(index));
}
-void InstructionSelection::callBuiltinTypeofName(const QString &name, V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofName(const QString &name, IR::Temp *result)
{
generateFunctionCall(result, __qmljs_builtin_typeof_name, Assembler::ContextRegister,
Assembler::PointerToString(name));
}
-void InstructionSelection::callBuiltinTypeofValue(V4IR::Expr *value, V4IR::Temp *result)
+void InstructionSelection::callBuiltinTypeofValue(IR::Expr *value, IR::Temp *result)
{
generateFunctionCall(result, __qmljs_builtin_typeof, Assembler::ContextRegister,
Assembler::PointerToValue(value));
}
-void InstructionSelection::callBuiltinDeleteMember(V4IR::Temp *base, const QString &name, V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteMember(IR::Temp *base, const QString &name, IR::Temp *result)
{
generateFunctionCall(result, __qmljs_delete_member, Assembler::ContextRegister,
Assembler::Reference(base), Assembler::PointerToString(name));
}
-void InstructionSelection::callBuiltinDeleteSubscript(V4IR::Temp *base, V4IR::Expr *index,
- V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteSubscript(IR::Temp *base, IR::Expr *index,
+ IR::Temp *result)
{
generateFunctionCall(result, __qmljs_delete_subscript, Assembler::ContextRegister,
Assembler::Reference(base), Assembler::PointerToValue(index));
}
-void InstructionSelection::callBuiltinDeleteName(const QString &name, V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteName(const QString &name, IR::Temp *result)
{
generateFunctionCall(result, __qmljs_delete_name, Assembler::ContextRegister,
Assembler::PointerToString(name));
}
-void InstructionSelection::callBuiltinDeleteValue(V4IR::Temp *result)
+void InstructionSelection::callBuiltinDeleteValue(IR::Temp *result)
{
_as->storeValue(Primitive::fromBoolean(false), result);
}
-void InstructionSelection::callBuiltinThrow(V4IR::Expr *arg)
+void InstructionSelection::callBuiltinThrow(IR::Expr *arg)
{
generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_throw, Assembler::ContextRegister,
Assembler::PointerToValue(arg));
_as->jumpToExceptionHandler();
}
-void InstructionSelection::callBuiltinUnwindException(V4IR::Temp *result)
+void InstructionSelection::callBuiltinUnwindException(IR::Temp *result)
{
generateFunctionCall(result, __qmljs_builtin_unwind_exception, Assembler::ContextRegister);
generateFunctionCall(Assembler::ContextRegister, __qmljs_builtin_push_catch_scope, Assembler::ContextRegister, s);
}
-void InstructionSelection::callBuiltinForeachIteratorObject(V4IR::Temp *arg, V4IR::Temp *result)
+void InstructionSelection::callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result)
{
Q_ASSERT(arg);
Q_ASSERT(result);
generateFunctionCall(result, __qmljs_foreach_iterator_object, Assembler::ContextRegister, Assembler::Reference(arg));
}
-void InstructionSelection::callBuiltinForeachNextPropertyname(V4IR::Temp *arg, V4IR::Temp *result)
+void InstructionSelection::callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result)
{
Q_ASSERT(arg);
Q_ASSERT(result);
generateFunctionCall(result, __qmljs_foreach_next_property_name, Assembler::Reference(arg));
}
-void InstructionSelection::callBuiltinPushWithScope(V4IR::Temp *arg)
+void InstructionSelection::callBuiltinPushWithScope(IR::Temp *arg)
{
Q_ASSERT(arg);
Assembler::TrustedImm32(deletable), Assembler::PointerToString(name));
}
-void InstructionSelection::callBuiltinDefineGetterSetter(V4IR::Temp *object, const QString &name, V4IR::Temp *getter, V4IR::Temp *setter)
+void InstructionSelection::callBuiltinDefineGetterSetter(IR::Temp *object, const QString &name, IR::Temp *getter, IR::Temp *setter)
{
Q_ASSERT(object);
Q_ASSERT(getter);
Assembler::Reference(object), Assembler::PointerToString(name), Assembler::PointerToValue(getter), Assembler::PointerToValue(setter));
}
-void InstructionSelection::callBuiltinDefineProperty(V4IR::Temp *object, const QString &name,
- V4IR::Expr *value)
+void InstructionSelection::callBuiltinDefineProperty(IR::Temp *object, const QString &name,
+ IR::Expr *value)
{
Q_ASSERT(object);
Q_ASSERT(value->asTemp() || value->asConst());
Assembler::PointerToValue(value));
}
-void InstructionSelection::callBuiltinDefineArray(V4IR::Temp *result, V4IR::ExprList *args)
+void InstructionSelection::callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args)
{
Q_ASSERT(result);
baseAddressForCallArguments(), Assembler::TrustedImm32(length));
}
-void InstructionSelection::callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4IR::ExprList *args)
+void InstructionSelection::callBuiltinDefineObjectLiteral(IR::Temp *result, IR::ExprList *args)
{
Q_ASSERT(result);
const int classId = registerJSClass(args);
- V4IR::ExprList *it = args;
+ IR::ExprList *it = args;
while (it) {
it = it->next;
baseAddressForCallArguments(), Assembler::TrustedImm32(classId));
}
-void InstructionSelection::callBuiltinSetupArgumentObject(V4IR::Temp *result)
+void InstructionSelection::callBuiltinSetupArgumentObject(IR::Temp *result)
{
generateFunctionCall(result, __qmljs_builtin_setup_arguments_object, Assembler::ContextRegister);
}
generateFunctionCall(Assembler::Void, __qmljs_builtin_convert_this_to_object, Assembler::ContextRegister);
}
-void InstructionSelection::callValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result)
{
Q_ASSERT(value);
baseAddressForCallData());
}
-void InstructionSelection::loadThisObject(V4IR::Temp *temp)
+void InstructionSelection::loadThisObject(IR::Temp *temp)
{
_as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, callData)), Assembler::ScratchRegister);
#if defined(VALUE_FITS_IN_REGISTER)
#endif
}
-void InstructionSelection::loadQmlIdArray(V4IR::Temp *temp)
+void InstructionSelection::loadQmlIdArray(IR::Temp *temp)
{
generateFunctionCall(temp, __qmljs_get_id_array, Assembler::ContextRegister);
}
-void InstructionSelection::loadQmlImportedScripts(V4IR::Temp *temp)
+void InstructionSelection::loadQmlImportedScripts(IR::Temp *temp)
{
generateFunctionCall(temp, __qmljs_get_imported_scripts, Assembler::ContextRegister);
}
-void InstructionSelection::loadQmlContextObject(V4IR::Temp *temp)
+void InstructionSelection::loadQmlContextObject(IR::Temp *temp)
{
generateFunctionCall(temp, __qmljs_get_context_object, Assembler::ContextRegister);
}
-void InstructionSelection::loadQmlScopeObject(V4IR::Temp *temp)
+void InstructionSelection::loadQmlScopeObject(IR::Temp *temp)
{
generateFunctionCall(temp, __qmljs_get_scope_object, Assembler::ContextRegister);
}
-void InstructionSelection::loadQmlSingleton(const QString &name, V4IR::Temp *temp)
+void InstructionSelection::loadQmlSingleton(const QString &name, IR::Temp *temp)
{
generateFunctionCall(temp, __qmljs_get_qml_singleton, Assembler::ContextRegister, Assembler::PointerToString(name));
}
-void InstructionSelection::loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp)
+void InstructionSelection::loadConst(IR::Const *sourceConst, IR::Temp *targetTemp)
{
- if (targetTemp->kind == V4IR::Temp::PhysicalRegister) {
- if (targetTemp->type == V4IR::DoubleType) {
- Q_ASSERT(sourceConst->type == V4IR::DoubleType);
+ if (targetTemp->kind == IR::Temp::PhysicalRegister) {
+ if (targetTemp->type == IR::DoubleType) {
+ Q_ASSERT(sourceConst->type == IR::DoubleType);
_as->toDoubleRegister(sourceConst, (Assembler::FPRegisterID) targetTemp->index);
- } else if (targetTemp->type == V4IR::SInt32Type) {
- Q_ASSERT(sourceConst->type == V4IR::SInt32Type);
+ } else if (targetTemp->type == IR::SInt32Type) {
+ Q_ASSERT(sourceConst->type == IR::SInt32Type);
_as->toInt32Register(sourceConst, (Assembler::RegisterID) targetTemp->index);
- } else if (targetTemp->type == V4IR::UInt32Type) {
- Q_ASSERT(sourceConst->type == V4IR::UInt32Type);
+ } else if (targetTemp->type == IR::UInt32Type) {
+ Q_ASSERT(sourceConst->type == IR::UInt32Type);
_as->toUInt32Register(sourceConst, (Assembler::RegisterID) targetTemp->index);
- } else if (targetTemp->type == V4IR::BoolType) {
- Q_ASSERT(sourceConst->type == V4IR::BoolType);
+ } else if (targetTemp->type == IR::BoolType) {
+ Q_ASSERT(sourceConst->type == IR::BoolType);
_as->move(Assembler::TrustedImm32(convertToValue(sourceConst).int_32),
(Assembler::RegisterID) targetTemp->index);
} else {
}
}
-void InstructionSelection::loadString(const QString &str, V4IR::Temp *targetTemp)
+void InstructionSelection::loadString(const QString &str, IR::Temp *targetTemp)
{
Pointer srcAddr = _as->loadStringAddress(Assembler::ReturnValueRegister, str);
_as->loadPtr(srcAddr, Assembler::ReturnValueRegister);
#endif
}
-void InstructionSelection::loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *targetTemp)
+void InstructionSelection::loadRegexp(IR::RegExp *sourceRegexp, IR::Temp *targetTemp)
{
int id = registerRegExp(sourceRegexp);
generateFunctionCall(targetTemp, __qmljs_lookup_runtime_regexp, Assembler::ContextRegister, Assembler::TrustedImm32(id));
}
-void InstructionSelection::getActivationProperty(const V4IR::Name *name, V4IR::Temp *temp)
+void InstructionSelection::getActivationProperty(const IR::Name *name, IR::Temp *temp)
{
if (useFastLookups && name->global) {
uint index = registerGlobalGetterLookup(*name->id);
generateFunctionCall(temp, __qmljs_get_activation_property, Assembler::ContextRegister, Assembler::PointerToString(*name->id));
}
-void InstructionSelection::setActivationProperty(V4IR::Expr *source, const QString &targetName)
+void InstructionSelection::setActivationProperty(IR::Expr *source, const QString &targetName)
{
// ### should use a lookup call here
generateFunctionCall(Assembler::Void, __qmljs_set_activation_property,
Assembler::ContextRegister, Assembler::PointerToString(targetName), Assembler::PointerToValue(source));
}
-void InstructionSelection::initClosure(V4IR::Closure *closure, V4IR::Temp *target)
+void InstructionSelection::initClosure(IR::Closure *closure, IR::Temp *target)
{
int id = closure->value;
generateFunctionCall(target, __qmljs_init_closure, Assembler::ContextRegister, Assembler::TrustedImm32(id));
}
-void InstructionSelection::getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target)
+void InstructionSelection::getProperty(IR::Expr *base, const QString &name, IR::Temp *target)
{
if (useFastLookups) {
uint index = registerGetterLookup(name);
}
}
-void InstructionSelection::getQObjectProperty(V4IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, V4IR::Temp *target)
+void InstructionSelection::getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, IR::Temp *target)
{
if (attachedPropertiesId != 0)
generateFunctionCall(target, __qmljs_get_attached_property, Assembler::ContextRegister, Assembler::TrustedImm32(attachedPropertiesId), Assembler::TrustedImm32(propertyIndex));
Assembler::TrustedImm32(captureRequired));
}
-void InstructionSelection::setProperty(V4IR::Expr *source, V4IR::Expr *targetBase,
+void InstructionSelection::setProperty(IR::Expr *source, IR::Expr *targetBase,
const QString &targetName)
{
if (useFastLookups) {
}
}
-void InstructionSelection::setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex)
+void InstructionSelection::setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex)
{
generateFunctionCall(Assembler::Void, __qmljs_set_qobject_property, Assembler::ContextRegister, Assembler::PointerToValue(targetBase),
Assembler::TrustedImm32(propertyIndex), Assembler::PointerToValue(source));
}
-void InstructionSelection::getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target)
+void InstructionSelection::getElement(IR::Expr *base, IR::Expr *index, IR::Temp *target)
{
if (useFastLookups) {
uint lookup = registerIndexedGetterLookup();
Assembler::PointerToValue(base), Assembler::PointerToValue(index));
}
-void InstructionSelection::setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex)
+void InstructionSelection::setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex)
{
if (useFastLookups) {
uint lookup = registerIndexedSetterLookup();
Assembler::PointerToValue(source));
}
-void InstructionSelection::copyValue(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp)
+void InstructionSelection::copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
if (*sourceTemp == *targetTemp)
return;
- if (sourceTemp->kind == V4IR::Temp::PhysicalRegister) {
- if (targetTemp->kind == V4IR::Temp::PhysicalRegister) {
- if (sourceTemp->type == V4IR::DoubleType)
+ if (sourceTemp->kind == IR::Temp::PhysicalRegister) {
+ if (targetTemp->kind == IR::Temp::PhysicalRegister) {
+ if (sourceTemp->type == IR::DoubleType)
_as->moveDouble((Assembler::FPRegisterID) sourceTemp->index,
(Assembler::FPRegisterID) targetTemp->index);
else
return;
} else {
switch (sourceTemp->type) {
- case V4IR::DoubleType:
+ case IR::DoubleType:
_as->storeDouble((Assembler::FPRegisterID) sourceTemp->index, targetTemp);
break;
- case V4IR::SInt32Type:
+ case IR::SInt32Type:
_as->storeInt32((Assembler::RegisterID) sourceTemp->index, targetTemp);
break;
- case V4IR::UInt32Type:
+ case IR::UInt32Type:
_as->storeUInt32((Assembler::RegisterID) sourceTemp->index, targetTemp);
break;
- case V4IR::BoolType:
+ case IR::BoolType:
_as->storeBool((Assembler::RegisterID) sourceTemp->index, targetTemp);
break;
default:
}
return;
}
- } else if (targetTemp->kind == V4IR::Temp::PhysicalRegister) {
+ } else if (targetTemp->kind == IR::Temp::PhysicalRegister) {
switch (targetTemp->type) {
- case V4IR::DoubleType:
- Q_ASSERT(sourceTemp->type == V4IR::DoubleType);
+ case IR::DoubleType:
+ Q_ASSERT(sourceTemp->type == IR::DoubleType);
_as->toDoubleRegister(sourceTemp, (Assembler::FPRegisterID) targetTemp->index);
return;
- case V4IR::BoolType:
- Q_ASSERT(sourceTemp->type == V4IR::BoolType);
+ case IR::BoolType:
+ Q_ASSERT(sourceTemp->type == IR::BoolType);
_as->toInt32Register(sourceTemp, (Assembler::RegisterID) targetTemp->index);
return;
- case V4IR::SInt32Type:
- Q_ASSERT(sourceTemp->type == V4IR::SInt32Type);
+ case IR::SInt32Type:
+ Q_ASSERT(sourceTemp->type == IR::SInt32Type);
_as->toInt32Register(sourceTemp, (Assembler::RegisterID) targetTemp->index);
return;
- case V4IR::UInt32Type:
- Q_ASSERT(sourceTemp->type == V4IR::UInt32Type);
+ case IR::UInt32Type:
+ Q_ASSERT(sourceTemp->type == IR::UInt32Type);
_as->toUInt32Register(sourceTemp, (Assembler::RegisterID) targetTemp->index);
return;
default:
Assembler::ScratchRegister);
}
-void InstructionSelection::swapValues(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp)
+void InstructionSelection::swapValues(IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
- if (sourceTemp->kind == V4IR::Temp::PhysicalRegister) {
- if (targetTemp->kind == V4IR::Temp::PhysicalRegister) {
+ if (sourceTemp->kind == IR::Temp::PhysicalRegister) {
+ if (targetTemp->kind == IR::Temp::PhysicalRegister) {
Q_ASSERT(sourceTemp->type == targetTemp->type);
- if (sourceTemp->type == V4IR::DoubleType) {
+ if (sourceTemp->type == IR::DoubleType) {
_as->moveDouble((Assembler::FPRegisterID) targetTemp->index, Assembler::FPGpr0);
_as->moveDouble((Assembler::FPRegisterID) sourceTemp->index,
(Assembler::FPRegisterID) targetTemp->index);
}
return;
}
- } else if (sourceTemp->kind == V4IR::Temp::StackSlot) {
- if (targetTemp->kind == V4IR::Temp::StackSlot) {
+ } else if (sourceTemp->kind == IR::Temp::StackSlot) {
+ if (targetTemp->kind == IR::Temp::StackSlot) {
// Note: a swap for two stack-slots can involve different types.
#if CPU(X86_64)
_as->load64(_as->stackSlotPointer(targetTemp), Assembler::ReturnValueRegister);
}
}
- V4IR::Temp *stackTemp = sourceTemp->kind == V4IR::Temp::StackSlot ? sourceTemp : targetTemp;
- V4IR::Temp *registerTemp = sourceTemp->kind == V4IR::Temp::PhysicalRegister ? sourceTemp
+ IR::Temp *stackTemp = sourceTemp->kind == IR::Temp::StackSlot ? sourceTemp : targetTemp;
+ IR::Temp *registerTemp = sourceTemp->kind == IR::Temp::PhysicalRegister ? sourceTemp
: targetTemp;
Assembler::Pointer addr = _as->stackSlotPointer(stackTemp);
- if (registerTemp->type == V4IR::DoubleType) {
+ if (registerTemp->type == IR::DoubleType) {
_as->loadDouble(addr, Assembler::FPGpr0);
_as->storeDouble((Assembler::FPRegisterID) registerTemp->index, addr);
_as->moveDouble(Assembler::FPGpr0, (Assembler::FPRegisterID) registerTemp->index);
- } else if (registerTemp->type == V4IR::UInt32Type) {
+ } else if (registerTemp->type == IR::UInt32Type) {
_as->toUInt32Register(addr, Assembler::ScratchRegister);
_as->storeUInt32((Assembler::RegisterID) registerTemp->index, addr);
_as->move(Assembler::ScratchRegister, (Assembler::RegisterID) registerTemp->index);
addr.offset += 4;
quint32 tag;
switch (registerTemp->type) {
- case V4IR::BoolType:
+ case IR::BoolType:
tag = QV4::Value::_Boolean_Type;
break;
- case V4IR::SInt32Type:
+ case IR::SInt32Type:
tag = QV4::Value::_Integer_Type;
break;
default:
#define setOpContext(op, opName, operation) \
do { opContext = operation; opName = isel_stringIfy(operation); } while (0)
-void InstructionSelection::unop(V4IR::AluOp oper, V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp)
+void InstructionSelection::unop(IR::AluOp oper, IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
QV4::JIT::Unop unop(_as, oper);
unop.generate(sourceTemp, targetTemp);
}
-void InstructionSelection::binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target)
+void InstructionSelection::binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target)
{
QV4::JIT::Binop binop(_as, oper);
binop.generate(leftSource, rightSource, target);
}
-void InstructionSelection::callProperty(V4IR::Expr *base, const QString &name, V4IR::ExprList *args,
- V4IR::Temp *result)
+void InstructionSelection::callProperty(IR::Expr *base, const QString &name, IR::ExprList *args,
+ IR::Temp *result)
{
assert(base != 0);
}
}
-void InstructionSelection::callSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::ExprList *args,
- V4IR::Temp *result)
+void InstructionSelection::callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args,
+ IR::Temp *result)
{
assert(base != 0);
baseAddressForCallData());
}
-void InstructionSelection::convertType(V4IR::Temp *source, V4IR::Temp *target)
+void InstructionSelection::convertType(IR::Temp *source, IR::Temp *target)
{
switch (target->type) {
- case V4IR::DoubleType:
+ case IR::DoubleType:
convertTypeToDouble(source, target);
break;
- case V4IR::BoolType:
+ case IR::BoolType:
convertTypeToBool(source, target);
break;
- case V4IR::SInt32Type:
+ case IR::SInt32Type:
convertTypeToSInt32(source, target);
break;
- case V4IR::UInt32Type:
+ case IR::UInt32Type:
convertTypeToUInt32(source, target);
break;
default:
}
}
-void InstructionSelection::convertTypeSlowPath(V4IR::Temp *source, V4IR::Temp *target)
+void InstructionSelection::convertTypeSlowPath(IR::Temp *source, IR::Temp *target)
{
- Q_ASSERT(target->type != V4IR::BoolType);
+ Q_ASSERT(target->type != IR::BoolType);
- if (target->type & V4IR::NumberType)
- unop(V4IR::OpUPlus, source, target);
+ if (target->type & IR::NumberType)
+ unop(IR::OpUPlus, source, target);
else
copyValue(source, target);
}
-void InstructionSelection::convertTypeToDouble(V4IR::Temp *source, V4IR::Temp *target)
+void InstructionSelection::convertTypeToDouble(IR::Temp *source, IR::Temp *target)
{
switch (source->type) {
- case V4IR::SInt32Type:
- case V4IR::BoolType:
- case V4IR::NullType:
+ case IR::SInt32Type:
+ case IR::BoolType:
+ case IR::NullType:
convertIntToDouble(source, target);
break;
- case V4IR::UInt32Type:
+ case IR::UInt32Type:
convertUIntToDouble(source, target);
break;
- case V4IR::UndefinedType:
+ case IR::UndefinedType:
_as->loadDouble(_as->loadTempAddress(Assembler::ScratchRegister, source), Assembler::FPGpr0);
_as->storeDouble(Assembler::FPGpr0, target);
break;
- case V4IR::StringType:
- case V4IR::VarType: {
+ case IR::StringType:
+ case IR::VarType: {
// load the tag:
Assembler::Pointer tagAddr = _as->loadTempAddress(Assembler::ScratchRegister, source);
tagAddr.offset += 4;
// it is a double:
isDbl.link(_as);
Assembler::Pointer addr2 = _as->loadTempAddress(Assembler::ScratchRegister, source);
- if (target->kind == V4IR::Temp::StackSlot) {
+ if (target->kind == IR::Temp::StackSlot) {
#if QT_POINTER_SIZE == 8
_as->load64(addr2, Assembler::ScratchRegister);
_as->store64(Assembler::ScratchRegister, _as->stackSlotPointer(target));
}
}
-void InstructionSelection::convertTypeToBool(V4IR::Temp *source, V4IR::Temp *target)
+void InstructionSelection::convertTypeToBool(IR::Temp *source, IR::Temp *target)
{
switch (source->type) {
- case V4IR::SInt32Type:
- case V4IR::UInt32Type:
+ case IR::SInt32Type:
+ case IR::UInt32Type:
convertIntToBool(source, target);
break;
- case V4IR::DoubleType: {
+ case IR::DoubleType: {
// The source is in a register if the register allocator is used. If the register
// allocator was not used, then that means that we can use any register for to
// load the double into.
Assembler::FPRegisterID reg;
- if (source->kind == V4IR::Temp::PhysicalRegister)
+ if (source->kind == IR::Temp::PhysicalRegister)
reg = (Assembler::FPRegisterID) source->index;
else
reg = _as->toDoubleRegister(source, (Assembler::FPRegisterID) 1);
// done:
done.link(_as);
} break;
- case V4IR::UndefinedType:
- case V4IR::NullType:
+ case IR::UndefinedType:
+ case IR::NullType:
_as->storeBool(false, target);
break;
- case V4IR::StringType:
- case V4IR::VarType:
+ case IR::StringType:
+ case IR::VarType:
default:
generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_to_boolean,
Assembler::PointerToValue(source));
}
}
-void InstructionSelection::convertTypeToSInt32(V4IR::Temp *source, V4IR::Temp *target)
+void InstructionSelection::convertTypeToSInt32(IR::Temp *source, IR::Temp *target)
{
switch (source->type) {
- case V4IR::VarType: {
+ case IR::VarType: {
#if QT_POINTER_SIZE == 8
Assembler::Pointer addr = _as->loadTempAddress(Assembler::ScratchRegister, source);
isInt.link(_as);
success.link(_as);
- if (target->kind == V4IR::Temp::StackSlot) {
+ if (target->kind == IR::Temp::StackSlot) {
Assembler::Pointer targetAddr = _as->stackSlotPointer(target);
_as->store32(Assembler::ReturnValueRegister, targetAddr);
targetAddr.offset += 4;
// check if it's an int32:
Assembler::Jump fallback = _as->branch32(Assembler::NotEqual, Assembler::ReturnValueRegister,
Assembler::TrustedImm32(Value::_Integer_Type));
- if (target->kind == V4IR::Temp::StackSlot) {
+ if (target->kind == IR::Temp::StackSlot) {
_as->load32(addr, Assembler::ScratchRegister);
Assembler::Pointer targetAddr = _as->stackSlotPointer(target);
_as->store32(Assembler::ScratchRegister, targetAddr);
#endif
} break;
- case V4IR::DoubleType: {
+ case IR::DoubleType: {
Assembler::Jump success =
_as->branchTruncateDoubleToInt32(_as->toDoubleRegister(source),
Assembler::ReturnValueRegister,
success.link(_as);
_as->storeInt32(Assembler::ReturnValueRegister, target);
} break;
- case V4IR::UInt32Type:
+ case IR::UInt32Type:
_as->storeInt32(_as->toUInt32Register(source, Assembler::ReturnValueRegister), target);
break;
- case V4IR::NullType:
- case V4IR::UndefinedType:
+ case IR::NullType:
+ case IR::UndefinedType:
_as->move(Assembler::TrustedImm32(0), Assembler::ReturnValueRegister);
_as->storeInt32(Assembler::ReturnValueRegister, target);
break;
- case V4IR::BoolType:
+ case IR::BoolType:
_as->storeInt32(_as->toInt32Register(source, Assembler::ReturnValueRegister), target);
break;
- case V4IR::StringType:
+ case IR::StringType:
default:
generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_value_to_int32,
_as->loadTempAddress(Assembler::ScratchRegister, source));
} // switch (source->type)
}
-void InstructionSelection::convertTypeToUInt32(V4IR::Temp *source, V4IR::Temp *target)
+void InstructionSelection::convertTypeToUInt32(IR::Temp *source, IR::Temp *target)
{
switch (source->type) {
- case V4IR::VarType: {
+ case IR::VarType: {
// load the tag:
Assembler::Pointer tagAddr = _as->loadTempAddress(Assembler::ScratchRegister, source);
tagAddr.offset += 4;
intDone.link(_as);
} break;
- case V4IR::DoubleType: {
+ case IR::DoubleType: {
Assembler::FPRegisterID reg = _as->toDoubleRegister(source);
Assembler::Jump success =
_as->branchTruncateDoubleToUint32(reg, Assembler::ReturnValueRegister,
success.link(_as);
_as->storeUInt32(Assembler::ReturnValueRegister, target);
} break;
- case V4IR::NullType:
- case V4IR::UndefinedType:
+ case IR::NullType:
+ case IR::UndefinedType:
_as->move(Assembler::TrustedImm32(0), Assembler::ReturnValueRegister);
_as->storeUInt32(Assembler::ReturnValueRegister, target);
break;
- case V4IR::StringType:
+ case IR::StringType:
generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_value_to_uint32,
Assembler::PointerToValue(source));
_as->storeUInt32(Assembler::ReturnValueRegister, target);
break;
- case V4IR::SInt32Type:
- case V4IR::BoolType:
+ case IR::SInt32Type:
+ case IR::BoolType:
_as->storeUInt32(_as->toInt32Register(source, Assembler::ReturnValueRegister), target);
break;
default:
} // switch (source->type)
}
-void InstructionSelection::constructActivationProperty(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Temp *result)
{
assert(func != 0);
prepareCallData(args, 0);
}
-void InstructionSelection::constructProperty(V4IR::Temp *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::constructProperty(IR::Temp *base, const QString &name, IR::ExprList *args, IR::Temp *result)
{
prepareCallData(args, base);
if (useFastLookups) {
baseAddressForCallData());
}
-void InstructionSelection::constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result)
+void InstructionSelection::constructValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result)
{
assert(value != 0);
baseAddressForCallData());
}
-void InstructionSelection::visitJump(V4IR::Jump *s)
+void InstructionSelection::visitJump(IR::Jump *s)
{
if (!_removableJumps.contains(s))
_as->jumpToBlock(_block, s->target);
}
-void InstructionSelection::visitCJump(V4IR::CJump *s)
+void InstructionSelection::visitCJump(IR::CJump *s)
{
- if (V4IR::Temp *t = s->cond->asTemp()) {
+ if (IR::Temp *t = s->cond->asTemp()) {
Assembler::RegisterID reg;
- if (t->kind == V4IR::Temp::PhysicalRegister) {
- Q_ASSERT(t->type == V4IR::BoolType);
+ if (t->kind == IR::Temp::PhysicalRegister) {
+ Q_ASSERT(t->type == IR::BoolType);
reg = (Assembler::RegisterID) t->index;
- } else if (t->kind == V4IR::Temp::StackSlot && t->type == V4IR::BoolType) {
+ } else if (t->kind == IR::Temp::StackSlot && t->type == IR::BoolType) {
reg = Assembler::ReturnValueRegister;
_as->toInt32Register(t, reg);
} else {
_as->generateCJumpOnNonZero(reg, _block, s->iftrue, s->iffalse);
return;
- } else if (V4IR::Const *c = s->cond->asConst()) {
+ } else if (IR::Const *c = s->cond->asConst()) {
// TODO: SSA optimization for constant condition evaluation should remove this.
// See also visitCJump() in RegAllocInfo.
generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_to_boolean,
Assembler::PointerToValue(c));
_as->generateCJumpOnNonZero(Assembler::ReturnValueRegister, _block, s->iftrue, s->iffalse);
return;
- } else if (V4IR::Binop *b = s->cond->asBinop()) {
- if (b->left->type == V4IR::DoubleType && b->right->type == V4IR::DoubleType
+ } else if (IR::Binop *b = s->cond->asBinop()) {
+ if (b->left->type == IR::DoubleType && b->right->type == IR::DoubleType
&& visitCJumpDouble(b->op, b->left, b->right, s->iftrue, s->iffalse))
return;
- if (b->op == V4IR::OpStrictEqual || b->op == V4IR::OpStrictNotEqual) {
+ if (b->op == IR::OpStrictEqual || b->op == IR::OpStrictNotEqual) {
visitCJumpStrict(b, s->iftrue, s->iffalse);
return;
}
- if (b->op == V4IR::OpEqual || b->op == V4IR::OpNotEqual) {
+ if (b->op == IR::OpEqual || b->op == IR::OpNotEqual) {
visitCJumpEqual(b, s->iftrue, s->iffalse);
return;
}
const char *opName = 0;
switch (b->op) {
default: Q_UNREACHABLE(); assert(!"todo"); break;
- case V4IR::OpGt: setOp(op, opName, __qmljs_cmp_gt); break;
- case V4IR::OpLt: setOp(op, opName, __qmljs_cmp_lt); break;
- case V4IR::OpGe: setOp(op, opName, __qmljs_cmp_ge); break;
- case V4IR::OpLe: setOp(op, opName, __qmljs_cmp_le); break;
- case V4IR::OpEqual: setOp(op, opName, __qmljs_cmp_eq); break;
- case V4IR::OpNotEqual: setOp(op, opName, __qmljs_cmp_ne); break;
- case V4IR::OpStrictEqual: setOp(op, opName, __qmljs_cmp_se); break;
- case V4IR::OpStrictNotEqual: setOp(op, opName, __qmljs_cmp_sne); break;
- case V4IR::OpInstanceof: setOpContext(op, opName, __qmljs_cmp_instanceof); break;
- case V4IR::OpIn: setOpContext(op, opName, __qmljs_cmp_in); break;
+ case IR::OpGt: setOp(op, opName, __qmljs_cmp_gt); break;
+ case IR::OpLt: setOp(op, opName, __qmljs_cmp_lt); break;
+ case IR::OpGe: setOp(op, opName, __qmljs_cmp_ge); break;
+ case IR::OpLe: setOp(op, opName, __qmljs_cmp_le); break;
+ case IR::OpEqual: setOp(op, opName, __qmljs_cmp_eq); break;
+ case IR::OpNotEqual: setOp(op, opName, __qmljs_cmp_ne); break;
+ case IR::OpStrictEqual: setOp(op, opName, __qmljs_cmp_se); break;
+ case IR::OpStrictNotEqual: setOp(op, opName, __qmljs_cmp_sne); break;
+ case IR::OpInstanceof: setOpContext(op, opName, __qmljs_cmp_instanceof); break;
+ case IR::OpIn: setOpContext(op, opName, __qmljs_cmp_in); break;
} // switch
// TODO: in SSA optimization, do constant expression evaluation.
Q_UNREACHABLE();
}
-void InstructionSelection::visitRet(V4IR::Ret *s)
+void InstructionSelection::visitRet(IR::Ret *s)
{
if (!s) {
// this only happens if the method doesn't have a return statement and can
// only exit through an exception
- } else if (V4IR::Temp *t = s->expr->asTemp()) {
+ } else if (IR::Temp *t = s->expr->asTemp()) {
#if CPU(X86) || CPU(ARM)
# if CPU(X86)
Assembler::RegisterID highReg = JSC::ARMRegisters::r1;
# endif
- if (t->kind == V4IR::Temp::PhysicalRegister) {
+ if (t->kind == IR::Temp::PhysicalRegister) {
switch (t->type) {
- case V4IR::DoubleType:
+ case IR::DoubleType:
_as->moveDoubleToInts((Assembler::FPRegisterID) t->index, lowReg, highReg);
break;
- case V4IR::UInt32Type: {
+ case IR::UInt32Type: {
Assembler::RegisterID srcReg = (Assembler::RegisterID) t->index;
Assembler::Jump intRange = _as->branch32(Assembler::GreaterThanOrEqual, srcReg, Assembler::TrustedImm32(0));
_as->convertUInt32ToDouble(srcReg, Assembler::FPGpr0, Assembler::ReturnValueRegister);
_as->move(Assembler::TrustedImm32(QV4::Value::_Integer_Type), highReg);
done.link(_as);
} break;
- case V4IR::SInt32Type:
+ case IR::SInt32Type:
_as->move((Assembler::RegisterID) t->index, lowReg);
_as->move(Assembler::TrustedImm32(QV4::Value::_Integer_Type), highReg);
break;
- case V4IR::BoolType:
+ case IR::BoolType:
_as->move((Assembler::RegisterID) t->index, lowReg);
_as->move(Assembler::TrustedImm32(QV4::Value::_Boolean_Type), highReg);
break;
_as->load32(addr, highReg);
}
#else
- if (t->kind == V4IR::Temp::PhysicalRegister) {
- if (t->type == V4IR::DoubleType) {
+ if (t->kind == IR::Temp::PhysicalRegister) {
+ if (t->type == IR::DoubleType) {
_as->moveDoubleTo64((Assembler::FPRegisterID) t->index,
Assembler::ReturnValueRegister);
_as->move(Assembler::TrustedImm64(QV4::Value::NaNEncodeMask),
Assembler::ScratchRegister);
_as->xor64(Assembler::ScratchRegister, Assembler::ReturnValueRegister);
- } else if (t->type == V4IR::UInt32Type) {
+ } else if (t->type == IR::UInt32Type) {
Assembler::RegisterID srcReg = (Assembler::RegisterID) t->index;
Assembler::Jump intRange = _as->branch32(Assembler::GreaterThanOrEqual, srcReg, Assembler::TrustedImm32(0));
_as->convertUInt32ToDouble(srcReg, Assembler::FPGpr0, Assembler::ReturnValueRegister);
_as->zeroExtend32ToPtr((Assembler::RegisterID) t->index, Assembler::ReturnValueRegister);
quint64 tag;
switch (t->type) {
- case V4IR::SInt32Type:
+ case IR::SInt32Type:
tag = QV4::Value::_Integer_Type;
break;
- case V4IR::BoolType:
+ case IR::BoolType:
tag = QV4::Value::_Boolean_Type;
break;
default:
_as->copyValue(Assembler::ReturnValueRegister, t);
}
#endif
- } else if (V4IR::Const *c = s->expr->asConst()) {
+ } else if (IR::Const *c = s->expr->asConst()) {
QV4::Primitive retVal = convertToValue(c);
#if CPU(X86)
_as->move(Assembler::TrustedImm32(retVal.int_32), JSC::X86Registers::eax);
_as->ret();
}
-int InstructionSelection::prepareVariableArguments(V4IR::ExprList* args)
+int InstructionSelection::prepareVariableArguments(IR::ExprList* args)
{
int argc = 0;
- for (V4IR::ExprList *it = args; it; it = it->next) {
+ for (IR::ExprList *it = args; it; it = it->next) {
++argc;
}
int i = 0;
- for (V4IR::ExprList *it = args; it; it = it->next, ++i) {
- V4IR::Expr *arg = it->expr;
+ for (IR::ExprList *it = args; it; it = it->next, ++i) {
+ IR::Expr *arg = it->expr;
Q_ASSERT(arg != 0);
Pointer dst(_as->stackLayout().argumentAddressForCall(i));
- if (arg->asTemp() && arg->asTemp()->kind != V4IR::Temp::PhysicalRegister)
+ if (arg->asTemp() && arg->asTemp()->kind != IR::Temp::PhysicalRegister)
_as->memcopyValue(dst, arg->asTemp(), Assembler::ScratchRegister);
else
_as->copyValue(dst, arg);
return argc;
}
-int InstructionSelection::prepareCallData(V4IR::ExprList* args, V4IR::Expr *thisObject)
+int InstructionSelection::prepareCallData(IR::ExprList* args, IR::Expr *thisObject)
{
int argc = 0;
- for (V4IR::ExprList *it = args; it; it = it->next) {
+ for (IR::ExprList *it = args; it; it = it->next) {
++argc;
}
_as->copyValue(p, thisObject);
int i = 0;
- for (V4IR::ExprList *it = args; it; it = it->next, ++i) {
- V4IR::Expr *arg = it->expr;
+ for (IR::ExprList *it = args; it; it = it->next, ++i) {
+ IR::Expr *arg = it->expr;
Q_ASSERT(arg != 0);
Pointer dst(_as->stackLayout().argumentAddressForCall(i));
- if (arg->asTemp() && arg->asTemp()->kind != V4IR::Temp::PhysicalRegister)
+ if (arg->asTemp() && arg->asTemp()->kind != IR::Temp::PhysicalRegister)
_as->memcopyValue(dst, arg->asTemp(), Assembler::ScratchRegister);
else
_as->copyValue(dst, arg);
return idx;
}
-Assembler::ImplicitAddress Assembler::ConstantTable::loadValueAddress(V4IR::Const *c,
+Assembler::ImplicitAddress Assembler::ConstantTable::loadValueAddress(IR::Const *c,
RegisterID baseReg)
{
return loadValueAddress(convertToValue(c), baseReg);
linkBuffer.patch(label, tablePtr);
}
-bool InstructionSelection::visitCJumpDouble(V4IR::AluOp op, V4IR::Expr *left, V4IR::Expr *right,
- V4IR::BasicBlock *iftrue, V4IR::BasicBlock *iffalse)
+bool InstructionSelection::visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Expr *right,
+ IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
{
if (!isPregOrConst(left) || !isPregOrConst(right))
return false;
return true;
}
-void InstructionSelection::visitCJumpStrict(V4IR::Binop *binop, V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock)
+void InstructionSelection::visitCJumpStrict(IR::Binop *binop, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
- Q_ASSERT(binop->op == V4IR::OpStrictEqual || binop->op == V4IR::OpStrictNotEqual);
+ Q_ASSERT(binop->op == IR::OpStrictEqual || binop->op == IR::OpStrictNotEqual);
- if (visitCJumpStrictNullUndefined(V4IR::NullType, binop, trueBlock, falseBlock))
+ if (visitCJumpStrictNullUndefined(IR::NullType, binop, trueBlock, falseBlock))
return;
- if (visitCJumpStrictNullUndefined(V4IR::UndefinedType, binop, trueBlock, falseBlock))
+ if (visitCJumpStrictNullUndefined(IR::UndefinedType, binop, trueBlock, falseBlock))
return;
if (visitCJumpStrictBool(binop, trueBlock, falseBlock))
return;
- V4IR::Expr *left = binop->left;
- V4IR::Expr *right = binop->right;
+ IR::Expr *left = binop->left;
+ IR::Expr *right = binop->right;
_as->generateFunctionCallImp(Assembler::ReturnValueRegister, "__qmljs_cmp_se", __qmljs_cmp_se,
Assembler::PointerToValue(left), Assembler::PointerToValue(right));
- _as->generateCJumpOnCompare(binop->op == V4IR::OpStrictEqual ? Assembler::NotEqual : Assembler::Equal,
+ _as->generateCJumpOnCompare(binop->op == IR::OpStrictEqual ? Assembler::NotEqual : Assembler::Equal,
Assembler::ReturnValueRegister, Assembler::TrustedImm32(0),
_block, trueBlock, falseBlock);
}
// Only load the non-null temp.
-bool InstructionSelection::visitCJumpStrictNullUndefined(V4IR::Type nullOrUndef, V4IR::Binop *binop,
- V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock)
+bool InstructionSelection::visitCJumpStrictNullUndefined(IR::Type nullOrUndef, IR::Binop *binop,
+ IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
- Q_ASSERT(nullOrUndef == V4IR::NullType || nullOrUndef == V4IR::UndefinedType);
+ Q_ASSERT(nullOrUndef == IR::NullType || nullOrUndef == IR::UndefinedType);
- V4IR::Expr *varSrc = 0;
- if (binop->left->type == V4IR::VarType && binop->right->type == nullOrUndef)
+ IR::Expr *varSrc = 0;
+ if (binop->left->type == IR::VarType && binop->right->type == nullOrUndef)
varSrc = binop->left;
- else if (binop->left->type == nullOrUndef && binop->right->type == V4IR::VarType)
+ else if (binop->left->type == nullOrUndef && binop->right->type == IR::VarType)
varSrc = binop->right;
if (!varSrc)
return false;
- if (varSrc->asTemp() && varSrc->asTemp()->kind == V4IR::Temp::PhysicalRegister) {
+ if (varSrc->asTemp() && varSrc->asTemp()->kind == IR::Temp::PhysicalRegister) {
_as->jumpToBlock(_block, falseBlock);
return true;
}
- if (V4IR::Const *c = varSrc->asConst()) {
+ if (IR::Const *c = varSrc->asConst()) {
if (c->type == nullOrUndef)
_as->jumpToBlock(_block, trueBlock);
else
return true;
}
- V4IR::Temp *t = varSrc->asTemp();
+ IR::Temp *t = varSrc->asTemp();
Q_ASSERT(t);
Assembler::Pointer tagAddr = _as->loadTempAddress(Assembler::ScratchRegister, t);
const Assembler::RegisterID tagReg = Assembler::ScratchRegister;
_as->load32(tagAddr, tagReg);
- Assembler::RelationalCondition cond = binop->op == V4IR::OpStrictEqual ? Assembler::Equal
+ Assembler::RelationalCondition cond = binop->op == IR::OpStrictEqual ? Assembler::Equal
: Assembler::NotEqual;
- const Assembler::TrustedImm32 tag(nullOrUndef == V4IR::NullType ? int(QV4::Value::_Null_Type)
+ const Assembler::TrustedImm32 tag(nullOrUndef == IR::NullType ? int(QV4::Value::_Null_Type)
: int(QV4::Value::Undefined_Type));
_as->generateCJumpOnCompare(cond, tagReg, tag, _block, trueBlock, falseBlock);
return true;
}
-bool InstructionSelection::visitCJumpStrictBool(V4IR::Binop *binop, V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock)
+bool InstructionSelection::visitCJumpStrictBool(IR::Binop *binop, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
- V4IR::Expr *boolSrc = 0, *otherSrc = 0;
- if (binop->left->type == V4IR::BoolType) {
+ IR::Expr *boolSrc = 0, *otherSrc = 0;
+ if (binop->left->type == IR::BoolType) {
boolSrc = binop->left;
otherSrc = binop->right;
- } else if (binop->right->type == V4IR::BoolType) {
+ } else if (binop->right->type == IR::BoolType) {
boolSrc = binop->right;
otherSrc = binop->left;
} else {
return false;
}
- Assembler::RelationalCondition cond = binop->op == V4IR::OpStrictEqual ? Assembler::Equal
+ Assembler::RelationalCondition cond = binop->op == IR::OpStrictEqual ? Assembler::Equal
: Assembler::NotEqual;
- if (otherSrc->type == V4IR::BoolType) { // both are boolean
+ if (otherSrc->type == IR::BoolType) { // both are boolean
Assembler::RegisterID one = _as->toBoolRegister(boolSrc, Assembler::ReturnValueRegister);
Assembler::RegisterID two = _as->toBoolRegister(otherSrc, Assembler::ScratchRegister);
_as->generateCJumpOnCompare(cond, one, two, _block, trueBlock, falseBlock);
return true;
}
- if (otherSrc->type != V4IR::VarType) {
+ if (otherSrc->type != IR::VarType) {
_as->jumpToBlock(_block, falseBlock);
return true;
}
- V4IR::Temp *otherTemp = otherSrc->asTemp();
+ IR::Temp *otherTemp = otherSrc->asTemp();
Q_ASSERT(otherTemp); // constants cannot have "var" type
- Q_ASSERT(otherTemp->kind != V4IR::Temp::PhysicalRegister);
+ Q_ASSERT(otherTemp->kind != IR::Temp::PhysicalRegister);
Assembler::Pointer otherAddr = _as->loadTempAddress(Assembler::ReturnValueRegister, otherTemp);
otherAddr.offset += 4; // tag address
_as->load32(otherAddr, Assembler::ScratchRegister);
Assembler::Jump noBool = _as->branch32(Assembler::NotEqual, Assembler::ScratchRegister,
Assembler::TrustedImm32(QV4::Value::_Boolean_Type));
- if (binop->op == V4IR::OpStrictEqual)
+ if (binop->op == IR::OpStrictEqual)
_as->addPatch(falseBlock, noBool);
else
_as->addPatch(trueBlock, noBool);
return true;
}
-bool InstructionSelection::visitCJumpNullUndefined(V4IR::Type nullOrUndef, V4IR::Binop *binop,
- V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock)
+bool InstructionSelection::visitCJumpNullUndefined(IR::Type nullOrUndef, IR::Binop *binop,
+ IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
- Q_ASSERT(nullOrUndef == V4IR::NullType || nullOrUndef == V4IR::UndefinedType);
+ Q_ASSERT(nullOrUndef == IR::NullType || nullOrUndef == IR::UndefinedType);
- V4IR::Expr *varSrc = 0;
- if (binop->left->type == V4IR::VarType && binop->right->type == nullOrUndef)
+ IR::Expr *varSrc = 0;
+ if (binop->left->type == IR::VarType && binop->right->type == nullOrUndef)
varSrc = binop->left;
- else if (binop->left->type == nullOrUndef && binop->right->type == V4IR::VarType)
+ else if (binop->left->type == nullOrUndef && binop->right->type == IR::VarType)
varSrc = binop->right;
if (!varSrc)
return false;
- if (varSrc->asTemp() && varSrc->asTemp()->kind == V4IR::Temp::PhysicalRegister) {
+ if (varSrc->asTemp() && varSrc->asTemp()->kind == IR::Temp::PhysicalRegister) {
_as->jumpToBlock(_block, falseBlock);
return true;
}
- if (V4IR::Const *c = varSrc->asConst()) {
+ if (IR::Const *c = varSrc->asConst()) {
if (c->type == nullOrUndef)
_as->jumpToBlock(_block, trueBlock);
else
return true;
}
- V4IR::Temp *t = varSrc->asTemp();
+ IR::Temp *t = varSrc->asTemp();
Q_ASSERT(t);
Assembler::Pointer tagAddr = _as->loadTempAddress(Assembler::ScratchRegister, t);
const Assembler::RegisterID tagReg = Assembler::ScratchRegister;
_as->load32(tagAddr, tagReg);
- if (binop->op == V4IR::OpNotEqual)
+ if (binop->op == IR::OpNotEqual)
qSwap(trueBlock, falseBlock);
Assembler::Jump isNull = _as->branch32(Assembler::Equal, tagReg, Assembler::TrustedImm32(int(QV4::Value::_Null_Type)));
Assembler::Jump isUndefined = _as->branch32(Assembler::Equal, tagReg, Assembler::TrustedImm32(int(QV4::Value::Undefined_Type)));
}
-void InstructionSelection::visitCJumpEqual(V4IR::Binop *binop, V4IR::BasicBlock *trueBlock,
- V4IR::BasicBlock *falseBlock)
+void InstructionSelection::visitCJumpEqual(IR::Binop *binop, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
- Q_ASSERT(binop->op == V4IR::OpEqual || binop->op == V4IR::OpNotEqual);
+ Q_ASSERT(binop->op == IR::OpEqual || binop->op == IR::OpNotEqual);
- if (visitCJumpNullUndefined(V4IR::NullType, binop, trueBlock, falseBlock))
+ if (visitCJumpNullUndefined(IR::NullType, binop, trueBlock, falseBlock))
return;
- V4IR::Expr *left = binop->left;
- V4IR::Expr *right = binop->right;
+ IR::Expr *left = binop->left;
+ IR::Expr *right = binop->right;
_as->generateFunctionCallImp(Assembler::ReturnValueRegister, "__qmljs_cmp_eq", __qmljs_cmp_eq,
Assembler::PointerToValue(left), Assembler::PointerToValue(right));
- _as->generateCJumpOnCompare(binop->op == V4IR::OpEqual ? Assembler::NotEqual : Assembler::Equal,
+ _as->generateCJumpOnCompare(binop->op == IR::OpEqual ? Assembler::NotEqual : Assembler::Equal,
Assembler::ReturnValueRegister, Assembler::TrustedImm32(0),
_block, trueBlock, falseBlock);
}
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
-namespace MASM {
+namespace QV4 {
+namespace JIT {
class Q_QML_EXPORT InstructionSelection:
- protected V4IR::IRDecoder,
+ protected IR::IRDecoder,
public EvalInstructionSelection
{
public:
- InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator);
+ InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator);
~InstructionSelection();
virtual void run(int functionIndex);
protected:
virtual QV4::CompiledData::CompilationUnit *backendCompileStep();
- virtual void callBuiltinInvalid(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void callBuiltinTypeofMember(V4IR::Expr *base, const QString &name, V4IR::Temp *result);
- virtual void callBuiltinTypeofSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *result);
- virtual void callBuiltinTypeofName(const QString &name, V4IR::Temp *result);
- virtual void callBuiltinTypeofValue(V4IR::Expr *value, V4IR::Temp *result);
- virtual void callBuiltinDeleteMember(V4IR::Temp *base, const QString &name, V4IR::Temp *result);
- virtual void callBuiltinDeleteSubscript(V4IR::Temp *base, V4IR::Expr *index, V4IR::Temp *result);
- virtual void callBuiltinDeleteName(const QString &name, V4IR::Temp *result);
- virtual void callBuiltinDeleteValue(V4IR::Temp *result);
- virtual void callBuiltinThrow(V4IR::Expr *arg);
+ virtual void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Temp *result);
+ virtual void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Temp *result);
+ virtual void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Temp *result);
+ virtual void callBuiltinTypeofName(const QString &name, IR::Temp *result);
+ virtual void callBuiltinTypeofValue(IR::Expr *value, IR::Temp *result);
+ virtual void callBuiltinDeleteMember(IR::Temp *base, const QString &name, IR::Temp *result);
+ virtual void callBuiltinDeleteSubscript(IR::Temp *base, IR::Expr *index, IR::Temp *result);
+ virtual void callBuiltinDeleteName(const QString &name, IR::Temp *result);
+ virtual void callBuiltinDeleteValue(IR::Temp *result);
+ virtual void callBuiltinThrow(IR::Expr *arg);
virtual void callBuiltinReThrow();
- virtual void callBuiltinUnwindException(V4IR::Temp *);
+ virtual void callBuiltinUnwindException(IR::Temp *);
virtual void callBuiltinPushCatchScope(const QString &exceptionName);
- virtual void callBuiltinForeachIteratorObject(V4IR::Temp *arg, V4IR::Temp *result);
- virtual void callBuiltinForeachNextPropertyname(V4IR::Temp *arg, V4IR::Temp *result);
- virtual void callBuiltinPushWithScope(V4IR::Temp *arg);
+ virtual void callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result);
+ virtual void callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result);
+ virtual void callBuiltinPushWithScope(IR::Temp *arg);
virtual void callBuiltinPopScope();
virtual void callBuiltinDeclareVar(bool deletable, const QString &name);
- virtual void callBuiltinDefineGetterSetter(V4IR::Temp *object, const QString &name, V4IR::Temp *getter, V4IR::Temp *setter);
- virtual void callBuiltinDefineProperty(V4IR::Temp *object, const QString &name, V4IR::Expr *value);
- virtual void callBuiltinDefineArray(V4IR::Temp *result, V4IR::ExprList *args);
- virtual void callBuiltinDefineObjectLiteral(V4IR::Temp *result, V4IR::ExprList *args);
- virtual void callBuiltinSetupArgumentObject(V4IR::Temp *result);
+ virtual void callBuiltinDefineGetterSetter(IR::Temp *object, const QString &name, IR::Temp *getter, IR::Temp *setter);
+ virtual void callBuiltinDefineProperty(IR::Temp *object, const QString &name, IR::Expr *value);
+ virtual void callBuiltinDefineArray(IR::Temp *result, IR::ExprList *args);
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *result, IR::ExprList *args);
+ virtual void callBuiltinSetupArgumentObject(IR::Temp *result);
virtual void callBuiltinConvertThisToObject();
- virtual void callValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void callProperty(V4IR::Expr *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void callSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void convertType(V4IR::Temp *source, V4IR::Temp *target);
- virtual void loadThisObject(V4IR::Temp *temp);
- virtual void loadQmlIdArray(V4IR::Temp *temp);
- virtual void loadQmlImportedScripts(V4IR::Temp *temp);
- virtual void loadQmlContextObject(V4IR::Temp *temp);
- virtual void loadQmlScopeObject(V4IR::Temp *temp);
- virtual void loadQmlSingleton(const QString &name, V4IR::Temp *temp);
- virtual void loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp);
- virtual void loadString(const QString &str, V4IR::Temp *targetTemp);
- virtual void loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *targetTemp);
- virtual void getActivationProperty(const V4IR::Name *name, V4IR::Temp *temp);
- virtual void setActivationProperty(V4IR::Expr *source, const QString &targetName);
- virtual void initClosure(V4IR::Closure *closure, V4IR::Temp *target);
- virtual void getProperty(V4IR::Expr *base, const QString &name, V4IR::Temp *target);
- virtual void setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &targetName);
- virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int propertyIndex);
- virtual void getQObjectProperty(V4IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, V4IR::Temp *target);
- virtual void getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target);
- virtual void setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex);
- virtual void copyValue(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp);
- virtual void swapValues(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp);
- virtual void unop(V4IR::AluOp oper, V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp);
- virtual void binop(V4IR::AluOp oper, V4IR::Expr *leftSource, V4IR::Expr *rightSource, V4IR::Temp *target);
+ virtual void callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result);
+ virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Temp *result);
+ virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Temp *result);
+ virtual void convertType(IR::Temp *source, IR::Temp *target);
+ virtual void loadThisObject(IR::Temp *temp);
+ virtual void loadQmlIdArray(IR::Temp *temp);
+ virtual void loadQmlImportedScripts(IR::Temp *temp);
+ virtual void loadQmlContextObject(IR::Temp *temp);
+ virtual void loadQmlScopeObject(IR::Temp *temp);
+ virtual void loadQmlSingleton(const QString &name, IR::Temp *temp);
+ virtual void loadConst(IR::Const *sourceConst, IR::Temp *targetTemp);
+ virtual void loadString(const QString &str, IR::Temp *targetTemp);
+ virtual void loadRegexp(IR::RegExp *sourceRegexp, IR::Temp *targetTemp);
+ virtual void getActivationProperty(const IR::Name *name, IR::Temp *temp);
+ virtual void setActivationProperty(IR::Expr *source, const QString &targetName);
+ virtual void initClosure(IR::Closure *closure, IR::Temp *target);
+ virtual void getProperty(IR::Expr *base, const QString &name, IR::Temp *target);
+ virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName);
+ virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex);
+ virtual void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, int attachedPropertiesId, IR::Temp *target);
+ virtual void getElement(IR::Expr *base, IR::Expr *index, IR::Temp *target);
+ virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex);
+ virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp);
+ virtual void swapValues(IR::Temp *sourceTemp, IR::Temp *targetTemp);
+ virtual void unop(IR::AluOp oper, IR::Temp *sourceTemp, IR::Temp *targetTemp);
+ virtual void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Temp *target);
typedef Assembler::Address Address;
typedef Assembler::Pointer Pointer;
return _as->stackLayout().callDataAddress();
}
- virtual void constructActivationProperty(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void constructProperty(V4IR::Temp *base, const QString &name, V4IR::ExprList *args, V4IR::Temp *result);
- virtual void constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result);
+ virtual void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Temp *result);
+ virtual void constructProperty(IR::Temp *base, const QString &name, IR::ExprList *args, IR::Temp *result);
+ virtual void constructValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result);
- virtual void visitJump(V4IR::Jump *);
- virtual void visitCJump(V4IR::CJump *);
- virtual void visitRet(V4IR::Ret *);
+ virtual void visitJump(IR::Jump *);
+ virtual void visitCJump(IR::CJump *);
+ virtual void visitRet(IR::Ret *);
- bool visitCJumpDouble(V4IR::AluOp op, V4IR::Expr *left, V4IR::Expr *right,
- V4IR::BasicBlock *iftrue, V4IR::BasicBlock *iffalse);
- void visitCJumpStrict(V4IR::Binop *binop, V4IR::BasicBlock *trueBlock, V4IR::BasicBlock *falseBlock);
- bool visitCJumpStrictNullUndefined(V4IR::Type nullOrUndef, V4IR::Binop *binop,
- V4IR::BasicBlock *trueBlock, V4IR::BasicBlock *falseBlock);
- bool visitCJumpStrictBool(V4IR::Binop *binop, V4IR::BasicBlock *trueBlock, V4IR::BasicBlock *falseBlock);
- bool visitCJumpNullUndefined(V4IR::Type nullOrUndef, V4IR::Binop *binop,
- V4IR::BasicBlock *trueBlock, V4IR::BasicBlock *falseBlock);
- void visitCJumpEqual(V4IR::Binop *binop, V4IR::BasicBlock *trueBlock, V4IR::BasicBlock *falseBlock);
+ bool visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Expr *right,
+ IR::BasicBlock *iftrue, IR::BasicBlock *iffalse);
+ void visitCJumpStrict(IR::Binop *binop, IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
+ bool visitCJumpStrictNullUndefined(IR::Type nullOrUndef, IR::Binop *binop,
+ IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
+ bool visitCJumpStrictBool(IR::Binop *binop, IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
+ bool visitCJumpNullUndefined(IR::Type nullOrUndef, IR::Binop *binop,
+ IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
+ void visitCJumpEqual(IR::Binop *binop, IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
private:
- void convertTypeSlowPath(V4IR::Temp *source, V4IR::Temp *target);
- void convertTypeToDouble(V4IR::Temp *source, V4IR::Temp *target);
- void convertTypeToBool(V4IR::Temp *source, V4IR::Temp *target);
- void convertTypeToSInt32(V4IR::Temp *source, V4IR::Temp *target);
- void convertTypeToUInt32(V4IR::Temp *source, V4IR::Temp *target);
+ void convertTypeSlowPath(IR::Temp *source, IR::Temp *target);
+ void convertTypeToDouble(IR::Temp *source, IR::Temp *target);
+ void convertTypeToBool(IR::Temp *source, IR::Temp *target);
+ void convertTypeToSInt32(IR::Temp *source, IR::Temp *target);
+ void convertTypeToUInt32(IR::Temp *source, IR::Temp *target);
- void convertIntToDouble(V4IR::Temp *source, V4IR::Temp *target)
+ void convertIntToDouble(IR::Temp *source, IR::Temp *target)
{
- if (target->kind == V4IR::Temp::PhysicalRegister) {
+ if (target->kind == IR::Temp::PhysicalRegister) {
_as->convertInt32ToDouble(_as->toInt32Register(source, Assembler::ScratchRegister),
(Assembler::FPRegisterID) target->index);
} else {
}
}
- void convertUIntToDouble(V4IR::Temp *source, V4IR::Temp *target)
+ void convertUIntToDouble(IR::Temp *source, IR::Temp *target)
{
Assembler::RegisterID tmpReg = Assembler::ScratchRegister;
Assembler::RegisterID reg = _as->toInt32Register(source, tmpReg);
- if (target->kind == V4IR::Temp::PhysicalRegister) {
+ if (target->kind == IR::Temp::PhysicalRegister) {
_as->convertUInt32ToDouble(reg, (Assembler::FPRegisterID) target->index, tmpReg);
} else {
_as->convertUInt32ToDouble(_as->toUInt32Register(source, tmpReg),
}
}
- void convertIntToBool(V4IR::Temp *source, V4IR::Temp *target)
+ void convertIntToBool(IR::Temp *source, IR::Temp *target)
{
- Assembler::RegisterID reg = target->kind == V4IR::Temp::PhysicalRegister
+ Assembler::RegisterID reg = target->kind == IR::Temp::PhysicalRegister
? (Assembler::RegisterID) target->index
: Assembler::ScratchRegister;
#define generateFunctionCall(t, function, ...) \
_as->generateFunctionCallImp(t, isel_stringIfy(function), function, __VA_ARGS__)
- int prepareVariableArguments(V4IR::ExprList* args);
- int prepareCallData(V4IR::ExprList* args, V4IR::Expr *thisObject);
+ int prepareVariableArguments(IR::ExprList* args);
+ int prepareCallData(IR::ExprList* args, IR::Expr *thisObject);
template <typename Retval, typename Arg1, typename Arg2, typename Arg3>
void generateLookupCall(Retval retval, uint index, uint getterSetterOffset, Arg1 arg1, Arg2 arg2, Arg3 arg3)
generateLookupCall(retval, index, getterSetterOffset, arg1, arg2, Assembler::VoidType());
}
- V4IR::BasicBlock *_block;
- QSet<V4IR::Jump *> _removableJumps;
+ IR::BasicBlock *_block;
+ QSet<IR::Jump *> _removableJumps;
Assembler* _as;
CompilationUnit *compilationUnit;
{
public:
virtual ~ISelFactory() {}
- virtual EvalInstructionSelection *create(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, V4IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
+ virtual EvalInstructionSelection *create(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
{ return new InstructionSelection(qmlEngine, execAllocator, module, jsGenerator); }
virtual bool jitCompileRegexps() const
{ return true; }
};
-} // end of namespace MASM
-} // end of namespace QQmlJS
+} // end of namespace JIT
+} // end of namespace QV4
QT_END_NAMESPACE
Q_DECLARE_TYPEINFO(Use, Q_MOVABLE_TYPE);
-using namespace QQmlJS::V4IR;
+using namespace QV4::IR;
-namespace QQmlJS {
-namespace MASM {
+namespace QV4 {
+namespace JIT {
class RegAllocInfo: public IRDecoder
{
public:
RegAllocInfo(): _currentStmt(0) {}
- void collect(Function *function)
+ void collect(IR::Function *function)
{
foreach (BasicBlock *bb, function->basicBlocks) {
foreach (Stmt *s, bb->statements) {
#endif // DEBUG_REGALLOC
protected: // IRDecoder
- virtual void callBuiltinInvalid(V4IR::Name *, V4IR::ExprList *, V4IR::Temp *) {}
- virtual void callBuiltinTypeofMember(V4IR::Expr *, const QString &, V4IR::Temp *) {}
- virtual void callBuiltinTypeofSubscript(V4IR::Expr *, V4IR::Expr *, V4IR::Temp *) {}
- virtual void callBuiltinTypeofName(const QString &, V4IR::Temp *) {}
- virtual void callBuiltinTypeofValue(V4IR::Expr *, V4IR::Temp *) {}
- virtual void callBuiltinDeleteMember(V4IR::Temp *, const QString &, V4IR::Temp *) {}
- virtual void callBuiltinDeleteSubscript(V4IR::Temp *, V4IR::Expr *, V4IR::Temp *) {}
- virtual void callBuiltinDeleteName(const QString &, V4IR::Temp *) {}
- virtual void callBuiltinDeleteValue(V4IR::Temp *) {}
- virtual void callBuiltinThrow(V4IR::Expr *) {}
+ virtual void callBuiltinInvalid(IR::Name *, IR::ExprList *, IR::Temp *) {}
+ virtual void callBuiltinTypeofMember(IR::Expr *, const QString &, IR::Temp *) {}
+ virtual void callBuiltinTypeofSubscript(IR::Expr *, IR::Expr *, IR::Temp *) {}
+ virtual void callBuiltinTypeofName(const QString &, IR::Temp *) {}
+ virtual void callBuiltinTypeofValue(IR::Expr *, IR::Temp *) {}
+ virtual void callBuiltinDeleteMember(IR::Temp *, const QString &, IR::Temp *) {}
+ virtual void callBuiltinDeleteSubscript(IR::Temp *, IR::Expr *, IR::Temp *) {}
+ virtual void callBuiltinDeleteName(const QString &, IR::Temp *) {}
+ virtual void callBuiltinDeleteValue(IR::Temp *) {}
+ virtual void callBuiltinThrow(IR::Expr *) {}
virtual void callBuiltinReThrow() {}
- virtual void callBuiltinUnwindException(V4IR::Temp *) {}
+ virtual void callBuiltinUnwindException(IR::Temp *) {}
virtual void callBuiltinPushCatchScope(const QString &) {};
- virtual void callBuiltinForeachIteratorObject(V4IR::Temp *, V4IR::Temp *) {}
- virtual void callBuiltinForeachNextProperty(V4IR::Temp *, V4IR::Temp *) {}
- virtual void callBuiltinForeachNextPropertyname(V4IR::Temp *, V4IR::Temp *) {}
- virtual void callBuiltinPushWithScope(V4IR::Temp *) {}
+ virtual void callBuiltinForeachIteratorObject(IR::Temp *, IR::Temp *) {}
+ virtual void callBuiltinForeachNextProperty(IR::Temp *, IR::Temp *) {}
+ virtual void callBuiltinForeachNextPropertyname(IR::Temp *, IR::Temp *) {}
+ virtual void callBuiltinPushWithScope(IR::Temp *) {}
virtual void callBuiltinPopScope() {}
virtual void callBuiltinDeclareVar(bool , const QString &) {}
- virtual void callBuiltinDefineGetterSetter(V4IR::Temp *, const QString &, V4IR::Temp *, V4IR::Temp *) {}
- virtual void callBuiltinDefineProperty(V4IR::Temp *, const QString &, V4IR::Expr *) {}
- virtual void callBuiltinDefineArray(V4IR::Temp *, V4IR::ExprList *) {}
- virtual void callBuiltinDefineObjectLiteral(V4IR::Temp *, V4IR::ExprList *) {}
- virtual void callBuiltinSetupArgumentObject(V4IR::Temp *) {}
+ virtual void callBuiltinDefineGetterSetter(IR::Temp *, const QString &, IR::Temp *, IR::Temp *) {}
+ virtual void callBuiltinDefineProperty(IR::Temp *, const QString &, IR::Expr *) {}
+ virtual void callBuiltinDefineArray(IR::Temp *, IR::ExprList *) {}
+ virtual void callBuiltinDefineObjectLiteral(IR::Temp *, IR::ExprList *) {}
+ virtual void callBuiltinSetupArgumentObject(IR::Temp *) {}
virtual void callBuiltinConvertThisToObject() {}
- virtual void callValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result)
+ virtual void callValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result)
{
addDef(result);
addUses(value, Use::CouldHaveRegister);
addCall();
}
- virtual void callProperty(V4IR::Expr *base, const QString &name, V4IR::ExprList *args,
- V4IR::Temp *result)
+ virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args,
+ IR::Temp *result)
{
Q_UNUSED(name)
addCall();
}
- virtual void callSubscript(V4IR::Expr *base, V4IR::Expr *index, V4IR::ExprList *args,
- V4IR::Temp *result)
+ virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args,
+ IR::Temp *result)
{
addDef(result);
addUses(base->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void convertType(V4IR::Temp *source, V4IR::Temp *target)
+ virtual void convertType(IR::Temp *source, IR::Temp *target)
{
addDef(target);
addHint(target, source);
}
- virtual void constructActivationProperty(V4IR::Name *, V4IR::ExprList *args, V4IR::Temp *result)
+ virtual void constructActivationProperty(IR::Name *, IR::ExprList *args, IR::Temp *result)
{
addDef(result);
addUses(args, Use::CouldHaveRegister);
addCall();
}
- virtual void constructProperty(V4IR::Temp *base, const QString &, V4IR::ExprList *args, V4IR::Temp *result)
+ virtual void constructProperty(IR::Temp *base, const QString &, IR::ExprList *args, IR::Temp *result)
{
addDef(result);
addUses(base, Use::CouldHaveRegister);
addCall();
}
- virtual void constructValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result)
+ virtual void constructValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result)
{
addDef(result);
addUses(value, Use::CouldHaveRegister);
addCall();
}
- virtual void loadThisObject(V4IR::Temp *temp)
+ virtual void loadThisObject(IR::Temp *temp)
{
addDef(temp);
}
- virtual void loadQmlIdArray(V4IR::Temp *temp)
+ virtual void loadQmlIdArray(IR::Temp *temp)
{
addDef(temp);
addCall();
}
- virtual void loadQmlImportedScripts(V4IR::Temp *temp)
+ virtual void loadQmlImportedScripts(IR::Temp *temp)
{
addDef(temp);
addCall();
addCall();
}
- virtual void loadConst(V4IR::Const *sourceConst, V4IR::Temp *targetTemp)
+ virtual void loadConst(IR::Const *sourceConst, IR::Temp *targetTemp)
{
Q_UNUSED(sourceConst);
addDef(targetTemp);
}
- virtual void loadString(const QString &str, V4IR::Temp *targetTemp)
+ virtual void loadString(const QString &str, IR::Temp *targetTemp)
{
Q_UNUSED(str);
addDef(targetTemp);
}
- virtual void loadRegexp(V4IR::RegExp *sourceRegexp, V4IR::Temp *targetTemp)
+ virtual void loadRegexp(IR::RegExp *sourceRegexp, IR::Temp *targetTemp)
{
Q_UNUSED(sourceRegexp);
addCall();
}
- virtual void getActivationProperty(const V4IR::Name *, V4IR::Temp *temp)
+ virtual void getActivationProperty(const IR::Name *, IR::Temp *temp)
{
addDef(temp);
addCall();
}
- virtual void setActivationProperty(V4IR::Expr *source, const QString &)
+ virtual void setActivationProperty(IR::Expr *source, const QString &)
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void initClosure(V4IR::Closure *closure, V4IR::Temp *target)
+ virtual void initClosure(IR::Closure *closure, IR::Temp *target)
{
Q_UNUSED(closure);
addCall();
}
- virtual void getProperty(V4IR::Expr *base, const QString &, V4IR::Temp *target)
+ virtual void getProperty(IR::Expr *base, const QString &, IR::Temp *target)
{
addDef(target);
addUses(base->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void setProperty(V4IR::Expr *source, V4IR::Expr *targetBase, const QString &)
+ virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &)
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addUses(targetBase->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void setQObjectProperty(V4IR::Expr *source, V4IR::Expr *targetBase, int /*propertyIndex*/)
+ virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int /*propertyIndex*/)
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addUses(targetBase->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void getQObjectProperty(V4IR::Expr *base, int /*propertyIndex*/, bool /*captureRequired*/, int /*attachedPropertiesId*/, V4IR::Temp *target)
+ virtual void getQObjectProperty(IR::Expr *base, int /*propertyIndex*/, bool /*captureRequired*/, int /*attachedPropertiesId*/, IR::Temp *target)
{
addDef(target);
addUses(base->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void getElement(V4IR::Expr *base, V4IR::Expr *index, V4IR::Temp *target)
+ virtual void getElement(IR::Expr *base, IR::Expr *index, IR::Temp *target)
{
addDef(target);
addUses(base->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void setElement(V4IR::Expr *source, V4IR::Expr *targetBase, V4IR::Expr *targetIndex)
+ virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex)
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addUses(targetBase->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void copyValue(V4IR::Temp *sourceTemp, V4IR::Temp *targetTemp)
+ virtual void copyValue(IR::Temp *sourceTemp, IR::Temp *targetTemp)
{
addDef(targetTemp);
addUses(sourceTemp, Use::CouldHaveRegister);
addHint(targetTemp, sourceTemp);
}
- virtual void swapValues(V4IR::Temp *, V4IR::Temp *)
+ virtual void swapValues(IR::Temp *, IR::Temp *)
{
// Inserted by the register allocator, so it cannot occur here.
Q_UNREACHABLE();
addDef(targetTemp);
bool needsCall = true;
- if (oper == OpNot && sourceTemp->type == V4IR::BoolType && targetTemp->type == V4IR::BoolType)
+ if (oper == OpNot && sourceTemp->type == IR::BoolType && targetTemp->type == IR::BoolType)
needsCall = false;
#if 0 // TODO: change masm to generate code
}
}
- virtual void visitJump(V4IR::Jump *) {}
- virtual void visitCJump(V4IR::CJump *s)
+ virtual void visitJump(IR::Jump *) {}
+ virtual void visitCJump(IR::CJump *s)
{
if (Temp *t = s->cond->asTemp()) {
#if 0 // TODO: change masm to generate code
}
}
- virtual void visitRet(V4IR::Ret *s)
+ virtual void visitRet(IR::Ret *s)
{ addUses(s->expr->asTemp(), Use::CouldHaveRegister); }
- virtual void visitPhi(V4IR::Phi *s)
+ virtual void visitPhi(IR::Phi *s)
{
addDef(s->targetTemp, true);
foreach (Expr *e, s->d->incoming) {
}
protected:
- virtual void callBuiltin(V4IR::Call *c, V4IR::Temp *result)
+ virtual void callBuiltin(IR::Call *c, IR::Temp *result)
{
addDef(result);
addUses(c->base->asTemp(), Use::CouldHaveRegister);
}
};
-} // MASM namespace
-} // MOTH namespace
+} // JIT namespace
+} // QV4 namespace
QT_END_NAMESPACE
QT_USE_NAMESPACE
-using namespace QT_PREPEND_NAMESPACE(QQmlJS::MASM);
-using namespace QT_PREPEND_NAMESPACE(QQmlJS::V4IR);
-using namespace QT_PREPEND_NAMESPACE(QQmlJS);
+using namespace QT_PREPEND_NAMESPACE(QV4::JIT);
+using namespace QT_PREPEND_NAMESPACE(QV4::IR);
+using namespace QT_PREPEND_NAMESPACE(QV4);
namespace {
class ResolutionPhase: protected StmtVisitor, protected ExprVisitor {
const QVector<LifeTimeInterval> &_intervals;
QVector<const LifeTimeInterval *> _unprocessed;
- Function *_function;
+ IR::Function *_function;
#if !defined(QT_NO_DEBUG)
RegAllocInfo *_info;
#endif
- const QHash<V4IR::Temp, int> &_assignedSpillSlots;
- QHash<V4IR::Temp, const LifeTimeInterval *> _intervalForTemp;
+ const QHash<IR::Temp, int> &_assignedSpillSlots;
+ QHash<IR::Temp, const LifeTimeInterval *> _intervalForTemp;
const QVector<int> &_intRegs;
const QVector<int> &_fpRegs;
QHash<BasicBlock *, QList<const LifeTimeInterval *> > _liveAtEnd;
public:
- ResolutionPhase(const QVector<LifeTimeInterval> &intervals, Function *function, RegAllocInfo *info,
- const QHash<V4IR::Temp, int> &assignedSpillSlots,
+ ResolutionPhase(const QVector<LifeTimeInterval> &intervals, IR::Function *function, RegAllocInfo *info,
+ const QHash<IR::Temp, int> &assignedSpillSlots,
const QVector<int> &intRegs, const QVector<int> &fpRegs)
: _intervals(intervals)
, _function(function)
}
virtual void visitConst(Const *) {}
- virtual void visitString(String *) {}
- virtual void visitRegExp(RegExp *) {}
+ virtual void visitString(IR::String *) {}
+ virtual void visitRegExp(IR::RegExp *) {}
virtual void visitName(Name *) {}
virtual void visitClosure(Closure *) {}
virtual void visitConvert(Convert *e) { e->expr->accept(this); }
{
}
-void RegisterAllocator::run(Function *function, const Optimizer &opt)
+void RegisterAllocator::run(IR::Function *function, const Optimizer &opt)
{
_activeSpillSlots.resize(function->tempCount);
{
Temp t;
t.init(Temp::PhysicalRegister, reg, 0);
- t.type = isFP ? V4IR::DoubleType : V4IR::SInt32Type;
+ t.type = isFP ? IR::DoubleType : IR::SInt32Type;
LifeTimeInterval i;
i.setTemp(t);
i.setReg(reg);
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
-namespace MASM {
+namespace QV4 {
+namespace JIT {
class RegAllocInfo;
class RegisterAllocator
{
- typedef V4IR::LifeTimeInterval LifeTimeInterval;
+ typedef IR::LifeTimeInterval LifeTimeInterval;
QVector<int> _normalRegisters;
QVector<int> _fpRegisters;
QVector<LifeTimeInterval> _unhandled, _active, _inactive, _handled;
- QHash<V4IR::Temp, int> _lastAssignedRegister;
- QHash<V4IR::Temp, int> _assignedSpillSlots;
+ QHash<IR::Temp, int> _lastAssignedRegister;
+ QHash<IR::Temp, int> _assignedSpillSlots;
QVector<int> _activeSpillSlots;
Q_DISABLE_COPY(RegisterAllocator)
RegisterAllocator(const QVector<int> &normalRegisters, const QVector<int> &fpRegisters);
~RegisterAllocator();
- void run(V4IR::Function *function, const V4IR::Optimizer &opt);
+ void run(IR::Function *function, const IR::Optimizer &opt);
private:
void prepareRanges();
int lastUse) const;
int nextIntersection(const LifeTimeInterval ¤t, const LifeTimeInterval &another,
const int position) const;
- int nextUse(const V4IR::Temp &t, int startPosition) const;
+ int nextUse(const IR::Temp &t, int startPosition) const;
void split(LifeTimeInterval ¤t, int beforePosition, bool skipOptionalRegisterUses =false);
void splitInactiveAtEndOfLifetimeHole(int reg, bool isFPReg, int position);
- void assignSpillSlot(const V4IR::Temp &t, int startPos, int endPos);
- void resolve(V4IR::Function *function, const V4IR::Optimizer &opt);
+ void assignSpillSlot(const IR::Temp &t, int startPos, int endPos);
+ void resolve(IR::Function *function, const IR::Optimizer &opt);
void dump() const;
};
-} // end of namespace MASM
-} // end of namespace QQmlJS
+} // end of namespace JIT
+} // end of namespace QV4
QT_END_NAMESPACE
using namespace QV4;
using namespace JIT;
-using namespace QQmlJS;
-using namespace MASM;
-
#define stringIfyx(s) #s
#define stringIfy(s) stringIfyx(s)
#define setOp(operation) \
do { call = operation; name = stringIfy(operation); } while (0)
-void Unop::generate(QQmlJS::V4IR::Temp *source, QQmlJS::V4IR::Temp *target)
+void Unop::generate(IR::Temp *source, IR::Temp *target)
{
UnaryOpName call = 0;
const char *name = 0;
switch (op) {
- case V4IR::OpNot:
+ case IR::OpNot:
generateNot(source, target);
return;
- case V4IR::OpUMinus:
+ case IR::OpUMinus:
generateUMinus(source, target);
return;
- case V4IR::OpUPlus: setOp(__qmljs_uplus); break;
- case V4IR::OpCompl:
+ case IR::OpUPlus: setOp(__qmljs_uplus); break;
+ case IR::OpCompl:
generateCompl(source, target);
return;
- case V4IR::OpIncrement: setOp(__qmljs_increment); break;
- case V4IR::OpDecrement: setOp(__qmljs_decrement); break;
+ case IR::OpIncrement: setOp(__qmljs_increment); break;
+ case IR::OpDecrement: setOp(__qmljs_decrement); break;
default:
Q_UNREACHABLE();
} // switch
}
}
-void Unop::generateUMinus(V4IR::Temp *source, V4IR::Temp *target)
+void Unop::generateUMinus(IR::Temp *source, IR::Temp *target)
{
- if (source->type == V4IR::SInt32Type) {
+ if (source->type == IR::SInt32Type) {
Assembler::RegisterID tReg = Assembler::ScratchRegister;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
tReg = (Assembler::RegisterID) target->index;
Assembler::RegisterID sReg = as->toInt32Register(source, tReg);
as->move(sReg, tReg);
as->neg32(tReg);
- if (target->kind != V4IR::Temp::PhysicalRegister)
+ if (target->kind != IR::Temp::PhysicalRegister)
as->storeInt32(tReg, target);
return;
}
as->generateFunctionCallImp(target, "__qmljs_uminus", __qmljs_uminus, Assembler::PointerToValue(source));
}
-void Unop::generateNot(V4IR::Temp *source, V4IR::Temp *target)
+void Unop::generateNot(IR::Temp *source, IR::Temp *target)
{
- if (source->type == V4IR::BoolType) {
+ if (source->type == IR::BoolType) {
Assembler::RegisterID tReg = Assembler::ScratchRegister;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
tReg = (Assembler::RegisterID) target->index;
as->xor32(Assembler::TrustedImm32(0x1), as->toInt32Register(source, tReg), tReg);
- if (target->kind != V4IR::Temp::PhysicalRegister)
+ if (target->kind != IR::Temp::PhysicalRegister)
as->storeBool(tReg, target);
return;
- } else if (source->type == V4IR::SInt32Type) {
+ } else if (source->type == IR::SInt32Type) {
Assembler::RegisterID tReg = Assembler::ScratchRegister;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
tReg = (Assembler::RegisterID) target->index;
as->compare32(Assembler::Equal,
as->toInt32Register(source, Assembler::ScratchRegister), Assembler::TrustedImm32(0),
tReg);
- if (target->kind != V4IR::Temp::PhysicalRegister)
+ if (target->kind != IR::Temp::PhysicalRegister)
as->storeBool(tReg, target);
return;
- } else if (source->type == V4IR::DoubleType) {
+ } else if (source->type == IR::DoubleType) {
// ###
}
// ## generic implementation testing for int/bool
as->generateFunctionCallImp(target, "__qmljs_not", __qmljs_not, Assembler::PointerToValue(source));
}
-void Unop::generateCompl(V4IR::Temp *source, V4IR::Temp *target)
+void Unop::generateCompl(IR::Temp *source, IR::Temp *target)
{
- if (source->type == V4IR::SInt32Type) {
+ if (source->type == IR::SInt32Type) {
Assembler::RegisterID tReg = Assembler::ScratchRegister;
- if (target->kind == V4IR::Temp::PhysicalRegister)
+ if (target->kind == IR::Temp::PhysicalRegister)
tReg = (Assembler::RegisterID) target->index;
as->xor32(Assembler::TrustedImm32(0xffffffff), as->toInt32Register(source, tReg), tReg);
- if (target->kind != V4IR::Temp::PhysicalRegister)
+ if (target->kind != IR::Temp::PhysicalRegister)
as->storeInt32(tReg, target);
return;
}
#if ENABLE(ASSEMBLER)
-namespace QQmlJS {
-namespace MASM {
-class Assembler;
-}
-}
-
namespace QV4 {
namespace JIT {
+class Assembler;
+
struct Unop {
- Unop(QQmlJS::MASM::Assembler *assembler, QQmlJS::V4IR::AluOp operation)
+ Unop(Assembler *assembler, IR::AluOp operation)
: as(assembler)
, op(operation)
{}
- void generate(QQmlJS::V4IR::Temp *source, QQmlJS::V4IR::Temp *target);
+ void generate(IR::Temp *source, IR::Temp *target);
- void generateUMinus(QQmlJS::V4IR::Temp *source, QQmlJS::V4IR::Temp *target);
- void generateNot(QQmlJS::V4IR::Temp *source, QQmlJS::V4IR::Temp *target);
- void generateCompl(QQmlJS::V4IR::Temp *source, QQmlJS::V4IR::Temp *target);
+ void generateUMinus(IR::Temp *source, IR::Temp *target);
+ void generateNot(IR::Temp *source, IR::Temp *target);
+ void generateCompl(IR::Temp *source, IR::Temp *target);
- QQmlJS::MASM::Assembler *as;
- QQmlJS::V4IR::AluOp op;
+ Assembler *as;
+ IR::AluOp op;
};
}
void Debugger::setBreakOnInstruction(Function *function, qptrdiff codeOffset, bool onoff)
{
uchar *codePtr = const_cast<uchar *>(function->codeData) + codeOffset;
- QQmlJS::Moth::Instr::instr_debug *debug = reinterpret_cast<QQmlJS::Moth::Instr::instr_debug *>(codePtr);
+ Moth::Instr::instr_debug *debug = reinterpret_cast<Moth::Instr::instr_debug *>(codePtr);
debug->breakPoint = onoff;
}
bool Debugger::hasBreakOnInstruction(Function *function, qptrdiff codeOffset)
{
uchar *codePtr = const_cast<uchar *>(function->codeData) + codeOffset;
- QQmlJS::Moth::Instr::instr_debug *debug = reinterpret_cast<QQmlJS::Moth::Instr::instr_debug *>(codePtr);
+ Moth::Instr::instr_debug *debug = reinterpret_cast<Moth::Instr::instr_debug *>(codePtr);
return debug->breakPoint;
}
}
-ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
+ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
: current(0)
, memoryManager(new QV4::MemoryManager)
, executableAllocator(new QV4::ExecutableAllocator)
#ifdef V4_ENABLE_JIT
static const bool forceMoth = !qgetenv("QV4_FORCE_INTERPRETER").isEmpty();
if (forceMoth)
- factory = new QQmlJS::Moth::ISelFactory;
+ factory = new Moth::ISelFactory;
else
- factory = new QQmlJS::MASM::ISelFactory;
+ factory = new JIT::ISelFactory;
#else // !V4_ENABLE_JIT
- factory = new QQmlJS::Moth::ISelFactory;
+ factory = new Moth::ISelFactory;
#endif // V4_ENABLE_JIT
}
iselFactory.reset(factory);
{
Q_ASSERT(!debugger);
debugger = new Debugging::Debugger(this);
- iselFactory.reset(new QQmlJS::Moth::ISelFactory);
+ iselFactory.reset(new Moth::ISelFactory);
}
void ExecutionEngine::enableProfiler()
Returned<RegExpObject> *ExecutionEngine::newRegExpObject(const QString &pattern, int flags)
{
- bool global = (flags & QQmlJS::V4IR::RegExp::RegExp_Global);
+ bool global = (flags & IR::RegExp::RegExp_Global);
bool ignoreCase = false;
bool multiline = false;
- if (flags & QQmlJS::V4IR::RegExp::RegExp_IgnoreCase)
+ if (flags & IR::RegExp::RegExp_IgnoreCase)
ignoreCase = true;
- if (flags & QQmlJS::V4IR::RegExp::RegExp_Multiline)
+ if (flags & IR::RegExp::RegExp_Multiline)
multiline = true;
Scope scope(this);
MemoryManager *memoryManager;
ExecutableAllocator *executableAllocator;
ExecutableAllocator *regExpAllocator;
- QScopedPointer<QQmlJS::EvalISelFactory> iselFactory;
+ QScopedPointer<EvalISelFactory> iselFactory;
Value *jsStackLimit;
// bookkeeping.
MultiplyWrappedQObjectMap *m_multiplyWrappedQObjects;
- ExecutionEngine(QQmlJS::EvalISelFactory *iselFactory = 0);
+ ExecutionEngine(EvalISelFactory *iselFactory = 0);
~ExecutionEngine();
void enableDebugger();
if (!fe)
return v4->currentContext()->throwSyntaxError(QLatin1String("Parse error"));
- QQmlJS::V4IR::Module module(v4->debugger != 0);
+ IR::Module module(v4->debugger != 0);
QQmlJS::RuntimeCodegen cg(v4->currentContext(), f->strictMode);
cg.generateFromFunctionExpression(QString(), function, fe, &module);
QV4::Compiler::JSUnitGenerator jsGenerator(&module);
- QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(QQmlEnginePrivate::get(v4), v4->executableAllocator, &module, &jsGenerator));
+ QScopedPointer<EvalInstructionSelection> isel(v4->iselFactory->create(QQmlEnginePrivate::get(v4), v4->executableAllocator, &module, &jsGenerator));
QV4::CompiledData::CompilationUnit *compilationUnit = isel->compile();
QV4::Function *vmf = compilationUnit->linkToEngine(v4);
MemoryManager::GCBlocker gcBlocker(v4->memoryManager);
- V4IR::Module module(v4->debugger != 0);
+ IR::Module module(v4->debugger != 0);
QQmlJS::Engine ee, *engine = ⅇ
Lexer lexer(engine);
using namespace QQmlJS;
using namespace QQmlJS::AST;
- QQmlJS::V4IR::Module module(engine->debugger != 0);
+ IR::Module module(engine->debugger != 0);
QQmlJS::Engine ee;
QQmlJS::Lexer lexer(&ee);
}
Compiler::JSUnitGenerator jsGenerator(&module);
- QScopedPointer<QQmlJS::EvalInstructionSelection> isel(engine->iselFactory->create(QQmlEnginePrivate::get(engine), engine->executableAllocator, &module, &jsGenerator));
+ QScopedPointer<EvalInstructionSelection> isel(engine->iselFactory->create(QQmlEnginePrivate::get(engine), engine->executableAllocator, &module, &jsGenerator));
isel->setUseFastLookups(false);
return isel->compile();
}
# define TRACE(n, str, ...)
#endif // DO_TRACE_INSTR
-using namespace QQmlJS;
-using namespace QQmlJS::Moth;
+using namespace QV4;
+using namespace QV4::Moth;
#define MOTH_BEGIN_INSTR_COMMON(I) { \
const InstrMeta<(int)Instr::I>::DataType &instr = InstrMeta<(int)Instr::I>::data(*genericInstr); \
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
+namespace QV4 {
namespace Moth {
class VME
};
} // namespace Moth
-} // namespace QQmlJS
+} // namespace QV4
QT_END_NAMESPACE
this->unit = unit;
this->unitRoot = root;
this->output = out;
- this->jsModule.reset(new QQmlJS::V4IR::Module(enginePrivate->v4engine()->debugger));
+ this->jsModule.reset(new IR::Module(enginePrivate->v4engine()->debugger));
this->jsModule->isQmlModule = true;
// Compile types
if (!jsModule->functions.isEmpty()) {
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Compiler::JSUnitGenerator jsUnitGenerator(jsModule.data());
- QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(enginePrivate, v4->executableAllocator, jsModule.data(), &jsUnitGenerator));
+ QScopedPointer<EvalInstructionSelection> isel(v4->iselFactory->create(enginePrivate, v4->executableAllocator, jsModule.data(), &jsUnitGenerator));
isel->setUseFastLookups(false);
QV4::CompiledData::CompilationUnit *jsUnit = isel->compile(/*generated unit data*/true);
output->compilationUnit = jsUnit;
// Must do id property first. This is to ensure that the id given to any
// id reference created matches the order in which the objects are
// instantiated
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+ for (QQmlScript::Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
if (prop->name() == id_string) {
COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
break;
}
// Merge
- Property *defaultProperty = 0;
- Property *skipProperty = 0;
+ QQmlScript::Property *defaultProperty = 0;
+ QQmlScript::Property *skipProperty = 0;
if (obj->defaultProperty) {
defaultProperty = obj->defaultProperty;
- Property *explicitProperty = 0;
+ QQmlScript::Property *explicitProperty = 0;
QString defaultPropertyName = obj->metatype->defaultPropertyName();
if (!defaultPropertyName.isEmpty()) {
QHashedStringRef r(*s);
if (obj->propertiesHashField.test(r.hash())) {
- for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) {
+ for (QQmlScript::Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) {
if (ep->name() == r) {
explicitProperty = ep;
break;
skipProperty = explicitProperty; // We merge the values into defaultProperty
// Find the correct insertion point
- Value *insertPos = 0;
+ QQmlScript::Value *insertPos = 0;
- for (Value *v = defaultProperty->values.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = defaultProperty->values.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
if (!(v->location.start < explicitProperty->values.first()->location.start))
break;
insertPos = v;
cp = output->types.at(obj->type).type->customParser();
// Build all explicit properties specified
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+ for (QQmlScript::Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
if (prop == skipProperty)
continue;
// Build the default property
if (defaultProperty) {
- Property *prop = defaultProperty;
+ QQmlScript::Property *prop = defaultProperty;
bool canDefer = false;
if (isCustomParser) {
void QQmlCompiler::genObjectBody(QQmlScript::Object *obj)
{
- for (Property *prop = obj->scriptStringProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->scriptStringProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
Q_ASSERT(prop->scriptStringScope != -1);
const QString &script = prop->values.first()->value.asScript();
Instruction::StoreScriptString ss;
}
bool seenDefer = false;
- for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->valueProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
if (prop->isDeferred) {
seenDefer = true;
continue;
dinit.listStackSize = compileState->listDepth.maxDepth();
output->addInstruction(dinit);
- for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->valueProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
if (!prop->isDeferred)
continue;
genValueProperty(prop, obj);
output->instruction(deferIdx)->defer.deferCount = output->nextInstructionIndex() - nextInstructionIndex;
}
- for (Property *prop = obj->signalProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->signalProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
QQmlScript::Value *v = prop->values.first();
- if (v->type == Value::SignalObject) {
+ if (v->type == QQmlScript::Value::SignalObject) {
genObject(v->object);
assign.signal = output->indexForString(prop->name().toString());
output->addInstruction(assign);
- } else if (v->type == Value::SignalExpression) {
+ } else if (v->type == QQmlScript::Value::SignalExpression) {
Instruction::StoreSignal store;
store.runtimeFunctionIndex = compileState->jsCompileData[v->signalData.signalScopeObject].runtimeFunctionIndices.at(v->signalData.functionIndex);
}
- for (Property *prop = obj->attachedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->attachedProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
Instruction::FetchAttached fetch;
fetch.id = prop->index;
fetch.line = prop->location.start.line;
output->addInstruction(pop);
}
- for (Property *prop = obj->groupedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->groupedProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
Instruction::FetchObject fetch;
fetch.property = prop->index;
fetch.line = prop->location.start.line;
output->addInstruction(pop);
}
- for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->valueTypeProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
if (!prop->isAlias)
genValueTypeProperty(obj, prop);
}
- for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->valueProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
if (prop->isDeferred)
continue;
if (prop->isAlias)
genValueProperty(prop, obj);
}
- for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
+ for (QQmlScript::Property *prop = obj->valueTypeProperties.first(); prop; prop = QQmlScript::Object::PropertyList::next(prop)) {
if (prop->isAlias)
genValueTypeProperty(obj, prop);
}
}
-void QQmlCompiler::genValueTypeProperty(QQmlScript::Object *obj,QQmlScript::Property *prop)
+void QQmlCompiler::genValueTypeProperty(QQmlScript::Object *obj, QQmlScript::Property *prop)
{
Instruction::FetchValueType fetch;
fetch.property = prop->index;
if (obj->type == -1 || output->types.at(obj->type).component) {
// We only have to do this if this is a composite type. If it is a builtin
// type it can't possibly already have bindings that need to be cleared.
- for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) {
+ for (QQmlScript::Property *vprop = prop->value->valueProperties.first(); vprop; vprop = QQmlScript::Object::PropertyList::next(vprop)) {
if (!vprop->values.isEmpty()) {
Q_ASSERT(vprop->index >= 0 && vprop->index < 32);
fetch.bindingSkipList |= (1 << vprop->index);
output->addInstruction(fetch);
- for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) {
+ for (QQmlScript::Property *vprop = prop->value->valueProperties.first(); vprop; vprop = QQmlScript::Object::PropertyList::next(vprop)) {
genPropertyAssignment(vprop, prop->value, prop);
}
compileState->objectDepth.push();
// Find, check and set the "id" property (if any)
- Property *idProp = 0;
+ QQmlScript::Property *idProp = 0;
if (obj->properties.isMany() ||
(obj->properties.isOne() && obj->properties.first()->name() != id_string))
COMPILE_EXCEPTION(obj->properties.first(), tr("Component elements may not contain properties other than id"));
Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
// sub-context
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+ for (QQmlScript::Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
if (isSignalPropertyName(prop->name())) {
COMPILE_CHECK(buildSignal(prop, obj, ctxt));
} else {
if (prop->values.first()->object) {
COMPILE_CHECK(buildObject(prop->values.first()->object, ctxt));
- prop->values.first()->type = Value::SignalObject;
+ prop->values.first()->type = QQmlScript::Value::SignalObject;
} else {
- prop->values.first()->type = Value::SignalExpression;
+ prop->values.first()->type = QQmlScript::Value::SignalExpression;
if (!prop->values.first()->value.isScript())
COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)"));
if (!nsProp->value)
COMPILE_EXCEPTION(nsProp, tr("Invalid use of namespace"));
- for (Property *prop = nsProp->value->properties.first(); prop; prop = nsProp->value->properties.next(prop)) {
+ for (QQmlScript::Property *prop = nsProp->value->properties.first(); prop; prop = nsProp->value->properties.next(prop)) {
if (!isAttachedPropertyName(prop->name()))
COMPILE_EXCEPTION(prop, tr("Expected type name"));
fetch.type = listType;
output->addInstruction(fetch);
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->values.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
- if (v->type == Value::CreatedObject) {
+ if (v->type == QQmlScript::Value::CreatedObject) {
genObject(v->object);
if (listTypeIsInterface) {
output->addInstruction(store);
}
- } else if (v->type == Value::PropertyBinding) {
+ } else if (v->type == QQmlScript::Value::PropertyBinding) {
genBindingAssignment(v, prop, obj);
QQmlScript::Object *obj,
QQmlScript::Property *valueTypeProperty)
{
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->values.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
- Q_ASSERT(v->type == Value::CreatedObject ||
- v->type == Value::PropertyBinding ||
- v->type == Value::Literal);
+ Q_ASSERT(v->type == QQmlScript::Value::CreatedObject ||
+ v->type == QQmlScript::Value::PropertyBinding ||
+ v->type == QQmlScript::Value::Literal);
- if (v->type == Value::CreatedObject) {
+ if (v->type == QQmlScript::Value::CreatedObject) {
genObject(v->object);
output->addInstruction(store);
}
- } else if (v->type == Value::PropertyBinding) {
+ } else if (v->type == QQmlScript::Value::PropertyBinding) {
genBindingAssignment(v, prop, obj, valueTypeProperty);
- } else if (v->type == Value::Literal) {
+ } else if (v->type == QQmlScript::Value::Literal) {
genLiteralAssignment(prop, v);
}
- for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->onValues.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
- Q_ASSERT(v->type == Value::ValueSource ||
- v->type == Value::ValueInterceptor);
+ Q_ASSERT(v->type == QQmlScript::Value::ValueSource ||
+ v->type == QQmlScript::Value::ValueInterceptor);
- if (v->type == Value::ValueSource) {
+ if (v->type == QQmlScript::Value::ValueSource) {
genObject(v->object, valueTypeProperty?true:false);
Instruction::StoreValueSource store;
store.castValue = valueType->propertyValueSourceCast();
output->addInstruction(store);
- } else if (v->type == Value::ValueInterceptor) {
+ } else if (v->type == QQmlScript::Value::ValueInterceptor) {
genObject(v->object, valueTypeProperty?true:false);
Instruction::StoreValueInterceptor store;
if (compileState->ids.value(val))
COMPILE_EXCEPTION(prop, tr("id is not unique"));
- prop->values.first()->type = Value::Id;
+ prop->values.first()->type = QQmlScript::Value::Id;
obj->id = val;
addId(val, obj);
if (prop->type >= 0 && valueType) {
if (!prop->values.isEmpty()) {
// Only error if we are assigning values, and not e.g. a property interceptor
- for (Property *dotProp = prop->value->properties.first(); dotProp; dotProp = prop->value->properties.next(dotProp)) {
+ for (QQmlScript::Property *dotProp = prop->value->properties.first(); dotProp; dotProp = prop->value->properties.next(dotProp)) {
if (!dotProp->values.isEmpty()) {
if (prop->values.first()->location < prop->value->location) {
COMPILE_EXCEPTION(prop->value, tr( "Property has already been assigned a value"));
}
if (prop->isAlias) {
- for (Property *vtProp = prop->value->properties.first(); vtProp; vtProp = prop->value->properties.next(vtProp)) {
+ for (QQmlScript::Property *vtProp = prop->value->properties.first(); vtProp; vtProp = prop->value->properties.next(vtProp)) {
vtProp->isAlias = true;
}
}
// assignment to the value type as a whole. Therefore we need to look
// for (and build) assignments to the entire value type before looking
// for any onValue assignments.
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->values.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
if (v->object) {
COMPILE_EXCEPTION(v->object, tr("Objects cannot be assigned to value types"));
}
COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt));
}
- for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->onValues.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
Q_ASSERT(v->object);
COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt));
}
COMPILE_EXCEPTION(obj, tr("Invalid property use"));
obj->metatype = enginePrivate->cache(type);
- for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
+ for (QQmlScript::Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) {
QQmlPropertyData *d = property(obj, prop->name());
if (d == 0)
COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, value, &isEnumAssignment));
if (isEnumAssignment) {
- value->type = Value::Literal;
+ value->type = QQmlScript::Value::Literal;
} else {
JSBindingReference *reference = pool->New<JSBindingReference>();
reference->expression = value->value;
reference->bindingContext = ctxt;
reference->bindingContext.owner++;
addBindingReference(reference);
- value->type = Value::PropertyBinding;
+ value->type = QQmlScript::Value::PropertyBinding;
}
} else {
COMPILE_CHECK(testLiteralAssignment(prop, value));
- value->type = Value::Literal;
+ value->type = QQmlScript::Value::Literal;
}
}
- for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->onValues.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
Q_ASSERT(v->object);
COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
bool listTypeIsInterface = QQmlMetaType::isInterface(listType);
bool assignedBinding = false;
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->values.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
if (v->object) {
- v->type = Value::CreatedObject;
+ v->type = QQmlScript::Value::CreatedObject;
COMPILE_CHECK(buildObject(v->object, ctxt));
// We check object coercian here. We check interface assignment
if (prop->values.isMany())
COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign multiple values to a singular property") );
- for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->values.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
if (v->object) {
COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
}
}
- for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) {
+ for (QQmlScript::Value *v = prop->onValues.first(); v; v = QQmlScript::Property::ValueList::next(v)) {
Q_ASSERT(v->object);
COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt));
}
// Assigning an object to an interface ptr property
COMPILE_CHECK(buildObject(v->object, ctxt));
- v->type = Value::CreatedObject;
+ v->type = QQmlScript::Value::CreatedObject;
} else if (prop->type == QMetaType::QVariant) {
// Assigning an object to a QVariant
COMPILE_CHECK(buildObject(v->object, ctxt));
- v->type = Value::CreatedObject;
+ v->type = QQmlScript::Value::CreatedObject;
} else {
// Normally buildObject() will set this up, but we need the static
// meta object earlier to test for assignability. It doesn't matter
// Simple assignment
COMPILE_CHECK(buildObject(v->object, ctxt));
- v->type = Value::CreatedObject;
+ v->type = QQmlScript::Value::CreatedObject;
} else if (propertyMetaObject && propertyMetaObject->metaObject() == &QQmlComponent::staticMetaObject) {
// Automatic "Component" insertion
QQmlScript::Object *root = v->object;
- QQmlScript::Object *component = pool->New<Object>();
+ QQmlScript::Object *component = pool->New<QQmlScript::Object>();
component->type = componentTypeRef();
component->metatype = enginePrivate->cache(&QQmlComponent::staticMetaObject);
component->location = root->location;
- QQmlScript::Value *componentValue = pool->New<Value>();
+ QQmlScript::Value *componentValue = pool->New<QQmlScript::Value>();
componentValue->object = root;
component->getDefaultProperty()->addValue(componentValue);
v->object = component;
if (isPropertyInterceptor && baseObj->synthdata.isEmpty())
buildDynamicMeta(baseObj, ForceCreation);
- v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ v->type = isPropertyValue ? QQmlScript::Value::ValueSource : QQmlScript::Value::ValueInterceptor;
} else {
COMPILE_EXCEPTION(v, tr("\"%1\" cannot operate on \"%2\"").arg(elementName(v->object)).arg(prop->name().toString()));
}
bool isEnumAssignment = false;
COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, v, &isEnumAssignment));
if (isEnumAssignment) {
- v->type = Value::Literal;
+ v->type = QQmlScript::Value::Literal;
return true;
}
}
COMPILE_CHECK(testLiteralAssignment(prop, v));
- v->type = Value::Literal;
+ v->type = QQmlScript::Value::Literal;
}
return true;
bool ok;
int enumval = evaluateEnum(typeName.toString(), enumValue.toUtf8(), &ok);
if (ok) {
- v->type = Value::Literal;
+ v->type = QQmlScript::Value::Literal;
v->value = QQmlScript::Variant((double)enumval);
*isAssignment = true;
}
if (!ok)
return true;
- v->type = Value::Literal;
+ v->type = QQmlScript::Value::Literal;
v->value = QQmlScript::Variant((double)value);
*isAssignment = true;
{
JSBindingReference *reference = pool->New<JSBindingReference>();
reference->expression = value;
- reference->property = pool->New<Property>();
+ reference->property = pool->New<QQmlScript::Property>();
reference->property->setName(name);
reference->value = 0;
reference->bindingContext = QQmlCompilerTypes::BindingContext(customParser->object);
QHashField methodNames;
// Check properties
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) {
const QQmlScript::Object::DynamicProperty &prop = *p;
if (prop.isDefaultProperty) {
}
if (propNames.testAndSet(prop.name.hash())) {
- for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p;
+ for (QQmlScript::Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p;
p2 = obj->dynamicProperties.next(p2)) {
if (p2->name == prop.name) {
COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line,
}
}
- for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
+ for (QQmlScript::Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
const QQmlScript::Object::DynamicSignal &currSig = *s;
if (methodNames.testAndSet(currSig.name.hash())) {
- for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2 != s;
+ for (QQmlScript::Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2 != s;
s2 = obj->dynamicSignals.next(s2)) {
if (s2->name == currSig.name)
COMPILE_EXCEPTION(&currSig, tr("Duplicate signal name"));
COMPILE_EXCEPTION(&currSig, tr("Illegal signal name"));
}
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ for (QQmlScript::Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
const QQmlScript::Object::DynamicSlot &currSlot = *s;
if (methodNames.testAndSet(currSlot.name.hash())) {
- for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2;
+ for (QQmlScript::Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2;
s2 = obj->dynamicSignals.next(s2)) {
if (s2->name == currSlot.name)
COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name"));
}
- for (Object::DynamicSlot *s2 = obj->dynamicSlots.first(); s2 != s;
+ for (QQmlScript::Object::DynamicSlot *s2 = obj->dynamicSlots.first(); s2 != s;
s2 = obj->dynamicSlots.next(s2)) {
if (s2->name == currSlot.name)
COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name"));
bool QQmlCompiler::mergeDynamicMetaProperties(QQmlScript::Object *obj)
{
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
p = obj->dynamicProperties.next(p)) {
- if (!p->defaultValue || p->type == Object::DynamicProperty::Alias)
+ if (!p->defaultValue || p->type == QQmlScript::Object::DynamicProperty::Alias)
continue;
- Property *property = 0;
+ QQmlScript::Property *property = 0;
if (p->isDefaultProperty) {
property = obj->getDefaultProperty();
} else {
Q_ASSERT(obj->synthCache == 0);
struct TypeData {
- Object::DynamicProperty::Type dtype;
+ QQmlScript::Object::DynamicProperty::Type dtype;
int metaType;
} builtinTypes[] = {
- { Object::DynamicProperty::Var, qMetaTypeId<QJSValue>() },
- { Object::DynamicProperty::Variant, QMetaType::QVariant },
- { Object::DynamicProperty::Int, QMetaType::Int },
- { Object::DynamicProperty::Bool, QMetaType::Bool },
- { Object::DynamicProperty::Real, QMetaType::Double },
- { Object::DynamicProperty::String, QMetaType::QString },
- { Object::DynamicProperty::Url, QMetaType::QUrl },
- { Object::DynamicProperty::Color, QMetaType::QColor },
- { Object::DynamicProperty::Font, QMetaType::QFont },
- { Object::DynamicProperty::Time, QMetaType::QTime },
- { Object::DynamicProperty::Date, QMetaType::QDate },
- { Object::DynamicProperty::DateTime, QMetaType::QDateTime },
- { Object::DynamicProperty::Rect, QMetaType::QRectF },
- { Object::DynamicProperty::Point, QMetaType::QPointF },
- { Object::DynamicProperty::Size, QMetaType::QSizeF },
- { Object::DynamicProperty::Vector2D, QMetaType::QVector2D },
- { Object::DynamicProperty::Vector3D, QMetaType::QVector3D },
- { Object::DynamicProperty::Vector4D, QMetaType::QVector4D },
- { Object::DynamicProperty::Matrix4x4, QMetaType::QMatrix4x4 },
- { Object::DynamicProperty::Quaternion, QMetaType::QQuaternion }
+ { QQmlScript::Object::DynamicProperty::Var, qMetaTypeId<QJSValue>() },
+ { QQmlScript::Object::DynamicProperty::Variant, QMetaType::QVariant },
+ { QQmlScript::Object::DynamicProperty::Int, QMetaType::Int },
+ { QQmlScript::Object::DynamicProperty::Bool, QMetaType::Bool },
+ { QQmlScript::Object::DynamicProperty::Real, QMetaType::Double },
+ { QQmlScript::Object::DynamicProperty::String, QMetaType::QString },
+ { QQmlScript::Object::DynamicProperty::Url, QMetaType::QUrl },
+ { QQmlScript::Object::DynamicProperty::Color, QMetaType::QColor },
+ { QQmlScript::Object::DynamicProperty::Font, QMetaType::QFont },
+ { QQmlScript::Object::DynamicProperty::Time, QMetaType::QTime },
+ { QQmlScript::Object::DynamicProperty::Date, QMetaType::QDate },
+ { QQmlScript::Object::DynamicProperty::DateTime, QMetaType::QDateTime },
+ { QQmlScript::Object::DynamicProperty::Rect, QMetaType::QRectF },
+ { QQmlScript::Object::DynamicProperty::Point, QMetaType::QPointF },
+ { QQmlScript::Object::DynamicProperty::Size, QMetaType::QSizeF },
+ { QQmlScript::Object::DynamicProperty::Vector2D, QMetaType::QVector2D },
+ { QQmlScript::Object::DynamicProperty::Vector3D, QMetaType::QVector3D },
+ { QQmlScript::Object::DynamicProperty::Vector4D, QMetaType::QVector4D },
+ { QQmlScript::Object::DynamicProperty::Matrix4x4, QMetaType::QMatrix4x4 },
+ { QQmlScript::Object::DynamicProperty::Quaternion, QMetaType::QQuaternion }
};
static const int builtinTypeCount = sizeof(builtinTypes) / sizeof(TypeData);
int aliasCount = 0;
int varPropCount = 0;
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
p = obj->dynamicProperties.next(p)) {
- if (p->type == Object::DynamicProperty::Alias)
+ if (p->type == QQmlScript::Object::DynamicProperty::Alias)
aliasCount++;
- else if (p->type == Object::DynamicProperty::Var)
+ else if (p->type == QQmlScript::Object::DynamicProperty::Var)
varPropCount++;
if (p->name.isLatin1()) {
COMPILE_EXCEPTION(p, tr("Cannot override FINAL property"));
}
- for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
+ for (QQmlScript::Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
if (s->name.isLatin1()) {
s->nameIndex = cStringNameCount;
cStringNameCount += s->name.length();
}
}
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ for (QQmlScript::Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
if (s->name.isLatin1()) {
s->nameIndex = cStringNameCount;
cStringNameCount += s->name.length();
cache->_dynamicStringData.resize(cStringNameCount);
cStringData = cache->_dynamicStringData.data();
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
p = obj->dynamicProperties.next(p)) {
if (p->nameIndex == -1) continue;
*myData++ = 'g'; *myData++ = 'e'; *myData++ = 'd';
}
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ for (QQmlScript::Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
if (s->nameIndex == -1) continue;
*myData++ = s->name.at(ii).unicode();
}
- for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s;
+ for (QQmlScript::Object::DynamicSignal *s = obj->dynamicSignals.first(); s;
s = obj->dynamicSignals.next(s)) {
if (s->nameIndex == -1) continue;
if (ii == NSS_Var && varPropCount == 0) continue;
else if (ii == NSS_Alias && aliasCount == 0) continue;
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
p = obj->dynamicProperties.next(p)) {
- if ((ii == NSS_Normal && (p->type == Object::DynamicProperty::Alias ||
- p->type == Object::DynamicProperty::Var)) ||
- ((ii == NSS_Var) && (p->type != Object::DynamicProperty::Var)) ||
- ((ii == NSS_Alias) && (p->type != Object::DynamicProperty::Alias)))
+ if ((ii == NSS_Normal && (p->type == QQmlScript::Object::DynamicProperty::Alias ||
+ p->type == QQmlScript::Object::DynamicProperty::Var)) ||
+ ((ii == NSS_Var) && (p->type != QQmlScript::Object::DynamicProperty::Var)) ||
+ ((ii == NSS_Alias) && (p->type != QQmlScript::Object::DynamicProperty::Alias)))
continue;
quint32 flags = QQmlPropertyData::IsSignal | QQmlPropertyData::IsFunction |
}
// Dynamic signals
- for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
+ for (QQmlScript::Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) {
int paramCount = s->parameterNames.count();
QList<QByteArray> names;
names.append(s->parameterNames.at(i).toString().toUtf8());
} else {
// lazily resolved type
- Q_ASSERT(s->parameterTypes.at(i) == Object::DynamicProperty::Custom);
+ Q_ASSERT(s->parameterTypes.at(i) == QQmlScript::Object::DynamicProperty::Custom);
QQmlType *qmltype = 0;
if (!unit->imports().resolveType(s->parameterTypeNames.at(i).toString(), &qmltype, 0, 0, 0))
COMPILE_EXCEPTION(s, tr("Invalid signal parameter type: %1").arg(s->parameterTypeNames.at(i).toString()));
// Dynamic slots
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ for (QQmlScript::Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
int paramCount = s->parameterNames.count();
quint32 flags = QQmlPropertyData::IsFunction | QQmlPropertyData::IsVMEFunction;
// Dynamic properties (except var and aliases)
int effectiveSignalIndex = cache->signalHandlerIndexCacheStart;
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
p = obj->dynamicProperties.next(p)) {
- if (p->type == Object::DynamicProperty::Alias ||
- p->type == Object::DynamicProperty::Var)
+ if (p->type == QQmlScript::Object::DynamicProperty::Alias ||
+ p->type == QQmlScript::Object::DynamicProperty::Var)
continue;
int propertyType = 0;
propertyType = builtinTypes[p->type].metaType;
vmePropertyType = propertyType;
- if (p->type == Object::DynamicProperty::Variant)
+ if (p->type == QQmlScript::Object::DynamicProperty::Variant)
propertyFlags |= QQmlPropertyData::IsQVariant;
} else {
- Q_ASSERT(p->type == Object::DynamicProperty::CustomList ||
- p->type == Object::DynamicProperty::Custom);
+ Q_ASSERT(p->type == QQmlScript::Object::DynamicProperty::CustomList ||
+ p->type == QQmlScript::Object::DynamicProperty::Custom);
QQmlType *qmltype = 0;
if (!unit->imports().resolveType(p->customType.toString(), &qmltype, 0, 0, 0))
QQmlCompiledData *data = tdata->compiledData();
- if (p->type == Object::DynamicProperty::Custom) {
+ if (p->type == QQmlScript::Object::DynamicProperty::Custom) {
propertyType = data->metaTypeId;
vmePropertyType = QMetaType::QObjectStar;
} else {
tdata->release();
} else {
- if (p->type == Object::DynamicProperty::Custom) {
+ if (p->type == QQmlScript::Object::DynamicProperty::Custom) {
propertyType = qmltype->typeId();
vmePropertyType = QMetaType::QObjectStar;
} else {
}
}
- if (p->type == Object::DynamicProperty::Custom)
+ if (p->type == QQmlScript::Object::DynamicProperty::Custom)
propertyFlags |= QQmlPropertyData::IsQObjectDerived;
else
propertyFlags |= QQmlPropertyData::IsQList;
}
- if (!p->isReadOnly && p->type != Object::DynamicProperty::CustomList)
+ if (!p->isReadOnly && p->type != QQmlScript::Object::DynamicProperty::CustomList)
propertyFlags |= QQmlPropertyData::IsWritable;
if (p->nameIndex != -1) {
}
// Now do var properties
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p && varPropCount;
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p && varPropCount;
p = obj->dynamicProperties.next(p)) {
- if (p->type != Object::DynamicProperty::Var)
+ if (p->type != QQmlScript::Object::DynamicProperty::Var)
continue;
quint32 propertyFlags = QQmlPropertyData::IsVarProperty;
((QQmlVMEMetaData *)dynamicData.data())->aliasCount = aliasCount;
// Dynamic slot data - comes after the property data
- for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
+ for (QQmlScript::Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) {
VMD::MethodData methodData = { /*runtimeFunctionIndex*/ 0, // To be filled in later
s->parameterNames.count(),
s->location.start.line };
int effectivePropertyIndex = cache->propertyIndexCacheStart + cache->propertyIndexCache.count();
int effectiveAliasIndex = 0;
- for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
+ for (QQmlScript::Object::DynamicProperty *p = obj->dynamicProperties.first(); p;
p = obj->dynamicProperties.next(p)) {
- if (p->type != Object::DynamicProperty::Alias)
+ if (p->type != QQmlScript::Object::DynamicProperty::Alias)
continue;
if (!p->defaultValue)
reference->value = value;
reference->bindingContext = ctxt;
addBindingReference(reference);
- value->type = Value::PropertyBinding;
+ value->type = QQmlScript::Value::PropertyBinding;
return true;
}
reference->text = text;
reference->n = n;
v->bindingReference = reference;
- v->type = Value::PropertyBinding;
+ v->type = QQmlScript::Value::PropertyBinding;
return true;
}
reference->comment = comment;
reference->n = n;
v->bindingReference = reference;
- v->type = Value::PropertyBinding;
+ v->type = QQmlScript::Value::PropertyBinding;
return true;
}
QVector<QQmlContextData::ObjectIdMapping> cache(compileState->ids.count());
int i = 0;
- for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o), ++i)
+ for (QQmlScript::Object *o = compileState->ids.first(); o; o = compileState->ids.next(o), ++i)
cache[i] = QQmlContextData::ObjectIdMapping(o->id, o->idIndex);
output->contextCaches.append(cache);
if (componentStats)
componentStats->componentStat.ids = compileState->ids.count();
- for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject;
+ for (QQmlScript::Object *aliasObject = compileState->aliasingObjects.first(); aliasObject;
aliasObject = compileState->aliasingObjects.next(aliasObject))
COMPILE_CHECK(buildDynamicMetaAliases(aliasObject));
JSCodeGen::ObjectIdMapping idMapping;
if (compileState->ids.count() > 0) {
idMapping.reserve(compileState->ids.count());
- for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o)) {
+ for (QQmlScript::Object *o = compileState->ids.first(); o; o = compileState->ids.next(o)) {
JSCodeGen::IdMapping m;
m.name = o->id;
m.idIndex = o->idIndex;
int cachedComponentTypeRef;
int cachedTranslationContextIndex;
- QScopedPointer<QQmlJS::V4IR::Module> jsModule;
+ QScopedPointer<IR::Module> jsModule;
// Compiler component statistics. Only collected if QML_COMPILER_STATS=1
struct ComponentStat
rootNode.d->name = root->typeReference->name;
rootNode.d->location = root->location.start;
- for (Property *p = root->properties.first(); p; p = root->properties.next(p)) {
+ for (QQmlScript::Property *p = root->properties.first(); p; p = root->properties.next(p)) {
rootNode.d->properties << fromProperty(p);
}
return compiler->bindingIdentifier(binding, this);
}
-AST::Node *QQmlCustomParser::astForBinding(int scriptIndex) const
+QQmlJS::AST::Node *QQmlCustomParser::astForBinding(int scriptIndex) const
{
return compiler->astForBinding(scriptIndex);
}
extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed; // from qhash.cpp
QT_END_NAMESPACE
-using namespace QT_PREPEND_NAMESPACE(QQmlJS::V4IR);
+using namespace QT_PREPEND_NAMESPACE(QV4::IR);
void tst_v4misc::initTestCase()
{
switch (mode) {
case use_masm:
case use_moth: {
- QQmlJS::EvalISelFactory* iSelFactory = 0;
+ QV4::EvalISelFactory* iSelFactory = 0;
if (mode == use_moth) {
- iSelFactory = new QQmlJS::Moth::ISelFactory;
+ iSelFactory = new QV4::Moth::ISelFactory;
#ifdef V4_ENABLE_JIT
} else {
- iSelFactory = new QQmlJS::MASM::ISelFactory;
+ iSelFactory = new QV4::JIT::ISelFactory;
#endif // V4_ENABLE_JIT
}