platform/upstream/qtdeclarative.git
11 years agoFix v8::Persistent
Lars Knoll [Sat, 9 Mar 2013 22:18:25 +0000 (23:18 +0100)]
Fix v8::Persistent

Implement it in a similar way as PersistentValue

Change-Id: If4adba61a8bfedce657f07ee24662c3b13384fd9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd exception handling support to the v8 API
Lars Knoll [Fri, 8 Mar 2013 21:52:55 +0000 (22:52 +0100)]
Add exception handling support to the v8 API

Not all calls are yet propertly protected by try/catch
statements, but it should work in principle.

Change-Id: I5ddaf433b0a454106dc2743fe2ccfc5822fb3926
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement more missing bits & pieces including a fake "QML mode"
Simon Hausmann [Fri, 8 Mar 2013 14:48:50 +0000 (15:48 +0100)]
Implement more missing bits & pieces including a fake "QML mode"

Change-Id: Ifbbc5004ada03b6efa7a9884938ff5d59220c5fb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix name lookup for named function expressions
Simon Hausmann [Fri, 8 Mar 2013 13:11:42 +0000 (14:11 +0100)]
Fix name lookup for named function expressions

Change-Id: Ia36b2b5c5b40475450fe369c7d6cb5e3965a4488
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented a whole more API...
Simon Hausmann [Fri, 8 Mar 2013 12:02:26 +0000 (13:02 +0100)]
Implemented a whole more API...

Change-Id: Ica73c21e58b406abd6310c59ec0f541ae2cc9155
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented invocation callback on FunctionTemplate
Simon Hausmann [Fri, 8 Mar 2013 10:47:26 +0000 (11:47 +0100)]
Implemented invocation callback on FunctionTemplate

Change-Id: I718f10f28a053eda78e086407183706e8fad317b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented v8::Arguments
Simon Hausmann [Fri, 8 Mar 2013 09:53:41 +0000 (10:53 +0100)]
Implemented v8::Arguments

Change-Id: I02f7072c13c319b1bdf77471360308bd0d0d3d2a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented Template::Set
Simon Hausmann [Fri, 8 Mar 2013 09:47:18 +0000 (10:47 +0100)]
Implemented Template::Set

Change-Id: I237fdf6acdfad9805306e4fc5f437457efa8eb7f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMinor API change for easier implementation
Simon Hausmann [Fri, 8 Mar 2013 09:41:38 +0000 (10:41 +0100)]
Minor API change for easier implementation

Change v8::Template::Set to take Handle<Value> instead of Handle<Data>
and remove incorrect Data inheritance from Value

Change-Id: Iaa71d4437c9913c7a79bc5322f05dafce6e3c89c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoVarious fixes
Simon Hausmann [Fri, 8 Mar 2013 09:34:19 +0000 (10:34 +0100)]
Various fixes

* Make V4V8 object a template in preparation for future changes
* Fix handle <> local conversions
* Implemented v8::External

Change-Id: I27b57c767a31393e1b8b05f3150c16158b178f0d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemaining implementation of ObjectTemplate
Simon Hausmann [Thu, 7 Mar 2013 15:35:46 +0000 (16:35 +0100)]
Remaining implementation of ObjectTemplate

Change-Id: I299b252346b2c5696fb11eb7b8dc527d94dbaf3b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFirst implementation of ObjectTemplate::SetAccessor
Simon Hausmann [Thu, 7 Mar 2013 13:59:25 +0000 (14:59 +0100)]
First implementation of ObjectTemplate::SetAccessor

Change-Id: Iee403e3b542423726f95a0b516a4e2d5938ea2ed
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix use/def for exception var.
Erik Verbruggen [Fri, 8 Mar 2013 11:17:33 +0000 (12:17 +0100)]
Fix use/def for exception var.

A try defines the exception var, because it is the first time it is
mentioned. It might also use it, but that could be seen as
an initialization.

Change-Id: Ibacd12edc02f99c8049003655373122d7916978b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix liveness analysis.
Erik Verbruggen [Fri, 8 Mar 2013 09:44:04 +0000 (10:44 +0100)]
Fix liveness analysis.

When a move has a temp that is either a scoped local or a formal,
then instead of "returning" from the visit, the source expr still has
to be visited. It might contain a use.

Change-Id: Ibd54fdc3488b1348e63ecd5a0c1b1036ae111c8a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix MSVC build.
Erik Verbruggen [Fri, 8 Mar 2013 08:57:33 +0000 (09:57 +0100)]
Fix MSVC build.

Suppress error for methods that have to return a value, but are marked
as Q_UNIMPLEMENTED by adding a Q_UNREACHABLE.

Change-Id: I2f7d3027fd5a8949b7c330d8cab3f3f095e11450
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCompile fixes for MSVC.
Erik Verbruggen [Fri, 8 Mar 2013 08:56:44 +0000 (09:56 +0100)]
Compile fixes for MSVC.

When a class is dllexported, the methods cannot also be marked as such.
They are exported automatically. The error message is:

d:\dev\v4vm\src\v4\qv4v8.h(1525) : error C2487: 'New' : member of dll interface class may not be declared with dll interface

Change-Id: Ib44ee401e35c723b20c8c9f2dceab02736c77a3f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago"Fix" llvm build.
Erik Verbruggen [Thu, 7 Mar 2013 16:00:17 +0000 (17:00 +0100)]
"Fix" llvm build.

In a way that it the compiler doesn't complain anymore.

Change-Id: I877b1a051b2ffcbd63a04cf219733b2b21cb9128
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix exception handling on Mac OS X
Simon Hausmann [Thu, 7 Mar 2013 11:53:34 +0000 (12:53 +0100)]
Fix exception handling on Mac OS X

Re-introduce the old register_frame and deregister_frame approach
on Mac OS X until we have something faster.

Change-Id: Idf524857c91175535184b29c11265c7d26f064a7
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoSimple but effective dead-assignment removal.
Erik Verbruggen [Wed, 6 Mar 2013 10:48:05 +0000 (11:48 +0100)]
Simple but effective dead-assignment removal.

At the moment we only generate a dead assignment when initializing the
return value to undefined (and subsequently assign to it). With upcoming
patches, esp. constant propagation, there will be more dead assignments.

Change-Id: I423ed77fb0693ca6c2855d1e0200e6a205d01f4f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix String::get and start using it
Lars Knoll [Thu, 7 Mar 2013 12:41:21 +0000 (13:41 +0100)]
Fix String::get and start using it

Change-Id: I80cc7533effad2a1fa3fe60c2596ed9d27e843c9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAnd use the vtbl methods for delete as well.
Lars Knoll [Thu, 7 Mar 2013 12:14:34 +0000 (13:14 +0100)]
And use the vtbl methods for delete as well.

Change-Id: I7632382ccb8aa2f8ae733f638bb42eddbc739c6a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement Object::query/queryIndexed
Lars Knoll [Thu, 7 Mar 2013 11:57:49 +0000 (12:57 +0100)]
Implement Object::query/queryIndexed

Change-Id: I7feea63d0e9eb7c1e633536aea4c4a4dbd03b462
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup put and properly implement it for strings
Lars Knoll [Thu, 7 Mar 2013 11:55:02 +0000 (12:55 +0100)]
Cleanup put and properly implement it for strings

Change-Id: I10dda09c8a087bc7ef34c0315c698e08c35ec28d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix build with clang
Simon Hausmann [Thu, 7 Mar 2013 07:40:36 +0000 (08:40 +0100)]
Fix build with clang

It suggests a template keyword here to make it clear that As() is template dependent

Change-Id: I0a228ad51b7a7a09e3774465f7118e3e6e247e93
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFirst part of moving get/put etc. into the Managed vtbl.
Lars Knoll [Thu, 7 Mar 2013 11:25:59 +0000 (12:25 +0100)]
First part of moving get/put etc. into the Managed vtbl.

Change-Id: I6fe14b02205901dbffa25c6c1b4883fb99586417
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake Object::hasProperty() inline
Lars Knoll [Thu, 7 Mar 2013 09:57:48 +0000 (10:57 +0100)]
Make Object::hasProperty() inline

Simply call getPropertyDescriptor instead

Change-Id: I9e156a45dd10bf250fa156820ec2f3d5bbe80bbc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement v8::AccessorInfo
Lars Knoll [Thu, 7 Mar 2013 09:31:29 +0000 (10:31 +0100)]
Implement v8::AccessorInfo

Change-Id: I72598ad9941b35e7268f6a90c26c91f37593bed4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove v8 internal namespace
Lars Knoll [Thu, 7 Mar 2013 09:26:03 +0000 (10:26 +0100)]
Remove v8 internal namespace

Change-Id: I78d0ddb1b5b790cb74cfa2d115e7dd47ebb30ab1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoA few more API methods implemented
Lars Knoll [Wed, 6 Mar 2013 21:21:26 +0000 (22:21 +0100)]
A few more API methods implemented

Change-Id: I4168ad5bb934a74e6957969417fdcf491a7374a1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMore v8 API
Lars Knoll [Wed, 6 Mar 2013 20:43:58 +0000 (21:43 +0100)]
More v8 API

Change-Id: If62d4a0dbe8f59d62bef2cce0bb9002be47957bc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement more of the v8 API
Lars Knoll [Wed, 6 Mar 2013 20:28:03 +0000 (21:28 +0100)]
Implement more of the v8 API

Change-Id: Ibc8feb95b9473712105cf79e98fc0cef8c3b0fe7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix slowness in unwind table registration
Simon Hausmann [Wed, 6 Mar 2013 19:04:47 +0000 (20:04 +0100)]
Fix slowness in unwind table registration

__register_frame and __deregister_frame are very slow when called
with many functions many times, like in some of the tests that use
a lot of eval(). Change the approach to interposing a function symbol
that is called in libgcc whenever a PC -> FDE lookup is required.

This also changes the code to create the unwind info on-demand.

Change-Id: I99dfcc921b087831ad00f79bad9e7bcfb0cc8c33
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMake sure that the value stored in the Exception object is not garbage collected
Simon Hausmann [Wed, 6 Mar 2013 19:04:43 +0000 (20:04 +0100)]
Make sure that the value stored in the Exception object is not garbage collected

Change-Id: I7e3c4e0d1d9a23a54922a3254962ac2dc42bf67b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoGet rid of 'Value ExecutionEngine::exception' member
Simon Hausmann [Wed, 6 Mar 2013 19:04:39 +0000 (20:04 +0100)]
Get rid of 'Value ExecutionEngine::exception' member

Instead the JS exception value is now part of the C++ Exception object.

This also allows getting rid of some run-time functions.

Change-Id: I43ff773cacd5e925ba96601f3633ccf3b62273be
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoGet rid of the builtin_get_exception call in the IR
Simon Hausmann [Wed, 6 Mar 2013 19:04:36 +0000 (20:04 +0100)]
Get rid of the builtin_get_exception call in the IR

Instead allocate a temp to hold the exception to rethrow and pass the address
of that to the TRY statement. Then it can be set in the run-time.

Change-Id: Ic15869e8e5ab5119b26f98fc45dbdb1a2ad9d21e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup: Get rid of calls to builtin_{push,pop}_catch_scope in the IR
Simon Hausmann [Wed, 6 Mar 2013 19:04:31 +0000 (20:04 +0100)]
Cleanup: Get rid of calls to builtin_{push,pop}_catch_scope in the IR

These calls aren't needed anymore and can easily be done on the run-time level
instead right before and after calling the catch block.

Change-Id: I445361688782d12269764578e83ebb21ae184190
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplement a few mere methods in the v8 API
Lars Knoll [Wed, 6 Mar 2013 17:12:39 +0000 (18:12 +0100)]
Implement a few mere methods in the v8 API

Change-Id: Ia95866060e27c4311ce819c7aec04f328fa8eca1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoOptimize exception throwing
Simon Hausmann [Wed, 6 Mar 2013 19:04:21 +0000 (20:04 +0100)]
Optimize exception throwing

Introduce a try statement in the IR that allows the back-end to jump to the try
and catch blocks directly instead of having a conditional jump for each entry.

For the case where we have no catch but only try { ... } finally { ... } we
create a synthetic catch block that sets hasException to true, to ensure that
when an exception is thrown during try we execute finally and then rethrow the
exception.

Change-Id: If4be5421f9731522beab80e843283b517d4aa41c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplement most of the New() methods in the v8 API
Lars Knoll [Wed, 6 Mar 2013 13:54:30 +0000 (14:54 +0100)]
Implement most of the New() methods in the v8 API

Change-Id: Icf88354656ae12ae38a24eaebfd1b1d22e755c52
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement external object comparison
Lars Knoll [Wed, 6 Mar 2013 13:01:07 +0000 (14:01 +0100)]
Implement external object comparison

Change-Id: Ieec34aa1b410766510919a99c5964c288b4addc1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement the various v8 Cast methods
Lars Knoll [Wed, 6 Mar 2013 11:31:46 +0000 (12:31 +0100)]
Implement the various v8 Cast methods

Change-Id: I056fbcb229ef3b487e28e14c6d58007aeb7ba8a0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a bug in Persistent::New
Lars Knoll [Wed, 6 Mar 2013 10:19:02 +0000 (11:19 +0100)]
Fix a bug in Persistent::New

Change-Id: Iac13aa897e64bca6b50ea90bd5e2804e2212e008
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanups
Lars Knoll [Wed, 6 Mar 2013 10:18:56 +0000 (11:18 +0100)]
Cleanups

Change-Id: Ifbe085eea9f1f605af0b802f299f82f24a14e9b1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd stubs for all the methods in the v8 API
Lars Knoll [Wed, 6 Mar 2013 08:55:15 +0000 (09:55 +0100)]
Add stubs for all the methods in the v8 API

Qt Qml and Qt Quick now link against V4 :)

Change-Id: I8320875bdeab91d800fbf530b0d57a67dc872188
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSimplify conversion between VM::Value and V8::Value
Lars Knoll [Tue, 5 Mar 2013 21:41:49 +0000 (22:41 +0100)]
Simplify conversion between VM::Value and V8::Value

Also implement the Exception class and ThrowException.

Change-Id: Ib9ca804cb82288d9da8b74f6cd3c38ecd61dbc1b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement v8::Undefined/Null/True/False
Lars Knoll [Tue, 5 Mar 2013 21:21:40 +0000 (22:21 +0100)]
Implement v8::Undefined/Null/True/False

Change-Id: I831e3b5e53d06edcbce57d37fc43995154b26305
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove API not used by Qml
Lars Knoll [Tue, 5 Mar 2013 19:28:06 +0000 (20:28 +0100)]
Remove API not used by Qml

Change-Id: Ibd202369f320c2db501d7a900941f0734326db7d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake a V8 hello world actually work.
Lars Knoll [Tue, 5 Mar 2013 16:13:15 +0000 (17:13 +0100)]
Make a V8 hello world actually work.

Change-Id: Ia80004d2104e72e7c871be3582cab26ca9e493bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement v8::Script::Run()
Simon Hausmann [Tue, 5 Mar 2013 15:37:08 +0000 (16:37 +0100)]
Implement v8::Script::Run()

Change-Id: I7456e0a5e389216aac84d3ca9d66cc1e7f688008
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMove function execution into a little ExecutionEngine::run helper function
Simon Hausmann [Tue, 5 Mar 2013 15:11:22 +0000 (16:11 +0100)]
Move function execution into a little ExecutionEngine::run helper function

This will allow for re-use from the v8 wrapper API.

Change-Id: I2330432dad43d7fd7af6147e96a0cbbb340cd917
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoInitial v8'ish API wrappers for QML integration
Simon Hausmann [Fri, 15 Feb 2013 13:59:34 +0000 (14:59 +0100)]
Initial v8'ish API wrappers for QML integration

The goal is for these wrappers to exist only for a limited period
of time until all of QML is ported to use pure v4vm.

Change-Id: I4568420a2116420ae6f45bc5eb1e3d464a7c4cc3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd support for associating external resources with garbage collected JS objects
Simon Hausmann [Tue, 5 Mar 2013 12:12:37 +0000 (13:12 +0100)]
Add support for associating external resources with garbage collected JS objects

Change-Id: Ib09096b684997ac77902e3cc50458092e2f569a2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove unused wtf inclusion from qv4managed.h
Simon Hausmann [Fri, 15 Feb 2013 13:58:01 +0000 (14:58 +0100)]
Remove unused wtf inclusion from qv4managed.h

This allows including this header file outside of the module, i.e. in
a qml integration.

Change-Id: I0aed18d76dfacfdf5e615cc12f3d2904fcef9091
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRename qv4ir_p.h to qv4jsir_p.h to avoid conflict with qtdeclarative
Simon Hausmann [Tue, 5 Mar 2013 11:49:35 +0000 (12:49 +0100)]
Rename qv4ir_p.h to qv4jsir_p.h to avoid conflict with qtdeclarative

Change-Id: I0e222141232f191e47950318f8262144de486703
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup unwind handler
Simon Hausmann [Mon, 4 Mar 2013 14:30:40 +0000 (15:30 +0100)]
Cleanup unwind handler

Store the platform specific unwind info (CIE/FDE on Linux/Mac x86/x86-64) directly
inside the VM::Function and therefore make all the functions of UnwindHelper static.

Also calculate the function size correctly.

Change-Id: If6a6b92a250044c6799218ef3506f34d630674c7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup: Rename __builtin_delete_exception_handler
Simon Hausmann [Mon, 4 Mar 2013 11:14:54 +0000 (12:14 +0100)]
Cleanup: Rename __builtin_delete_exception_handler

This IR builtin function no more deletes an exception handler, instead it tells
the back-end to stop try catching exceptions. In MASM and Moth this is
implemented by returning from the nested function call initiated by the try.

Change-Id: Ia8336c998817a73aeed03f4a05d4b592cc9143ad
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup: Get rid of manual unwind stack
Simon Hausmann [Mon, 4 Mar 2013 11:12:21 +0000 (12:12 +0100)]
Cleanup: Get rid of manual unwind stack

Instead of doing the ExecutionContext unwinding at the time of throw, do it
at the time of catch, conveniently through an accept() method of the Exception
object. That allows us to get rid of the separate handler registration stack.

The only tricky part are that some execution contexts are allocated on the stack.
When exceptions are thrown through that, we have to catch, unwinding up until that
point (or rather the parent of the stack allocated context that's going to be
deleted) and then simply rethrow.

This patch also gets rid of the __builtin_delete_exception_handler. The next patch
will rename the remainder to what it really does now.

Change-Id: I00bb113b3a2fe24f7054c03fdfb8fed5cc1258b1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix IR control flow after a throw statement.
Erik Verbruggen [Mon, 4 Mar 2013 10:17:55 +0000 (11:17 +0100)]
Fix IR control flow after a throw statement.

A throw statement in a try block will now jump to the catch/finally, and
a throw statement outside will jump to the exit block. This follows what
happens during run-time, which fixes liveness issues with the
return-temp of calls to builtin_create_exception_handler.

Change-Id: I70f14f03f0431d3fc962c22984d4f486a1d81c7d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix off-by-one in assertion for argc/args in calls.
Erik Verbruggen [Mon, 4 Mar 2013 08:32:16 +0000 (09:32 +0100)]
Fix off-by-one in assertion for argc/args in calls.

When a call is done with 1 argument, it is not copied into the outgoing
args array, but passed by-reference. So when it happens to be the last
element in the stack frame, then args + argc == stackSize (because argc
is 1).

Change-Id: Idb769c95e9066c24a9d93cdcc24e13d3a9acc995
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoOptimise array construction
Lars Knoll [Mon, 4 Mar 2013 10:48:49 +0000 (11:48 +0100)]
Optimise array construction

Cache the InternalClass for ArrayObject and
use it directly in the constructor.

Change-Id: I17346045cd14852c400c7f3886414953e4dff869
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSmall optimisation for string concatenation
Lars Knoll [Mon, 4 Mar 2013 10:47:59 +0000 (11:47 +0100)]
Small optimisation for string concatenation

The real fix will require a string class that can hold
several substrings.

Change-Id: I0e23f248048781b0f623d01087397afaeefcc97a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDo not re-use temp for both parameter and result.
Erik Verbruggen [Fri, 1 Mar 2013 13:34:56 +0000 (14:34 +0100)]
Do not re-use temp for both parameter and result.

Change-Id: Iffd50459bc55960ac5cef1e246cd3d2664565a8a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMoved isNegative(double) into another header.
Erik Verbruggen [Fri, 1 Mar 2013 13:28:46 +0000 (14:28 +0100)]
Moved isNegative(double) into another header.

So it can be used in codegen.

Change-Id: Iba1294a58cf6785eb9c37b34c39c4ec0281cd694
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove shared subexpressions from the function's IR code.
Erik Verbruggen [Fri, 1 Mar 2013 13:26:35 +0000 (14:26 +0100)]
Remove shared subexpressions from the function's IR code.

Change-Id: I4502eb9c86aba14142f1ae15f1ba560255a2cb6a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix warning about unused parameter.
Erik Verbruggen [Mon, 4 Mar 2013 08:05:38 +0000 (09:05 +0100)]
Fix warning about unused parameter.

Change-Id: Ia94e1ac073dc16a0eb9841677343dbaddad923ae
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplement JavaScript exceptions using C++ exceptions
Simon Hausmann [Fri, 1 Mar 2013 16:04:21 +0000 (17:04 +0100)]
Implement JavaScript exceptions using C++ exceptions

Instead of registering catch handlers with setjmp and throwing JS exceptions
with longjmp, they are now thrown and caught as C++ exceptions. This allows for
tight interoperability between C++ and JS in the future and allows for clear
semantics with regards to cleaning up memory in the engine when throwing
exceptions. (destructors are guaranteed to be called, unlike with
setjmp/longjmp).

The recent unwind table additions allow for the exceptions to be thrown through
JIT generated code.

Catching the exception is done by re-using the existing IR semantics where the
beginning of a try block is marked by registering an exception handler.
Execution after the registration continues conditionally, based on the return
value of builtin_create_exception_handler. A return value of is 0 the try
block(s) are executed. If an exception is thrown during that time, execution
resumes at the point where builtin_create_exception_handler returns, but with a
return value of 1. If an exception is thrown within the catch handler, the
execution resumes again at the same point, but the inCatch IR variable will
guide execution straight to the finally block(s), which calls
delete_exception_handler.

In the JIT as well as the interpreter this is implemented by entering a C++
code section that contains a C++ try {} catch {} block, in which the calling
function is called again and continues right at the next instruction (or the
interpreter loop is recursively entered). An exception will throw us out of
that scope and back into the try {} catch {} wrapper, which can call again
into the calling function.

The IR guarantees that delete_exception_handler is always called, regardless of
how the try or catch blocks are terminated. That is where in the JIT and
interpreter we return from the nested function call and return back into the
original stack frame, effectively unregistering the catch handler.

Further cleanups with regards to the naming and the exception handler stack
will come in subsequent patches, this is merely the minimal patch set to
change to the new mechanism.

This patch set breaks ARM until ARM exception handler tables are implemented.

The interpreter changes are based on a patchset from Erik
from https://codereview.qt-project.org/#change,45750

Change-Id: I543f2bd37b2186f7e48ffcab177d57b5ce932a0c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix builtin_define_property
Lars Knoll [Sat, 2 Mar 2013 23:50:33 +0000 (00:50 +0100)]
Fix builtin_define_property

Commit 72c1fe5822aa65f4a3f70f78e058fb7e3154a4b6 broke
object literals that uses numbers as keys (e.g.
{ "2": "bla" }. This fixes it while keeping the faster
code path.

Change-Id: I0e89eb6e03da6a2e55d833ac0ad956f35e597297
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix crashes on ia32 with array literals
Simon Hausmann [Sun, 3 Mar 2013 09:20:05 +0000 (10:20 +0100)]
Fix crashes on ia32 with array literals

prepareVariableArguments uses copyValue to copy/initialize the
arguments for a variable arguments call. Previously it called
copyValue with only temps as source, which on ia32 is implemented
as
    (1) load temp from memory into FP reg
    (2) store FP reg into destination memory location

After Gerrit change Id5757dd7a910be13db4958da7e449172ec1b04ae the
source of copyValue can now also be an IR::Expr and hence a constant
value. On ia32 it is unfortunately not possible to load a constant
floating point value into an FP reg right away. However in this
very situation it's sufficient to store the correct VM::Value in
the destination memory address right away. This is now done using
a template specialization of copyValue.

The old code compiled because we accidentally picked the
loadDouble(const void *address) overload of MASM, with address
pointing to the IR::Expr :)

Change-Id: Ie43f9be432cfcb844cc5e706e63bd3e91e857bac
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMore efficient initialization of array literals
Lars Knoll [Fri, 1 Mar 2013 15:47:07 +0000 (16:47 +0100)]
More efficient initialization of array literals

Initialize array literals in one go instead of going
through repeated calls to the runtime for each value.

This gives quite a nice speed improvement on the splay
tree benchmark.

Change-Id: Id5757dd7a910be13db4958da7e449172ec1b04ae
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSkip some really slow tests
Lars Knoll [Sat, 2 Mar 2013 23:54:48 +0000 (00:54 +0100)]
Skip some really slow tests

The test cases themself finish in ~10-20 secs. Unfortunately
__deregister_frame seems to be extremely slow if you have many
functions (as is the case in these tests). It takes many minutes
to then clean up the engine and deregister all frames.

Change-Id: Idaa829f64c91d324e650b1d22b94dec6becad3d4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMinor optimisation: Avoid some function calls
Lars Knoll [Fri, 1 Mar 2013 14:02:46 +0000 (15:02 +0100)]
Minor optimisation: Avoid some function calls

Change-Id: Ie30b95af01c6623262fbbd93f51c115262531fe8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix crashes on ia32
Simon Hausmann [Fri, 1 Mar 2013 22:16:03 +0000 (23:16 +0100)]
Fix crashes on ia32

sizeof(VM::String) != sizeof(VM::String*) :)

Change-Id: I1e59de64ad5f73e478519c618f28806c151d94f5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented DaylightSavingTA for Windows.
Erik Verbruggen [Fri, 1 Mar 2013 14:09:17 +0000 (15:09 +0100)]
Implemented DaylightSavingTA for Windows.

Change-Id: I5421c325a307e11837fd8135a6306b519fe29ad4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSave some overhead in builtin_define_property
Lars Knoll [Fri, 1 Mar 2013 13:03:04 +0000 (14:03 +0100)]
Save some overhead in builtin_define_property

Change-Id: I632b8a5e46bc8119789acde6362cfd8e86ce901b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDon't spend all the time in gc in some cases
Lars Knoll [Fri, 1 Mar 2013 12:34:52 +0000 (13:34 +0100)]
Don't spend all the time in gc in some cases

Some test cases actually caused the GC to get triggered
too often. This could happen if a GC run would collect up
very few freed objects. In that case the next GC run would
get triggered after these few objects where used up.

The commit adds a count to make sure we don't trigger GC too
early.

Change-Id: Ia51056e33869b072e801c0be02807a5d40ef97c9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years ago[masm] Fix build on ARM
Simon Hausmann [Wed, 27 Feb 2013 19:14:00 +0000 (20:14 +0100)]
[masm] Fix build on ARM

Allocate a LocalsRegister here, too

Change-Id: I1f05f52948616e4979beb8935f6b4e46791a6937
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoTool to generate FDE and CIE tables using libdwarf
Simon Hausmann [Fri, 22 Feb 2013 16:15:58 +0000 (17:15 +0100)]
Tool to generate FDE and CIE tables using libdwarf

This makes it easier to generate the right magic bits and bytes
across different architectures.

Change-Id: I83cf8f348f4ea92febfe463e1ffd627808e1bb44
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoEnable DW2 unwind helper on MacOS.
Erik Verbruggen [Wed, 27 Feb 2013 14:27:41 +0000 (15:27 +0100)]
Enable DW2 unwind helper on MacOS.

Change-Id: I1c1671d0b3953ce2e8f57bbf68023731470e3da1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix null-unwind helper compilation.
Erik Verbruggen [Wed, 27 Feb 2013 14:27:20 +0000 (15:27 +0100)]
Fix null-unwind helper compilation.

Change-Id: I82af0ae373157d412b138334c8d80fa6e17591df
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDo not generate udis86 files when udis86 is disabled.
Erik Verbruggen [Wed, 27 Feb 2013 12:50:17 +0000 (13:50 +0100)]
Do not generate udis86 files when udis86 is disabled.

Change-Id: Iaed45c949d29ac81a60adec3437f2790d23a58d5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd class to help the platform unwind JIT code.
Erik Verbruggen [Thu, 21 Feb 2013 13:30:35 +0000 (14:30 +0100)]
Add class to help the platform unwind JIT code.

Currently only x86_64 and x86 is supported.

Change-Id: I80fe60543b71e7073a0666d5ebb10144a75a488c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix warning about unused parameter.
Erik Verbruggen [Wed, 27 Feb 2013 12:07:21 +0000 (13:07 +0100)]
Fix warning about unused parameter.

Change-Id: Ic8f95211b29fd5b3f4ffa4bc931fc15f004b30b1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd overloaded destructor to suppress warning on MSVC.
Erik Verbruggen [Wed, 27 Feb 2013 12:07:00 +0000 (13:07 +0100)]
Add overloaded destructor to suppress warning on MSVC.

main.cpp(357) : warning C4291: 'void *QQmlJS::VM::Managed::operator new(size_t,QQmlJS::VM::MemoryManager *)' : no matching operator delete found; memory will not be freed if initialization throws an exception
        d:\dev\v4vm\src\v4\qv4managed.h(112) : see declaration of 'QQmlJS::VM::Managed::operator new'

Change-Id: Idd7f54f257ae93fdf04ecbf3f938e3b2d981bf89
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoApparently MSVC needs EH enabled for SJLJ.
Erik Verbruggen [Wed, 27 Feb 2013 11:15:39 +0000 (12:15 +0100)]
Apparently MSVC needs EH enabled for SJLJ.

Change-Id: Ieab8157816237151dcfcf3eccfb3de177c4ad221
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoIgnore by-produces of builds on Windows.
Erik Verbruggen [Wed, 27 Feb 2013 11:22:34 +0000 (12:22 +0100)]
Ignore by-produces of builds on Windows.

Change-Id: I0626a2ee0f29866b8fa4b37958d1288f50a476f6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoReplace STL function that MS deprecated.
Erik Verbruggen [Wed, 27 Feb 2013 11:19:53 +0000 (12:19 +0100)]
Replace STL function that MS deprecated.

Change-Id: I0577d2ae42a7593e4bc886345c97072523aacc48
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMark throwing functions as no-return.
Erik Verbruggen [Wed, 27 Feb 2013 11:18:51 +0000 (12:18 +0100)]
Mark throwing functions as no-return.

Now the compiler cannot only optimise for this, but also stop complaining
about callers not returning any value.

Change-Id: I71d98721f70849178613096408e959d7e24dca8a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd ToS retrieval and register saving for MSVC.
Erik Verbruggen [Wed, 27 Feb 2013 11:17:38 +0000 (12:17 +0100)]
Add ToS retrieval and register saving for MSVC.

No __asm no cry.

Change-Id: I95f4df5d5ba9d04aa0bcc8d0b0b5901d51533d16
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix declaration linkage type to be the same as the defenition.
Erik Verbruggen [Wed, 27 Feb 2013 11:16:19 +0000 (12:16 +0100)]
Fix declaration linkage type to be the same as the defenition.

Change-Id: I86c96bd4076b60b896803ee1c53c2ecf9aa86e1f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix crypto.js on arm
Simon Hausmann [Mon, 18 Feb 2013 21:30:42 +0000 (22:30 +0100)]
Fix crypto.js on arm

Due to our large amount of temps we also end up creating large stack frames and
thus add large constants to the stack pointer. That affects the encoding of the
immediates and MacroAssemblerARMv7 ASSERTs out for values that require
encoding.

This is unlikely to get fixed upstream and it's infact impossible to create a
testcase with JSC JIT due to the fact that it barely uses the stack frame.
I'd rather not patch the upstream file as it is a condition hard to find and
a patch easy to drop by accident. Instead this patch adds a simple workaround
that comes are low cost: Just load the immediate into a register and do the
addition.

Change-Id: Ia551a15d2f5f6243b295a9bfd19df778467189ec
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Prepare local stack frame for new upcoming exception handling
Simon Hausmann [Tue, 26 Feb 2013 11:58:16 +0000 (12:58 +0100)]
[masm] Prepare local stack frame for new upcoming exception handling

Access local temps through a newly allocated LocalsRegister instead of the
regular frame pointer register. In the new exception handling we're going to
re-enter our function in the middle and want to access the same local temps,
but we can't do that through the stack frame pointer then, because that one
will _have_ to continue to point to the local stack frame in order for
unwinding to work properly.

Also the callee saved registers are now stored right below the stack
frame pointer instead of at the bottom of the stack. This way they
can be described easily in the unwind info as always relative to the
canonical frame address.

Change-Id: I53ef6291d99396577a72ceb9246f7ca3d99e5137
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build with clang
Simon Hausmann [Tue, 26 Feb 2013 11:49:38 +0000 (12:49 +0100)]
Fix build with clang

It tells us quite explicitly how it wants a default constructor
for VoidType :)

Change-Id: I854370c869f179da7f842fbf675e05678285630d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix failing assertion when running the test suite
Simon Hausmann [Tue, 26 Feb 2013 11:45:47 +0000 (12:45 +0100)]
Fix failing assertion when running the test suite

The test suite does things like "1 instanceof 1" and expects a
type error to be thrown. Therefore we should not assert(!"unreachable")
when instanceof is called with a numberic constant but just fall back
to the run-time implementation, which does the right thing.

Change-Id: Iced93e679d56f4491d38c50b669e12dd160c220c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Implement sign text using cross-arch masm api
Simon Hausmann [Mon, 25 Feb 2013 09:13:46 +0000 (10:13 +0100)]
[masm] Implement sign text using cross-arch masm api

Use branchTest32 to implement the test for the sign bit in right
shift operations.

Change-Id: I07b3ead4d32761ee3d5f529259be5b5987b7ec5a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoSome smaller optimisations
Lars Knoll [Sun, 24 Feb 2013 21:31:58 +0000 (22:31 +0100)]
Some smaller optimisations

Ideally these checks should get inlined in the generated
assembly.

Change-Id: I4f63f7235a7d3bbdf8413df9f7d674104ff95b07
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSmall cleanup
Lars Knoll [Sat, 16 Feb 2013 22:27:07 +0000 (23:27 +0100)]
Small cleanup

Change-Id: I1733ad823ef00114b4544bb0bdf40fede4eea073
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix the sameValue algorithm when comparing ints to doubles.
Lars Knoll [Sat, 16 Feb 2013 22:26:16 +0000 (23:26 +0100)]
Fix the sameValue algorithm when comparing ints to doubles.

Change-Id: I96fb3e8c47a336ef4e0e3cab44e6dfd4d5aff70a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix inline assembly version of ushr
Lars Knoll [Sat, 16 Feb 2013 19:44:53 +0000 (20:44 +0100)]
Fix inline assembly version of ushr

-1 >> 0 should return UINT_MAX, as the result is an
unsigned int according to spec. The only way the result
of the inline shr operation can be signed is by shifting
0 bytes. But the easiest implementation is to test the
result for signed-ness and then fall back to the slow
implementation.

Change-Id: Ic4614006d06cf01376ef95b6f23ca2c7216a2812
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoStore 0 constants as integers, not as doubles
Lars Knoll [Sat, 16 Feb 2013 12:19:36 +0000 (13:19 +0100)]
Store 0 constants as integers, not as doubles

Change-Id: Ibb49d1fd8221d65262b1c18b9833233ef97cee8e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix use of CPU(X86_64) to determine 64-bit architecture
Simon Hausmann [Thu, 21 Feb 2013 11:07:17 +0000 (12:07 +0100)]
Fix use of CPU(X86_64) to determine 64-bit architecture

Use QT_POINTER_SIZE == 8 instead

Change-Id: I7e3283132682c9f882b4d7b1ee067428bb23d42a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>