platform/upstream/qtdeclarative.git
11 years agoDon't allow this as LHS operand
Lars Knoll [Wed, 12 Dec 2012 07:22:06 +0000 (08:22 +0100)]
Don't allow this as LHS operand

Change-Id: I18a16721312b07485d0671bf072da27dc97490a8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove IR::Function from the runtime.
Erik Verbruggen [Tue, 11 Dec 2012 09:03:40 +0000 (10:03 +0100)]
Remove IR::Function from the runtime.

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>
11 years agoMake MASM InstructionSelection reentrant
Simon Hausmann [Tue, 11 Dec 2012 10:17:55 +0000 (11:17 +0100)]
Make MASM InstructionSelection reentrant

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>
11 years agoMake the Math constants constant
Lars Knoll [Tue, 11 Dec 2012 22:58:40 +0000 (23:58 +0100)]
Make the Math constants constant

Mark the Math.pi etc. constants as readonly.

Change-Id: I9224400ae48c7f21fc3b0478898c7c78aa7f45df
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement Object.getOwnPropertyDescriptor
Lars Knoll [Tue, 11 Dec 2012 19:45:19 +0000 (20:45 +0100)]
Implement Object.getOwnPropertyDescriptor

Change-Id: I800d3ebd93e41c7b0618e13ce8141d230b1bd58e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement Object.defineProperties and fix Object.create
Lars Knoll [Tue, 11 Dec 2012 19:27:17 +0000 (20:27 +0100)]
Implement Object.defineProperties and fix Object.create

Change-Id: I5a55b8d9b3c8e34018defcbe8ee97bde43a714c6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix infinite look when constructing a Function with no arguments
Lars Knoll [Tue, 11 Dec 2012 18:34:48 +0000 (19:34 +0100)]
Fix infinite look when constructing a Function with no arguments

Change-Id: Ic64d8f68678df3a6d71b0681ce32ad8f2a8802fe
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoUse QString::toDouble to convert to numbers
Lars Knoll [Mon, 10 Dec 2012 23:41:35 +0000 (00:41 +0100)]
Use QString::toDouble to convert to numbers

QString::toDouble() is always using the C locale in Qt 5,
strtod_l seems to have some stability issues for me, and
creating a locale on the stack doesn't sound very performant.

Change-Id: I35705a125b0c5913a5390ed1429c4e7490300f92
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoProperly set up the 'this' pointer
Lars Knoll [Mon, 10 Dec 2012 18:30:08 +0000 (19:30 +0100)]
Properly set up the 'this' pointer

Make sure the this pointer is setup correctly for
function calls. Also make sure we set the strict mode
flag correctly in all functions.

Change-Id: Idaacc92bf6469145b7addfac2bbddea588e85c2d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoReturn the this object if we ask for it
Lars Knoll [Sun, 9 Dec 2012 04:16:04 +0000 (05:16 +0100)]
Return the this object if we ask for it

This makes expressions such as typeof(this) work
correctly.

Change-Id: I44270f877fdee648e69ae44089ffc8fb57243401
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoAdd gc() function to triggering manual call to gc
Simon Hausmann [Sat, 8 Dec 2012 17:20:54 +0000 (18:20 +0100)]
Add gc() function to triggering manual call to gc

Similar to jsc

Change-Id: I7c547ef10cb1620523465fe659cd3075dd27a456
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd initial version of stack walker
Simon Hausmann [Sat, 8 Dec 2012 17:22:25 +0000 (18:22 +0100)]
Add initial version of stack walker

Not used yet

Change-Id: Id096f7efd5582d2a20c3b921180be0ebf48996a5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix compilation on posix-compliant systems.
Erik Verbruggen [Mon, 10 Dec 2012 08:56:30 +0000 (09:56 +0100)]
Fix compilation on posix-compliant systems.

memalign is deprecated and linux-only, and malloc.h does not exist on
non-glibc systems.

Change-Id: I44942378b7514c2a3fb6cb5f60256bbcc8ffe370
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix linker warning.
Erik Verbruggen [Tue, 4 Dec 2012 09:54:32 +0000 (10:54 +0100)]
Fix linker warning.

When compiling LLVM with GCC or Clang, the visibility for inline
methods is set to hidden. When linking code compiled without this
flag to LLVM, the system linker will produce warnings like:

ld: warning: direct access in llvm::fdbgs() to global weak symbol llvm::formatted_raw_ostream::~formatted_raw_ostream() means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

Change-Id: Ia86ff44660d448c8b0673e229137855e56c895f5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCreate a temp when a new expression is called with e.g. a closure
Lars Knoll [Sat, 8 Dec 2012 15:01:23 +0000 (07:01 -0800)]
Create a temp when a new expression is called with e.g. a closure

Don't crash on e.g.
var x = new (function() { return this; })

Change-Id: I120410b40ecda7fdc41e1dcc2c17251397143bc1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement Object.create/defineProperty/defineProperties
Lars Knoll [Sat, 8 Dec 2012 07:57:35 +0000 (23:57 -0800)]
Implement Object.create/defineProperty/defineProperties

Change-Id: I3a71597d012b5fb7d7a2f482f4a16431c71c1c22
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoKeep references while moving other expressions into a temp
Lars Knoll [Sat, 8 Dec 2012 06:44:51 +0000 (22:44 -0800)]
Keep references while moving other expressions into a temp

delete and typeof need to get correct references as arguments.
But we still need to evaluate other expressions correctly. The
best way to do that is to store them in a temp.

Change-Id: I7bcd152742bf752df47fd63a837952c57ea70bf5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix new/free mismatch
Simon Hausmann [Sat, 8 Dec 2012 04:18:22 +0000 (05:18 +0100)]
Fix new/free mismatch

Earlier patch replaced new with malloc, so when free'ing we also
have to use free() instead of delete.

Change-Id: I353494d88d4de91eb115b7c3dc41fcc556ff6aeb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix shadow builds
Simon Hausmann [Sat, 8 Dec 2012 06:32:04 +0000 (07:32 +0100)]
Fix shadow builds

Make it clear that the generated itab.c file ends up in the OUT_PWD,
so that for dependency tracking we can assume to find it there
instead of in the source dir.

Change-Id: I8c6435e5ba203819cde485cc1291037af58da000
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix typeof to work with undefined references
Lars Knoll [Sat, 8 Dec 2012 04:31:19 +0000 (20:31 -0800)]
Fix typeof to work with undefined references

Change-Id: I90cd2b34a25476dfee1ec01315275b6c179d11dc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix gc on ia32
Simon Hausmann [Sat, 8 Dec 2012 04:18:22 +0000 (05:18 +0100)]
Fix gc on ia32

* size += sizeof(MMInfo) risk unaligning size, to run it through align() again
* Don't rely on new returning an aligned pointer, use memalign
* Enable #ifdefs for 32-bit MMInfo/MMObject

Change-Id: If22abb9e0d77ece385793ea5e92540f177d3a07c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFixed memory leak.
Erik Verbruggen [Thu, 6 Dec 2012 12:52:16 +0000 (13:52 +0100)]
Fixed memory leak.

Change-Id: Id4ae9d9192e2f2bd97e4a789a1613b669feaccb0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd a MemoryManager, which does GC for the interpreter.
Erik Verbruggen [Tue, 4 Dec 2012 12:40:18 +0000 (13:40 +0100)]
Add a MemoryManager, which does GC for the interpreter.

Todo:
- stack walking for MASM
- fix all TODOs/FIXMEs and hidden treasures (bugs).

Change-Id: I36f8cdc3a545df7287ce1df17b3570a9c017865e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd utility function to print stack traces from lldb/gdb.
Erik Verbruggen [Tue, 4 Dec 2012 09:31:31 +0000 (10:31 +0100)]
Add utility function to print stack traces from lldb/gdb.

Change-Id: I81315a1cd6900dbecfc9a39d9dc4256461163921
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years ago[masm] Inline ushr
Simon Hausmann [Tue, 4 Dec 2012 22:11:28 +0000 (23:11 +0100)]
[masm] Inline ushr

Change-Id: Ia3855625e72ae7ed50b9890edbad11e2aa338930
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoUse __get__, so that accessor properties work correctly
Lars Knoll [Tue, 4 Dec 2012 22:12:51 +0000 (14:12 -0800)]
Use __get__, so that accessor properties work correctly

Change-Id: I99f06c09017b50bffeb34a8158f0dbf902c75945
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused method
Lars Knoll [Tue, 4 Dec 2012 21:50:49 +0000 (13:50 -0800)]
Remove unused method

Change-Id: Ic8dd47453951bd129e0dcceeb43ecfa299d4c189
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGet rid of the ActivationObject
Lars Knoll [Tue, 4 Dec 2012 21:46:48 +0000 (13:46 -0800)]
Get rid of the ActivationObject

Also implement __qmljs_xxx_activation_property
in a more correct way.

Change-Id: I60c330bccca21fad99930987ed78153114a80c7d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake crypto.js work in both v4 and nodejs
Lars Knoll [Tue, 4 Dec 2012 22:26:29 +0000 (14:26 -0800)]
Make crypto.js work in both v4 and nodejs

Change-Id: I7cb200d1626404898ed94b71972499864b2d99d9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years ago[masm] Remove unused variable
Simon Hausmann [Tue, 4 Dec 2012 21:32:32 +0000 (22:32 +0100)]
[masm] Remove unused variable

Change-Id: I6034dad659ea4029256828bee06e8621902fd52c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Clean up inline arithmetic operations implementation
Simon Hausmann [Tue, 4 Dec 2012 20:21:08 +0000 (21:21 +0100)]
[masm] Clean up inline arithmetic operations implementation

Less namespacing, less clutter.

Change-Id: I08935413fc8dc021f2c207c2a8237067fd8f4c43
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Implement and/or and xor inline
Simon Hausmann [Tue, 4 Dec 2012 19:59:13 +0000 (20:59 +0100)]
[masm] Implement and/or and xor inline

Change-Id: I1e2703eaf1f8d4f5397690380ab6a76859ee1720
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Implement shl and shr inline
Simon Hausmann [Tue, 4 Dec 2012 19:54:54 +0000 (20:54 +0100)]
[masm] Implement shl and shr inline

Change-Id: Ibc5475030a68d9270e283aa8ac981661c590a29f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Simplify inline op registration code
Simon Hausmann [Tue, 4 Dec 2012 19:37:05 +0000 (20:37 +0100)]
[masm] Simplify inline op registration code

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>
11 years ago[masm] Implement inline multiplication
Simon Hausmann [Tue, 4 Dec 2012 19:06:26 +0000 (20:06 +0100)]
[masm] Implement inline multiplication

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>
11 years agoUse two operand version of imul
Simon Hausmann [Tue, 4 Dec 2012 19:00:25 +0000 (20:00 +0100)]
Use two operand version of imul

This is a slightly nicer variant to use and is easier on the register
usage

Change-Id: I6c9299f99251594b5a1adaed1e7dae9a5419c370
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago[masm] Cleanup: avoid redundant convertToValue() call in binop generation
Simon Hausmann [Sun, 2 Dec 2012 18:34:50 +0000 (19:34 +0100)]
[masm] Cleanup: avoid redundant convertToValue() call in binop generation

We already do that conversion to a constant VM::Value earlier.

Change-Id: I142435f2be7c841f322ccfc34473b23cf85e6b5c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCorrectly set the strict mode flag when calling eval()
Lars Knoll [Tue, 4 Dec 2012 19:02:26 +0000 (11:02 -0800)]
Correctly set the strict mode flag when calling eval()

Change-Id: I677eea907a3b79373c0784c1496ed97f0f5ee6f6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoThrow proper type and reference errors
Lars Knoll [Tue, 4 Dec 2012 18:50:25 +0000 (10:50 -0800)]
Throw proper type and reference errors

Change-Id: I898017f3e63ada72fc2e50abfa1880f9fd7ffe37
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAllow only the ExecutionEngine's StringPool to create Strings.
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>
11 years agoFix another memory leak.
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>
11 years agoMerged Value load instructions.
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>
11 years agoPass the ExecutionContext into the code generator
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>
11 years agoFix clobber list for inline add/sub/mul instructions
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>
11 years agoFix code generation for try statements
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>
11 years ago[masm] Clean up binop code generation
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>
11 years agoRemove the callFunction() method
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>
11 years agoFix qmljs_call_property
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>
11 years agoThrow when trying to set an undefined variable in strict mode
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>
11 years agoFurther clean up the ExecutionContext
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>
11 years agoRemove the DeclarativeEnvironment class again
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>
11 years agoRemove the outer member in declarativeEnvironment
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>
11 years ago[masm] First implementation of inline addition / subtraction
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>
11 years agoSimplify push(IR::Const*)
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>
11 years agoClean up the DeclarativeEnvironment
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>
11 years agoGet rid of variableEnvironment
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>
11 years agoGive primeIds the amount of bits it requires
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>
11 years agoAdd some debugging infrastructure to the interpreter.
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>
11 years agoSet the name of a function in more (most?) cases.
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>
11 years agoFix missing code generation for inplace operations on locals.
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>
11 years agoFix outgoing argument start position.
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>
11 years agoImplement Object.keys and obj.proto.propertyIsEnumerable
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>
11 years agoImplement Object.seal/freeze/preventExtensions
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>
11 years agoAdd defineGetter and defineSetter methods to Object
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>
11 years agoFix copy-paste coding error. "m" is null in the else part.
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>
11 years agoTune the message property (value) of SytaxError a bit.
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>
11 years agoReplace qIsNaN usage with std::isnan, which is often faster.
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>
11 years agoTune the bucket count a bit to be a prime upto 68000 entries.
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>
11 years agoIntroduce a simple string pool to speed up lookups.
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>
11 years agoStop leaking the DeclarativeEnvironment and ExecutionContext.
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>
11 years agoThrow a SyntaxError instead of printing an error message.
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>
11 years agoFix a bug in Object::__put__()
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>
11 years agoObey strict mode for property getters and setters
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>
11 years agoRemove unused methods
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>
11 years agoImplement the first parts of strict mode.
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>
11 years agoCheck for strict mode, and store it.
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>
11 years agoAdd more built-ins to the interpreter.
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>
11 years agoCorrectly instantiate variables in the local scope
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>
11 years agoFix constant value parameter passing on ia32
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>
11 years agoFix: do not rune codegen when there is no program.
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>
11 years agoFix the worst problems with eval()
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>
11 years agoFix some issues with the delete operator
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>
11 years agoSupport for the with statement
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>
11 years agoRemove some unused methods
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>
11 years agoFix return from generated code when return value is passed on the stack
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>
11 years agoFix compilation on ia32
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>
11 years agoCorrectly bind varibles in the global context
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>
11 years agoFixed temp compression and added a whole lot of debug info.
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>
11 years agoFix for local count in the global context.
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>
11 years agoKeep the EvalISelFactory in the ExecutionEngine.
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>
11 years agoFix function calls on linux/ia32
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>
11 years agoUse an isel factory instead of MASM in FunctionCTor.
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>
11 years agoCleanup instruction selection interface for MASM and MOTH.
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>
11 years agoCompress temp usage in the interpreter.
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>
11 years agoActually return the return value from the interpreter.
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>
11 years agoMake LLVM backend compile again.
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>
11 years agoFix debug code and add some asserts.
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>
11 years agoMove the exception variable into the engine
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>
11 years agoRemove the unused handlersBlock in the IR::Function
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>
11 years agoMake masm work again
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>