aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmljs
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-06-22 09:44:55 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-06-22 08:07:21 +0000
commit40e8109ceff8519920245a01d82357dc57639f46 (patch)
treef9ea38dba859ed4cc736fbeb4522cfe423d8ec5e /tools/qmljs
parent135b8232923e77f9b3d0ff2f928423f3ee00cdb8 (diff)
Don't use the ISel's anymore
Move the code that generates the CompilationUnit over to Codegen, and don't use the ISel's at all anymore when compiling JS/QML. Change-Id: Iba89082c386c3d3fd58ac25a4651c5d39178cc5c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'tools/qmljs')
-rw-r--r--tools/qmljs/qmljs.cpp145
1 files changed, 49 insertions, 96 deletions
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index 182547490d..0fd897225c 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -32,10 +32,6 @@
#include "private/qv4errorobject_p.h"
#include "private/qv4globalobject_p.h"
#include "private/qv4codegen_p.h"
-#if QT_CONFIG(qml_interpreter)
-#include "private/qv4isel_moth_p.h"
-#include "private/qv4vme_moth_p.h"
-#endif
#include "private/qv4objectproto_p.h"
#include "private/qv4isel_p.h"
#include "private/qv4mm_p.h"
@@ -44,12 +40,6 @@
#include "private/qv4string_p.h"
#include "private/qqmlbuiltinfunctions_p.h"
-#ifdef V4_ENABLE_JIT
-# include "private/qv4isel_masm_p.h"
-#else
-QT_REQUIRE_CONFIG(qml_interpreter);
-#endif // V4_ENABLE_JIT
-
#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
@@ -87,32 +77,10 @@ int main(int argc, char *argv[])
QStringList args = app.arguments();
args.removeFirst();
- enum {
- use_masm,
- use_moth
- } mode;
-#ifdef V4_ENABLE_JIT
- mode = use_masm;
-#else
- mode = use_moth;
-#endif
-
bool runAsQml = false;
bool cache = false;
if (!args.isEmpty()) {
- if (args.constFirst() == QLatin1String("--jit")) {
- mode = use_masm;
- args.removeFirst();
- }
-
-#if QT_CONFIG(qml_interpreter)
- if (args.constFirst() == QLatin1String("--interpret")) {
- mode = use_moth;
- args.removeFirst();
- }
-#endif
-
if (args.constFirst() == QLatin1String("--qml")) {
runAsQml = true;
args.removeFirst();
@@ -129,79 +97,64 @@ int main(int argc, char *argv[])
}
}
- switch (mode) {
- case use_masm:
- case use_moth: {
- QV4::EvalISelFactory* iSelFactory = 0;
- if (mode == use_moth) {
-#if QT_CONFIG(qml_interpreter)
- iSelFactory = new QV4::Moth::ISelFactory;
-#endif
-#ifdef V4_ENABLE_JIT
- } else {
- iSelFactory = new QV4::JIT::ISelFactory<>;
-#endif // V4_ENABLE_JIT
- }
-
- QV4::ExecutionEngine vm(iSelFactory);
+ QV4::ExecutionEngine vm;
- QV4::Scope scope(&vm);
- QV4::ScopedContext ctx(scope, vm.rootContext());
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
- QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension);
+ QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension);
- for (const QString &fn : qAsConst(args)) {
- QFile file(fn);
- if (file.open(QFile::ReadOnly)) {
- QScopedPointer<QV4::Script> script;
- if (cache && QFile::exists(fn + QLatin1Char('c'))) {
- QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = iSelFactory->createUnitForLoading();
- QString error;
- if (unit->loadFromDisk(QUrl::fromLocalFile(fn), QFileInfo(fn).lastModified(), iSelFactory, &error)) {
- script.reset(new QV4::Script(&vm, nullptr, unit));
- } else {
- std::cout << "Error loading" << qPrintable(fn) << "from disk cache:" << qPrintable(error) << std::endl;
- }
+ for (const QString &fn : qAsConst(args)) {
+ QFile file(fn);
+ if (file.open(QFile::ReadOnly)) {
+ QScopedPointer<QV4::Script> script;
+ if (cache && QFile::exists(fn + QLatin1Char('c'))) {
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = QQmlJS::Codegen::createUnitForLoading();
+ QString error;
+ if (unit->loadFromDisk(QUrl::fromLocalFile(fn), QFileInfo(fn).lastModified(), &error)) {
+ script.reset(new QV4::Script(&vm, nullptr, unit));
+ } else {
+ std::cout << "Error loading" << qPrintable(fn) << "from disk cache:" << qPrintable(error) << std::endl;
}
- if (!script) {
- const QString code = QString::fromUtf8(file.readAll());
- file.close();
+ }
+ if (!script) {
+ const QString code = QString::fromUtf8(file.readAll());
+ file.close();
- script.reset(new QV4::Script(ctx, code, fn));
- script->parseAsBinding = runAsQml;
- script->parse();
- }
- QV4::ScopedValue result(scope);
- if (!scope.engine->hasException) {
- const auto unit = script->compilationUnit;
- if (cache && unit && !(unit->data->flags & QV4::CompiledData::Unit::StaticData)) {
- if (unit->data->sourceTimeStamp == 0) {
- const_cast<QV4::CompiledData::Unit*>(unit->data)->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch();
- }
- QString saveError;
- if (!unit->saveToDisk(QUrl::fromLocalFile(fn), &saveError)) {
- std::cout << "Error saving JS cache file: " << qPrintable(saveError) << std::endl;
- }
+ script.reset(new QV4::Script(ctx, code, fn));
+ script->parseAsBinding = runAsQml;
+ script->parse();
+ }
+ QV4::ScopedValue result(scope);
+ if (!scope.engine->hasException) {
+ const auto unit = script->compilationUnit;
+ if (cache && unit && !(unit->data->flags & QV4::CompiledData::Unit::StaticData)) {
+ if (unit->data->sourceTimeStamp == 0) {
+ const_cast<QV4::CompiledData::Unit*>(unit->data)->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch();
+ }
+ QString saveError;
+ if (!unit->saveToDisk(QUrl::fromLocalFile(fn), &saveError)) {
+ std::cout << "Error saving JS cache file: " << qPrintable(saveError) << std::endl;
}
- result = script->run();
- }
- if (scope.engine->hasException) {
- QV4::StackTrace trace;
- QV4::ScopedValue ex(scope, scope.engine->catchException(&trace));
- showException(ctx, ex, trace);
- return EXIT_FAILURE;
- }
- if (!result->isUndefined()) {
- if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
- std::cout << "exit value: " << qPrintable(result->toQString()) << std::endl;
}
- } else {
- std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl;
+ result = script->run();
+ }
+ if (scope.engine->hasException) {
+ QV4::StackTrace trace;
+ QV4::ScopedValue ex(scope, scope.engine->catchException(&trace));
+ showException(ctx, ex, trace);
return EXIT_FAILURE;
}
+ if (!result->isUndefined()) {
+ if (! qgetenv("SHOW_EXIT_VALUE").isEmpty())
+ std::cout << "exit value: " << qPrintable(result->toQString()) << std::endl;
+ }
+ } else {
+ std::cerr << "Error: cannot open file " << fn.toUtf8().constData() << std::endl;
+ return EXIT_FAILURE;
}
+ }
- vm.memoryManager->dumpStats();
- } return EXIT_SUCCESS;
- } // switch (mode)
+ vm.memoryManager->dumpStats();
+ return EXIT_SUCCESS;
}