Erik Verbruggen [Tue, 4 Dec 2012 11:00:23 +0000 (12:00 +0100)]
Allow only the ExecutionEngine's StringPool to create Strings.
Strings are the only non-Object Values living on the heap. So by
tracking creation, we can help the future GC a lot.
Change-Id: I5d5044f9ff10da42aeb75dd4a556d6ab3d839b1a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 4 Dec 2012 10:30:26 +0000 (11:30 +0100)]
Fix another memory leak.
Now we should only leak objects that are VM::Values, and directly
related objects like the PropertyTable. The directly related ones will
disappear through destructor calls when the VM::Values are GC-ed.
Change-Id: Id221ac62a22671d86bbc6ac9beea49d2bd5b330d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Erik Verbruggen [Tue, 4 Dec 2012 09:55:01 +0000 (10:55 +0100)]
Merged Value load instructions.
Change-Id: I45601d9618f8f569ff5705693fbea383d73c031d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sun, 2 Dec 2012 18:58:35 +0000 (10:58 -0800)]
Pass the ExecutionContext into the code generator
Use the contexts strict mode flag to correctly parse
eval code inside strict mode sections.
Add code to allow the code generator to throw syntax
errors.
Change-Id: I4e4258b0d0b88952f4d609ec51bbe8db9a1c66a9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Sun, 2 Dec 2012 19:10:09 +0000 (20:10 +0100)]
Fix clobber list for inline add/sub/mul instructions
These inline asm blocks do also change flags, therefore we need to add the
condition code register to the list of clobbered pseudo registers.
Change-Id: Iea7b2557813bbb2fa86d7506e6416092fdc14702
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Sun, 2 Dec 2012 18:29:59 +0000 (10:29 -0800)]
Fix code generation for try statements
The old code was not correctly handling statements as
try { return; } finally {...}
and others. In addition it was hard to read an maintain.
We now keep a stack of try statements inside the code
generator. Loops know about their surrounding try statement.
Whenever a break, continue or return statement is encountered
we now generate code for the finally statements and exception
handlers we need to cleanup.
Change-Id: I53bcc0587f1e923be00fea9b562453ef1e96b2de
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Sun, 2 Dec 2012 18:04:57 +0000 (19:04 +0100)]
[masm] Clean up binop code generation
Instead of a gigantic switch and that duplicated across regular binop
and in-place binop, let's use one table where we can store all sorts
of meta-information about various aspects of the op implementations.
Then we can centralize the code for generating the inline operation
as well as the call to the fallback in one helper function.
Change-Id: I13b6dae7fd2a1490ae315689fa5f813eee83dd7b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Sat, 1 Dec 2012 19:08:26 +0000 (20:08 +0100)]
Remove the callFunction() method
Give Object a virtual call() method, that simply throws
a type error. FunctionObject reimplements this to do the
right thing.
Change-Id: I5a11a4de0302ad86b9ad3a822501224e11692b70
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 18:57:26 +0000 (19:57 +0100)]
Fix qmljs_call_property
Change-Id: Ic32fc8815704ed201a3b50eae05ff2705372210d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 18:39:57 +0000 (19:39 +0100)]
Throw when trying to set an undefined variable in strict mode
Change-Id: Ia4cbe302b96e53147aa7857dcded811e73136329
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 13:25:54 +0000 (14:25 +0100)]
Further clean up the ExecutionContext
remove the distinction between initCallContext and
initConstructorContext. Since the context now has a
pointer to the current function, we can also simplify
the wireupPrototype method.
Change-Id: I06cbaced2438b01b3033182e136e1504c087c8c0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 13:05:07 +0000 (14:05 +0100)]
Remove the DeclarativeEnvironment class again
The class is a specification detail that we can implement
in a more performant way. ExecutionContext now contains
everything needed again.
Change-Id: Ideb5f04eeeecaf2b8543676c626e3943e4d6d7a1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 30 Nov 2012 22:15:55 +0000 (23:15 +0100)]
Remove the outer member in declarativeEnvironment
The function already has it as the scope parameter, so
don't duplicate the data.
Change-Id: Iadd0418cafa9ad273db11c06c44086ac64b1e5bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Sun, 2 Dec 2012 00:04:34 +0000 (01:04 +0100)]
[masm] First implementation of inline addition / subtraction
Change-Id: I4e54ae0feded8d99737245c870e0dfbb9b80247e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Sat, 1 Dec 2012 22:59:53 +0000 (23:59 +0100)]
Simplify push(IR::Const*)
Use the convertToValue() function instead of manually trying to
convert the IR::Const to a VM::Value.
Change-Id: Ib669def3c2ef3dfba6cabb0b0c0b3c1d014a13ca
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Fri, 30 Nov 2012 08:48:46 +0000 (09:48 +0100)]
Clean up the DeclarativeEnvironment
Add a pointer to the FunctionObject in there, and remove the
duplication of the formal and local variable names.
Change-Id: Id8017b3e167228292b5d351e02b8927f0bfb41eb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Thu, 29 Nov 2012 21:37:25 +0000 (22:37 +0100)]
Get rid of variableEnvironment
Found out that the variableEnv is only required
for two use cases: To expose the exception in the
catch statement, and to create temporary
environments for the with() statment. Both can be
better handled differently and don't require the
overhead of two environments.
Change-Id: I149e1fd7bdfc3267544b141b6f94e46e42cf641b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Thu, 29 Nov 2012 21:25:21 +0000 (22:25 +0100)]
Give primeIds the amount of bits it requires
Also mark the prime number array as const
Change-Id: Ieae3e5d13decb0edf0d086780b323a12351a55d8
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:41:26 +0000 (14:41 +0100)]
Add some debugging infrastructure to the interpreter.
This currently mainly intended to be useful in a C++ debugger. The
infrastructure makes it a lot easier to access (parent) contexts, find
function names, etc.
Change-Id: I0493d3a3bd4bf5c3a03379c1a2b545ed76862cd5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:39:19 +0000 (14:39 +0100)]
Set the name of a function in more (most?) cases.
Change-Id: I1c2b9d61b6d97e3c2a8cb976fb6be8b68d51ae28
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:36:16 +0000 (14:36 +0100)]
Fix missing code generation for inplace operations on locals.
Change-Id: I8fe7d87eabf2566f251319e8dae005aacc27eb0d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:35:18 +0000 (14:35 +0100)]
Fix outgoing argument start position.
Change-Id: Ie1b86746dc578ce479f5c072e2e1190826a7739c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Wed, 28 Nov 2012 22:26:26 +0000 (23:26 +0100)]
Implement Object.keys and obj.proto.propertyIsEnumerable
Change-Id: I30df135ad95f24246e43553b2711ad1008319d56
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 28 Nov 2012 22:10:03 +0000 (23:10 +0100)]
Implement Object.seal/freeze/preventExtensions
And the corresponding getters.
Change-Id: I5038ec3f87f932d65c67cafd36ec00b9970a5f51
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 28 Nov 2012 21:45:43 +0000 (22:45 +0100)]
Add defineGetter and defineSetter methods to Object
These methods are de-facto standard (every engine implements
them), and also allow testing of accessor properties.
Change-Id: I1fcaa7467f7be56ea758bf511e843385f74b9641
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 13:59:42 +0000 (14:59 +0100)]
Fix copy-paste coding error. "m" is null in the else part.
Change-Id: I5ef62c984f169b9a50ec1d90bd02c5593fde3745
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 13:16:21 +0000 (14:16 +0100)]
Tune the message property (value) of SytaxError a bit.
Change-Id: I231eb1eeb8f01461ea61b3989743bbd01256e251
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:47:20 +0000 (13:47 +0100)]
Replace qIsNaN usage with std::isnan, which is often faster.
Change-Id: Ie4d16fcdb575ca168d5b58978c5a510acf0cd1ca
std::isnan is often a compiler intrinsic.
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:44:26 +0000 (13:44 +0100)]
Tune the bucket count a bit to be a prime upto 68000 entries.
The ECMA test suite has some tests that throw in vars with all possible
unicode names. So, this should make it safer for longer.
Change-Id: I4a65ab7d09a357d7665509d38e401098ab6e4607
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:39:14 +0000 (13:39 +0100)]
Introduce a simple string pool to speed up lookups.
This change uniques string pointers, so the String::isEqualTo will more
often succeed in the pointer-equality case.
Change-Id: I1d4f1a70147c48bc75359642a56a0446b5fbf199
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:35:53 +0000 (13:35 +0100)]
Stop leaking the DeclarativeEnvironment and ExecutionContext.
Also fixes non-POD warnings with Clang, as the constructor of the
DeclarativeEnvironment is now gone.
Change-Id: I15e02aabb195243415b088a8b030f0064a7e84a3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 10:00:23 +0000 (11:00 +0100)]
Throw a SyntaxError instead of printing an error message.
Change-Id: I94ef8a4f2bea80bc3689b104e381a9dc134439fa
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Tue, 27 Nov 2012 23:12:33 +0000 (00:12 +0100)]
Fix a bug in Object::__put__()
The method was always throwing in strict mode, due to
a missing return statement.
Change-Id: I85e44f8067d1f2aea76d03e42abf31a0d5a2d180
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Tue, 27 Nov 2012 22:23:04 +0000 (23:23 +0100)]
Obey strict mode for property getters and setters
Change-Id: I6f51cd72c2607989c55373dfee53130381f5ef75
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Tue, 27 Nov 2012 21:59:51 +0000 (22:59 +0100)]
Remove unused methods
Change-Id: I4b0553b1fb6522131a05a66f8cba44bce5192e55
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Tue, 27 Nov 2012 21:42:20 +0000 (22:42 +0100)]
Implement the first parts of strict mode.
Tested with eval() which now obeys strict mode
semantics.
Change-Id: Ib3c7f31047e43c1ef0fa74261f23ec4f2ea4244f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Erik Verbruggen [Tue, 27 Nov 2012 15:46:04 +0000 (16:46 +0100)]
Check for strict mode, and store it.
Change-Id: I88e48a982eb6d4041aed085de0420d98cf96d406
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 27 Nov 2012 11:17:19 +0000 (12:17 +0100)]
Add more built-ins to the interpreter.
Change-Id: I6a1656a8a2042b0a02d6e3bb8e59c9db52f6fd5d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Mon, 26 Nov 2012 22:26:39 +0000 (23:26 +0100)]
Correctly instantiate variables in the local scope
This fixes cases where eval() would create variables
in the wrong scope.
Change-Id: Ie93ec2d1fb125e588c1b6ffa2ca8ca4b6e3112c9
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Simon Hausmann [Mon, 26 Nov 2012 21:49:35 +0000 (22:49 +0100)]
Fix constant value parameter passing on ia32
Fix the order of tag and value when pushing constants onto the stack, given
that the stack grows in reverse order.
This fixes crypto.js and all sorts of other tests.
Change-Id: I1f6aa546e5453f890db582283fd4da609292f22b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Mon, 26 Nov 2012 13:38:14 +0000 (14:38 +0100)]
Fix: do not rune codegen when there is no program.
Happens in valid cases like an empty JS file (or one only containing
comments).
Change-Id: I553f57503b46da29276b06532a14e2a74395d84c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Sun, 25 Nov 2012 19:53:57 +0000 (20:53 +0100)]
Fix the worst problems with eval()
Support is still not fully compliant. Especially
variables declared within eval() might end
up in the wrong (global) scope in some cases.
Change-Id: I44d60f57b2af0b54a2759bd887fb2b3751116cd2
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Sat, 24 Nov 2012 23:26:28 +0000 (00:26 +0100)]
Fix some issues with the delete operator
Properly implement delete operator for identifiers
and local variables.
Change-Id: I8ac55edc80c31a94d11444c9f5c78caf4b131c95
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 24 Nov 2012 21:07:02 +0000 (22:07 +0100)]
Support for the with statement
Add the with object (list) to the environment, and check properties
there if it's available.
Generate IR statements implementing with() support.
Add two new builtin methods to enter and leave a with scope.
Implement support for the builtin's in masm.
Make sure exception handling works across with scopes.
Change-Id: I8257a16cfccc91a1acedfd740ade711b016b33fd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 24 Nov 2012 21:04:33 +0000 (22:04 +0100)]
Remove some unused methods
Change-Id: Ic23a93822ff28701890e97c2d5844fa9a23c4b4a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Sat, 24 Nov 2012 08:59:51 +0000 (09:59 +0100)]
Fix return from generated code when return value is passed on the stack
On ia32 the return VM value doesn't fit into a register. Instead the
caller provides a pointer to where the return value can be stored
as a first invisible argument. This is where we then copy the return
value to. It is the callee's responsibility to remove that one invisible
argument from the stack. Usually this is done using a "ret <n>" instruction,
which however masm doesn't support, so we emulate it. That might not be
any slower, since it's kind of replacing the CISC ret <n> instruction with
RISC :)
Change-Id: I4cb842e5a0a95a3d52867e66216dd711d627cf25
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Sat, 24 Nov 2012 07:37:20 +0000 (08:37 +0100)]
Fix compilation on ia32
Added a stub loadArgument(Expr, Register) that isn't actually
used at run-time
Change-Id: Ie75df4dbdde84f9c51f164292ff2fc9b01aa1da3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Fri, 23 Nov 2012 22:56:25 +0000 (23:56 +0100)]
Correctly bind varibles in the global context
Variables need to be bound to the execution context
before entering the method. For the global scope this
implies that declared variables are available, but may
be undefined. The lines:
print(x)
var x = 1;
has to print 'undefined' and not throw a type error.
Change-Id: I9d7062823da83cd4c4e74588693bb0ce8dc85c6b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Erik Verbruggen [Thu, 22 Nov 2012 15:28:13 +0000 (16:28 +0100)]
Fixed temp compression and added a whole lot of debug info.
Unlike the variables (locals), the return value did not have a fixed
temp. So by pinning it, it won't move around.
Change-Id: Ib35024e2baa60b64fcb05ca4aa7f49acad89e7cb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 22 Nov 2012 11:18:56 +0000 (12:18 +0100)]
Fix for local count in the global context.
Change-Id: If0f07c995a51df45603c5581c721da15c1050158
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 20 Nov 2012 12:41:49 +0000 (13:41 +0100)]
Keep the EvalISelFactory in the ExecutionEngine.
Also corrected the class name cApiTaliSatiOn.
Change-Id: I131566e904c8ee575686a469f16d098dd512d865
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Tue, 20 Nov 2012 09:50:42 +0000 (10:50 +0100)]
Fix function calls on linux/ia32
Remove supposed stack size alignment correction after function calls
This code was supposed to "align" the stack pointer after a function call,
but we can't really add more to the stack pointer than what we previously
subtracted.
It should've practically been a noop on amd64 since we don't actually
use the stack for function calls there, which is why this manifested only
on ia32.
Change-Id: I5644e9e179bd1b7c45daca7d88687bd5d83a4104
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Erik Verbruggen [Tue, 20 Nov 2012 12:24:24 +0000 (13:24 +0100)]
Use an isel factory instead of MASM in FunctionCTor.
Change-Id: I070f056411f16d837ff5eac191fac11cd0bd3c47
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 20 Nov 2012 11:45:36 +0000 (12:45 +0100)]
Cleanup instruction selection interface for MASM and MOTH.
This fixes a regression in MOTH.
Change-Id: Icd9e2ebf49ab6190bf932a94da03c4171c8d9c61
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 20 Nov 2012 08:35:32 +0000 (09:35 +0100)]
Compress temp usage in the interpreter.
Uses a variation on linear scan register allocation as the algorithm. As
it depends on liveness analysis, keep that data around after codegen is
finished (in IR::Stmt::Data). Added clean-up code for it in the
IR::Function destructor.
Change-Id: If3636648efbafcc1df469a24aaa885e21e6a2f16
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 20 Nov 2012 08:48:11 +0000 (09:48 +0100)]
Actually return the return value from the interpreter.
Change-Id: I38cb4bc431f1bab796f08fc217747e06070a2c78
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 20 Nov 2012 08:47:18 +0000 (09:47 +0100)]
Make LLVM backend compile again.
Moved common code into a separate function.
Change-Id: Iaa96c27214659a23b3df70b80560fb8f42792b38
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 20 Nov 2012 09:08:14 +0000 (10:08 +0100)]
Fix debug code and add some asserts.
Change-Id: I947a72ff43190d15fd4a2857ed97b75cc510db66
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Mon, 19 Nov 2012 21:24:12 +0000 (22:24 +0100)]
Move the exception variable into the engine
It's easier to store this in the engine then
in the execution context.
Change-Id: I01ff447602a7d785165e774bdf6e1735c073be2d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Mon, 19 Nov 2012 20:32:15 +0000 (21:32 +0100)]
Remove the unused handlersBlock in the IR::Function
This block was used for the old exception handling mechanism
that is not in use anymore.
Change-Id: If5adf89e43a22ab167378827c0e97f9907d8a366
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Mon, 19 Nov 2012 15:14:37 +0000 (16:14 +0100)]
Make masm work again
Masm can't currently deal correctly with a single
instance of the isel object. Otherwise we'll
get completely wrong pointers to the different
methods set up.
Change-Id: Ic3ee06f2f83e5491a6b9ee422ae39611b89d1460
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Sun, 18 Nov 2012 23:00:50 +0000 (00:00 +0100)]
return results directly instead of using the context
The result variable in the context is not really
required, as we can return results directly in the
return value register.
Change-Id: I12554c228500aa24625ef82e31fd7f72989a71bb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Erik Verbruggen [Mon, 19 Nov 2012 13:59:53 +0000 (14:59 +0100)]
Added missing file.
Change-Id: I2b55ed78e8b30bffc67c4a1eee0bf4a438f0f29a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Mon, 19 Nov 2012 12:15:25 +0000 (13:15 +0100)]
Fix isel for eval and a whole bunch of other warnings.
A factory is now passed along to do the codegen for eval().
Change-Id: If15b1f28c9c0a8f8b6d18b56d6e7bc5d942927e5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Mon, 19 Nov 2012 10:54:54 +0000 (11:54 +0100)]
Added isNaN and isFinite to the global context.
Change-Id: Ia85d27a6ac82fd5dbf6b0f706747afa6418626b1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Sun, 18 Nov 2012 22:33:06 +0000 (23:33 +0100)]
Better handling of contexts and environments
Make the ExecutionContext standard compliant.
Move most of it's members into a new
DeclarativeEnvironment data structure that
contains locals and arguments.
Change-Id: I094f559168810dbd3717d677fe28750076015976
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 17 Nov 2012 21:14:06 +0000 (22:14 +0100)]
Properly namespace the math header
Change-Id: I0f4ac76376028081b13b1cdeaadc4c9b09c1556d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 17 Nov 2012 21:10:52 +0000 (22:10 +0100)]
Move Value into it's own header/cpp file
Change-Id: I2872d824a2016a653e64f0332f6416f416eef0e7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 17 Nov 2012 20:54:26 +0000 (21:54 +0100)]
Move the engine and context classes into their own files
Change-Id: Ie20138990908a921ca3d7475618275ed82d9cb5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 16 Nov 2012 22:07:10 +0000 (23:07 +0100)]
Rename Context to ExecutionContext
This is so it'll map to the name used in the
ECMAScript spec once the other refactorings
are in.
Change-Id: I8dcc7ad43b457ce50e7123c57bc4c770bcda8d11
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 16 Nov 2012 21:21:34 +0000 (22:21 +0100)]
Create a proper function object for eval
Still doesn't work correctly, as we can't modify
the global context there.
Change-Id: Ifd0ab217c3cf2d0c1b86f09907b440ea31c29ac8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Erik Verbruggen [Thu, 15 Nov 2012 15:56:52 +0000 (16:56 +0100)]
Fix __qmljs_string_to_number.
Stop using QString::toDouble, because it doesn't handle Infinity,
-Infinity,
10e10000, etc.
Change-Id: Ic51bc1d7fe4d2d233b551b87d48833f3ba76a6dc
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 15 Nov 2012 15:31:03 +0000 (16:31 +0100)]
Fix possible null-pointer deref.
Change-Id: I8c4e2c34b2a3803d1346a1f716a0e40bde6bfdff
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 15 Nov 2012 15:29:47 +0000 (16:29 +0100)]
Do not save/restore interpreter stack for exceptions.
Only the instruction pointer and targetTempIndex are needed.
Change-Id: I21279d68e74dac42d875e3ced9004e9d3c42c29d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 14 Nov 2012 14:16:17 +0000 (15:16 +0100)]
Fix for calling Error constructor as a function (15.11.1).
Change-Id: I989c2a546b7e4d9a4fd2f7ff8b682c747d38332f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>