Commit Graph

135 Commits

Author SHA1 Message Date
Erik Verbruggen e1072a54f4 Fix warning about unused parameter.
Change-Id: Ic8f95211b29fd5b3f4ffa4bc931fc15f004b30b1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-27 13:22:13 +01:00
Erik Verbruggen d0818647da 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>
2013-02-27 13:21:55 +01:00
Erik Verbruggen 896fbe080c Apparently MSVC needs EH enabled for SJLJ.
Change-Id: Ieab8157816237151dcfcf3eccfb3de177c4ad221
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-27 13:21:15 +01:00
Erik Verbruggen 7f153b3dcd Replace STL function that MS deprecated.
Change-Id: I0577d2ae42a7593e4bc886345c97072523aacc48
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-27 12:48:41 +01:00
Erik Verbruggen 048f896a98 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>
2013-02-27 12:47:57 +01:00
Erik Verbruggen 3ad3a6e838 Add ToS retrieval and register saving for MSVC.
No __asm no cry.

Change-Id: I95f4df5d5ba9d04aa0bcc8d0b0b5901d51533d16
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-27 12:47:29 +01:00
Erik Verbruggen 9cab0bc22c Fix declaration linkage type to be the same as the defenition.
Change-Id: I86c96bd4076b60b896803ee1c53c2ecf9aa86e1f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-27 12:42:10 +01:00
Simon Hausmann da6ccb1908 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>
2013-02-27 08:45:12 +01:00
Simon Hausmann 31352048f9 [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>
2013-02-26 23:46:17 +01:00
Simon Hausmann dcfdad0f5c 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>
2013-02-26 23:44:07 +01:00
Simon Hausmann 2fa092cbcd 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>
2013-02-26 23:43:42 +01:00
Simon Hausmann 5c8c2307c5 [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>
2013-02-25 22:54:03 +01:00
Lars Knoll be99576879 Some smaller optimisations
Ideally these checks should get inlined in the generated
assembly.

Change-Id: I4f63f7235a7d3bbdf8413df9f7d674104ff95b07
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-25 08:05:35 +01:00
Lars Knoll b9f623b591 Small cleanup
Change-Id: I1733ad823ef00114b4544bb0bdf40fede4eea073
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-25 08:05:04 +01:00
Lars Knoll 78e7edb64e Fix the sameValue algorithm when comparing ints to doubles.
Change-Id: I96fb3e8c47a336ef4e0e3cab44e6dfd4d5aff70a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-25 08:03:24 +01:00
Lars Knoll baf73673e1 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>
2013-02-25 08:01:49 +01:00
Lars Knoll f41cb7eb71 Store 0 constants as integers, not as doubles
Change-Id: Ibb49d1fd8221d65262b1c18b9833233ef97cee8e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-25 07:34:07 +01:00
Simon Hausmann 1d1b6b0ffc 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>
2013-02-21 20:32:09 +01:00
Simon Hausmann bbf1b545a2 Port __qmljs_get_thisobject to new calling convention
Change-Id: I59a921d6838fd4e8419bf6cf62d5dca39e1142cd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-02-20 09:58:59 +01:00
Simon Hausmann e4809181f2 [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>
2013-02-19 11:12:57 +01:00
Simon Hausmann b76ec55784 [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>
2013-02-19 11:12:03 +01:00
Simon Hausmann 6274c47ad3 [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>
2013-02-19 11:09:09 +01:00
Simon Hausmann 0b2752565b [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>
2013-02-19 11:08:13 +01:00
Simon Hausmann 25a61d3d23 [masm] Support inline ops on architectures without memory src operands
Change-Id: Idc4240c0fae35e42246f176536b9c16ee28123d2
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-02-19 10:47:34 +01:00
Simon Hausmann 3aad45174e [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>
2013-02-19 10:44:55 +01:00
Simon Hausmann 5172497e71 [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>
2013-02-19 10:44:25 +01:00
Lars Knoll c586479abe Minor cleanup
Change-Id: I8c3fea7c6b330c3e32b10c945f6e7b96a06daa8e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-16 17:44:43 +01:00
Lars Knoll 699633d464 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>
2013-02-16 00:58:04 +01:00
Lars Knoll e962832eb6 Retain the proper nesting structure in the VM:Function objects
Change-Id: I83c0889be7fe354f96fca68f786ca2a05121bb56
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-16 00:47:11 +01:00
Simon Hausmann 7bfdc4be02 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>
2013-02-15 13:14:47 +01:00
Simon Hausmann a7b444b526 Port the remaining functions called from masm to pass-by-reference/pointer
Change-Id: I1ea15fc500d0d2168aded2b6a2739420eb007b45
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-15 11:09:23 +01:00
Simon Hausmann a8ef93dc6b [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>
2013-02-15 11:08:55 +01:00
Simon Hausmann 483b9fc544 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>
2013-02-15 09:37:14 +01:00
Lars Knoll f6d0f64ee6 cleanup __qmljs_to_boolean vs Value.toBoolean()
Change-Id: Ic93eed2d4e68972d373bf1521387331ce26bac43
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-15 07:45:44 +01:00
Lars Knoll 7fea47a1bd remove __qmljs_throw_type_error
Change-Id: Ib666fa478e3e306117b50afebbd7826fa5b0738e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-15 07:43:34 +01:00
Lars Knoll a7e9ea3c1f 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>
2013-02-15 07:42:34 +01:00
Lars Knoll 37c2b54239 Fix a few more runtime signatures and optimise toObject conversion
Change-Id: Ibd1e4b7f2c9609b4ac08d75c8a0e2d5a86521605
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-14 22:25:30 +01:00
Lars Knoll e2ebdffd15 Adapt get/set_element to new calling convention
Change-Id: I5e2bca8ee2435bf678dbf9eb15172ed59c80b52e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-14 22:23:26 +01:00
Simon Hausmann 61b941f717 Ported closure init runtime functions to new calling convention
Change-Id: Icb5765069b296977480d896aacfbd09d64dbdad6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-14 20:30:43 +01:00
Simon Hausmann d6ad661feb Ported run-time exception throwing functions to new calling convention
Change-Id: Icc05eb78deb6d087a06f77d28b71fd49c9705e4c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-14 20:30:14 +01:00
Simon Hausmann 86a207e87d Fix argument order of unary ops
Change-Id: Id108c4b74f03cac8181a9308413b69e6bf1ef83e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-14 20:29:36 +01:00
Simon Hausmann 79e311cb2c Ported built-in exception getter to new calling convention
Change-Id: Ica14229cfa280afba2003b3b50930c2986aa2f23
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-14 20:29:14 +01:00
Simon Hausmann 30af543228 Convert property deletion runtime functions to new calling convention
Change-Id: I312ccbd65d9aad5e8db349af94c00bed0fd73544
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-14 20:28:51 +01:00
Simon Hausmann 46f70d324f Convert unary ops to new calling convention
Change-Id: I974fd474c4f35885e42dd219e2daa65098f4e0a1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-14 20:28:20 +01:00
Simon Hausmann 4d21c8b2b6 Convert construct runtime functions to new calling convention
Change-Id: I063508ff780d2f6371f77eca7138a09d78e1a45e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-02-14 20:27:28 +01:00
Lars Knoll da5ac2aabd 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>
2013-02-14 15:05:47 +01:00
Lars Knoll 134abefda2 Remove another virtual.
Change-Id: Id83e7e5153160247b15c1506cb3c741cc6b77368
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-14 14:57:50 +01:00
Lars Knoll 99fec39372 Remove another virtual
Change-Id: I185be24d4c09d2078c3459460875c4711bf17ddb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-14 14:57:28 +01:00
Lars Knoll 1056456cb5 Move call/construct over into the new vtable.
Change-Id: I4f58a1fac25440695bdc62a49adb51a887616a5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-14 14:57:00 +01:00
Lars Knoll bed14ea268 Remove another virtual and de-inline a call method
Change-Id: Ia7cc0bf9f4024a65020fef75666ae13d3691bc54
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-02-14 14:51:15 +01:00