platform/upstream/qtdeclarative.git
11 years agoPrevent accidental allocation of GC managed objects on the regular heap
Simon Hausmann [Thu, 13 Dec 2012 11:58:21 +0000 (12:58 +0100)]
Prevent accidental allocation of GC managed objects on the regular heap

Make the regular new operator private. As it turns out no other changes
were required, all the existing objects are already allocated on the
GC heap, thanks to the new* factor functions in ExecutionEngine.

Change-Id: I9b69221b5bbc4491ca909ec6bb5afe0f3c010b54
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoUse a smart pointer for ExecutionEngine::stringPool
Jędrzej Nowacki [Thu, 13 Dec 2012 09:46:31 +0000 (10:46 +0100)]
Use a smart pointer for ExecutionEngine::stringPool

Change-Id: I5434fbd146e9d8dcc0000327c5a5b953bc744b83
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoUse a smart pointer for Object::members.
Jędrzej Nowacki [Thu, 13 Dec 2012 09:19:14 +0000 (10:19 +0100)]
Use a smart pointer for Object::members.

Change-Id: I070c00281a5b92de82568d4d4e0bb35700233a21
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused property (Object::klass)
Jędrzej Nowacki [Thu, 13 Dec 2012 09:14:22 +0000 (10:14 +0100)]
Remove unused property (Object::klass)

Change-Id: I623ceeceb810719f44ed832f0cc37a1d74430db3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDon't reset the function pointer in leaveCallContext()
Lars Knoll [Thu, 13 Dec 2012 11:11:47 +0000 (12:11 +0100)]
Don't reset the function pointer in leaveCallContext()

We need the function pointer to be able to map variable names
correctly. Fixes the remaining problems with nested functions
and closures.

Change-Id: I976be2df57b93edb3b762afc33790c4483430b05
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCorrectly set up nested functions
Lars Knoll [Thu, 13 Dec 2012 11:09:04 +0000 (12:09 +0100)]
Correctly set up nested functions

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>
11 years agoFix ObjectCtor::call
Lars Knoll [Wed, 12 Dec 2012 21:10:50 +0000 (22:10 +0100)]
Fix ObjectCtor::call

Change-Id: Ifa74ba46ed5213661d009fcd748d66f2b5670814
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix NumberCtor::construct
Lars Knoll [Wed, 12 Dec 2012 21:05:42 +0000 (22:05 +0100)]
Fix NumberCtor::construct

Change-Id: I4714a447d2a4fc71e73c7492fc8ed939efc0192f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix StringCtr::call
Lars Knoll [Wed, 12 Dec 2012 20:39:26 +0000 (21:39 +0100)]
Fix StringCtr::call

Check for the number of arguments, not whether the first arg
is undefined.

Change-Id: I23829404dfd4547f829b1bc7a4407017d79f7162
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix the bit shift and complement operators
Lars Knoll [Wed, 12 Dec 2012 20:33:17 +0000 (21:33 +0100)]
Fix the bit shift and complement operators

Take care of some corner cases and make them pass the
test suite.

Change-Id: Ic83508859800c62681ee873968b475ef81fffb82
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix string to number conversion
Lars Knoll [Thu, 13 Dec 2012 00:53:13 +0000 (01:53 +0100)]
Fix string to number conversion

Change-Id: Ib261bc61a5fd6ed99292a5021b173330b2fd96e7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix the Number constructor.
Lars Knoll [Thu, 13 Dec 2012 00:44:20 +0000 (01:44 +0100)]
Fix the Number constructor.

new Number() is supposed to return a number object
initialized with 0.

Change-Id: I1c88abee81da0d84485e2d606bf72a8c9283ed61
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix delete expression.
Lars Knoll [Thu, 13 Dec 2012 00:39:36 +0000 (01:39 +0100)]
Fix delete expression.

Change-Id: Ifc0918272c615889aee4ae63435071a72aad7119
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix return values for Object.protoype.seal/freeze/preventExtensions
Lars Knoll [Thu, 13 Dec 2012 00:29:10 +0000 (01:29 +0100)]
Fix return values for Object.protoype.seal/freeze/preventExtensions

Change-Id: Icc9844cfac5d8afae09ca10eeed024e65385801f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a possible crash when setting a property on a primitive type
Lars Knoll [Thu, 13 Dec 2012 00:28:46 +0000 (01:28 +0100)]
Fix a possible crash when setting a property on a primitive type

Change-Id: Icb8d97536b87779cdc3e543260755509232e10cb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix Object.prototype.isPrototypeOf()
Lars Knoll [Thu, 13 Dec 2012 00:15:44 +0000 (01:15 +0100)]
Fix Object.prototype.isPrototypeOf()

Implement the method according to spec (15.2.4.6)

Change-Id: I84b943366dcb1048966d4ae2f60bcbf01c99e7ea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix access rights for builtin properties
Lars Knoll [Wed, 12 Dec 2012 23:53:04 +0000 (00:53 +0100)]
Fix access rights for builtin properties

According to the spec all builtin properties have
writable: true, enumerable: false and configurable:true
by default. This is what is now being used. Some constants
have all attributes set to false, and there is an extra
method for setting these readonly properties.

Change-Id: If5ba875bcc9f1644aa8a07a2d9b37716bf228e12
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix isNaN and isFinite
Lars Knoll [Wed, 12 Dec 2012 22:43:53 +0000 (23:43 +0100)]
Fix isNaN and isFinite

We need to convert objects to numbers before doing the
check.

Change-Id: Ie25128b6145845a3eb3e0098f5c5fc09f2be6830
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix increment and decrement operators
Lars Knoll [Wed, 12 Dec 2012 21:46:57 +0000 (22:46 +0100)]
Fix increment and decrement operators

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>
11 years agoValue properties of the Number constructor are readonly
Lars Knoll [Wed, 12 Dec 2012 19:48:11 +0000 (20:48 +0100)]
Value properties of the Number constructor are readonly

See 15.7.3.2 - 15.7.3.6

Change-Id: I39cace57456ecce9532ba6547b3dab5735fd874d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoFix assertion
Lars Knoll [Wed, 12 Dec 2012 21:57:06 +0000 (22:57 +0100)]
Fix assertion

Change-Id: I2c79d7c8c5f8624a5cfd5cb1c5af1488ccd5aada
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix masm compilation.
Erik Verbruggen [Wed, 12 Dec 2012 12:23:02 +0000 (13:23 +0100)]
Fix masm compilation.

Change-Id: I74f08976c046f7e8a6c16c786e6d32720ad88485
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup: Added a storeValue() overload that operates on an IR::Temp*
Simon Hausmann [Tue, 11 Dec 2012 13:43:50 +0000 (14:43 +0100)]
Cleanup: Added a storeValue() overload that operates on an IR::Temp*

Change-Id: Iab23eaa41f4ef4d3f99dccd6d2075fa4ba8e918e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCorrectly handle negative 0
Lars Knoll [Wed, 12 Dec 2012 19:34:31 +0000 (20:34 +0100)]
Correctly handle negative 0

-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>
11 years agoFix indentation
Lars Knoll [Wed, 12 Dec 2012 19:34:19 +0000 (20:34 +0100)]
Fix indentation

Change-Id: I8ccb47cae3214ab2ac8ed51657856f51fc6c4e95
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAvoid uninitialized ExecutionContext::current pointer
Simon Hausmann [Sat, 8 Dec 2012 20:12:11 +0000 (21:12 +0100)]
Avoid uninitialized ExecutionContext::current pointer

Change-Id: I63fb1fbb39786fc349ccc121a25951b15ec31d57
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix some smaller bugs in toPropertyDescriptor
Lars Knoll [Wed, 12 Dec 2012 18:41:10 +0000 (19:41 +0100)]
Fix some smaller bugs in toPropertyDescriptor

This should now be fully compliant with 8.10.5

Change-Id: I4afacb95a9ec0eb9366181da9dbeb74a5c34c55b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a bug in __qmljs_string_to_number
Lars Knoll [Wed, 12 Dec 2012 18:18:40 +0000 (19:18 +0100)]
Fix a bug in __qmljs_string_to_number

The check whether we successfully converted the whole
string was broken, leading to lots of NaN's when converting.

Change-Id: Iea0c37e5900e4fe1a1d0adca9a91e76aeb544336
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoThrow a type error if defaultValue doesn't lead to a primitive type
Lars Knoll [Wed, 12 Dec 2012 18:06:19 +0000 (19:06 +0100)]
Throw a type error if defaultValue doesn't lead to a primitive type

As specified in 8.12.8, we need to throw a type error if calling
[[defaultValue]] on an object doesn't convert to a primitive
type.

Change-Id: I6b5db91a36a21c6037998efb15646d00d49b5d4c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoUse a new and empty cleanup list for try statements when entering a function
Lars Knoll [Wed, 12 Dec 2012 17:35:42 +0000 (18:35 +0100)]
Use a new and empty cleanup list for try statements when entering a function

The cleanup list is local to a function definition. Otherwise inner functions
would create cleanup code for try statements in outer functions leading
to crashes.

Change-Id: I5d35893b0ea6b0692cda44d5b34b0bb3dfc93fdd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove references to deleted basic blocks
Lars Knoll [Wed, 12 Dec 2012 17:21:36 +0000 (18:21 +0100)]
Remove references to deleted basic blocks

When linearizing, we can sometimes remove some basic blocks
that are never being jumped to. In this case we also need to
clean up the back references to these blocks from other
blocks.

This fixes a valgrind error with SHOW_CODE=1

Change-Id: I07d74cef24d6cf2c8bcc1e748e314a3a5b5ed60a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSmall cleanup
Lars Knoll [Wed, 12 Dec 2012 08:00:30 +0000 (09:00 +0100)]
Small cleanup

Change-Id: Ia25515e5f5e9af561c66589a2aa0c524167719ff
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix hasProperty internal method
Lars Knoll [Wed, 12 Dec 2012 08:00:19 +0000 (09:00 +0100)]
Fix hasProperty internal method

Change-Id: Ifd0b19d6ff011bb85475e6654681a022c8f58e2d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoProperly set the prototype for regexp objects
Lars Knoll [Wed, 12 Dec 2012 07:28:08 +0000 (08:28 +0100)]
Properly set the prototype for regexp objects

Clean up the code, so that regexp's get instantiated by
the ExecutionEngine

Change-Id: Iacc8d9fee0427342156747d6e8814d7660bdbb1a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
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>