platform/upstream/qtdeclarative.git
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>
11 years agoPort __qmljs_get_thisobject to new calling convention
Simon Hausmann [Sun, 17 Feb 2013 21:21:51 +0000 (22:21 +0100)]
Port __qmljs_get_thisobject to new calling convention

Change-Id: I59a921d6838fd4e8419bf6cf62d5dca39e1142cd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years ago[masm] Fix function name replacement in disassembly on ia32
Simon Hausmann [Sun, 17 Feb 2013 21:12:22 +0000 (22:12 +0100)]
[masm] Fix function name replacement in disassembly on ia32

Cast the void* to a quintptr, to make sure we call the right
QByteArray::number overload depending on the size of a pointer
on the archicture. Otherwise we generate 0x1324 strings that
we can't successfully replace with the function names in the
disassembler output.

Change-Id: Iddc82534487d93547b597d39286b92ffdff6da6c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years ago[masm] Fix writing of return value on arm
Simon Hausmann [Sun, 17 Feb 2013 20:44:05 +0000 (21:44 +0100)]
[masm] Fix writing of return value on arm

On arm the pointer to the storage of the VM::Value to return is passed in r0.
The value in that register is destroyed soon after, so later when we want to
access it in visitRet() we'll get garbage.

To solve this we behave similar to gcc now, which upon function entry saves the
values of the registers used for parameter passing onto the stack. Except that
on arm we now do this before pushing the link register, which makes the stack
frame look identical to ia32. (old ebp / return address / arg 0 / arg 1 / ...)

With that we can theoretically access the pointer to the return value storage.
In practice we also need to change meaning of the addressForArgument() helper
function to only return the address of arguments on the stack. But that makes
sense since Address() is meaningless for values passed in registers.

Also tightened the #ifdef in visitRet() for determining whether to use the
return value register or not. That wasn't strictly necessary, but makes
the condition a bit clearer.

Change-Id: I6fbef6645275ebaa75484d666b4bbfd073f945a5
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years ago[masm] Fix function return on arm
Simon Hausmann [Sun, 17 Feb 2013 20:36:02 +0000 (21:36 +0100)]
[masm] Fix function return on arm

Whether we should do ret(n) or ret should depend on whether the caller
provides the pointer to the return value as hidden first parameter or not.
That's the case on ia32 but not on x86-64 or arm, where the first parameter
register is used instead. So the correct preprocessor macro to use here
is ARGUMENTS_IN_REGISTERS instead of VALUE_FITS_IN_REGISTER.

Change-Id: I3a8a8fa316896848baca37626f87ed98c096e14a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years ago[masm] Cleanup argument handling
Simon Hausmann [Sun, 17 Feb 2013 20:15:29 +0000 (21:15 +0100)]
[masm] Cleanup argument handling

Simplify the code for determining whether to push a function call parameter
onto the stack or into a register.

Change-Id: I3ab9230b8c0a3b2466c3000d89faf4fd79f927eb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years ago[masm] Support inline ops on architectures without memory src operands
Simon Hausmann [Sun, 17 Feb 2013 20:06:13 +0000 (21:06 +0100)]
[masm] Support inline ops on architectures without memory src operands

Change-Id: Idc4240c0fae35e42246f176536b9c16ee28123d2
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years ago[masm] Fix typo on register assignment
Simon Hausmann [Sun, 17 Feb 2013 19:44:48 +0000 (20:44 +0100)]
[masm] Fix typo on register assignment

On ARM registers are in JSC::ARMRegisters instead of JSC::X86Registers :)

Change-Id: Ib11f0b3caa84a5015905f0a7937b4250c6f76c78
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years ago[masm] Fix incorrect stack pointer adjustment when leaving function
Simon Hausmann [Sun, 17 Feb 2013 19:42:21 +0000 (20:42 +0100)]
[masm] Fix incorrect stack pointer adjustment when leaving function

Make sure to calculate the frame size when entering the function the
same way as when leaving it, otherwise the stack pointer adjustment
is wrong and we get nice crashes.

Change-Id: I19f953c3243cf6f1448ad95cad7587fbdca2ae6d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoMinor cleanup
Lars Knoll [Fri, 15 Feb 2013 23:15:34 +0000 (00:15 +0100)]
Minor cleanup

Change-Id: I8c3fea7c6b330c3e32b10c945f6e7b96a06daa8e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoreference locals in outer functions by index
Lars Knoll [Fri, 15 Feb 2013 12:36:49 +0000 (13:36 +0100)]
reference locals in outer functions by index

This makes V4 reference all variables in scopes
that are not the global scope by index. The JIT and
the interpreter walk up the scope chain to get the
correct reference.

Variables are only resolved by name for the global
scope, if the scope contains an eval statement (as
eval can define new variables) and inside with and
catch scopes.

Change-Id: Ib9f9d1a03d50124130aefd169eeb071533ba3520
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRetain the proper nesting structure in the VM:Function objects
Lars Knoll [Fri, 15 Feb 2013 12:31:32 +0000 (13:31 +0100)]
Retain the proper nesting structure in the VM:Function objects

Change-Id: I83c0889be7fe354f96fca68f786ca2a05121bb56
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix multiple variable assignments
Simon Hausmann [Fri, 15 Feb 2013 11:40:09 +0000 (12:40 +0100)]
Fix multiple variable assignments

When doing var foo = bar = 42; then we would assign 42 to bar and bar to foo,
resulting in the wrong value for foo if bar was read-only for example.

The spec says in 11.13.1.6 that the rval is to be returned, so we just do
that via the temp we already have.

Change-Id: I44ea895abe4796af10c371baac22c2b26f37b519
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoPort the remaining functions called from masm to pass-by-reference/pointer
Simon Hausmann [Fri, 15 Feb 2013 08:54:10 +0000 (09:54 +0100)]
Port the remaining functions called from masm to pass-by-reference/pointer

Change-Id: I1ea15fc500d0d2168aded2b6a2739420eb007b45
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Save guard const reference method calls
Simon Hausmann [Fri, 15 Feb 2013 07:27:21 +0000 (08:27 +0100)]
[masm] Save guard const reference method calls

Introduce a Reference type next to PointerToValue for which we can ensure that
it's non-null using an assert. Otherwise implemented push(PointerToValue)
to push a null pointer if the temp is null, instead of asserting.

Change-Id: I70f15e39dd80a6b2c65630060cba35f3417c0634
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoDon't assert when running into the JS debugger statement
Simon Hausmann [Fri, 15 Feb 2013 08:30:24 +0000 (09:30 +0100)]
Don't assert when running into the JS debugger statement

Instead use Q_UNIMPLEMENTED() that just prints a warning. This
really is missing functionality that in the meanwhile shouldn't cause
crashes due to failing assertions.

Change-Id: I85314d04e35af35b95dc81e9cbdd659d13f43798
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
11 years agoAdd the mandatory license file to be consistent and proper
Laszlo Papp [Thu, 14 Feb 2013 22:57:59 +0000 (22:57 +0000)]
Add the mandatory license file to be consistent and proper

See the following mailing list thread for further details:
http://lists.qt-project.org/pipermail/development/2013-February/009810.html

Change-Id: Iec80c7cbeeafca7d2cdd63eb9c918d8dedbc6cd0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agocleanup __qmljs_to_boolean vs Value.toBoolean()
Lars Knoll [Thu, 14 Feb 2013 22:16:50 +0000 (23:16 +0100)]
cleanup __qmljs_to_boolean vs Value.toBoolean()

Change-Id: Ic93eed2d4e68972d373bf1521387331ce26bac43
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoremove __qmljs_throw_type_error
Lars Knoll [Thu, 14 Feb 2013 22:04:12 +0000 (23:04 +0100)]
remove __qmljs_throw_type_error

Change-Id: Ib666fa478e3e306117b50afebbd7826fa5b0738e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoVarious cleanups in the runtime
Lars Knoll [Thu, 14 Feb 2013 22:00:11 +0000 (23:00 +0100)]
Various cleanups in the runtime

Remove unused code, inline where we only use a method
once.

Change-Id: I1896efc3f4d309082aff2f80f944e19c1ede2f50
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a few more runtime signatures and optimise toObject conversion
Lars Knoll [Thu, 14 Feb 2013 20:41:49 +0000 (21:41 +0100)]
Fix a few more runtime signatures and optimise toObject conversion

Change-Id: Ibd1e4b7f2c9609b4ac08d75c8a0e2d5a86521605
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdapt get/set_element to new calling convention
Lars Knoll [Thu, 14 Feb 2013 19:58:10 +0000 (20:58 +0100)]
Adapt get/set_element to new calling convention

Change-Id: I5e2bca8ee2435bf678dbf9eb15172ed59c80b52e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoPorted closure init runtime functions to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 15:18:01 +0000 (16:18 +0100)]
Ported closure init runtime functions to new calling convention

Change-Id: Icb5765069b296977480d896aacfbd09d64dbdad6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoPorted run-time exception throwing functions to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 15:15:19 +0000 (16:15 +0100)]
Ported run-time exception throwing functions to new calling convention

Change-Id: Icc05eb78deb6d087a06f77d28b71fd49c9705e4c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix argument order of unary ops
Simon Hausmann [Thu, 14 Feb 2013 15:11:16 +0000 (16:11 +0100)]
Fix argument order of unary ops

Change-Id: Id108c4b74f03cac8181a9308413b69e6bf1ef83e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoPorted built-in exception getter to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 15:04:15 +0000 (16:04 +0100)]
Ported built-in exception getter to new calling convention

Change-Id: Ica14229cfa280afba2003b3b50930c2986aa2f23
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoConvert property deletion runtime functions to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 15:02:40 +0000 (16:02 +0100)]
Convert property deletion runtime functions to new calling convention

Change-Id: I312ccbd65d9aad5e8db349af94c00bed0fd73544
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoConvert unary ops to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 14:55:43 +0000 (15:55 +0100)]
Convert unary ops to new calling convention

Change-Id: I974fd474c4f35885e42dd219e2daa65098f4e0a1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoConvert construct runtime functions to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 14:47:06 +0000 (15:47 +0100)]
Convert construct runtime functions to new calling convention

Change-Id: I063508ff780d2f6371f77eca7138a09d78e1a45e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMove the destructor into the new vtable.
Lars Knoll [Thu, 14 Feb 2013 14:00:06 +0000 (15:00 +0100)]
Move the destructor into the new vtable.

This makes all runtime structures fully non virtual.

Change-Id: I804568ca9bc33d4be0324ed542df8eab5892c0eb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove another virtual.
Lars Knoll [Thu, 14 Feb 2013 13:21:37 +0000 (14:21 +0100)]
Remove another virtual.

Change-Id: Id83e7e5153160247b15c1506cb3c741cc6b77368
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSilence compiler
Lars Knoll [Thu, 14 Feb 2013 13:18:59 +0000 (14:18 +0100)]
Silence compiler

Change-Id: Id248400c50609811baebb1ea710210915e5274c9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove another virtual
Lars Knoll [Thu, 14 Feb 2013 13:18:34 +0000 (14:18 +0100)]
Remove another virtual

Change-Id: I185be24d4c09d2078c3459460875c4711bf17ddb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove call/construct over into the new vtable.
Lars Knoll [Thu, 14 Feb 2013 13:07:57 +0000 (14:07 +0100)]
Move call/construct over into the new vtable.

Change-Id: I4f58a1fac25440695bdc62a49adb51a887616a5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove another virtual and de-inline a call method
Lars Knoll [Thu, 14 Feb 2013 10:53:23 +0000 (11:53 +0100)]
Remove another virtual and de-inline a call method

Change-Id: Ia7cc0bf9f4024a65020fef75666ae13d3691bc54
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert builtin type of functions to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 11:56:05 +0000 (12:56 +0100)]
Convert builtin type of functions to new calling convention

Change-Id: Ie0c9300eead2171c899bca54635e6fdf301385d3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoConverted calling runtime functions to new calling convention
Simon Hausmann [Thu, 14 Feb 2013 12:28:49 +0000 (13:28 +0100)]
Converted calling runtime functions to new calling convention

Change-Id: I03837e9b392957bd64a6710c1b85b4429556ba06
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix print and gc in builtin v4 method
Simon Hausmann [Thu, 14 Feb 2013 11:29:16 +0000 (12:29 +0100)]
Fix print and gc in builtin v4 method

Also removed unused TestHarness stuff.

Change-Id: I6332d9a34f471df07cfa0e9709a203e99a48b524
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoConvert builtin typeof to the new calling convention
Simon Hausmann [Thu, 14 Feb 2013 11:16:30 +0000 (12:16 +0100)]
Convert builtin typeof to the new calling convention

Change-Id: I40f268c53dacf2ee188b3d1df9391df3e5e812f8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoConvert run-time functions that take a Value * for arguments to use a Value reference
Simon Hausmann [Thu, 14 Feb 2013 09:45:49 +0000 (10:45 +0100)]
Convert run-time functions that take a Value * for arguments to use a Value reference

This keeps the C++ implementation code simpler while still providing the same
(pointer based) calling convention.

Change-Id: Ib72acf1dfdf4638f6d109a0771fdafc921a544d2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove the virtual call(ctx) method
Lars Knoll [Thu, 14 Feb 2013 10:10:17 +0000 (11:10 +0100)]
Remove the virtual call(ctx) method

This is better handled in ScriptFunction and BuiltinFunctionOld.

Change-Id: Id896b1ddac47a9ce52e86abff901c87b7e627271
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDon't use the slow call() method for Date()
Lars Knoll [Thu, 14 Feb 2013 10:02:57 +0000 (11:02 +0100)]
Don't use the slow call() method for Date()

Change-Id: Ifc29ef18a173a210a8831b87ba3f1adcbe9911d6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove the generic construct() implementation into ScriptFunction
Lars Knoll [Thu, 14 Feb 2013 10:00:39 +0000 (11:00 +0100)]
Move the generic construct() implementation into ScriptFunction

This is the only place we really need it, as the generic
construct method defined by the spec mainly applies to
functions defined in script.

Change-Id: I4fe4219715a4a9393900db6a2532e42fafaea2db
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove the virtual contruct(ctx) method
Lars Knoll [Thu, 14 Feb 2013 09:46:30 +0000 (10:46 +0100)]
Remove the virtual contruct(ctx) method

The more general and faster construct method taking
more arguments is now used in all cases.

Change-Id: I183e4279526e5a937938a72d494a537faf4bc825
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoUse faster call/construct methods
Lars Knoll [Thu, 14 Feb 2013 08:20:33 +0000 (09:20 +0100)]
Use faster call/construct methods

Change-Id: I3e3c2ab42f20d9d5f38d3f9681d05de9487d80bd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement hasInstance through the new 'vtable'
Lars Knoll [Thu, 14 Feb 2013 08:10:30 +0000 (09:10 +0100)]
Implement hasInstance through the new 'vtable'

Change-Id: I59aea0f64e7ac955c3f1243936d77f2c12103621
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd a C style vtable to Managed and use it for markObjects
Lars Knoll [Wed, 13 Feb 2013 22:00:10 +0000 (23:00 +0100)]
Add a C style vtable to Managed and use it for markObjects

We need to replace the C++ vtable with a home made one for additional
flexibility. This will help us deal properly with primitive this
values, and allow us to enable certain optimisations where we can
change behavior at runtime (e.g. use optimised lookups as long as
we don't have any accessor properties defined).

Change-Id: I6a3852692bdc5c4f0bde05f6ff2b296013ba47e5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoReplace post increment with pre increment if we don't need the result.
Lars Knoll [Wed, 13 Feb 2013 21:27:15 +0000 (22:27 +0100)]
Replace post increment with pre increment if we don't need the result.

Same for decrement operations.

Change-Id: I9ef33f12f8cf009e9d441989dbc6bc6a233b8994
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert post inc/dev operators to new calling convention
Lars Knoll [Wed, 13 Feb 2013 21:13:53 +0000 (22:13 +0100)]
Convert post inc/dev operators to new calling convention

Change-Id: Idbfa6852d308337076a1aa18cdeb43460fb5bed6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert inplace binops to pointer based calling convention
Lars Knoll [Wed, 13 Feb 2013 20:14:17 +0000 (21:14 +0100)]
Convert inplace binops to pointer based calling convention

Change-Id: Ie39fb9160573c79ea765466fc9750e2f50b52ab3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agomake binops pointer based
Lars Knoll [Wed, 13 Feb 2013 15:22:10 +0000 (16:22 +0100)]
make binops pointer based

Change-Id: Ic03e134ba2c0f51f6a72bd875aba1d30eee8fd2d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agothrowing a type error doesn't return a value
Lars Knoll [Wed, 13 Feb 2013 14:36:53 +0000 (15:36 +0100)]
throwing a type error doesn't return a value

Change-Id: Id7a03c1804e66dfad8448e3e3ec70832152e09fa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove get/set_property over to pointer based calling convention
Lars Knoll [Wed, 13 Feb 2013 13:42:56 +0000 (14:42 +0100)]
Move get/set_property over to pointer based calling convention

Change-Id: I4afc0e90bd4763d170e06adddf70cf133c9ebbf7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoChange activition property calls to be pointer based
Lars Knoll [Wed, 13 Feb 2013 13:15:08 +0000 (14:15 +0100)]
Change activition property calls to be pointer based

After longer discussions, we actually found out that
passing Values by reference (ie. as pointers) is most
likely quite a bit more efficient then passing them by
value. This is esp. true on 32bit platforms.

So change the runtime back to a pointer based calling
convention.

Change-Id: I948d361b6876109d77fc58f11ceb47109cf631d1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused method
Lars Knoll [Wed, 13 Feb 2013 12:41:49 +0000 (13:41 +0100)]
Remove unused method

Change-Id: I8fdb8febafa996b26d2db503a57788c9ccbf3307
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix lookups in catch scopes
Lars Knoll [Wed, 13 Feb 2013 11:44:37 +0000 (12:44 +0100)]
Fix lookups in catch scopes

Change-Id: I6fa7546bb7c8d5bc1b52de8adb5c5cc8cb97c9ad
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years ago[masm] Remove unused code
Simon Hausmann [Wed, 13 Feb 2013 09:35:46 +0000 (10:35 +0100)]
[masm] Remove unused code

We don't need to save & restore esi on ia32 between calls, because it's
actually a callee saved register.

Change-Id: I452bc59c42b5428a4f5f32e379be144c744cfd2a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix scoping for catch blocks
Simon Hausmann [Fri, 8 Feb 2013 12:33:50 +0000 (13:33 +0100)]
Fix scoping for catch blocks

Based on Lars' idea, done together with Erik.

For proper scoping of the exception variable in catch blocks, it is necessary
to define the new scope (ExecutionContext for us) at run-time, it cannot be
determined at compile time.

This patch implements the necessary logic to create the new execution context
when entering a try block and re-uses the existing pop_scope infrastructure for
destroying it again. Within the catch scope it is necessary to do all lookups by
name, so the existing _function->insideWith variable was re-used and renamed
to _function->insideWithOrCatch. Additionally the new context also stores the
name and value of the separately scoped exception variable that shadows any
existing equally named variables in outter scopes.

CodeGen::unwindException also had a bug that it would generate the finally code
with the wrong _function->insideWithOrCatch level, resulting in name lookups
inside finally instead of local index lookups.

Change-Id: I5616af38c3558e553e971a6a894ce5239ccb8422
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoOptimise property access
Lars Knoll [Tue, 12 Feb 2013 21:50:41 +0000 (22:50 +0100)]
Optimise property access

Change-Id: I24e41395cd6f648b121f9a08ab1eaacae234e081
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup: Reduce cpu specific #ifdefs in common masm code
Simon Hausmann [Tue, 12 Feb 2013 14:55:44 +0000 (15:55 +0100)]
Cleanup: Reduce cpu specific #ifdefs in common masm code

Centralize the callee save register handling as well as potentially cpu
specific stack frame enter/leave code (like ARM doesn't automatically save the
link register) inside bigger cpu specific #ifdefs instead of sprinkling them
throughout the code. That should make it easier in the future to port to
new calling conventions and architectures.

Change-Id: I92fed7cc3d0f7eb4da86843b7ad59581a64f635f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAlso lookup properties in the prototype by index
Lars Knoll [Tue, 12 Feb 2013 21:25:39 +0000 (22:25 +0100)]
Also lookup properties in the prototype by index

We can only do this when getting properties, as setting
values will always happen on the main object.

Change-Id: I0336dd393bf78144d54ed8b6008011a7046e325d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a crash in JSON
Lars Knoll [Tue, 12 Feb 2013 20:46:01 +0000 (21:46 +0100)]
Fix a crash in JSON

Fully initialize the property descriptor when parsing
JSON.

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