aboutsummaryrefslogtreecommitdiffstats
path: root/moth
Commit message (Collapse)AuthorAgeFilesLines
* Another fix to the temp compression.Erik Verbruggen2012-12-201-15/+17
| | | | | | | Pin all temps that escape BBs, not only the return value. Change-Id: Idf21d117bfd12224cbff4cef35766c454189a5fa Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change the interpreter's stack frame to be allocated with alloca.Erik Verbruggen2012-12-194-149/+5
| | | | | Change-Id: Ia02ad1af3bb0f429a6078029bf7aaee5a17f3413 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Debugging fixes.Erik Verbruggen2012-12-181-0/+4
| | | | | Change-Id: I53b7301c28314210f96acc358744ff7e2a65546d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix temp compression, and actually add var decl instructions.Erik Verbruggen2012-12-181-0/+7
| | | | | Change-Id: Ic73a8e4284fd7644e37251498a659e107e49f0d8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix instruction tracing.Erik Verbruggen2012-12-181-4/+4
| | | | | Change-Id: Ie2ff005e2914bc372e4c6d08dd28d34efdde8da3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix moth isel for typeof.Erik Verbruggen2012-12-183-13/+72
| | | | | Change-Id: If5b5a91a69d6b6bf0fd3eaf4c21a42c575839be2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix a bug in catch{}finally{} and simplify codeLars Knoll2012-12-172-0/+8
| | | | | | | | | | | There was a bug in the implementation of unwindException(), that caused failures when called twice from one catch statement. Also refactor and simplify the TryStatement code further by introducing a rethrow builtin. Change-Id: I77bf37f1707042f402488ef2dfaf4e59bf8dc82a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Correctly set up nested functionsLars Knoll2012-12-132-11/+23
| | | | | | | | | Make sure we have the correct set of nested functions in both IR::Function and VM::Function. This is required so that closures can work correctly. Change-Id: I42493d5ee503090653b71650c8d19e06c4bcfdda Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix increment and decrement operatorsLars Knoll2012-12-121-0/+2
| | | | | | | | These operators have semantics that are different from (foo + 1), as they always convert the LHS to a number first. Change-Id: I3fb4a1a328e3dfcb334875435c3cec90d01b67dd Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Remove IR::Function from the runtime.Erik Verbruggen2012-12-113-35/+43
| | | | | | | | | | This fixes potential leaks of IR::Functions, lowers the memory usage of the functions that the VM needs (because the IR fields are not present in the VM::Function), and makes both managed by the module respectively the ExecutionEngine. Change-Id: I6748ad98b062f994eae9dd14f1919aec5aa7c0b0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add a MemoryManager, which does GC for the interpreter.Erik Verbruggen2012-12-084-16/+169
| | | | | | | | | Todo: - stack walking for MASM - fix all TODOs/FIXMEs and hidden treasures (bugs). Change-Id: I36f8cdc3a545df7287ce1df17b3570a9c017865e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add utility function to print stack traces from lldb/gdb.Erik Verbruggen2012-12-071-5/+2
| | | | | Change-Id: I81315a1cd6900dbecfc9a39d9dc4256461163921 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merged Value load instructions.Erik Verbruggen2012-12-043-92/+12
| | | | | Change-Id: I45601d9618f8f569ff5705693fbea383d73c031d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the DeclarativeEnvironment class againLars Knoll2012-12-021-15/+13
| | | | | | | | | 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>
* Clean up the DeclarativeEnvironmentLars Knoll2012-11-301-8/+8
| | | | | | | | 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>
* Get rid of variableEnvironmentLars Knoll2012-11-301-7/+7
| | | | | | | | | | | | 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>
* Add some debugging infrastructure to the interpreter.Erik Verbruggen2012-11-292-0/+24
| | | | | | | | | 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>
* Fix missing code generation for inplace operations on locals.Erik Verbruggen2012-11-291-35/+48
| | | | | Change-Id: I8fe7d87eabf2566f251319e8dae005aacc27eb0d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix outgoing argument start position.Erik Verbruggen2012-11-293-12/+36
| | | | | Change-Id: Ie1b86746dc578ce479f5c072e2e1190826a7739c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix copy-paste coding error. "m" is null in the else part.Erik Verbruggen2012-11-281-1/+1
| | | | | Change-Id: I5ef62c984f169b9a50ec1d90bd02c5593fde3745 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add more built-ins to the interpreter.Erik Verbruggen2012-11-273-24/+75
| | | | | Change-Id: I6a1656a8a2042b0a02d6e3bb8e59c9db52f6fd5d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix some issues with the delete operatorLars Knoll2012-11-251-2/+2
| | | | | | | | Properly implement delete operator for identifiers and local variables. Change-Id: I8ac55edc80c31a94d11444c9f5c78caf4b131c95 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fixed temp compression and added a whole lot of debug info.Erik Verbruggen2012-11-222-10/+50
| | | | | | | | 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>
* Fix for local count in the global context.Erik Verbruggen2012-11-222-13/+28
| | | | | Change-Id: If0f07c995a51df45603c5581c721da15c1050158 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Keep the EvalISelFactory in the ExecutionEngine.Erik Verbruggen2012-11-211-1/+1
| | | | | | | Also corrected the class name cApiTaliSatiOn. Change-Id: I131566e904c8ee575686a469f16d098dd512d865 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup instruction selection interface for MASM and MOTH.Erik Verbruggen2012-11-202-10/+9
| | | | | | | This fixes a regression in MOTH. Change-Id: Icd9e2ebf49ab6190bf932a94da03c4171c8d9c61 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Compress temp usage in the interpreter.Erik Verbruggen2012-11-201-0/+107
| | | | | | | | | | 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>
* Actually return the return value from the interpreter.Erik Verbruggen2012-11-201-2/+1
| | | | | Change-Id: I38cb4bc431f1bab796f08fc217747e06070a2c78 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix debug code and add some asserts.Erik Verbruggen2012-11-201-2/+14
| | | | | Change-Id: I947a72ff43190d15fd4a2857ed97b75cc510db66 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* return results directly instead of using the contextLars Knoll2012-11-202-7/+12
| | | | | | | | | 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>
* Fix isel for eval and a whole bunch of other warnings.Erik Verbruggen2012-11-191-2/+16
| | | | | | | A factory is now passed along to do the codegen for eval(). Change-Id: If15b1f28c9c0a8f8b6d18b56d6e7bc5d942927e5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Better handling of contexts and environmentsLars Knoll2012-11-191-4/+4
| | | | | | | | | | 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>
* Rename Context to ExecutionContextLars Knoll2012-11-194-19/+19
| | | | | | | | | 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>
* Do not save/restore interpreter stack for exceptions.Erik Verbruggen2012-11-152-20/+12
| | | | | | | Only the instruction pointer and targetTempIndex are needed. Change-Id: I21279d68e74dac42d875e3ced9004e9d3c42c29d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Changed the interpreter and compiler backends to move consts.Erik Verbruggen2012-11-143-21/+33
| | | | | | | See https://codereview.qt-project.org/39510 for details. Change-Id: I308364cd7d66ad2fd12e6ab7e185882fe8d1795e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix optimisation for passing a single argument to a call.Erik Verbruggen2012-11-141-6/+13
| | | | | Change-Id: I57a881ccd9f86a36d2d2ea5451046652ac0aca21 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix interpreter exception handling.Erik Verbruggen2012-11-142-4/+46
| | | | | | | | | 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>
* Untangle the Jump/CJump interpreter instructions.Erik Verbruggen2012-11-141-1/+6
| | | | | | | Shrinks the instruction size of a Jump a bit. Change-Id: I1a6b043d13e8493d8b0d23011141d46c10414fa8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove the tempRegister from moth by loading/storing values directly.Erik Verbruggen2012-11-144-118/+189
| | | | | Change-Id: I51982d5852db2e10234620d63c235484c5b8a573 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Added more builtins to moth.Erik Verbruggen2012-11-123-4/+87
| | | | | | | | | | | | - 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>
* Allow Const's as operands to Binop in moth.Erik Verbruggen2012-11-123-7/+32
| | | | | Change-Id: Ic0954c8170bc720a02fa88f3ab50112bff4767a7 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Allow Const's as operands to BinopLars Knoll2012-11-121-4/+4
| | | | | | | | | | | 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>
* Fixed/added name handling in expressions for moth.Erik Verbruggen2012-11-073-30/+65
| | | | | Change-Id: I6dc2faed00a465b74735d23e4c0bda9498dc7bd9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix use of uninitialised values.Erik Verbruggen2012-11-071-7/+7
| | | | | | | Also fix a typo in a variable name. Change-Id: I5e21544b69bed777c6733e2f517d52aca93a900b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Added more instruction selection to moth to get crypto.js through.Erik Verbruggen2012-11-074-25/+288
| | | | | Change-Id: Ic9582ea3241d97ef619304ece9f18c7eaae90407 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix temp/local addressing in MOTH.Erik Verbruggen2012-11-071-3/+4
| | | | | Change-Id: Iae9d7a7679b2e315c671de6890ccdaafa28f8a03 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add tracing for runtime methods.Erik Verbruggen2012-11-072-4/+7
| | | | | Change-Id: I540297e83e3e297d0724c3e08e5780eee0d2fac8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Added calls to built-ins to moth.Erik Verbruggen2012-11-073-5/+87
| | | | | Change-Id: I277b1136ed3b073a9fc85726dc714ef68109fbfa Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implemented calls in the interpreter.Erik Verbruggen2012-10-254-40/+96
| | | | | Change-Id: Iafc9b04a1aa39272ab8aac24fb410a23df02a756 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Added loading of "this" and renamed "ActivateProperty" to "StoreName".Erik Verbruggen2012-10-243-17/+35
| | | | | Change-Id: I033abe53368a815a9e3d036021429732f5526ea2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>