platform/upstream/qtdeclarative.git
11 years agoCentralize code to determine system page size
Simon Hausmann [Thu, 7 Feb 2013 15:42:55 +0000 (16:42 +0100)]
Centralize code to determine system page size

Use the existing WTF::pageSize() instead of calling sysconf
ourselves.

Change-Id: If68c793898253a239e13070e3454653474f61790
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build against Windows.h
Simon Hausmann [Thu, 7 Feb 2013 15:38:06 +0000 (16:38 +0100)]
Fix build against Windows.h

The system header file is kind enough to define a macro called CONST,
which conflicts with our IR member function. Resolve the conflict by
deleting the macro.

Change-Id: I19ec1eadd54159a9bea128ef2a586d089f56b548
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix conflict of member variable with compiler intrinsic
Simon Hausmann [Thu, 7 Feb 2013 15:33:57 +0000 (16:33 +0100)]
Fix conflict of member variable with compiler intrinsic

Rename the _asm variable to _as, to avoid a conflict with _asm
with MSVC.

Change-Id: Id8e2ff965c5e26e3d80b1656020d1889b1eb291b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplement thread stack base determination with the MSVC + x86 combination
Simon Hausmann [Thu, 7 Feb 2013 15:31:56 +0000 (16:31 +0100)]
Implement thread stack base determination with the MSVC + x86 combination

Change-Id: Idfb4961cc15f9740d3f3bdd126424d3fa7b3e454
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove unnecessary sys/mman.h inclusion
Simon Hausmann [Thu, 7 Feb 2013 15:29:48 +0000 (16:29 +0100)]
Remove unnecessary sys/mman.h inclusion

Change-Id: Ic4bbc6a595849042a9c970ba2d0ad5785fe1b89a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build with non-gcc compilers
Simon Hausmann [Thu, 7 Feb 2013 15:28:17 +0000 (16:28 +0100)]
Fix build with non-gcc compilers

Properly protect the inline assembler integer math with preprocessor
macros. Enable only with gcc and on x86 and amd64.

Change-Id: I4a422addc1f3aba0f10d5541357d940bb4c29060
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build of time related code on Windows
Simon Hausmann [Thu, 7 Feb 2013 15:23:46 +0000 (16:23 +0100)]
Fix build of time related code on Windows

Use Q_OS_WIN instead of the non-existent Q_WS_WIN

Change-Id: Ia64908dfdb234bce5f0a2256bb292d91da2fcb68
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMake it possible to omit the udis86 assembler from compilation
Simon Hausmann [Thu, 7 Feb 2013 15:20:56 +0000 (16:20 +0100)]
Make it possible to omit the udis86 assembler from compilation

Disable it on Windows and enable it generally only on x86 and amd64
architectures.

Change-Id: If8f366a3095608b9afcd30dee6dc636d442d4107
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoWork around broken min/max macro definitions on Windows
Simon Hausmann [Thu, 7 Feb 2013 15:16:38 +0000 (16:16 +0100)]
Work around broken min/max macro definitions on Windows

Windows defines min and max to macros, which breaks code that for
example uses std::max. Defining NOMINMAX globally prevents WinDefs.h
from defining those macros.

Change-Id: Ib79a48f9139febd1429a11753ffef4430953a3b4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoDon't do -rdynamic on Windows
Simon Hausmann [Thu, 7 Feb 2013 15:15:26 +0000 (16:15 +0100)]
Don't do -rdynamic on Windows

It doesn't make sense :)

Change-Id: I7455cd157e1d5938317c7e488701bbb1651eb449
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix exports in v4 binary
Simon Hausmann [Thu, 7 Feb 2013 15:14:44 +0000 (16:14 +0100)]
Fix exports in v4 binary

Don't use the export macro on internal debug classes.

Change-Id: Id2f8069cc8b6703a3fafd3058524d46252eb57f8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix objects dir for debug and release builds
Simon Hausmann [Thu, 7 Feb 2013 15:13:41 +0000 (16:13 +0100)]
Fix objects dir for debug and release builds

Don't define OBJECTS_DIR, the qmake bits for Qt 5 modules takes
care of setting it to .obj/debug_shared and .obj/debug_release
accordingly for example. Hardcoding it just breaks that.

Change-Id: I1023de159c459194eba74134626892563d069a22
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAlso mark the last item in the last chunk
Lars Knoll [Wed, 6 Feb 2013 08:05:47 +0000 (09:05 +0100)]
Also mark the last item in the last chunk

Change-Id: I9af2232a987c1297cba08579e944b1c30d032088
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoInclude stdlib for arc4random().
Erik Verbruggen [Wed, 6 Feb 2013 14:41:00 +0000 (15:41 +0100)]
Include stdlib for arc4random().

Change-Id: Icf7f09d2007941cd1005e28eaf189d1265c71900
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRestore the context pointer after returning from setjmp
Lars Knoll [Wed, 6 Feb 2013 12:15:10 +0000 (13:15 +0100)]
Restore the context pointer after returning from setjmp

Change-Id: I68682400c80cf9a8f28d11d8031681d6d92f590b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDon't insert undefined elements into the sparse array
Lars Knoll [Tue, 5 Feb 2013 21:14:03 +0000 (22:14 +0100)]
Don't insert undefined elements into the sparse array

When converting to a sparse array, skip the missing
elements.

Change-Id: Ic5ae7973c200d530ad4f89aa23b46a2581198b5a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoInline some code only used from one place
Lars Knoll [Tue, 5 Feb 2013 21:13:27 +0000 (22:13 +0100)]
Inline some code only used from one place

Cleans up the qv4object class definition.

Change-Id: Ifca7f89afb3affce5d940b1b4f7dcfe71779012c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoRemove some duplicated code
Lars Knoll [Tue, 5 Feb 2013 15:15:38 +0000 (16:15 +0100)]
Remove some duplicated code

Change-Id: I02857ad6ab74bb70aebe1b6b74c21171e8d87d03
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoDon't use a QVector to store the array data
Lars Knoll [Sun, 3 Feb 2013 21:08:39 +0000 (22:08 +0100)]
Don't use a QVector to store the array data

Refactor the code to store the array data in a simple
C array. This will later on allow for direct inline
access to the data.

Change-Id: Ic829bf1a90abfcda27ab4291cb7d5721bbd58403
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoFix GC for the last object in a chunk.
Erik Verbruggen [Tue, 5 Feb 2013 21:49:26 +0000 (22:49 +0100)]
Fix GC for the last object in a chunk.

heapChunkBoundariesEnd points to the last entry in a chunk, so include
it as a valid address to be candidate for marking.

Change-Id: Ieb1fbb494ae2fd8ee5d38ae59529cf441fbcd729
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd memory scribbling back in.
Erik Verbruggen [Tue, 5 Feb 2013 21:47:10 +0000 (22:47 +0100)]
Add memory scribbling back in.

Disabled by default, turn on by setting the env. var. MM_SCRIBBLE.

Change-Id: I616f48976d7f0541390dd1920efc69e294c5056e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix compiler warning.
Erik Verbruggen [Tue, 5 Feb 2013 21:41:40 +0000 (22:41 +0100)]
Fix compiler warning.

Change-Id: I8cf22a60dfe42a4fcc3ab130aeb82f46e018c2f5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMOTH: have the VM::Function hold on to regexps.
Erik Verbruggen [Sun, 3 Feb 2013 11:19:15 +0000 (12:19 +0100)]
MOTH: have the VM::Function hold on to regexps.

When regexps were created, they were not added to the VM::Function's
generatedValues, resulting in premature collection.

Change-Id: Idac2202e3040c6311c6f1ceead641e51a8de9729
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix compilation for access to the extensible flag.
Erik Verbruggen [Sun, 3 Feb 2013 10:03:39 +0000 (11:03 +0100)]
Fix compilation for access to the extensible flag.

Change-Id: Iaff480e43d8bb241d01cd1f6bc75ddf3d060a33c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFixed the llvm bits of the build process.
Erik Verbruggen [Fri, 1 Feb 2013 11:57:22 +0000 (12:57 +0100)]
Fixed the llvm bits of the build process.

Change-Id: I618e0ee413e9548817f84473917ccb8051f689f2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoDon't use a QVector to hold the member data
Lars Knoll [Sun, 3 Feb 2013 11:34:32 +0000 (12:34 +0100)]
Don't use a QVector to hold the member data

We don't need any implicit sharing or atomic refcounting.
In addition, array access is faster this way.

Change-Id: I85e897b74bad92e126e7502fa8e934c9519b4a63
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRename qv4array.* to qv4sparsearray.*
Lars Knoll [Sun, 3 Feb 2013 10:43:38 +0000 (11:43 +0100)]
Rename qv4array.* to qv4sparsearray.*

Change-Id: I2c5a683145a4a8e4b243a7f2fe4274dfe2b5abe4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove the Array code into Object itself
Lars Knoll [Sun, 3 Feb 2013 10:36:55 +0000 (11:36 +0100)]
Move the Array code into Object itself

This allows simplifications of the code moving forward.

Change-Id: If65809fd3646e6dc2da6bc62190d6465b1b1ec12
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRename variables and functions
Lars Knoll [Sun, 3 Feb 2013 09:25:55 +0000 (10:25 +0100)]
Rename variables and functions

Prepare for merging the Array class with ArrayObject

Change-Id: I03a2b10f290e18f8933efc11f83c76716e3721f4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove the property data out of the hash table
Lars Knoll [Sat, 2 Feb 2013 08:52:27 +0000 (09:52 +0100)]
Move the property data out of the hash table

Change-Id: I814afa75706cec785ed53039f55ee407dec1ef90
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRefactor property access
Lars Knoll [Fri, 1 Feb 2013 14:59:22 +0000 (15:59 +0100)]
Refactor property access

Move the property descriptors into a a vector
and separate them from the lookup table.

This is a pre-requirement for a hidden class implementation
later on.

Change-Id: Ib08b8152597ae0b6c883eef0fced55ee0cb4c286
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a bug in Array::push_back
Lars Knoll [Fri, 1 Feb 2013 13:32:30 +0000 (14:32 +0100)]
Fix a bug in Array::push_back

We would in some cases write the value to the wrong place.
This fixes the type error in the DeltaBlue V8 benchmark.

Change-Id: Ic64570248d83890d5e66d718b9087c2bf966690a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoFix possible out of bounds access
Lars Knoll [Fri, 1 Feb 2013 13:31:24 +0000 (14:31 +0100)]
Fix possible out of bounds access

This lead to crashes in some complex code where a
pointer was just pointing to the end of the allocated chunk,
and we'd then read outside the chunk bounds for marking.

Change-Id: Ica41c4e98eb9901fbb8d291289a9c91078ded111
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoAvoid duplicated feature defines between tools/v4/v4.pro and src/v4/v4.pro
Simon Hausmann [Thu, 31 Jan 2013 22:52:09 +0000 (23:52 +0100)]
Avoid duplicated feature defines between tools/v4/v4.pro and src/v4/v4.pro

Centralize the macros in v4.pri that's included by both.

Change-Id: I1ae2ed3b7b97a4e905d2e4ae563c99c964253bb1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoBuild fix.
Jędrzej Nowacki [Thu, 31 Jan 2013 11:18:02 +0000 (12:18 +0100)]
Build fix.

Add proper LLVM detection for v4 tool.

Change-Id: I03ad3099ce9622df67b7c61ce1e72752b9f6e4bd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRe-enable llvm code in main.
Erik Verbruggen [Thu, 31 Jan 2013 10:04:47 +0000 (11:04 +0100)]
Re-enable llvm code in main.

The QMLJS_NO_LLVM flag should be provided by a pri file somewhere next
to the other v4.pro, not here.

Change-Id: I55c17d6a09f81141e9fa671bab9d3ee9a5830e6a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix compilation on Mac with clang.
Erik Verbruggen [Thu, 31 Jan 2013 09:58:01 +0000 (10:58 +0100)]
Fix compilation on Mac with clang.

Change-Id: Ib5ecd92a0b7209ed505d17620ba4097e8d54a53c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup namespaces.
Jędrzej Nowacki [Thu, 31 Jan 2013 09:00:06 +0000 (10:00 +0100)]
Cleanup namespaces.

QT_BEGIN_NAMESPACE and QT_END_NAMESPACE was added in header
files. Namespace coding convention got unified.

Change-Id: I971c9a9179d5cd512f8214457609f40992a8ca66
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoV8 benchmark suite
Lars Knoll [Thu, 31 Jan 2013 08:16:48 +0000 (09:16 +0100)]
V8 benchmark suite

We're currently failing two tests. Performance is between 2
and 20 times worse then V8 in full compiler mode.

Change-Id: Ie78b4e996511777cb665dbf161e41dcfa0210b9b
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
11 years agoDon't link v4 against QtGui
Simon Hausmann [Thu, 31 Jan 2013 06:21:19 +0000 (07:21 +0100)]
Don't link v4 against QtGui

The QT variable defaults to core and gui it seems, but we don't
need the latter.

Change-Id: I355d2ab5fb42da4eeaebb6a41ed638203d11650a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMinor improvements to Context creation
Lars Knoll [Wed, 30 Jan 2013 16:11:09 +0000 (17:11 +0100)]
Minor improvements to Context creation

Avoid converting the this object for builtins, and
remove the GC blocker that's not needed anymore.
Move some parts of the code out to the caller
of initCallContext().

Change-Id: I8b11dd1604fb14940e4d4e9f403c2a8bfc837c4b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert Math functions to contextless form
Lars Knoll [Wed, 30 Jan 2013 15:39:36 +0000 (16:39 +0100)]
Convert Math functions to contextless form

Change-Id: I49123f4396d64fb5e2a888d339c87c800981f4f3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake things more compliant with a regular Qt module
Lars Knoll [Wed, 30 Jan 2013 19:48:35 +0000 (20:48 +0100)]
Make things more compliant with a regular Qt module

Move the v4 tool into basedir/tools/v4
Small fix to sync.profile
Install v4 into QT_INSTALL_BINS
adjust test262.py to simply call 'v4' by default

Change-Id: If78f40632c226bc26f64b0eea06fe93d7770af3e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove some unused methods
Lars Knoll [Wed, 30 Jan 2013 15:25:57 +0000 (16:25 +0100)]
Remove some unused methods

Change-Id: Ib487078db163e03bb0bd1be762f1aa0da04434b4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoInline some code for property lookups
Lars Knoll [Wed, 30 Jan 2013 14:43:22 +0000 (15:43 +0100)]
Inline some code for property lookups

Speeds up fact.2.js and crypto.js by ~5-10%

Change-Id: I121b6c3dbbd89060f323a422286adf946d4f924a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake sure we compare identifiers
Lars Knoll [Wed, 30 Jan 2013 14:39:08 +0000 (15:39 +0100)]
Make sure we compare identifiers

Change-Id: I1fc63a062799857ccd937c194e7f305b31ca3567
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert a few more builtins into versions that don't need a context
Lars Knoll [Wed, 30 Jan 2013 14:10:39 +0000 (15:10 +0100)]
Convert a few more builtins into versions that don't need a context

Change-Id: I24920f3952cd356d50a056891dc075e56c951775
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd an identifier cache
Lars Knoll [Wed, 30 Jan 2013 13:56:40 +0000 (14:56 +0100)]
Add an identifier cache

This is very similar to the old string cache with a slight
twist:

Only strings we know will be used as identifiers (property names)
get entered into the cache. These are then also persistent and
won't ever get collected.

Change-Id: Id441694ef9faf30a87433ae22eb833d1db1d84f1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDon't ignore the v4 subdir
Lars Knoll [Wed, 30 Jan 2013 13:56:19 +0000 (14:56 +0100)]
Don't ignore the v4 subdir

Change-Id: Iea769db7251ba6c6289f23a2d29e194e7d6b2ba5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd subtypes to String
Lars Knoll [Wed, 30 Jan 2013 12:04:16 +0000 (13:04 +0100)]
Add subtypes to String

This allows to store the full array index in the string,
as well as to optimise identifiers going forward.

Change-Id: I08974a5ee1149869ecfb635932bf54026d2bbab4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove string hash and error type fields
Lars Knoll [Wed, 30 Jan 2013 10:04:45 +0000 (11:04 +0100)]
Move string hash and error type fields

Move the string hash back into the String class.
Add a subtype field to Managed, and use that to store
the type of the ErrorObject.

Change-Id: I4aa8f1f39f512e3a9084b249e173bff41175d543
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoOptimise decode/encodeURI
Lars Knoll [Wed, 30 Jan 2013 08:44:15 +0000 (09:44 +0100)]
Optimise decode/encodeURI

The code contained some needless creation of temporary
QStrings, that were taking up ~50% of the time spent in
these methods.

Change-Id: Iba494e5e92c08a0056d6eb6a947d080209aa7ce5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix compilation on 64bit
Lars Knoll [Wed, 30 Jan 2013 12:31:35 +0000 (13:31 +0100)]
Fix compilation on 64bit

Change-Id: I044a7aa1b52aa3df86a22db706d05ffd6a8d2e71
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
11 years agoBuild fixup, QT_BEGIN_HEADER was removed.
Jędrzej Nowacki [Wed, 30 Jan 2013 12:26:12 +0000 (13:26 +0100)]
Build fixup, QT_BEGIN_HEADER was removed.

Change-Id: I97b33e4c317aac53cfff1c7ef6f1a04bca9434ba
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoSay hello to QtV4 module.
Jędrzej Nowacki [Tue, 29 Jan 2013 13:20:50 +0000 (14:20 +0100)]
Say hello to QtV4 module.

Change-Id: I507cd5707b7d7223a0d901cf939896fb2649b684
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix a bug with Unicode surrogates in decodeURI
Lars Knoll [Wed, 30 Jan 2013 08:11:18 +0000 (09:11 +0100)]
Fix a bug with Unicode surrogates in decodeURI

Change-Id: Id8348c77ad4d5429c4b4116b8ef0dc94e130c4e3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAllocate larger chunks if we use lots of memory
Lars Knoll [Wed, 30 Jan 2013 07:58:27 +0000 (08:58 +0100)]
Allocate larger chunks if we use lots of memory

This avoids excessive GC activity on test cases that allocate
lots of memory. v4 now runs some of the test cases that were
too slow to run before.

Change-Id: Id668b03799b086445ec0fb48d577a5844f962de3
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoUse faster calling path for more builtin methods
Lars Knoll [Tue, 29 Jan 2013 21:08:35 +0000 (22:08 +0100)]
Use faster calling path for more builtin methods

This speeds up some test cases I have by a factor of 2.

Change-Id: Ief9e2845c974d701fa032937cafced323279e9ec
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoOptimise callProperty for Strings.
Lars Knoll [Tue, 29 Jan 2013 21:07:48 +0000 (22:07 +0100)]
Optimise callProperty for Strings.

Don't convert the String to a StringOject, just to
call a method on it's prototype. The result would
in any case be the same.

Change-Id: I74cea392b20b6c5642d010287ebf6e27c91eea83
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd a faster code path for calling builtin methods
Lars Knoll [Tue, 29 Jan 2013 20:23:19 +0000 (21:23 +0100)]
Add a faster code path for calling builtin methods

Builtin methods usually don't need a Context of their own,
so we can fully avoid the overhead of creating and destroying
it.

Implemented the support for making builtin methods context less
and verified it with some of the methods in String.prototype.

Change-Id: I187b46ba684183b4fba49ae70e3139d32ef585e0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove the virtual Object::className()
Lars Knoll [Tue, 29 Jan 2013 13:31:42 +0000 (14:31 +0100)]
Remove the virtual Object::className()

Change-Id: I70ecf244792c1c22b57ba7bdfed64b4b5b055e8c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove Object::call()
Lars Knoll [Tue, 29 Jan 2013 12:45:32 +0000 (13:45 +0100)]
Remove Object::call()

The method didn't make any sense. It's easier to directly
cast to a FunctionObject and check whether that succeded.

Change-Id: I8d76e2b93dc32d6a8fa82e66173d1d2c1e5da514
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAllocate execution context and local variables in one chunk
Lars Knoll [Tue, 29 Jan 2013 12:23:32 +0000 (13:23 +0100)]
Allocate execution context and local variables in one chunk

This avoids a few mallocs and in addition memory leaks where
the local variables or arguments array wasn't destroyed before.

crypto.js seems to run without a mem leak now :)

Change-Id: Icca74c5dba764fadabd7a77f233bdf5883046c86
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDon't copy formals and locals from VM::Function to FunctionObject
Lars Knoll [Tue, 29 Jan 2013 10:24:43 +0000 (11:24 +0100)]
Don't copy formals and locals from VM::Function to FunctionObject

This should make creation of a FunctionObject quite a bit cheaper

Change-Id: I0937f9f2354b7abc47c3673f4957bd70ff9a97b8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGarbage collection for Strings
Lars Knoll [Mon, 28 Jan 2013 15:46:09 +0000 (16:46 +0100)]
Garbage collection for Strings

Let String inherit from Managed, and manage them through
the same garbage collector as for regular objects.

Change-Id: Iae1e047daeff683519d52beddcaca7824a01bb27
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSplit CallBuitin variants into separate instructions.
Erik Verbruggen [Sun, 27 Jan 2013 08:59:37 +0000 (09:59 +0100)]
Split CallBuitin variants into separate instructions.

This saves space by removing (sometimes) unused parameters, and the need
to store and switch over another enum to determine which of the various
built-in instructions is called.

Change-Id: Ie59c49608bf445a07d406b45fd48cfb94bbfc919
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago"Fix" llvm build by adding empty definitions for missing methods.
Erik Verbruggen [Tue, 29 Jan 2013 08:17:22 +0000 (09:17 +0100)]
"Fix" llvm build by adding empty definitions for missing methods.

Change-Id: I172ad23bc56bda9b3a8276cb102599d6243026c4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoChange TEMP handling in the interpreter.
Erik Verbruggen [Fri, 25 Jan 2013 18:32:30 +0000 (19:32 +0100)]
Change TEMP handling in the interpreter.

By introducing the Param struct, and moving the ValueOrTemp into it
too, the parameter decoding for instructions is cleaner and less
error-prone: it de-couples the HIR/MIR representation from the
interpreter representation, and allows for proper handling of the
with-context.

Change-Id: I0bc8f72bc7ce62b8efa298cbea5711adac4a4d34
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build on ia32
Simon Hausmann [Mon, 28 Jan 2013 12:49:03 +0000 (13:49 +0100)]
Fix build on ia32

loadArgument(PointToValue) is architecture independent :)

Change-Id: I6ce8b7900088bc7052002a9ae60cbebdd5357d8d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoProperly working post increment/decrement operators
Lars Knoll [Sun, 27 Jan 2013 20:16:09 +0000 (21:16 +0100)]
Properly working post increment/decrement operators

This required some larger changes in our infrastructure.
Unfortunately the post increment/decrement operators
don't return the old value unmodified, but return
toNumber(oldValue).

At the same time they need to properly store the new value
into the referenced expression. The only way to solve this
(as we can't have two return values) is to pass a proper
reference into runtime methods.

Change-Id: I0e0c2cc011ab22d5d4b27924abc8c18372c104a5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSmaller cleanup
Lars Knoll [Mon, 28 Jan 2013 10:42:01 +0000 (11:42 +0100)]
Smaller cleanup

Change-Id: I42a1de385e286bf1e4568769886034161f7fe500
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agonew eval() should throw a type error
Lars Knoll [Mon, 28 Jan 2013 09:50:07 +0000 (10:50 +0100)]
new eval() should throw a type error

Change-Id: I487a11a060657ac1eeae4c51085ce907711b51c8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd a mechanism to protect managed objects from deletion
Lars Knoll [Mon, 28 Jan 2013 12:32:08 +0000 (13:32 +0100)]
Add a mechanism to protect managed objects from deletion

Change-Id: I6700dc94ad481e12ee7f00c04c0c37261e22a715
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
11 years agoSet the prototype for FunctionObject in it's constructor
Lars Knoll [Mon, 28 Jan 2013 09:41:42 +0000 (10:41 +0100)]
Set the prototype for FunctionObject in it's constructor

This avoids a few test failures where the prototype for
eval wasn't set up correctly.

Change-Id: I5a5c1dafe4a6328bf1bbc95901ff22df10083a86
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMost statements don't return a value
Lars Knoll [Mon, 28 Jan 2013 09:40:30 +0000 (10:40 +0100)]
Most statements don't return a value

In eval mode, we need to write the result of statements
into the return value. But most statements don't return
a value, so the statement shouldn't write a return value.

Change-Id: I9ce24fe6689bd2bb2aee6241ca84a25f9a266f5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoProperly set the length of the eval function
Lars Knoll [Mon, 28 Jan 2013 09:39:40 +0000 (10:39 +0100)]
Properly set the length of the eval function

Change-Id: I88a483f5c9a758c4983d5d3b2c684f6bc7e8cf55
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix call expressions with a subscript
Lars Knoll [Sun, 27 Jan 2013 21:39:01 +0000 (22:39 +0100)]
Fix call expressions with a subscript

Call expressions such as foo[bar]() where wrongly converted to a
temporary and then called by value. This made the call have the
wrong this argument, as the reference was resolved in the assignment
to the temporary.

Change-Id: Id6044f833dfcf9ee8fa4f9ec0602a929abdc2c48
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix constness of Value::toXXX functions.
Jędrzej Nowacki [Mon, 28 Jan 2013 11:54:07 +0000 (12:54 +0100)]
Fix constness of Value::toXXX functions.

Change-Id: I66d622555b2cca4e6aa546745fd0e46373dee919
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoNumber/Boolean.prototype.toString() also accept matching primitive values
Lars Knoll [Sun, 27 Jan 2013 21:31:28 +0000 (22:31 +0100)]
Number/Boolean.prototype.toString() also accept matching primitive values

These methods also accept matching (ie. booleans or numbers) primitives
as this argument.

Change-Id: Ib31cadd46d327381abf02847ae35e7be05715f84
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoThe function prototype has a length property
Lars Knoll [Sun, 27 Jan 2013 21:13:28 +0000 (22:13 +0100)]
The function prototype has a length property

Change-Id: I1ef4d7c86ac5c5a8e7ed08081a86c4f826527c0d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agotest function names for eval or arguments in strict mode
Lars Knoll [Sun, 27 Jan 2013 20:27:44 +0000 (21:27 +0100)]
test function names for eval or arguments in strict mode

using these as function names should trigger a syntax error
in strict mode.

Change-Id: I8d83fda72db856b692c8f6f1454c762255bcaef1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a bug in the evaluation of &&
Lars Knoll [Sun, 27 Jan 2013 16:30:40 +0000 (17:30 +0100)]
Fix a bug in the evaluation of &&

Change-Id: Ia446bd05dcca3fc146719284e5ac96d4c7d61c06
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoFix empty return statement in eval
Simon Hausmann [Fri, 25 Jan 2013 15:03:06 +0000 (16:03 +0100)]
Fix empty return statement in eval

It should throw a syntax error even inside eval it seems.

Change-Id: I4de6d96f9ba61569d7d7e723ecb5f2d946c8f4ad
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix remaining issues with the delete operator
Simon Hausmann [Fri, 25 Jan 2013 14:52:42 +0000 (15:52 +0100)]
Fix remaining issues with the delete operator

Delete on known temps should return true and false on known local variables.

Change-Id: I71be8361306eb825b975a3aee294665eb8561366
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix more tests with the delete operator
Simon Hausmann [Fri, 25 Jan 2013 13:00:48 +0000 (14:00 +0100)]
Fix more tests with the delete operator

Delete on non-reference types should return true. Delete on our
temporaries should evaluate to false.

Change-Id: Ic6b39a0cf5833900f2a492ac8b37386fc2963ab3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoSuppress a linker warning for unused flag.
Erik Verbruggen [Fri, 25 Jan 2013 08:34:54 +0000 (09:34 +0100)]
Suppress a linker warning for unused flag.

Change-Id: I53aaf5f7bc7ec63e92e02d18010b2f1d53c40a00
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove the isString and isArray flags in Managed
Lars Knoll [Fri, 25 Jan 2013 12:41:37 +0000 (13:41 +0100)]
Remove the isString and isArray flags in Managed

These are not needed anymore, as we have the type stored
in the object.

Change-Id: I86594f4c3b3669ee0576e1ca141a64494e82a176
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoInline casting of Value to objects
Lars Knoll [Fri, 25 Jan 2013 12:23:58 +0000 (13:23 +0100)]
Inline casting of Value to objects

Change-Id: Ic5538b8a0a1f430a265399bced0ce9fc0a79696e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove a bunch of virtuals in Object
Lars Knoll [Fri, 25 Jan 2013 12:13:06 +0000 (13:13 +0100)]
Remove a bunch of virtuals in Object

This should speed up casting to the derived types, and
simplify things in the longer term.

Change-Id: I7362c86e5e2724d5b7e245695f9fe29144999715
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFaster marking of objects in the GC
Lars Knoll [Fri, 25 Jan 2013 11:43:44 +0000 (12:43 +0100)]
Faster marking of objects in the GC

Change-Id: I4ccbf7fc50758fc176bfdb2f0382a7ec1f18d6ba
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd missing return statement
Lars Knoll [Fri, 25 Jan 2013 11:16:45 +0000 (12:16 +0100)]
Add missing return statement

Fixes crypto.js

Change-Id: If3b2d182b8e6a93acd2c32904e5b9a9fd49181cf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove a few virtual keywords that aren't required anymore
Lars Knoll [Fri, 25 Jan 2013 09:38:52 +0000 (10:38 +0100)]
Remove a few virtual keywords that aren't required anymore

Change-Id: Ic7d46d78cd1efeac16a25586c5b8fb3cb761512d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix compilation of llvm backend.
Erik Verbruggen [Thu, 24 Jan 2013 14:49:05 +0000 (15:49 +0100)]
Fix compilation of llvm backend.

Change-Id: I714977f7e5e7040a8fd252525cd9f84fbfe40862
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoDelete on a function argument should return false
Simon Hausmann [Thu, 24 Jan 2013 15:07:18 +0000 (16:07 +0100)]
Delete on a function argument should return false

Change-Id: I36aafcfa43bced2b8315af39432cf7731daaf458
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoThrow a syntax error if eval or arguments is used in increment/decrement expressions
Simon Hausmann [Thu, 24 Jan 2013 14:36:33 +0000 (15:36 +0100)]
Throw a syntax error if eval or arguments is used in increment/decrement expressions

Change-Id: Icd966b626a172302eb4b22f5cadba0085d31c320
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix inplace operators
Lars Knoll [Thu, 24 Jan 2013 14:32:12 +0000 (15:32 +0100)]
Fix inplace operators

We actually need to call __put__ on the result of the
operation even if the lhs didn't exist before.

Change-Id: I54acaab203fd34fd88a36685211e382a8399b11b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAvoid integer division by 0
Lars Knoll [Thu, 24 Jan 2013 14:31:54 +0000 (15:31 +0100)]
Avoid integer division by 0

Change-Id: I5c50878192e3f4dd6e7297e51a450840c4c1037e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoThrow a reference error when trying to use an invalid lvalue
Lars Knoll [Thu, 24 Jan 2013 14:03:00 +0000 (15:03 +0100)]
Throw a reference error when trying to use an invalid lvalue

Change-Id: I08c19710eaf58da100852fa9c2b07a4d8bb8b0c4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix return statement outside of function body
Simon Hausmann [Thu, 24 Jan 2013 13:27:36 +0000 (14:27 +0100)]
Fix return statement outside of function body

Such a program is syntactically incorrect

Change-Id: Ica23c67aae55890a36064987f6019d9d7f50585e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix properties of literal array initialisers
Simon Hausmann [Thu, 24 Jan 2013 11:53:47 +0000 (12:53 +0100)]
Fix properties of literal array initialisers

Array entries defined in such a way need to be own properties.
To avoid calling builtin_define_property with the integer index
converted to a string for each property, this patch also introduces
a builtin_define_array_property that takes an integer index instead.

Change-Id: Ib21f99a555b3237753a7930a7edc70bfcd49ac18
Reviewed-by: Lars Knoll <lars.knoll@digia.com>