Commit Graph

117 Commits

Author SHA1 Message Date
Lars Knoll d7416a80fa 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>
2012-11-19 10:28:56 +01:00
Erik Verbruggen 84f722c496 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>
2012-11-15 22:08:38 +01:00
Erik Verbruggen ef25fdacc8 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>
2012-11-15 22:05:33 +01:00
Erik Verbruggen 424532fd92 Fix for calling Error constructor as a function (15.11.1).
Change-Id: I989c2a546b7e4d9a4fd2f7ff8b682c747d38332f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-15 13:49:09 +01:00
Lars Knoll bd63199bba 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>
2012-11-15 13:43:53 +01:00
Lars Knoll 4810e095b7 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>
2012-11-15 13:40:55 +01:00
Lars Knoll 1cbec5b889 Remove unused variable and method
Change-Id: I357f3062f58e76c1749c9818426be5c0eedf3327
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-15 13:39:16 +01:00
Erik Verbruggen 8f69d75c78 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>
2012-11-14 11:45:03 +01:00
Lars Knoll bc42b47a11 Better argument ordering.
Change-Id: I1d47ce7bd2cf27bc43a0e9afbfb2914296c9d704
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-11-12 09:18:12 +01:00
Lars Knoll c5b258c21d 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>
2012-11-12 09:17:23 +01:00
Lars Knoll 29bc5f59a1 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>
2012-11-11 21:24:50 +01:00
Lars Knoll 0c1424362f 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>
2012-11-11 21:24:43 +01:00
Lars Knoll d5fe0946bd 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>
2012-11-11 21:24:38 +01:00
Lars Knoll 288e5048b7 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>
2012-11-11 21:24:32 +01:00
Lars Knoll d2fb24b80a 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>
2012-11-07 13:57:59 +01:00
Lars Knoll 29f8677ac2 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>
2012-10-31 17:00:03 +01:00
Lars Knoll ddba8f6bb0 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>
2012-10-31 16:57:24 +01:00
Lars Knoll 950e4f70a3 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>
2012-10-31 12:48:04 +01:00
Lars Knoll aa96410f3f 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>
2012-10-31 12:46:49 +01:00
Lars Knoll 577cbfa2ee Added basic support for 'for (var x in y)' statement
Change-Id: I8f3c8add78bebf92e0073348d1ecbdf3f328af6d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-31 12:45:49 +01:00
Erik Verbruggen 4554cdfdcb 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>
2012-10-25 09:29:37 +02:00
Erik Verbruggen 17b1b66104 Implemented calls in the interpreter.
Change-Id: Iafc9b04a1aa39272ab8aac24fb410a23df02a756
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-10-25 09:27:27 +02:00
Erik Verbruggen a412eab7a8 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>
2012-10-25 09:08:05 +02:00
Lars Knoll 5f06c71bc1 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>
2012-10-24 08:46:49 +02:00
Lars Knoll 04b12a90b8 Implement regexp support
Change-Id: I86c9bbe69c9ba4ae9d300b62e7d16b372f3478ea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-20 12:33:20 +02:00
Lars Knoll 03f9fb6b61 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>
2012-10-19 07:28:55 +02:00
Lars Knoll 285a4954e8 Micro optimisations
Change-Id: Ifae82d259f55e8e3791ef05eb7ea5f607fbfd747
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-18 15:04:06 +02:00
Lars Knoll 82ee7d361a Optimise function calls a little.
Change-Id: I906a4f27bf47ae0ae088ae40a747b28ba827e10a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-18 14:45:58 +02:00
Lars Knoll 19af71d4bf Remove unused method
Change-Id: I780afc37dd651922ca66770a69e9ae2050d198c4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-18 12:07:29 +02:00
Erik Verbruggen e0d4df2b3f Silence signed/unsigned comparison warning.
Change-Id: Id23e48b370a73baabcc6875b51067f60dadec0c4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-18 11:02:33 +02:00
Lars Knoll e5473687ec Cleanup
Remove __qmljs_init_object and replace it with
Value::fromObject

Change-Id: Ibc8bd9e7ecd56c6713dc08add72e5cd35ffea78e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-18 10:33:34 +02:00
Lars Knoll 535ed96f88 Clean up toUInt16 and fix a small typo in toUInt32
Change-Id: I49e57cb8eed83237d8b2477297e429cd38d07c19
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 22:56:18 +02:00
Lars Knoll 96fc5e908c Clean up to(U)Int and toInteger conversions
Change-Id: Ifdd4f22bd50ba2a4c0dd710ba346a36c84b2c305
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 22:48:58 +02:00
Lars Knoll 2fe85372df Simplify some builtin methods
Change-Id: I2c524b3634c65e7cc0ee72a21937048c4e3ae10a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 17:41:14 +02:00
Lars Knoll c2e3c31053 Make some methods inline
Change-Id: Ic36761b9ee95c7b51b0eb2c23daa01084d316067
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 16:42:17 +02:00
Lars Knoll 56e632c2c7 Implement some stubbed out methods
Change-Id: I7533c33850235fb914e35e4fbd92def654158db7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 14:54:39 +02:00
Lars Knoll c85ac2d9cf Pass Value, not 'const Value'
Passing const values doesn't make a whole lot of sense,
esp. when the passed object is POD.

Change-Id: I7372407862828cf7fa8461583069743ecf583170
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 14:53:34 +02:00
Lars Knoll 52a30a1e6f Fixed more calling conventions
Implemented a few stubs for qmljs_inplace_op_member

Change-Id: I542a535862339285db7ec0b547754453545a3dc0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 14:52:41 +02:00
Lars Knoll 617240f92a More changes to the new calling convention
Change-Id: Icc22f2ed342ced9eac0d62307151acca8031d2c2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 14:40:40 +02:00
Erik Verbruggen e6cb8faa91 Change usages of math.h into cmath. Fixes MacOS build.
At least on MacOS, but possibly elsewhere too, including cmath before or
after math.h will undefine e.g. the isinf macro (and others). The math.h
include headers will make sure that math.h cannot get included twice,
so this will end with a situation where isinf is undefined, but
std::isinf is there.

Change-Id: Ie59aeadf2adde511ea8db5eb2fafd3272a7e9d51
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 13:29:00 +02:00
Lars Knoll f5b98f6386 Generate correct code when calling values
__qmljs_call_value was still using a pointer to a Value.
In addition, qcv4isel_masm.cpp was using a wrong order
of the arguments.

Change-Id: I0414aa732ae8074420e4f11525f5b04712cc1bab
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 09:35:39 +02:00
Lars Knoll bd0e6209dd Convert most operations to the new calling convention
Change-Id: I2dbf61b215a03a3c44c9c6bc431859bb9d067625
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 09:32:13 +02:00
Lars Knoll 69e7dfe5f4 Convert some more methods to the new calling convention
Change-Id: Ieeeb86d94d1094213430a1b4afa0d3a91785ac45
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 09:11:03 +02:00
Lars Knoll 7efad31f67 Introduce a Bool typedef for boolean return values
This helps in the interpretation of the type returned
by a method. It also makes it easier to later on change
the type back to a real bool if it makes sense. Bool
is currently typedef'ed to uint.

Change-Id: I905d828f4f7b0f7e778b7f197c4ed61117ce5d16
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 09:09:56 +02:00
Lars Knoll b010e46d03 Convert some more methods to the new calling convention
Change-Id: I73a0e0e12b75828c83c5422d1c04a4ade4718324
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-17 09:08:46 +02:00
Lars Knoll bb09c83bcf Converting more runtime methods to the new calling convention
Change-Id: I331e7ebe6479bc5b6bac9cf4e3e6506a1cae1053
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-16 17:26:25 +02:00
Lars Knoll 537c5fa10d Move conversions to new calling convention
Change-Id: Iec01835b4fd27d8b71b7e709b05bcc757d09e417
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-16 16:57:24 +02:00
Lars Knoll f730f7526b More conversions to new calling convention
Change-Id: Iac67c9923bc3d7af76bb490cc8ca7cd3e922e192
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-16 16:57:18 +02:00
Lars Knoll 644804d6b8 More conversions to new calling convention
Change-Id: I6002715cc3f5c22d90a9ade6ae2152c2c3c8ebb2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-16 16:57:13 +02:00
Lars Knoll 3cdb661ee0 Converting more methods to the new calling convention
Change-Id: I5199a9e5439644cc259f131c8b0ba6a941989615
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-16 16:57:09 +02:00