Lars Knoll [Thu, 23 May 2013 13:23:06 +0000 (15:23 +0200)]
Remove all references to the old v4 code
The old v4 files have already been removed, so cleanup
all the #ifdef'ed code that still references them.
Change-Id: Ifc5c59add5af36a61586a43b13291d7836cccd78
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Thu, 23 May 2013 12:03:03 +0000 (14:03 +0200)]
Add some null pointer checks to v4::Script
This makes all eval() related tests pass again.
Change-Id: I067f2e0acf17932ec9b212723fc8df1ffc4c4884
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Simon Hausmann [Thu, 23 May 2013 10:50:39 +0000 (12:50 +0200)]
Fix failing assertion in tst_qqmlecmascript::singletonType
Don't try to call the singleton callback with the current scope but instead
execute it well-defined within the scope of the global context.
Change-Id: I6b59fad7d466a6070d1c748f909e1d8c0a1045ea
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 22 May 2013 21:10:01 +0000 (23:10 +0200)]
Fix crash in tst_qqmlecmascript::qtbug_22843()
Parse errors throw exceptions, which we must catch here. The caller will
check !m_program and return accordingly. This restores the previous
behavior also found in stable/dev.
Change-Id: Iecff94858ba12f13e581ec1664a092b3e9cd963d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 22 May 2013 20:48:38 +0000 (22:48 +0200)]
Fix failing assertion in QObject bindings when catching exception
Add missing accept() to ensure the context is unwound correctly.
Change-Id: I42f9d17c8df25beb151675377d4395f1e2b35eef
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 22 May 2013 20:45:45 +0000 (22:45 +0200)]
Fix another failing assertion when running qqmlecmascript tests
Value::IsUInt32() and friends are not implemented. Port this built-in
stringArg() function over to QV4::Value.
Change-Id: I48674892c238473f1d70b2184249b0db377ae399
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 22 May 2013 14:19:52 +0000 (16:19 +0200)]
Compile fixes for clang.
Change-Id: I691347f7cbd1023ce3c9c2e116d3ca5029f4a8e1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 22 May 2013 17:37:34 +0000 (19:37 +0200)]
Fix crash in Engine::currentStackFrame()
Don't accidentally shadow c with c :)
Change-Id: I4c5022428e8dfb0cda432283decaac8edae512f1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Wed, 22 May 2013 14:53:35 +0000 (16:53 +0200)]
Various fixes
Fix a regression in Script::run, and compilation for
v4 and an auto test.
Change-Id: I4026eebec0e02f4af03ca49ba714916ad90b34e7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 22 May 2013 14:35:28 +0000 (16:35 +0200)]
Remove QV8Engine::scriptValueFromInternal
Change-Id: I43d672d17c0bbb498be71d7a25f8ca1389aeadf7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 22 May 2013 14:26:45 +0000 (16:26 +0200)]
Move evaluateScript into QV4::Script
also remove an unused method in QV8Engine
Change-Id: I1e655e714755426ac0c48ee9cc08059104ddb3b3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 22 May 2013 14:16:49 +0000 (16:16 +0200)]
Local initialization is now done in codegen
Follow up on
2bd6e240a3c2b3dc7a2c81c639d4f30e4dfd685f
for Qml contexts.
Change-Id: I0c0d417a65cf537fc56696b4f996812b368ab387
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 22 May 2013 13:59:29 +0000 (15:59 +0200)]
Remove v8::Script and related classes
Port the last few usages of v8::Script over to the new
v4::Script class.
Change-Id: I0d117d273ca450d29a9111757603da8ae02e4ca4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 22 May 2013 13:47:55 +0000 (15:47 +0200)]
Remove now unused QV8Engine::qmlModeCompile methods
Change-Id: I55d89f1e2bd09cde3ef8f3b99bb4138d7247649c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Erik Verbruggen [Mon, 13 May 2013 06:57:33 +0000 (08:57 +0200)]
Local initialisation is now done in codegen.
Change-Id: Idbc19b2e4f71adf3b6674ac2ae6064b7ea347fff
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 22 May 2013 12:22:06 +0000 (14:22 +0200)]
Terminate for-condition-blocks when they are empty.
Change-Id: I21409ea43edf8b87c681b69c409d11230b205383
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 22 May 2013 12:11:59 +0000 (14:11 +0200)]
Make sure that case-blocks in a switch are terminated.
If the case is "fall-through", add a JUMP to the next case block.
Change-Id: I9e49c55dacc79d6154d4ae30db0acb3d3f457468
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 22 May 2013 08:46:09 +0000 (10:46 +0200)]
Cleanup: It's QQmlV4Function and so the flag should also be called V4Function instead of V8Function
Change-Id: I6d4d258e1fcad9097eb898f0b092f564cd4078ad
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Wed, 22 May 2013 12:30:57 +0000 (14:30 +0200)]
Replace usage of v8::Script and qmlModeCompile with QV4::Script
Change-Id: I114a0b7faed39be313cde5617a0ce4a06dece7e2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 22 May 2013 11:49:27 +0000 (13:49 +0200)]
Add a QV4::Script class
The class is a replacement for v8::Script. Start using it
in various places.
Change-Id: Ie5537639e44fa1ee23aea8605eae3c736819ef52
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 22 May 2013 13:43:27 +0000 (15:43 +0200)]
Fix memory corruption
The QString constructor taking a QStringDataRef doesn't refcount,
so we need to do it manually.
Change-Id: I076df18cfdb94ef796a42281b7bb1027798b609c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Wed, 22 May 2013 09:58:16 +0000 (11:58 +0200)]
Fix build on Windows
* Include stdint.h for uint16_t and friends
* Fix struct vs. class mismatch
* Export QV4::String as referenced by QQuick
* Eliminate declared but not defined destructor
* Fix v4classgen python script to not require argsparse, so that it works with older Python versions
* Replace the use of QStringLiteral in some places where we concatenate the
input (like "Foo" \n "Bar") and MSVC thinks that the two string literals have
a different "width" (8 bit vs. 16 bit) and therefore cannot be used with QStringLiteral
* Add src/qquick to the include search path to work around the differing include search path
semantics between MSVC and gcc
Change-Id: Iedcc21cc757c53b6c7d81b514fd857ff1f573b01
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Wed, 22 May 2013 08:47:36 +0000 (10:47 +0200)]
Add support for generating stack traces to QV4::ExecutionEngine
This makes it possible to remove the v8::StackTrace API
Change-Id: I53eee022a1030f0f6bf9a9268ca7cd3d5975724d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Wed, 22 May 2013 08:41:21 +0000 (10:41 +0200)]
Build fix for tests
This file uses uint16_t and therefore needs to include stdint.h for
the declarations.
Change-Id: Ifd95a4ade6ecb8560deca4d0118b985d939cfba2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Tue, 21 May 2013 20:46:15 +0000 (22:46 +0200)]
Add correct filename and line number info to v8::StackFrame
Change-Id: I14d4e1b78d62fd7ccf19a57d14a5a32df9385037
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 21 May 2013 20:04:36 +0000 (22:04 +0200)]
Remove v8 dependencies in qhashedstring
Also remove now unused API in v8::String
Change-Id: I2570aedf407c89ad85da01cf0e2153a52b4e562d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 21 May 2013 19:23:01 +0000 (21:23 +0200)]
Get rid of v8::String::(Ascii)Value
Change-Id: I792a94590efbec852620d101b620b263a90e1d54
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Tue, 21 May 2013 19:31:45 +0000 (21:31 +0200)]
Fix running through all tst_qqmlecmascript tests
* Implement SetHiddenField/GetHiddenField (hack)
* Fix recursive calls to SetEngine, to allow for the re-use of
the QQmlEngine member in tst_qqmlecmascript after ~QQmlEngine
was called on another instance
* Fix array sizing in function call parameter handling
* Don't try to clone the function object in Qt.binding (assert instead)
Change-Id: Ia3155dea8518348ec329037ca04e5c38e47a4f92
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 21 May 2013 15:06:36 +0000 (17:06 +0200)]
Finalize sequence wrapping
* Move into QV4 namespace
* Get rid of sequence wrapper instance, all static methods now
Change-Id: I9a9e7ce10890cfe4625b3571bdb4b0ffec34658a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 21 May 2013 14:31:05 +0000 (16:31 +0200)]
Fold qv8sequencewrapper_p_p.h into qv8sequencewrapper.cpp
Most of the implementation belongs into a C++ file instead of a header file,
it's not re-used from anywhere else.
Change-Id: Ib41e3e104d9544710343b869116368bbca999622
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 21 May 2013 14:24:00 +0000 (16:24 +0200)]
Eliminate last v8 dependency from QV8SequenceWrapper
Stub out file name and line number information in QV4::ExecutionContext,
used for warning generation.
Change-Id: I922541e1ee4a5e2211ca6c16494d2b9044a9c346
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 14 May 2013 16:58:34 +0000 (18:58 +0200)]
Port the rest of the sequence types to V4
Change-Id: Ia248f54b65b74d16e91e6ec72503eb967894586d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 21 May 2013 13:33:18 +0000 (15:33 +0200)]
Fix the build
Change-Id: I04a2e3c280b622378bf4431a77388e59eb31ad10
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Tue, 21 May 2013 10:45:12 +0000 (12:45 +0200)]
Get rid of v8::Primitive
Change-Id: Idd31a8d522119cade9bb18854e124b80f1c57123
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 21 May 2013 10:43:37 +0000 (12:43 +0200)]
Get rid of v8::Boolean
Change-Id: I10b4240db78532dfdf972bb0a6f191462d81caaa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 21 May 2013 10:37:52 +0000 (12:37 +0200)]
Get rid of v8::Number
Change-Id: I38bdf8fe4dd73c61317912ec6308a9a1e870ad99
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 21 May 2013 10:33:55 +0000 (12:33 +0200)]
Get rid of v8::Integer
Change-Id: I6b9ab830c4ff3cbf986dbcf7c056648b5a16a222
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 21 May 2013 08:56:08 +0000 (10:56 +0200)]
Remove some unused classes from the v8 API
Change-Id: I6fdb7903a3cdb3b3167144f78bd7cf58647deb67
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Tue, 21 May 2013 08:17:30 +0000 (10:17 +0200)]
Small exception handling fixes
* Don't accept the exception if we're going to re-throw it (partial unwind
is not necessary as we don't have a stack-based context to clean up)
* However do accept() it if we decided to handle it (in qqmlvme.cpp)
Change-Id: I63bfa34f30fe19ad36de746b1f15fc6b641e563b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 21 May 2013 08:27:25 +0000 (10:27 +0200)]
Fix crashes when invoking QML JS methods from C++
Make sure to size the QVarLengthArray properly to avoid out-of-bounds
access.
Change-Id: Id075730ffa2e366a729b401b8563ad7fd59597de
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Mon, 20 May 2013 22:05:52 +0000 (00:05 +0200)]
Get rid of v8::TryCatch and v8::Message
They are now unused, so let's remove them from the v8 API.
Change-Id: I9c1b39632cb88785ae6fdda671580e0426ae97ba
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 21:51:45 +0000 (23:51 +0200)]
Convert the remaining TryCatch statements to use QV4::Exception
v8::Script::Run doesn't catch the exception anymore. Instead we handle
this on the calling side, removing all needs for v8::TryCatch.
Change-Id: I946269a6734f50c728c4f153c00cd19db48f1a6a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 20:12:41 +0000 (22:12 +0200)]
Remove half the v8::TryCatch statements
Replacing the other half requires a replacement for v8::Script.
Change-Id: I40fe99302fba23f286773ec1adaf8d3751db901d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 18:32:58 +0000 (20:32 +0200)]
Fix return value for QQmlJavascriptExpression::evaluate
Change-Id: Idf95ee51b7d50682476371c7f49537930fdf96f1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 18:27:16 +0000 (20:27 +0200)]
Cleanup QQmlDelayedError
Remove dependency onto v8::Message and simplify conversion from
QV4::Exception to QQmlError.
Change-Id: Icfdfd7a2749210b2df9fda6cd5de94114b8adcfa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 18:24:42 +0000 (20:24 +0200)]
Add source file and line number to QV4::Exception
This will allow us to replace v8::Message properly and give
us proper error reporting for uncaught exceptions.
Change-Id: I1c03b6c21456dea06931a874bb2aa5a0b00aff62
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 16:55:49 +0000 (18:55 +0200)]
Move QQmlJavascriptExression::evaluate over to v4
Change-Id: Ic4093dc5413f43af55a74a0e0f8c316ac1c6d974
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 09:00:58 +0000 (11:00 +0200)]
Fix some parts of workerscript and convert to v4
Add some try/catch blocks around calls to v4, fixing
some crashes in the worker script auto test.
Change-Id: I591a25facc8afd5c6f99ffb7b75530c890318280
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 09:13:48 +0000 (11:13 +0200)]
Rename QV8Worker to QV4::Serialize
The class is only being used in WorkerScript, but in itself
only does serialization of JS Values.
Change-Id: Ibf1b06acf5abcfcc00cada9cc8cad9a833bd7ea3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 20 May 2013 09:00:06 +0000 (11:00 +0200)]
Comment out two lines that cause assertions
The subcontext code is only used to add debugging info
through the V8 API.
Change-Id: Ibcb3284180aca1568b44d9d387d96bfae715283d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sun, 19 May 2013 21:50:47 +0000 (23:50 +0200)]
Fix a bug in the creation of JS Array's from variant and string lists
Correctly set the arrayDataLen or V4 assumes the array is empty.
Change-Id: I6b7454b2e7a2b459b1e41e6d6234f89460013107
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sun, 19 May 2013 21:16:48 +0000 (23:16 +0200)]
Properly initialize regexp objects created from QRegExp's
Change-Id: Id6c9abe7e20bf91c37a6bd335117266a8e8aa8fd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sun, 19 May 2013 21:15:13 +0000 (23:15 +0200)]
Fix a bug in V4V8Object::put()
When a fallback handler returns an empty value it is not
intercepting the call, and thus the put() method of the base
obejct should get called.
Fixes most issues with worker threads.
Change-Id: I88f0fcb6349cc818163248d456e3fb916188f48f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Thu, 16 May 2013 10:17:22 +0000 (12:17 +0200)]
convert qv8workerscript to v4
Change-Id: Ifc204f53a46c857a2a7caaa4f6900d4300163dbb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Tue, 14 May 2013 06:43:45 +0000 (08:43 +0200)]
Fix connect/disconnect in QObject bindings
The hack of using ScriptOrigin to identify JS wrapper functions for Qt methods
is not possible for us to implement (or doesn't make sense). However the bindings
rely on this feature, so implement it using a semi-private property hack.
Change-Id: I6c7852f46916a9f549bf703d47546e7ddd75a1b1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Thu, 16 May 2013 07:31:28 +0000 (09:31 +0200)]
Smaller cleanups in qv8engine
Change-Id: I5cc7150c37312db78ce0985fe546646a9df61258
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 14 May 2013 00:33:03 +0000 (02:33 +0200)]
Don't GC constructors and prototypes
Change-Id: Iedc894927bc93dc3f5778a4f7855eb3ec37b946b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Tue, 14 May 2013 00:01:04 +0000 (02:01 +0200)]
convert QV8VariantWrapper to v4
Implement variant support through a QV4::VariantObject
class. Port scarce resource support for the
pixmap and image variants.
Change-Id: Ib6aac8debc7f57224ccddb912ab4342c5f1dec15
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 13 May 2013 16:39:57 +0000 (18:39 +0200)]
Change some APIs in qv8variantwrapper over to be v4 based
Change-Id: Idfba6a92bc23dbb8fe14d67ed4a4be901dc0e10a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 13 May 2013 16:30:16 +0000 (18:30 +0200)]
Fix QJSValue::toVariant and isVariant
Change-Id: I7360e37e34756e26f3e8936751c6b65a9d0a2167
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 13 May 2013 16:29:33 +0000 (18:29 +0200)]
More correct conversion to a QString when toString() throws
Change-Id: I0c11b5ed593593f849ec272ae17f2ef4525f3629
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 13 May 2013 16:07:44 +0000 (18:07 +0200)]
Give the QJSValuePrivate the pointer to the engine back
Unfortunately the value needs a pointer back to the engine, to keep
compatibility with the old code and have our tests pass unmodified.
Change-Id: Ibe26e6c770bd8d26dad4a26d42b40e3e1af4996c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Mon, 13 May 2013 14:11:35 +0000 (16:11 +0200)]
Another fix for getting more of the QML based tests running
The QML testlib uses the in operator on the QObject bindings, which provides
properties using the named fallback property query/enumerator. We need to
include those in Object::__hasProperty__, which is used to implement "if (foo in bar")
Change-Id: Ib30a9e9d90e0e2379e655f5282c269f1b5cceb8d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 14 May 2013 13:59:10 +0000 (15:59 +0200)]
First step towards porting sequence wrappers to V4
The idea is to wrap sequence container types such as QStringList or
QList<int> in a JS object that behaves like an array and also shares the
prototype.
The next step is to generalize the QStringList implementation to be re-usable
for the other sequence types.
This also required extending the object iterator with support for these
kind-of array types.
Change-Id: I5f0a14f904233944297708037c944964f1b74923
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 14:59:40 +0000 (16:59 +0200)]
Fix build of tst_qqmlecmascript
Comment out v8 persistent and weak reference handling related bits and
tests. Otherwise this auto test contains a lot of stuff we need.
Change-Id: Ieafd9c8ea5200e5429d6354243ccaddba4f4772e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 14:24:40 +0000 (16:24 +0200)]
Fix invocation of QQmlV4Functions in JS/QML
After the renaming of the class we also need to fix the two places where
we refer to the type by name.
Change-Id: I3c446cb31c2ecfc457f161f6b5cd7e30f44b2227
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 13:11:20 +0000 (15:11 +0200)]
Fix lookups for properties called "name" in QML
We give the function prototype the property name == "Function". The QML
scope object is created using a function template with a fallback property
handler and we inject it as activation object. Therefore a lookup for "name"
will end up as property looking up in activation object before going to the
fallback handler. The lookup for "name" will then succeed through the prototype
chain and find the FunctionPrototype's name property.
There are different ways of fixing this, including the QML side or the v8
binding implementation. But let's not give the function prototype the name
property - it doesn't appear to make much sense.
Change-Id: Icfb7bed7ef3e663ccb5f5cb189f664934264a558
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Sun, 12 May 2013 10:07:15 +0000 (12:07 +0200)]
Fix exception handling not working reliably on x86/x86-64 Linux (Part 2)
The registration of the unwind tables is done through the interposition
of the _Unwind_Find_FDE symbol from libgcc. Unfortunately that interposition
breaks when libgcc happens to come first in the linker scope. As it turns
out, the order is not for us to control, therefore the interposition may not
always work and our JIT generated functions may not get their unwind information
found at exception throwing time. That results in the program aborting with
an uncaught exception.
The proposed solution of replacing the interposition approach is two-fold:
(1) Go back to calling __register_frame explicitly, but only for functions that
exception _may_ pass through. In addition the performance of scalability of the
objects registered with __register_frame is a known issue upstream, as the LLVM
JIT also triggers the issue. It is being tracked at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56460
(2) Instead of registering one FDE per function, we can theoretically register
one FDE for _all_ JIT generate functions, because they all use the same stack
layout that has exactly the same unwinding requirements from any function call
site. Since we can't guarantee the presence of all JIT generated code within
the same contiguous memory area, we can at least do it per executable memory
allocation chunk (page size). One chunk can contain many functions.
This patch implements part (2) by moving the per-function unwind info straight
to into the executable memory chunk and registering the entire chunk (page)
with libgcc. This also separates the regexp JIT executable memory from regular
functions, because only for the memory of the latter we need to register unwind
info.
Change-Id: Ic4d1978686463c6d319436c9083e4d7cf0409829
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Sun, 12 May 2013 10:07:15 +0000 (12:07 +0200)]
Fix exception handling not working reliably on x86/x86-64 Linux (Part 1)
The registration of the unwind tables is done through the interposition
of the _Unwind_Find_FDE symbol from libgcc. Unfortunately that interposition
breaks when libgcc happens to come first in the linker scope. As it turns
out, the order is not for us to control, therefore the interposition may not
always work and our JIT generated functions may not get their unwind information
found at exception throwing time. That results in the program aborting with
an uncaught exception.
The proposed solution of replacing the interposition approach is two-fold:
(1) Go back to calling __register_frame explicitly, but only for functions that
exception _may_ pass through. In addition the performance of scalability of the
objects registered with __register_frame is a known issue upstream, as the LLVM
JIT also triggers the issue. It is being tracked at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56460
(2) Instead of registering one FDE per function, we can theoretically register
one FDE for _all_ JIT generate functions, because they all use the same stack
layout that has exactly the same unwinding requirements from any function call
site. Since we can't guarantee the presence of all JIT generated code within
the same contiguous memory area, we can at least do it per executable memory
allocation chunk (page size). One chunk can contain many functions.
This patch implements part (1) by delaying the registration of the FDE to right
before the exception gets thrown and then walks up the context chain. The test
cases that were previously slowed down before commit
b83696f9896401dd5e99eed35e36628710e44eeb are not affected because the many
temporary "eval" functions are never subject to exceptions.
Change-Id: I7cb8262e3e1f27d6de71a1e42be8a538cba6513f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 05:47:05 +0000 (07:47 +0200)]
Keep track of the currently code currently being run through eval()
We need to keep track of the possibly recursive eval calls for back trace
functionality in the future as well as changes to the exception handling.
Change-Id: Ie8a9343dfe43754fee48bab4b96b4ec2ab1fb67b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 08:30:02 +0000 (10:30 +0200)]
Remove unused variable
Change-Id: I20a17d8d1af0027e4be17eb067c61204c41b0f7c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 08:25:01 +0000 (10:25 +0200)]
Clean up context initialization
ExecutionContext and its subclasses have various members that are
initialized differently in different call sites. This makes it difficult
to add new members (must find all call sites).
This patch attempts to centralize the member initializations and changes the
usage pattern so that after object creation the corresponding init method needs
to be called before initializing any other members by hand.
Change-Id: I37ac8462ed894c8b234915e114ed032e12bda8bd
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 08:06:32 +0000 (10:06 +0200)]
Add missing pushContext/popContext in SimpleCallContext usage
Otherwise engine->current isn't set correctly, and that would cause issues
if for example method_getOwnPropertyNames in this case would throw an exception
Change-Id: I6f7f9cfec864a8f39e6968ce396237638c118475
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Mon, 13 May 2013 07:38:25 +0000 (09:38 +0200)]
Fix uninitialized context type variable
Uninitialized it may lead to incorrect casts if
somebody calls asCallContext() for example.
Change-Id: I12d28bc29567563da5b382f7bc294c394033cbf0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Mon, 13 May 2013 06:53:43 +0000 (08:53 +0200)]
Fix exports for functions used in inline methods.
Change-Id: I69781c6d4697de570be9c0f91560d3bef2376625
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Sun, 12 May 2013 12:36:02 +0000 (14:36 +0200)]
Fix QV4Engine::globalCode
Gcc appears to optimize away the temporary assignment unless we give
the object a name ;(
Change-Id: I9c10a92ec32654fd690cfd74a0f3e0cbf363de4c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Sun, 12 May 2013 13:00:48 +0000 (15:00 +0200)]
Fix crash when running some QML auto-tests
Engine identifiers are strings, which as Managed sub-classes have a pointer to
the internalClass. For strings we generally use engine->emptyClass. So before
creating any identifiers, engine->emptyClass must be initialized. Otherwise
putting any of the identifiers later into for example a QV4::PersistentValue
will cause crashes, because string->internalClass->engine will be an
uninitialized value.
Change-Id: I35a19a1701c5938b61f61e876d656e126a9b8e09
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 11:48:47 +0000 (13:48 +0200)]
Initial port of JS canvas bindings to use QV4::Object subclass instead of V8 resources
This patch comes with the same prototype injection as during the QML locale
patch. This will allow for incremental porting method by method for this huge
binding.
Change-Id: Ie258f021ac6f926302bb375a8ce7a12fb5e0512a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 14:49:35 +0000 (16:49 +0200)]
Fix typo in internal API
Enumberable -> Enumerable :)
Change-Id: I12afbade4c68c5bf86c3b623a1862e82483db844
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 14:46:01 +0000 (16:46 +0200)]
Add rudimentary internal field support
This patch maps the internal field support somewhat hackishly through
the public JS properties by prefixing them with _internalfield_.
Internal fields are used in only a few places in QML, including the context2d
bindings, which I'm trying to port along with passing auto tests.
Change-Id: I5fe6cd7a825f437b9d5cccbee8da67336d82002c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 14:41:27 +0000 (16:41 +0200)]
Fix running various QML auto-tests
The QML QTestLib support relies on listing test functions by doing
for (prop in theQmlComponentToTest) and relies on that iteration to include
the list of test functions declared. QV8QObjectWrapper does not set own
properties for all those functions but instead relies on the fallback
property enumerator and query feature of the V8 API (a patch that is Qt
specific).
This patch implements basic support for iteration over these properties.
The API also has support for named property handlers and indexed property
handlers. The former's dynamic property support is not used in QML, however
dynamic indexed properties are used in the JS sequence wrappers and not
covered by this patch.
Change-Id: Ic9ad3ac55b3c1e0a774a62154f83734255fe594d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 12:57:12 +0000 (14:57 +0200)]
Improve error reporting
Implement TryCatch::GetMessage by means of converting the exception value to a string.
That often produces rather readable error messages.
Change-Id: I50b040ffae1db19b4c9d962b2759c7eae0ebcea1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 11:21:26 +0000 (13:21 +0200)]
Remove unused engine pointer in QQmlLocaleData
As per the comment, this is unused now and can be removed :)
Change-Id: I74e26ee46755c6c4fcfc09fa4062690852f8b6cf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 11:06:32 +0000 (13:06 +0200)]
Fix visibility of named function expressions in surrounding environment
Quoting from the spec: "However, unlike in a FunctionDeclaration, the
Identifier in a FunctionExpression cannot be referenced from and does not
affect the scope enclosing the FunctionExpression."
This was visible in QML start-up when evaluating helper functions: "(function
foo() { ...})" was compiled and run in the global scope and the returned
funtcion expression is executed later on. However we incorrectly also ended up
entering "foo" as a name into the global scope (which it was executed in),
causing then for example "foo" to become part of the "illegal" names in QML.
The case at point was that qv8sequencewrapper.cpp evaluates a helper script
with a named function expression "compare" and then later the QML canvas
auto-test failed because somewhere it declared a JS function in the scope
of a QML item called "compare".
All tests still pass, we do handle the case of looking up the named function
already in qv4context.cpp (getProperty, etc.).
Change-Id: Id9daaff355ce35ae4bc96dcbaba9710cd8cc2211
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 10 May 2013 06:36:07 +0000 (08:36 +0200)]
Fix compilation of some qquick auto tests
Inline functions here use std::numeric_limits, so include the header
file.
Change-Id: Ib84f41b65ee965c3e0868f85643491feecceade5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Thu, 9 May 2013 12:36:32 +0000 (14:36 +0200)]
Port the of qml locale getters to V4 accessors
Added support for getters/setters to the class generator
as well as a simple help template for calling the member
function getters.
Change-Id: I3bb287a53d9f249837fa2c513d4886873476ad95
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 8 May 2013 18:26:04 +0000 (20:26 +0200)]
Fix unsafe casting to target thisobject in class generator
We must also check if the asFoo() on the managed object succeeds
before calling the method.
Change-Id: I26ed56fec044b54221ca44e7789a2e9d0acec9ec
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 8 May 2013 18:11:34 +0000 (20:11 +0200)]
Ported over a few more locale functions
This code is becoming much simpler :)
Change-Id: Icd31bedd13f4a8fce145992b2a7706594ac809bf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 8 May 2013 14:48:09 +0000 (16:48 +0200)]
Begin implement C++ style wrappers in QQmlLocale
The locale.currencySymbol function is converted into a member function
of the wrapper. For the time of the transition the prototype chain is
modified to be obj -> v8 proto template -> v4classgen generated proto
Change-Id: I72913e9d284a2a3678b23c7d7ce27fbb3447f1fb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Wed, 8 May 2013 14:22:39 +0000 (16:22 +0200)]
Cleanup v8 dependencies from QQmlV8Function
... and rename it to QQmlV4Function
Change-Id: Iad72347babf62691e26306877d4f229fda127eb7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 8 May 2013 13:56:03 +0000 (15:56 +0200)]
Remove v8 dependencies from QQmlV4Handle
Change-Id: I87d2183738ec7cfeea846a28f2b9aed79a233f68
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Wed, 8 May 2013 13:55:44 +0000 (15:55 +0200)]
Replace V8 resource in QQmlLocale with managed subclass
This is more lightweight and is the next step towards moving the
class binding away from V8.
Change-Id: Ic9c5901d3a6ef2f665ab22df9d2fcbb0698120eb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Wed, 8 May 2013 07:21:57 +0000 (09:21 +0200)]
Converted remaining regular QQmlLocale functions to QV4
What remains are property accessors
Change-Id: Iadc5168b7759dfd6d4fc0e8f28e286ddd684bc7f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Wed, 8 May 2013 13:21:42 +0000 (15:21 +0200)]
Fix PersistentValue::isEmpty()
A PersistentValue can have a d pointer and still be
empty (because it contains an empty value).
This fixes an assertion when destructing the QML engine
and qmlscene finally doesn't crash on exit anymore :)
Change-Id: Idce2bb42f562526af8ec09d9062cce7ac825a8dc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 8 May 2013 13:04:25 +0000 (15:04 +0200)]
Remove the remaining traces of v8::persistent
Change-Id: Id542914c64558c1eba30a300cb10606fa499e594
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 8 May 2013 12:36:48 +0000 (14:36 +0200)]
Remove v8::persistent usage from particles
Change-Id: I69cd4ccf51c40e2ee63f024a7ccc2d8b35b14ae4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 8 May 2013 12:30:24 +0000 (14:30 +0200)]
Remove v8::persistent usage from local storage
Change-Id: Ifda1ad5d4cfab86e9ced9e415d39ee392c676882
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 8 May 2013 12:25:40 +0000 (14:25 +0200)]
Remove v8::Persistent usage from qquickcanvas
Change-Id: If714583818f894e8ac839cd35cd475deff00eafb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 8 May 2013 12:24:30 +0000 (14:24 +0200)]
Move the QV4::Function out of qv4functionobject_p.h
QV4::Function has dependencies onto wtf. Moving it into it's
own header allows including qv4functionobject from other modules.
Change-Id: Ie6947085026a26ea250c232cc3b219737d009f5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 8 May 2013 12:02:11 +0000 (14:02 +0200)]
Remove v8::Persistent usage from qquickloader
Change-Id: I0a7ffdc3ed159ec8f506cadc73ba8ae77c003a41
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>