Commit Graph

38 Commits

Author SHA1 Message Date
Lars Knoll 025365f1dc Refactor marking GC'ed objects
Don't use recursive function calls anymore. Instead, push marked
objects onto the JS stack, and then pop them off when their children
are being marked.

Should reduce stack memory usage, and improves performance by ~5%.

Change-Id: I2d37d97579144fcba87ec8e9fd545dd220c01fbb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-05 18:54:51 +01:00
Erik Verbruggen a79e400150 Fix various compiler warnings in order to remove warn_off in the near future
Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-04 02:16:04 +01:00
Lars Knoll d4ff8bd1ec Remove qv4unwindhelper class
This class is not required anymore to generate stack traces, as
we now store the required information in the JS context stack.

Change-Id: I3893c805ca89dda70efde07fdd120e7dfaf3639f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-29 10:39:08 +01:00
Simon Hausmann b93ddb95a7 Qml JavaScript code generation cleanups
* Run the binding expressions, functions and signal handlers through
  the V4 codegen _per_ component, and run the isel at the end for the
  entire file. We need to do per-component codegen because we want to
  set up the correct id and object scopes, which are different for the
  root component and anonymous components.
* Changed V4IR::Module to allow for the concept of "qml modules" where
  there is no root function defined. This is a logical consequence of
  running v4 codegen multiple times with different input but the same
  V4IR::Module.

Change-Id: Ib3a719f83507cbab7c2e4e145ccad5b663c795cf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-20 21:11:54 +02:00
Lars Knoll d736b58d24 Fix possible crashes
This can (and does crash) when a gc gets triggered during the
linking stage of a compilation unit.

Change-Id: I06f1299adab68ff8e0a4755d02e246870797e7f2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-11 19:33:41 +02:00
Lars Knoll 979e625dc1 Mark strings stored in the lookups
Change-Id: I4cb72a3eee9f87305316137b0a1bfd4a003de840
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-11 08:56:17 +02:00
Lars Knoll 1e454c8aa6 Remove more uses of Value
Change-Id: I889e760f75b485a28e1f2a2c26b2337ae9bfafac
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-02 16:07:33 +02:00
Lars Knoll 1fb3cd12c8 Fix cases where mark() would access uninitialized memory
Change-Id: I4e07e20d30ba57759a0ece1c298a02b098718b33
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-22 15:29:00 +02:00
Lars Knoll 713ae5106f Change the runtime API over to using StringRef's instead of String*
Change-Id: I0ea95e6cca995dc5f98871f0369204af18e48111
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-22 01:06:20 +02:00
Simon Hausmann 57f7545f67 Fix destruction of QV4::CompiledData::CompilationUnit objects
Now that we store them per QML file, they live in the type cache and
can outlive the engine. Therefore the engine needs to free to unlink
any remaining units upon destruction. This needs to be done after the
"death" of the memory manager, which is likely to sweep away any
function objects that also hold a reference to the compilation units.

Change-Id: I3968d5995289e8d2bc1e3abbb1f8be88a0ab4e03
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-20 14:27:39 +02:00
Simon Hausmann 0615bced19 Fix crash in QV4::CompiledData::CompilationUnit
Don't crash when a CompilationUnit is created, never linked into an engine but instead
deleted (because there was an error elsewhere compililing the rest of QML
before it could reach the link-to-engine stage)

Change-Id: Iff535009b6b4d1fc4004987c98730251a3a7d8d8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-20 14:27:17 +02:00
Simon Hausmann 5c4c912391 Cleanup: Fold CompiledData::Value into CompiledData::Binding
Value isn't needed anywhere else

Change-Id: Ib12d85332a6096e6232a790a7e6fd63961329e3b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-20 14:26:09 +02:00
Simon Hausmann bbb78a92a9 Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into HEAD
Conflicts:
	src/qml/compiler/qv4isel_masm.cpp
	src/qml/jsruntime/qv4script.cpp
	src/qml/qml/qml.pri
	src/qml/qml/qqmltypeloader_p.h

Change-Id: Ia784d855a2131e3289454f12d841ca2c65be15c1
2013-09-20 08:29:17 +02:00
Lars Knoll 9dcc12d523 Convert a few more methods in ExecutionEngine to use protected pointers
Change-Id: I2e6b1b9dff52bbd16f35a00152c9ac557f8346eb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-18 13:14:08 +02:00
Giuseppe D'Angelo 4df73e62a7 Remove qSort usages from declarative
QtAlgorithms is getting deprecated,
see http://www.mail-archive.com/development@qt-project.org/msg01603.html

Change-Id: I8fa7d0186cc8f0ba562695974829e37f1eb87f2f
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-13 01:10:37 +02:00
Simon Hausmann 89402e0ef6 Merge branch 'dev' of qtdeclarative into wip/v4
Conflicts:
	src/qml/jsruntime/qv4script.cpp

Change-Id: I20136cab29d86862b5bd9208003200bc24bcdacf
2013-09-11 19:08:28 +02:00
Lars Knoll e6180ecdc2 Properly unwind the js stack for generated code
Surround all calls into generated code with a
try {} catch {} statement that resets the jstack
to the correct position.

Like this we properly unwind the js stack in all cases, and
can also use stricter assertions in our ScopedCallData, etc.
classes to check that the stack is healthy.

Change-Id: I7ca03e06ea55007be683305d9c2a6898cf5fc689
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-11 13:02:00 +02:00
Simon Hausmann c5694ba573 Make it possible to supply an external JS unit generator to the isel
This is needed for QML unit generation, when we share the JS generator
for QML types/strings and JS code.

Change-Id: I50f0c1fa6721d6e3e59417c6c256c82aec124e8f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-05 20:26:42 +02:00
Lars Knoll d8e31c098d Cleanup calls to Object::setPrototype()
Rather use the correct internalClass directly when constructing
the objects.

Change-Id: I8e916f1ce8f83d291c08ca6332fe85b1f57b90b5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-02 17:27:36 +02:00
Lars Knoll edee5c3dc0 Move prototype pointer into QV4::InternalClass
The prototype is actually the same for most objects. By
moving it into the internal class, we can save 8 bytes
per object, as well as allowing for some future
optimizations.

Also fix a bug in the implementation of the Error
prototype objects.

Change-Id: I4d4b641055f644a9b088f27be34bfdb0446279b7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-02 17:27:36 +02:00
Simon Hausmann e360eaa02f Temporarily collect a map of all functions in the engine
At the moment we collect a lot of compilation units (one per binding
expression!), which for long running QML accumulates and creates a horrible
performance when trying to retrieve back traces. There is work in progress
to reduces the number of units down to one per QML file, and then the
fixed sorted QVector might proof to be a more efficient data structure
for the lookups.

But until that code lands, this patch proposes to use a QMap instead for the
time being, that tracks all functions. This brings down the qtquickcontrols
auto-test run from 2.5 minutes to just under a minute on my machine.

Change-Id: I45bf609055877081daa984de90f291a030f2f24f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-02 14:32:47 +02:00
Simon Hausmann 90aaff37be Cleanup: Determine the root/entry function in isel independent code
Change-Id: I99004b872be9bd7d9dd0c798eb2d9bb4ddfa4cbd
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-19 16:11:49 +02:00
Simon Hausmann 2e7d90572c Prospective build fix for namespaced Qt builds
Add missing QT_BEGIN/END_NAMESPACE

Change-Id: I6beed22d8d1713be99de114ba747cf5e17223591
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-18 20:01:26 +02:00
Simon Hausmann ca2b4d1cca Fix invalid reads with strings
It may happen that a dynamically created compilation unit disappears before any
QV4::Strings it created. Those strings would still have a reference to the
QString data in the compilation unit. I don't see a choice other than making a
copy of the string data ;(. But this patch adds a flag that would allow for
avoiding it if we happen to know that the compilation unit data is static.

Change-Id: Ib35a4d2a566b301a25ffe56e392809e44e7b4ae8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-18 12:30:11 +02:00
Simon Hausmann 3bc7823fc8 Merge Function::init with the constructor
Change-Id: I557f8a80aa2c74398b94e87ed0f29fe8d2297150
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 21:39:51 +02:00
Simon Hausmann 3314912318 Eliminate all vm functions on the isel side
Change-Id: I7c0e50498c937ce554b019f98829fa8c5d96c18e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 21:38:07 +02:00
Simon Hausmann a44f92d925 Get rid of the functions list in QV4::ExecutionEngine
Change-Id: I97067dbb2819936a1b2029c9f63f0627cb6b8bd2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 19:22:24 +02:00
Simon Hausmann 0f0e7443ae Refcount the compilation unit and remove refcount from runtime function
Change-Id: Iaa2f96a6814f1b39589ffcfe3c84e3c229e25f1f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 19:18:48 +02:00
Simon Hausmann 944717a46c Ported the compile-time class setup for object literals to be run-time based
Change-Id: I21225e4bf0f66914229cf64fa29ce870548c0e93
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 16:52:18 +02:00
Simon Hausmann d017fe9b38 Store line number mappings in the compiled function
Change-Id: I4e37aac3618b20ccd52ce4833098781374a3daf6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 10:14:22 +02:00
Simon Hausmann b88626a3a5 Ported regular expressions over to be run-time generated data
Change-Id: I04e693d4923c97c3d869a5beb17011f6aad85f03
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-16 10:14:13 +02:00
Simon Hausmann c5c968933b Fix crashes with unmarked runtime strings
Runtime strings are identifiers, but they still require to be marked. Keep
track of all compilation units in the engine (one per file) and mark its
run-time strings.

Change-Id: Ie70b00dfa373c4567279591de2f717e8103c288f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 15:28:46 +02:00
Simon Hausmann 7b2c9178b9 Ported lookups to use the compiled data infrastructure
Change-Id: Idf75cd51087ea825f22aabda59661be461fd3b86
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 15:28:37 +02:00
Simon Hausmann 4b0765da3e Prepare MASM for better runtime string handling
Keep the run-time functions as-is by taking String pointers and use a little
bit of inline assembly to resolve the string ids to string pointers, by
adding a runtimeStrings array pointer next to the lookups in the context
(similar mechanism).

Change-Id: Ib5a70bdf47fef7c447d646ccfe03f3dc30d39f20
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 13:56:07 +02:00
Simon Hausmann 335a903d4b Move the masm compilation unit entirely into qv4isel_masm
Change-Id: If24b6a761dc2f2443520b31b5130ab44b739cdf3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:11:42 +02:00
Simon Hausmann 0d1e37e9f5 Fix writing the function offset table and initialize the pointer to the compiled function in the runtime function
Change-Id: I9aed9f394fedc4a4ea334f6ab1b72fe749c64c72
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:08:44 +02:00
Simon Hausmann 5f3ef18bf8 Begin using the compiled data structures for runtime strings
Change-Id: Idbf278a96624bf101df35de40577b38e593f22be
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-08-15 09:08:39 +02:00
Simon Hausmann 131964a3b5 Initial version of generator for new data structures
Change-Id: I172a504f8b4f8284967a4a02e207bf4c0a04c2a4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-08-15 09:08:35 +02:00