aboutsummaryrefslogtreecommitdiffstats
path: root/qv4isel_masm.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Set data properties using __defineOwnProperties__Lars Knoll2013-01-041-0/+17
| | | | | | | | | | | | Properties in object literals are defined using defineOwnProperty, so that they get set even if the object prototype contains a non writable property with the same name. This fixes all remaining test cases for 11.1.5 Change-Id: I3928a144d09c51c5bf20a25bcb1c6c3c243975ee Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Implement { get/set ... }Lars Knoll2013-01-031-0/+21
| | | | | | | | Implement support for defining accessor properties through { ... }. Implementation for moth is pending. Change-Id: I558b6811bc5656dc0fae78c49e23155043ce9cb1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix a bug in catch{}finally{} and simplify codeLars Knoll2012-12-171-1/+4
| | | | | | | | | | | 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>
* Fix return value corruption in masm codegenerationLars Knoll2012-12-171-2/+2
| | | | | | | | | | | In some cases, the first argument for runtime calls and the return value where being placed in the same location on the stack leading to corrupted return values. This mainly happens when no local variable are defined, but other functions are being called. Change-Id: I93f1e518ce2998f62fb9f38c538dd718f41e522d Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Correctly set up nested functionsLars Knoll2012-12-131-5/+2
| | | | | | | | | 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/+4
| | | | | | | | 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>
* Fix masm compilation.Erik Verbruggen2012-12-121-1/+1
| | | | | Change-Id: I74f08976c046f7e8a6c16c786e6d32720ad88485 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup: Added a storeValue() overload that operates on an IR::Temp*Simon Hausmann2012-12-121-9/+10
| | | | | Change-Id: Iab23eaa41f4ef4d3f99dccd6d2075fa4ba8e918e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Correctly handle negative 0Lars Knoll2012-12-121-24/+1
| | | | | | | | | -0 and +0 are two distinct numbers. Since integers only have one 0 value, we need to convert the number to double when negating a 0 Change-Id: I915c4bd7168eece947fa91c6b65137a873d4f75a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove IR::Function from the runtime.Erik Verbruggen2012-12-111-12/+17
| | | | | | | | | | 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>
* Make MASM InstructionSelection reentrantSimon Hausmann2012-12-111-251/+326
| | | | | | | | | | | | The isel is currently not reentrant because the MacroAssembler's instruction output buffer is inaccessible and can only be reset by destroying the instance and re-creating it. This patch moves assembler specific code into an Assembler subclass and changes isel to instantiate and use it instead of subclassing JSC::MacroAssembler. Change-Id: Ic633214c67f475195202459698077e47a75ece2f Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Fix typeof to work with undefined referencesLars Knoll2012-12-081-4/+16
| | | | | Change-Id: I90cd2b34a25476dfee1ec01315275b6c179d11dc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* [masm] Inline ushrSimon Hausmann2012-12-051-1/+1
| | | | | Change-Id: Ia3855625e72ae7ed50b9890edbad11e2aa338930 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Remove unused variableSimon Hausmann2012-12-041-5/+0
| | | | | Change-Id: I6034dad659ea4029256828bee06e8621902fd52c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Clean up inline arithmetic operations implementationSimon Hausmann2012-12-041-116/+11
| | | | | | | Less namespacing, less clutter. Change-Id: I08935413fc8dc021f2c207c2a8237067fd8f4c43 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Implement and/or and xor inlineSimon Hausmann2012-12-041-3/+40
| | | | | Change-Id: I1e2703eaf1f8d4f5397690380ab6a76859ee1720 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Implement shl and shr inlineSimon Hausmann2012-12-041-2/+32
| | | | | Change-Id: Ibc5475030a68d9270e283aa8ac981661c590a29f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Simplify inline op registration codeSimon Hausmann2012-12-041-19/+43
| | | | | | | | | | Don't store pointers to the JSC::MacroAssembler functions directly in our binops table but provide wrapper functions. Those can do operation specific things, like in case of mul32 map from (imm, reg) to (imm, reg, reg) or take care of overflow handling (needed for add/mul, but not shl/shr). Change-Id: I63297c5be22c2b978b5dedabdc3baa5be0e586af Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Implement inline multiplicationSimon Hausmann2012-12-041-11/+19
| | | | | | | | Unfortunately this requires an extra entry in the info for the binary op, because we can't do mul(imm, reg) only mul(imm, reg, reg). Change-Id: I75beb3cb08ff24421483e824afaa9703befa488a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Cleanup: avoid redundant convertToValue() call in binop generationSimon Hausmann2012-12-041-4/+3
| | | | | | | We already do that conversion to a constant VM::Value earlier. Change-Id: I142435f2be7c841f322ccfc34473b23cf85e6b5c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [masm] Clean up binop code generationSimon Hausmann2012-12-021-135/+127
| | | | | | | | | | | 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>
* Remove the DeclarativeEnvironment class againLars Knoll2012-12-021-4/+2
| | | | | | | | | 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>
* [masm] First implementation of inline addition / subtractionSimon Hausmann2012-12-021-3/+91
| | | | | Change-Id: I4e54ae0feded8d99737245c870e0dfbb9b80247e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Get rid of variableEnvironmentLars Knoll2012-11-301-2/+2
| | | | | | | | | | | | 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>
* Correctly instantiate variables in the local scopeLars Knoll2012-11-271-0/+12
| | | | | | | | This fixes cases where eval() would create variables in the wrong scope. Change-Id: Ie93ec2d1fb125e588c1b6ffa2ca8ca4b6e3112c9 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Fix some issues with the delete operatorLars Knoll2012-11-251-3/+9
| | | | | | | | Properly implement delete operator for identifiers and local variables. Change-Id: I8ac55edc80c31a94d11444c9f5c78caf4b131c95 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Support for the with statementLars Knoll2012-11-251-0/+9
| | | | | | | | | | | | 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>
* Fix return from generated code when return value is passed on the stackSimon Hausmann2012-11-241-2/+22
| | | | | | | | | | | | | | 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>
* Cleanup instruction selection interface for MASM and MOTH.Erik Verbruggen2012-11-201-19/+1
| | | | | | | This fixes a regression in MOTH. Change-Id: Icd9e2ebf49ab6190bf932a94da03c4171c8d9c61 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* return results directly instead of using the contextLars Knoll2012-11-201-2/+2
| | | | | | | | | 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-0/+14
| | | | | | | 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-2/+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-191-11/+11
| | | | | | | | | 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>
* Optimise move instructions involving constantsLars Knoll2012-11-141-14/+14
| | | | | Change-Id: Ic12a54ab1c5789cc5684d38961c58f6b34f9597a Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Allow Const's as operands to BinopLars Knoll2012-11-121-8/+6
| | | | | | | | | | | 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>
* Add missing break statementLars Knoll2012-10-311-0/+1
| | | | | Change-Id: I61e91701bbaa173c8189af9f703ac2b509b99cd0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Implement initial support for the delete operatorLars Knoll2012-10-311-13/+28
| | | | | | | And don't dump the assemply unless SHOW_CODE is set. Change-Id: I17ad36f002404b57c65f910048e5c82d42307976 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Added basic support for 'for (var x in y)' statementLars Knoll2012-10-311-0/+11
| | | | | Change-Id: I8f3c8add78bebf92e0073348d1ecbdf3f328af6d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Readability change: builtin_invalid implies baseName->id being set.Erik Verbruggen2012-10-251-32/+28
| | | | | | | And vice-versa, so drop the wrapping if statement. Change-Id: I57b7aef23feeee6b3f94edd5ca85bfc460bb2307 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix stack alignment to align on 16 byte boundaries.Erik Verbruggen2012-10-241-3/+0
| | | | | | | | Aligning on 16 byte boundaries is a requirement for MacOS, and it gives the optimal performance when using MMX on stack allocated data. Change-Id: I1c9a27e796f1c240002a05196490f15df68c3f73 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Proper exception handlingLars Knoll2012-10-241-28/+15
| | | | | | | | | | | 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>
* [masm] Cleanup: Eliminate ScratchRegister2 on AMD64Simon Hausmann2012-10-231-3/+5
| | | | | | | | | | | | | | | | Functions like loadArgument and storeValue that work right above the macro assembler may use ScratchRegister because they only call functions that do not "allocate" that register themselves. copyValue on the other hand is a higher-level function and may not use ScratchRegister because the functions it calls (i.e. loadArgument) may clobber it. In the 64-bit case of quickly copying one VM value to another location, we might as well use the ReturnValueRegister as intermediate register and therefore re-allow the use of ScratchRegister in the lower-level loadArgument/storeArgument functions. Change-Id: I9f0c0d326e5af87101972f0cceb86cffe4ebdd0d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Eliminate Gpr0-3 register aliasesSimon Hausmann2012-10-201-6/+6
| | | | | | | | Instead introduce a ScratchRegister which is explicitly different from the ReturnValueRegister and is therefore safe to use. Change-Id: I4675b6a4d242f3e02a4e848c7b65660ffa97cfe6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Reduce use of Gpr0Simon Hausmann2012-10-201-5/+4
| | | | | | | | | We don't need to explicitly operate on Gpr0 for the return value when we can use the ReturnValueRegister alias instead. No change in code generation because on Amd64 and Ia32 Gpr0 == ReturnValueRegister. Change-Id: Ia21613a51878093a9fb425879645ea3b8a4dbf72 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implement regexp supportLars Knoll2012-10-201-0/+5
| | | | | Change-Id: I86c9bbe69c9ba4ae9d300b62e7d16b372f3478ea Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make Value a real PODLars Knoll2012-10-191-2/+2
| | | | | | | | | | | | | | | Remove the inheritance from ValueData and ValueBase. Use a few ifdef's for 64 bit instead of a lot of template magic and inheritance to get the correct implementations for 32 and 64 bit. Saves some code, and makes Value a real POD type. Apparently this also helps gcc generate better code, crypto.js runs another few percent faster now. Change-Id: I9dac488b27e629e6ef8c096f2bee86a5d678fd49 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix insecure use of format string.Erik Verbruggen2012-10-181-3/+1
| | | | | Change-Id: I6cd282d5780e418bea7a07d4639c035a98b3ed65 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Inline string creation in the generated JIT codeLars Knoll2012-10-181-2/+3
| | | | | Change-Id: Ifaef87046c083b36222f6204291ee3a61ffcd20b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix warning about unused opName parameterSimon Hausmann2012-10-171-1/+1
| | | | | | | Pass it up to generateFunctionCall :) Change-Id: Ic05854e2a7b8bea09eb652e37df43587ffe62824 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add missing break statementLars Knoll2012-10-171-1/+1
| | | | | Change-Id: I9f5d4cb6a7db0cd63c419cdf41c1a7497453559e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>