platform/upstream/qtdeclarative.git
11 years agoTune break/continue exception trampoline block generation.
Erik Verbruggen [Thu, 15 Nov 2012 12:33:36 +0000 (13:33 +0100)]
Tune break/continue exception trampoline block generation.

If the break/continue trampoline blocks get reached, there cannot be a
pending exception, so don't bother with saving it.

Change-Id: Id079d48d961f21dd236dbc33fad1712edbd2df97
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdded all missing error objects.
Erik Verbruggen [Wed, 14 Nov 2012 15:44:08 +0000 (16:44 +0100)]
Added all missing error objects.

Change-Id: I806184c5593af44d79b21afb1e3235ec9afa1e2a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup Context initialization
Lars Knoll [Thu, 15 Nov 2012 12:31:57 +0000 (13:31 +0100)]
Cleanup Context initialization

Make the initialization for call() compliant
with the standard, and add a strict mode boolean.

Change-Id: I8617af8dbfde47d8b2a8a0a7ce0ab491031ba4ba
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSmaller cleanups in the Context class
Lars Knoll [Thu, 15 Nov 2012 11:58:49 +0000 (12:58 +0100)]
Smaller cleanups in the Context class

Change-Id: I02bc1cad6231988fdf453d0b4fdde55dd1ae9148
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoStore the activation object as a pointer, not as a Value.
Lars Knoll [Thu, 15 Nov 2012 11:23:39 +0000 (12:23 +0100)]
Store the activation object as a pointer, not as a Value.

The activation object inside the context is always an object,
or null. This avoids some needless conversions to and from
Value's.

Change-Id: Ibbd88c83fa073a4ed3cf03742129357dd9567cec
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused variable and method
Lars Knoll [Thu, 15 Nov 2012 11:11:38 +0000 (12:11 +0100)]
Remove unused variable and method

Change-Id: I357f3062f58e76c1749c9818426be5c0eedf3327
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRethrow the right exception after finally if catch is missing.
Erik Verbruggen [Thu, 15 Nov 2012 12:12:55 +0000 (13:12 +0100)]
Rethrow the right exception after finally if catch is missing.

Save the (unhandled) exception, because there might be another try block
with a catch in the finally block. Restore it at the end of the finally
block.

The codegen for the finally, which is also needed for the break/continue
trampoline blocks, has moved into a helper method.

Change-Id: Iff28506b92a3749c6a5585fb6d94f3120696e89a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd missing message property to the ErrorObject.
Erik Verbruggen [Wed, 14 Nov 2012 13:12:16 +0000 (14:12 +0100)]
Add missing message property to the ErrorObject.

Change-Id: Ice16360f98d1d66162440d972c6bfbc416884474
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoChanged the interpreter and compiler backends to move consts.
Erik Verbruggen [Wed, 14 Nov 2012 11:51:54 +0000 (12:51 +0100)]
Changed the interpreter and compiler backends to move consts.

See https://codereview.qt-project.org/39510 for details.

Change-Id: I308364cd7d66ad2fd12e6ab7e185882fe8d1795e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix optimisation for passing a single argument to a call.
Erik Verbruggen [Wed, 14 Nov 2012 11:18:50 +0000 (12:18 +0100)]
Fix optimisation for passing a single argument to a call.

Change-Id: I57a881ccd9f86a36d2d2ea5451046652ac0aca21
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoOptimise move instructions involving constants
Lars Knoll [Wed, 14 Nov 2012 08:07:01 +0000 (09:07 +0100)]
Optimise move instructions involving constants

Change-Id: Ic12a54ab1c5789cc5684d38961c58f6b34f9597a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoAdded more built-ins to the llvm backend and runtime.
Erik Verbruggen [Wed, 14 Nov 2012 09:10:04 +0000 (10:10 +0100)]
Added more built-ins to the llvm backend and runtime.

Change-Id: I7c63395bc80ce8d37d04f1102b02220a54050d06
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix codegen for try-statements in loops.
Erik Verbruggen [Wed, 14 Nov 2012 10:39:38 +0000 (11:39 +0100)]
Fix codegen for try-statements in loops.

The tricky part is that a break/continue in a try or catch block must
still execute the finally block.

Change-Id: I5215c1b5688d87f3c9d1dd168eed7f3555bae22a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix interpreter exception handling.
Erik Verbruggen [Wed, 14 Nov 2012 09:15:19 +0000 (10:15 +0100)]
Fix interpreter exception handling.

The stack frame of the interpreting function is restored, but all the
datastructures live on the heap. So, save them out on handler creation,
and restore them afterwards.

Change-Id: I84b84007cc9944b56926bf0387c2798f7841cd2a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoUntangle the Jump/CJump interpreter instructions.
Erik Verbruggen [Wed, 14 Nov 2012 09:12:42 +0000 (10:12 +0100)]
Untangle the Jump/CJump interpreter instructions.

Shrinks the instruction size of a Jump a bit.

Change-Id: I1a6b043d13e8493d8b0d23011141d46c10414fa8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove the tempRegister from moth by loading/storing values directly.
Erik Verbruggen [Tue, 13 Nov 2012 11:25:23 +0000 (12:25 +0100)]
Remove the tempRegister from moth by loading/storing values directly.

Change-Id: I51982d5852db2e10234620d63c235484c5b8a573
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoGive an error message when a JS file does not exist.
Erik Verbruggen [Tue, 13 Nov 2012 12:44:16 +0000 (13:44 +0100)]
Give an error message when a JS file does not exist.

Instead of silently failing, which is a bit ambiguous in case of test262.

Change-Id: I8b8dc066df63f93273ccc6c27547edfcd1a68cb7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdded different output types to LLVM backend to ease debugging.
Erik Verbruggen [Tue, 13 Nov 2012 08:54:24 +0000 (09:54 +0100)]
Added different output types to LLVM backend to ease debugging.

While in that area of code, also throw in the pass-managers for
some extra optimisations during compilation.

Change-Id: I1239ab9d21fc50b2e65c2f9d77a03ae593b607bc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd a script to test the interpreter on *.js files.
Nikolai Kosjar [Fri, 9 Nov 2012 14:16:58 +0000 (15:16 +0100)]
Add a script to test the interpreter on *.js files.

By default this will run ./v4 on all *.js files in test262 and generate
test reports based on the exit code and the output of the interpreter.

Change-Id: I5a90b9f4c5bf376c5c8df12b5e777d0626d9d82e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoFix property deletion.
Erik Verbruggen [Mon, 12 Nov 2012 15:19:04 +0000 (16:19 +0100)]
Fix property deletion.

Also tweak the bucket size calculation to be prime for just a bit
longer than.

Change-Id: I9fc6779956693301eb01a6558d4c20d8e39d8bad
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdded more builtins to moth.
Erik Verbruggen [Mon, 12 Nov 2012 13:31:05 +0000 (14:31 +0100)]
Added more builtins to moth.

- delete member
- delete subscript
- delete name
- delete value
- foreach-iterator-object
- foreach-next-property-name

Change-Id: I639a3c3a293ea88019e2f69e1f51ce2264a68bcc
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoChanged the LLVM backend to also support the LLVM JIT.
Erik Verbruggen [Mon, 12 Nov 2012 11:22:22 +0000 (12:22 +0100)]
Changed the LLVM backend to also support the LLVM JIT.

This is useful for quick LLVM codegen testing.

Change-Id: I45778371375b903e154222c47b15411d08085ae5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAllow Const's as operands to Binop in moth.
Erik Verbruggen [Mon, 12 Nov 2012 08:39:06 +0000 (09:39 +0100)]
Allow Const's as operands to Binop in moth.

Change-Id: Ic0954c8170bc720a02fa88f3ab50112bff4767a7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoSmaller 64 bit optimisation
Lars Knoll [Sun, 11 Nov 2012 21:29:25 +0000 (22:29 +0100)]
Smaller 64 bit optimisation

Change-Id: I78311310c6f986bf187e3923d1fb71e09f4569fb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoAllow Const's as operands to Binop
Lars Knoll [Thu, 25 Oct 2012 14:31:12 +0000 (16:31 +0200)]
Allow Const's as operands to Binop

This allows us to use expressions such as
%x = %y + const
in the IR.

This still requires an implementation for moth.

Change-Id: I134e96ddad08bcbe4f3ea5fa27c5338a96acac80
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoBetter argument ordering.
Lars Knoll [Sun, 11 Nov 2012 21:08:39 +0000 (22:08 +0100)]
Better argument ordering.

Change-Id: I1d47ce7bd2cf27bc43a0e9afbfb2914296c9d704
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoClean up inplace binary operations for subscripts.
Lars Knoll [Sun, 11 Nov 2012 20:56:38 +0000 (21:56 +0100)]
Clean up inplace binary operations for subscripts.

Remove a lot of duplicated code, and make it a lot
easier to implement JS compliant semantics.

Change-Id: Ic5ecb58d34a5df8fe05e86c5f906d70c50c51b54
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoThese methods are actually used now.
Lars Knoll [Sun, 11 Nov 2012 20:23:59 +0000 (21:23 +0100)]
These methods are actually used now.

Change-Id: Ic0d43902fec5d3b752678eadfbccb9f71e21d895
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoCorrect implementation of inplace binops
Lars Knoll [Sat, 10 Nov 2012 23:08:44 +0000 (00:08 +0100)]
Correct implementation of inplace binops

Fix the last parts of the inplace bitops to
do the correct thing.

Change-Id: I748dde919082193c034cdc20e92cc568d8efa225
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoImprove handling of binops on LHS expressions
Lars Knoll [Sat, 10 Nov 2012 22:35:06 +0000 (23:35 +0100)]
Improve handling of binops on LHS expressions

Add a generic method to handle binops such as +=
to Object and use it. We can probably remove
most of the __qmljs_inplace_xxx methods later
on and call one generic method instead.

Change-Id: If7cbd2e3012ad381e29b9eec2059e17f02a0a38a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoCleanup call and construct semantics
Lars Knoll [Sat, 10 Nov 2012 11:45:00 +0000 (12:45 +0100)]
Cleanup call and construct semantics

Implement proper call() and construct()
methods in FunctionObject, and remove
some duplicated initialization code.

Change-Id: I5c86f9f2cf6e4b65d23d000149db2b79c35538c4
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoImplement member operations for non integers indices
Lars Knoll [Fri, 9 Nov 2012 22:33:07 +0000 (23:33 +0100)]
Implement member operations for non integers indices

Implement the more general foo[expr] op= bar

Change-Id: Idb2143cfe4b48fc9ce177d699970818e877dc735
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoChange ConvertibleToInt to not interfere with valid addresses.
Erik Verbruggen [Wed, 7 Nov 2012 14:34:34 +0000 (15:34 +0100)]
Change ConvertibleToInt to not interfere with valid addresses.

Change-Id: I1415907f94d064e64bf5495b7c136355ffd866fe
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFixed compilation of LLVM glue-code.
Erik Verbruggen [Thu, 8 Nov 2012 13:54:37 +0000 (14:54 +0100)]
Fixed compilation of LLVM glue-code.

Change-Id: I3adc68012f7492281fe8849f58764473dcb3671e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoChanged commandline and return codes for test harness.
Erik Verbruggen [Thu, 8 Nov 2012 11:45:40 +0000 (12:45 +0100)]
Changed commandline and return codes for test harness.

The different backends can now be selected by command-line options,
and when none is specified, masm is used. The difference is that the
environment variable USE_MOTH is not used anymore.

The return codes are 0 or -1, so the test harness can easily check for
errors.

The ECMA test262 harness uses the $ERROR function to report errors. When
the environment variable IN_TEST_HARNESS is set, this function will get
added to the global object.

Change-Id: I291c72332ea50892afb99f9a0a15004ffc81c200
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFixed/added name handling in expressions for moth.
Erik Verbruggen [Wed, 7 Nov 2012 15:31:10 +0000 (16:31 +0100)]
Fixed/added name handling in expressions for moth.

Change-Id: I6dc2faed00a465b74735d23e4c0bda9498dc7bd9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix free memory reads
Lars Knoll [Fri, 2 Nov 2012 21:07:58 +0000 (22:07 +0100)]
Fix free memory reads

This doesn't quite fix all issues, as activation records
and arguments objects will still not work correctly in
all cases (esp. the inplace operators).

Change-Id: I0ebf2a08e6c61e4049d4b6f449987757bfc3f81c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix use of uninitialised values.
Erik Verbruggen [Wed, 7 Nov 2012 10:19:09 +0000 (11:19 +0100)]
Fix use of uninitialised values.

Also fix a typo in a variable name.

Change-Id: I5e21544b69bed777c6733e2f517d52aca93a900b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix build with shadow builds
Thiago Macieira [Wed, 7 Nov 2012 09:11:21 +0000 (10:11 +0100)]
Fix build with shadow builds

Otherwise, we get:
gmake: *** No rule to make target `/home/thiago/src/qt/qt5/v4vm/udis86_itab.c', needed by `udis86_itab_holder.o'.  Stop.

Change-Id: I1d84ec00b6422fb8601e271d427ef619d462fd28
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix codegen for void expressions.
Erik Verbruggen [Wed, 7 Nov 2012 08:54:30 +0000 (09:54 +0100)]
Fix codegen for void expressions.

Change-Id: If89306aa91995e84106437a802e1d6d1940f17e7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdded more instruction selection to moth to get crypto.js through.
Erik Verbruggen [Tue, 6 Nov 2012 11:54:20 +0000 (12:54 +0100)]
Added more instruction selection to moth to get crypto.js through.

Change-Id: Ic9582ea3241d97ef619304ece9f18c7eaae90407
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix temp/local addressing in MOTH.
Erik Verbruggen [Tue, 6 Nov 2012 11:31:53 +0000 (12:31 +0100)]
Fix temp/local addressing in MOTH.

Change-Id: Iae9d7a7679b2e315c671de6890ccdaafa28f8a03
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd tracing for runtime methods.
Erik Verbruggen [Tue, 6 Nov 2012 11:31:02 +0000 (12:31 +0100)]
Add tracing for runtime methods.

Change-Id: I540297e83e3e297d0724c3e08e5780eee0d2fac8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix compilation of LLVM backend.
Erik Verbruggen [Tue, 6 Nov 2012 11:24:32 +0000 (12:24 +0100)]
Fix compilation of LLVM backend.

Change-Id: I654f30c9811a74634cef9d27e07d016f73daa141
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdded calls to built-ins to moth.
Erik Verbruggen [Thu, 25 Oct 2012 08:08:22 +0000 (10:08 +0200)]
Added calls to built-ins to moth.

Change-Id: I277b1136ed3b073a9fc85726dc714ef68109fbfa
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix === operator
Lars Knoll [Thu, 1 Nov 2012 15:46:54 +0000 (16:46 +0100)]
Fix === operator

Correctly handle the case where one of the two
arguments is a double and the other an integer.

Change-Id: I589ac46acc30180b025c7e377c0523cf0889f294
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoInitial implementation of the Error prototype and constructor
Lars Knoll [Thu, 1 Nov 2012 14:37:47 +0000 (15:37 +0100)]
Initial implementation of the Error prototype and constructor

Change-Id: Iffd1a01b75bc923c0cd8c0b786558be20a52ab2c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement Function(...) and new Function(...)
Lars Knoll [Thu, 1 Nov 2012 13:49:09 +0000 (14:49 +0100)]
Implement Function(...) and new Function(...)

Change-Id: I3ff229740820883a99dee6e32370fc528bf9169c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd undefined, NaN and Infinity to the global object
Lars Knoll [Tue, 30 Oct 2012 06:45:58 +0000 (07:45 +0100)]
Add undefined, NaN and Infinity to the global object

Change-Id: Ic5047c231ab54ccc04043bf95418c0f6511b10bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd missing break statement
Lars Knoll [Tue, 30 Oct 2012 06:39:45 +0000 (07:39 +0100)]
Add missing break statement

Change-Id: I61e91701bbaa173c8189af9f703ac2b509b99cd0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement initial support for the delete operator
Lars Knoll [Tue, 30 Oct 2012 06:29:14 +0000 (07:29 +0100)]
Implement initial support for the delete operator

And don't dump the assemply unless SHOW_CODE is set.

Change-Id: I17ad36f002404b57c65f910048e5c82d42307976
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSet property attributes more correctly
Lars Knoll [Mon, 29 Oct 2012 14:50:07 +0000 (15:50 +0100)]
Set property attributes more correctly

Also now check for enumerable in for/in statements.

Change-Id: I03a9968fc3d7f8f5e4eaf26591040acd9cc8ced1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConformant implementation of the object internal methods
Lars Knoll [Mon, 29 Oct 2012 14:37:02 +0000 (15:37 +0100)]
Conformant implementation of the object internal methods

See section 8.12 of the standard. This implements
8.12.1 - 8.12.7 and 8.12.9

Also gave these methods standard conformant names.
They are marked as [[foo]] in the standard, which
translates to __foo__ in our code.

Change-Id: I1990d6c6dd24e929c23d5c51d36f1e2e0a0a3b63
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd a Value::sameValue() method
Lars Knoll [Mon, 29 Oct 2012 11:26:40 +0000 (12:26 +0100)]
Add a Value::sameValue() method

This implements Section 9.11 of the spec.
Also simplify __qmljs_strict_equal().

Change-Id: I99b33308c33f4d4732b4a72bd5327336b2b22257
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRework properties
Lars Knoll [Sun, 28 Oct 2012 20:56:15 +0000 (21:56 +0100)]
Rework properties

This brings the basic structure or accessing properties
more in line with the EcmaScript 5.1 specification.

There's however still quite some work to be done to
make things fully compliant.

Change-Id: If55afd7ae6e4f7aa5ce06afe49b1453b537ac98b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement the other variant of the 'for in' statement
Lars Knoll [Sun, 28 Oct 2012 19:33:54 +0000 (20:33 +0100)]
Implement the other variant of the 'for in' statement

Change-Id: I90823a97331fd15a8289bab93d7e9c1f34aaa10d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdded basic support for 'for (var x in y)' statement
Lars Knoll [Sun, 28 Oct 2012 15:24:06 +0000 (16:24 +0100)]
Added basic support for 'for (var x in y)' statement

Change-Id: I8f3c8add78bebf92e0073348d1ecbdf3f328af6d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConstant folding for unary operations
Lars Knoll [Thu, 25 Oct 2012 12:14:10 +0000 (14:14 +0200)]
Constant folding for unary operations

Do constant folding for unary operators.

Change-Id: I88f8b73c947d719ef089a9e53f7949fc6d66134b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMore correct type tagging for constant created from binops
Lars Knoll [Thu, 25 Oct 2012 12:27:14 +0000 (14:27 +0200)]
More correct type tagging for constant created from binops

In many cases the result of the binop is actually a boolean,
not a number. Correctly type the constant as boolean in this
case.

Change-Id: I3c9b1f5b9fbd15bf97e4bafc9ceee6947343fd32
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMoved definition of Value before the extern block to suppress warnings.
Erik Verbruggen [Thu, 25 Oct 2012 07:24:11 +0000 (09:24 +0200)]
Moved definition of Value before the extern block to suppress warnings.

Change-Id: Ic400255d0a7f6830dcb0604688d88d5020628b15
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove all is*Object methods.
Erik Verbruggen [Thu, 25 Oct 2012 07:15:11 +0000 (09:15 +0200)]
Remove all is*Object methods.

They differ from the isObject/isUndefined/etc. methods because they do
an extra virtual function call. And with isObject and friends being
cheap, is*Object methods could have made the same (but faulty)
impression.

Change-Id: I32f26a96e73251bd14f8198b0a1ffb5d59e53f31
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoReadability change: builtin_invalid implies baseName->id being set.
Erik Verbruggen [Wed, 24 Oct 2012 15:05:44 +0000 (17:05 +0200)]
Readability change: builtin_invalid implies baseName->id being set.

And vice-versa, so drop the wrapping if statement.

Change-Id: I57b7aef23feeee6b3f94edd5ca85bfc460bb2307
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented calls in the interpreter.
Erik Verbruggen [Wed, 24 Oct 2012 15:04:29 +0000 (17:04 +0200)]
Implemented calls in the interpreter.

Change-Id: Iafc9b04a1aa39272ab8aac24fb410a23df02a756
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemoved duplicate code for the various function call methods.
Erik Verbruggen [Wed, 24 Oct 2012 14:35:15 +0000 (16:35 +0200)]
Removed duplicate code for the various function call methods.

The main change is renaming __qmljs_call_function to callFunction, and
move duplicate error checking in there. Now __qmljs_call_value does not
do its own call anymore, but calls __qmljs_call_function. All calls to
__qmljs_call_function are replaced by calls to __qmljs_call_value.

Change-Id: I7fffc2e811c43e84e7344d70e2ed521331ed710d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdded loading of "this" and renamed "ActivateProperty" to "StoreName".
Erik Verbruggen [Wed, 24 Oct 2012 11:45:43 +0000 (13:45 +0200)]
Added loading of "this" and renamed "ActivateProperty" to "StoreName".

Change-Id: I033abe53368a815a9e3d036021429732f5526ea2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix LLVM backend compilation.
Erik Verbruggen [Wed, 24 Oct 2012 08:09:30 +0000 (10:09 +0200)]
Fix LLVM backend compilation.

Change-Id: I326cf2531a600fd09b888e9955052b29624ccdbe
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix stack alignment to align on 16 byte boundaries.
Erik Verbruggen [Tue, 23 Oct 2012 12:37:26 +0000 (14:37 +0200)]
Fix stack alignment to align on 16 byte boundaries.

Aligning on 16 byte boundaries is a requirement for MacOS, and it gives
the optimal performance when using MMX on stack allocated data.

Change-Id: I1c9a27e796f1c240002a05196490f15df68c3f73
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoProper exception handling
Lars Knoll [Sun, 21 Oct 2012 22:18:31 +0000 (00:18 +0200)]
Proper exception handling

Implement exceptions using setjmp/longjmp. The
advantage is that this removes all exception
handling overhead from regular code, the only
code that still has a (very small) overhead
is the try{} catch() {} statement.

Change-Id: I43d6a60dfc9dfd4b7a20d2e99ab0a9315b4d8a2f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdded property activation to the interpreter.
Erik Verbruggen [Tue, 23 Oct 2012 14:06:52 +0000 (16:06 +0200)]
Added property activation to the interpreter.

Change-Id: Icbc900f8d617c8736a5663d19f5691f336bedb30
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years ago[masm] Cleanup: Eliminate ScratchRegister2 on AMD64
Simon Hausmann [Mon, 22 Oct 2012 13:03:43 +0000 (15:03 +0200)]
[masm] Cleanup: Eliminate ScratchRegister2 on AMD64

Functions like loadArgument and storeValue that work right above
the macro assembler may use ScratchRegister because they only call
functions that do not "allocate" that register themselves.

copyValue on the other hand is a higher-level function and may not use
ScratchRegister because the functions it calls (i.e. loadArgument)
may clobber it. In the 64-bit case of quickly copying one VM value
to another location, we might as well use the ReturnValueRegister
as intermediate register and therefore re-allow the use of ScratchRegister
in the lower-level loadArgument/storeArgument functions.

Change-Id: I9f0c0d326e5af87101972f0cceb86cffe4ebdd0d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Cleanup: Use load64/store64 masm interface
Simon Hausmann [Mon, 22 Oct 2012 09:37:03 +0000 (11:37 +0200)]
[masm] Cleanup: Use load64/store64 masm interface

The API allows us to distinguish between loading/storing a 64-bit value
or a pointer and we should make use of that to make the code more readable
and to be able to run on x32 in the future.

Change-Id: Id2e1d8af566486540a1f6d086fb8db91f0fed6f8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix ScratchRegister usage on x86_64
Lars Knoll [Sun, 21 Oct 2012 16:22:26 +0000 (18:22 +0200)]
Fix ScratchRegister usage on x86_64

r11 is already being used quite a bit internally in
the macro assembler, leading to collisions and crashes.
Rather use r10 for most scratch operations.

Change-Id: I27bbbf825ca0e90af4ec85b8da12c25ae8ca00df
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMore LLVM code generation. This should complete the expressions.
Erik Verbruggen [Mon, 22 Oct 2012 08:33:04 +0000 (10:33 +0200)]
More LLVM code generation. This should complete the expressions.

Change-Id: Ic920ceb85cab38093b565acd1c14aeddf20d0bb3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix: implement missing virtual method.
Erik Verbruggen [Mon, 22 Oct 2012 08:40:20 +0000 (10:40 +0200)]
Fix: implement missing virtual method.

Change-Id: Iec6a70155ff2343dafa2116fa54740e891539c61
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup: Eliminate Gpr0-3 register aliases
Simon Hausmann [Sat, 20 Oct 2012 12:17:03 +0000 (14:17 +0200)]
Cleanup: Eliminate Gpr0-3 register aliases

Instead introduce a ScratchRegister which is explicitly different from
the ReturnValueRegister and is therefore safe to use.

Change-Id: I4675b6a4d242f3e02a4e848c7b65660ffa97cfe6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup: Reduce use of Gpr0
Simon Hausmann [Sat, 20 Oct 2012 11:48:43 +0000 (13:48 +0200)]
Cleanup: Reduce use of Gpr0

We don't need to explicitly operate on Gpr0 for the return value when we can
use the ReturnValueRegister alias instead. No change in code generation because
on Amd64 and Ia32 Gpr0 == ReturnValueRegister.

Change-Id: Ia21613a51878093a9fb425879645ea3b8a4dbf72
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build on ia32
Simon Hausmann [Sat, 20 Oct 2012 12:13:42 +0000 (14:13 +0200)]
Fix build on ia32

Fix undefinedValue() and nullValue() initializers.

Change-Id: I7117331137c7d76b39099b57a5dc17b15136fd26
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build on Ubuntu 12.10
Simon Hausmann [Sat, 20 Oct 2012 12:13:23 +0000 (14:13 +0200)]
Fix build on Ubuntu 12.10

Include unistd.h for sysconf as per man-page.

Change-Id: Iafd7687e6f12beda5ace1442c4d436c051d1beb0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplement regexp support
Lars Knoll [Fri, 19 Oct 2012 21:10:42 +0000 (23:10 +0200)]
Implement regexp support

Change-Id: I86c9bbe69c9ba4ae9d300b62e7d16b372f3478ea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdded LLVM code generation for in-place operators.
Erik Verbruggen [Fri, 19 Oct 2012 13:03:28 +0000 (15:03 +0200)]
Added LLVM code generation for in-place operators.

E.g. +=, <<=, etc.

Change-Id: Iffd5eac413e3c3714fedbab58415d9dc4ba42fa6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix the dataLog methods
Lars Knoll [Fri, 19 Oct 2012 08:23:09 +0000 (10:23 +0200)]
Fix the dataLog methods

qDebug doesn't have an overload taking a va_list.

Change-Id: Ic8d58d0a37c0bac11f1146eed9fdc105ddf1dfc8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake Value a real POD
Lars Knoll [Thu, 18 Oct 2012 22:02:21 +0000 (00:02 +0200)]
Make Value a real POD

Remove the inheritance from ValueData and ValueBase.
Use a few ifdef's for 64 bit instead of a lot of
template magic and inheritance to get the correct
implementations for 32 and 64 bit.

Saves some code, and makes Value a real POD type.

Apparently this also helps gcc generate better code,
crypto.js runs another few percent faster now.

Change-Id: I9dac488b27e629e6ef8c096f2bee86a5d678fd49
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoUse some tricks to speed up binary operators
Lars Knoll [Thu, 18 Oct 2012 21:48:31 +0000 (23:48 +0200)]
Use some tricks to speed up binary operators

Add some flags to the Value's tag that allow us to
simplify type conversion from null and bool to integer.
Add a method to allow checking in one go whether two
values are "integer compatible"

Change-Id: I0a05bdf881836ad3f8286c0365dd192bf7f6e5d6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove the is(Type) methods in Value
Lars Knoll [Thu, 18 Oct 2012 19:48:57 +0000 (21:48 +0200)]
Remove the is(Type) methods in Value

Simplify and optimise the Value::isXxx() methods
at the same time.

Change-Id: I3e8fa98cf7b91079a4450c048c6d0795d1684724
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMicro optimisations
Lars Knoll [Thu, 18 Oct 2012 12:52:22 +0000 (14:52 +0200)]
Micro optimisations

Change-Id: Ifae82d259f55e8e3791ef05eb7ea5f607fbfd747
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoOptimise function calls a little.
Lars Knoll [Thu, 18 Oct 2012 12:39:59 +0000 (14:39 +0200)]
Optimise function calls a little.

Change-Id: I906a4f27bf47ae0ae088ae40a747b28ba827e10a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused, commented out methods
Lars Knoll [Thu, 18 Oct 2012 10:15:48 +0000 (12:15 +0200)]
Remove unused, commented out methods

They don't make sense with the calling convention we now have.

Change-Id: I92f773c96588dd276227ba9bbe7414dbd7752db7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix integer arithmetics
Lars Knoll [Thu, 18 Oct 2012 10:04:51 +0000 (12:04 +0200)]
Fix integer arithmetics

The inline assembly could create incorrect results for
overflows, esp when multiplying.
Also fix the return type of Value::integerValue()

Change-Id: I4c8f195b37bcbb8fd4f0f3d0cd04a8cf73f193cd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused method
Lars Knoll [Thu, 18 Oct 2012 10:04:22 +0000 (12:04 +0200)]
Remove unused method

Change-Id: I780afc37dd651922ca66770a69e9ae2050d198c4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMoved LLVM specific code out of main.cpp.
Erik Verbruggen [Thu, 18 Oct 2012 09:07:10 +0000 (11:07 +0200)]
Moved LLVM specific code out of main.cpp.

Change-Id: I16c79667625d5034acb91cec13c22ed58b74984f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoClean up #ifdefs in storeValue
Simon Hausmann [Thu, 18 Oct 2012 08:35:27 +0000 (10:35 +0200)]
Clean up #ifdefs in storeValue

Use VALUE_FITS_IN_REGISTER instead of hard-coding CPU architectures

Change-Id: I6d5caa6b2cd8e379517d83fdebef46217f79a8d5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoSilence signed/unsigned comparison warning.
Erik Verbruggen [Thu, 18 Oct 2012 08:57:00 +0000 (10:57 +0200)]
Silence signed/unsigned comparison warning.

Change-Id: Id23e48b370a73baabcc6875b51067f60dadec0c4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix LLVM code generation to call the right methods.
Erik Verbruggen [Thu, 18 Oct 2012 08:46:31 +0000 (10:46 +0200)]
Fix LLVM code generation to call the right methods.

Change-Id: Ia63342d2808ca2e3cdd5b19e94054786cc34c495
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix insecure use of format string.
Erik Verbruggen [Thu, 18 Oct 2012 08:44:09 +0000 (10:44 +0200)]
Fix insecure use of format string.

Change-Id: I6cd282d5780e418bea7a07d4639c035a98b3ed65
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix unused parameter/variable warnings.
Erik Verbruggen [Thu, 18 Oct 2012 08:43:49 +0000 (10:43 +0200)]
Fix unused parameter/variable warnings.

Change-Id: I1e1fad753b99a52a1e65dcf38f64c394fa506735
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoClean up the relational operators
Lars Knoll [Thu, 18 Oct 2012 07:52:38 +0000 (09:52 +0200)]
Clean up the relational operators

Change-Id: I83cf1dd9204b95b0238ed2476cf2a3800b25a017
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup
Lars Knoll [Thu, 18 Oct 2012 06:52:40 +0000 (08:52 +0200)]
Cleanup

Remove __qmljs_init_object and replace it with
Value::fromObject

Change-Id: Ibc8bd9e7ecd56c6713dc08add72e5cd35ffea78e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoInline string creation in the generated JIT code
Lars Knoll [Thu, 18 Oct 2012 06:49:22 +0000 (08:49 +0200)]
Inline string creation in the generated JIT code

Change-Id: Ifaef87046c083b36222f6204291ee3a61ffcd20b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoChange usage of qIsNaN to std::isnan.
Erik Verbruggen [Wed, 17 Oct 2012 12:34:44 +0000 (14:34 +0200)]
Change usage of qIsNaN to std::isnan.

By using std::isnan the compiler/std-lib has a chance to optimize the
call away or maybe even generate an intrinsic. Furthermore, when the
runtime is compiled to bitcode for inclusion in generated code, we now
do not need to link against QtCore to get just one single function.

Change-Id: I79995afc1ba215f1ffd9a43df1808b833dfa8481
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix the shift operators
Lars Knoll [Wed, 17 Oct 2012 21:07:41 +0000 (23:07 +0200)]
Fix the shift operators

The JS spec demands that the right hand argument is being
masked with 0x1f before applying the nit shift.

See e.g. http://bclary.com/2004/11/07/#a-11.7

Change-Id: I6a7dee4708b2fe93df984f13752f7f00b5f2f367
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>