platform/upstream/qtdeclarative.git
11 years agoFix crash with v8-bench.js
Simon Hausmann [Thu, 21 Mar 2013 01:08:36 +0000 (02:08 +0100)]
Fix crash with v8-bench.js

Sometimes the arguments array of the context is provided by the caller and not
copied. In that case the address may not be valid anymore after the call, so
we need to reset arguments/argumentCount after the call in popContext, otherwise
we end up calling mark() on dangling pointers.

Also make sure to mark the entire arguments array, not too much and not too little,
i.e. use argumentCount.

Change-Id: I8b96521b0fb15142ed8c723a9354d275be48cc58
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix module operation to conform to IEEE 754 arithmic.
Erik Verbruggen [Tue, 19 Mar 2013 15:04:10 +0000 (16:04 +0100)]
Fix module operation to conform to IEEE 754 arithmic.

When the two operands are integers, and the result is 0 AND the
left-hand side is negative, then discard it and do the calculation based
on doubles. The reason is that the integer mod can only return +0,
while (-1 % -1) and (-1 % 1) should return -0.

Change-Id: I676e5bbdf3a7dcb29006d9101a9e5e7c33467c49
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoDistinguish better between a FunctionDecl and a FunctionExpr.
Erik Verbruggen [Tue, 19 Mar 2013 14:29:53 +0000 (15:29 +0100)]
Distinguish better between a FunctionDecl and a FunctionExpr.

An ExpressionStatement can not start with the function keyword because
that might make it ambiguous with a FunctionDeclaration. However, we
insert the same node for either, so if we have a FunctionExpression
that is actually a FunctionDeclaration, that is okay. If we have any
other ExpressionStatement that starts with a "function" token (e.g. a
call expression where the base is a FunctionExpression), error on it.

Change-Id: I76acf9aca97b05f25642f82006631cb375dd8c11
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix Number.prototype.toFixed.
Erik Verbruggen [Tue, 19 Mar 2013 13:21:18 +0000 (14:21 +0100)]
Fix Number.prototype.toFixed.

ECMA5.1 paragraph 15.7.4.5, item 7:

If x >= 10^21, then\r  a. Let m = ToString(x).

Change-Id: I36516177aefddd10fec8d3f55b7644d8f7f65f64
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix a edge case in String.lastIndexOf.
Erik Verbruggen [Tue, 19 Mar 2013 12:56:16 +0000 (13:56 +0100)]
Fix a edge case in String.lastIndexOf.

"".lastIndexOf() should return -1, not 0.

Change-Id: Iaf2359d7c1d315b2584a899ada61b658fc317f3c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMark test as passing after qtdeclarative change.
Erik Verbruggen [Tue, 19 Mar 2013 12:15:13 +0000 (13:15 +0100)]
Mark test as passing after qtdeclarative change.

Depends on https://codereview.qt-project.org/51392 .

Change-Id: I2309db6f2f829e4dd05cd20983b9b986c166b607
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMark more tests as passing after qtdeclarative change.
Erik Verbruggen [Mon, 18 Mar 2013 15:27:39 +0000 (16:27 +0100)]
Mark more tests as passing after qtdeclarative change.

Depending on https://codereview.qt-project.org/51264 .

Change-Id: Iaa1cf8e583944d7cf0f873f203b834e85712ea5f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoCheck if "use strict" has no escaped chars.
Erik Verbruggen [Mon, 18 Mar 2013 19:53:26 +0000 (20:53 +0100)]
Check if "use strict" has no escaped chars.

Change-Id: I7dc172eba02d454467ead1e18a1a59e98890dd54
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix function declaration best-practice check.
Erik Verbruggen [Mon, 18 Mar 2013 15:22:58 +0000 (16:22 +0100)]
Fix function declaration best-practice check.

Most checks only apply in strict mode (added that), except for a
function declaratin in a then/else part or a while body, which is in
a function body.

Change-Id: Ib7afecb1fb3a856ea57c7dd8b205854034739692
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoBuild fixes for Windows.
Erik Verbruggen [Mon, 18 Mar 2013 09:52:05 +0000 (10:52 +0100)]
Build fixes for Windows.

Change-Id: I8f758e8c7dced17b556c6cc2531f86b7dd974cb6
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFixes to run the test suite on Windown.
Erik Verbruggen [Mon, 18 Mar 2013 09:46:51 +0000 (10:46 +0100)]
Fixes to run the test suite on Windown.

Change-Id: I94292c873cb3029b19cc90bdfa6f9312215e6011
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMoved TemporaryAssignment into its own header.
Erik Verbruggen [Mon, 18 Mar 2013 10:03:51 +0000 (11:03 +0100)]
Moved TemporaryAssignment into its own header.

So we can re-use it without including all of qv4engine.h.

Change-Id: I3de1e6a26b20afef4969001dd2dd774688f25620
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoHandle best-practice conditional function declaration.
Erik Verbruggen [Wed, 13 Mar 2013 10:13:30 +0000 (11:13 +0100)]
Handle best-practice conditional function declaration.

Change-Id: I58b442b0af279922e8e9d9cbd17ab1d24994f08c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix initialization of call contexts
Lars Knoll [Thu, 14 Mar 2013 21:41:58 +0000 (17:41 -0400)]
Fix initialization of call contexts

Change-Id: Icf32af65ac89e4bf2bf28c72ca7161f4ad65b07b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agorename qmljs_math to qv4math
Lars Knoll [Thu, 14 Mar 2013 21:10:02 +0000 (17:10 -0400)]
rename qmljs_math to qv4math

Change-Id: Ie0a6eb35476da0a672856afdc082a935fb9be92e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRename qmljs_runtime to qv4runtime
Lars Knoll [Thu, 14 Mar 2013 21:08:29 +0000 (17:08 -0400)]
Rename qmljs_runtime to qv4runtime

Change-Id: I46ba9b2621be72116d94bee249ad5b798e951c88
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRename qmljs_value.* to qv4value.*
Lars Knoll [Thu, 14 Mar 2013 21:05:57 +0000 (17:05 -0400)]
Rename qmljs_value.* to qv4value.*

Change-Id: I1d85f5efd43854ea5d96c72d7a32823dc610453e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake ExecutionContext garbage collected
Lars Knoll [Thu, 14 Mar 2013 14:47:57 +0000 (15:47 +0100)]
Make ExecutionContext garbage collected

This comes with ~10 percent performance regression,
due to the extra allocation of the locals, but fixes
a long standing mem leak.

Change-Id: Ic683cc13a8c3bc66fe3f41dee61d5e388b9f3e32
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSome more optimisations to the memory manager
Lars Knoll [Thu, 14 Mar 2013 20:56:42 +0000 (16:56 -0400)]
Some more optimisations to the memory manager

Adjust chunk size to the size of objects stored inside.
Move stack base calculation to the constructor, no need to
do it at every gc run.

Change-Id: Id878cb067fb7ab38576e0811dcd3670617f33534
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove the parent pointer from ExecutionContext
Lars Knoll [Thu, 14 Mar 2013 13:03:04 +0000 (14:03 +0100)]
Remove the parent pointer from ExecutionContext

It's cleaner to have an explicit stack of contexts
in the Engine, esp. as the global context can get
pushed onto the stack several times. This avoids
an ugly hack in eval() where we created a 'copy'
of the global context.

Change-Id: I3936443fba6c1829a60a8e0e9a106ec75293274f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove all context management methods into the ExecutionEngine
Lars Knoll [Thu, 14 Mar 2013 11:59:11 +0000 (12:59 +0100)]
Move all context management methods into the ExecutionEngine

Centralizes this functionality, so it can be more easily handled
and modified in the future.

Change-Id: I733fb791b816a117343615ddd7d7a754f42d3dbb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRename qmljs_engine.* to qv4engine.*
Lars Knoll [Thu, 14 Mar 2013 11:48:00 +0000 (12:48 +0100)]
Rename qmljs_engine.* to qv4engine.*

Change-Id: I452fc11972c802acc14e0a3358d8c408b6dbded8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRename qmljs_environment.* to qv4context.*
Lars Knoll [Thu, 14 Mar 2013 11:43:27 +0000 (12:43 +0100)]
Rename qmljs_environment.* to qv4context.*

Change-Id: I6fe62b501803422f78b47a87c55e4278820725aa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoOptimise put and defineOwnProperty a bit
Lars Knoll [Fri, 8 Mar 2013 08:38:46 +0000 (09:38 +0100)]
Optimise put and defineOwnProperty a bit

Change-Id: Ie944ce76a744c2bbadce20da28ceb9104f9c95c2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused method
Lars Knoll [Fri, 8 Mar 2013 08:17:20 +0000 (09:17 +0100)]
Remove unused method

Change-Id: Ie96da445a7c94e43db1d293f254315eed6af6713
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused variable
Lars Knoll [Fri, 8 Mar 2013 08:17:11 +0000 (09:17 +0100)]
Remove unused variable

Change-Id: I83cab99dbb6905b4f480cf1584cdb96246fd987d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement another method in the v8 API
Lars Knoll [Wed, 13 Mar 2013 21:50:00 +0000 (17:50 -0400)]
Implement another method in the v8 API

Change-Id: I54918914a8c9b395211ccbff891a90ab069be4a5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMessage is refcounted
Lars Knoll [Wed, 13 Mar 2013 21:41:42 +0000 (17:41 -0400)]
Message is refcounted

Change-Id: Ic5097ea1eae6503f906157b3d4bf51a028c94280
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCatch some more exceptions in the v8 API
Lars Knoll [Wed, 13 Mar 2013 21:39:21 +0000 (17:39 -0400)]
Catch some more exceptions in the v8 API

Change-Id: I23428f7dce0771576ae1243812eeed7a534dc833
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove some debug output
Lars Knoll [Wed, 13 Mar 2013 21:09:18 +0000 (17:09 -0400)]
Remove some debug output

Change-Id: I9178da579194479eac8996290cda1ae056720b15
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup and unify context creation
Lars Knoll [Wed, 13 Mar 2013 21:05:34 +0000 (17:05 -0400)]
Cleanup and unify context creation

* Always create contexts on the heap. When embedding native methods
we can't create contexts on the stack anymore without running the
risk of them being used in some scope chain.
* Unify context creation for call contexts, share the code
* Add a hack for indirect calls to eval and create a new 'fake'
global context there, so we don't mess up the context stack (it
broke badly when unwinding exceptions before).

Change-Id: I5804224dc26582f24ec79518639ceb13a8a3e967
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoPass the current context to evalCall
Lars Knoll [Wed, 13 Mar 2013 21:03:51 +0000 (17:03 -0400)]
Pass the current context to evalCall

Passing the root context will seriously mess up our
JS call stack.

Change-Id: I513a9eb61bdc24b7a4542bc5f8556bf927af6c75
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a few warnings
Tor Arne Vestbø [Wed, 13 Mar 2013 13:15:50 +0000 (14:15 +0100)]
Fix a few warnings

Change-Id: I82efe66a28a76eb64b1254a7a9c6c60a0fce6228
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoBe conservative and assume that functions need activation
Lars Knoll [Tue, 12 Mar 2013 19:34:09 +0000 (15:34 -0400)]
Be conservative and assume that functions need activation

A function that doesn't need it's context allocated on the heap
should state so explicitly. If not it's better to assume that we
need a heap allocated context.

This fixes a crash on the QML clocks demo.

Change-Id: I0a67e6ed38c99e7dd75dd03d6cc2dda10d8b5ad7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove unused method
Lars Knoll [Tue, 12 Mar 2013 19:06:55 +0000 (15:06 -0400)]
Remove unused method

The method was only used to destroy the global context
and it's usage was wrong and needless there.

Change-Id: If97a0c94862b5f7f7ac4dff5ccb58dc2ef8cec4b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd valgrind support to our garbage collector
Lars Knoll [Tue, 12 Mar 2013 18:49:13 +0000 (14:49 -0400)]
Add valgrind support to our garbage collector

Tell valgrind about the memory we allocate and free in the
garbage collector. Also mark stack variables as initialized
before walking the stack.

This avoids all valgrind warnings related to GC and gives
proper warnings if we should attempt to access garbage collected
memory.

Change-Id: I7e923a163c25e7a5b4409b1b9c2191f314675f2d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd debugging function to dump Value contents.
Erik Verbruggen [Tue, 12 Mar 2013 13:18:04 +0000 (14:18 +0100)]
Add debugging function to dump Value contents.

Change-Id: I45e1d1d13fe7dee22809734595a3fbbfd03b123d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMoved temp compression to codegen to use for all backends.
Erik Verbruggen [Tue, 12 Mar 2013 11:46:44 +0000 (12:46 +0100)]
Moved temp compression to codegen to use for all backends.

Change-Id: I3afba14741f18782e71210b14d9d091fe0bebc51
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdded the constant propagation optimization.
Erik Verbruggen [Wed, 6 Mar 2013 10:52:40 +0000 (11:52 +0100)]
Added the constant propagation optimization.

Change-Id: I4fe680ff334a13085df425ad2badad08e548f21f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix & re-enable Temp compression for the interpreter.
Erik Verbruggen [Fri, 1 Mar 2013 13:27:50 +0000 (14:27 +0100)]
Fix & re-enable Temp compression for the interpreter.

Change-Id: Ie9e767d36d3d810bf0d2a173d04954277041f68f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix crash when calling Object.create(null)
Simon Hausmann [Tue, 12 Mar 2013 09:00:06 +0000 (10:00 +0100)]
Fix crash when calling Object.create(null)

O is allowed to be null here, so don't use objectValue() unconditionally
and instead use asObject().

Change-Id: I3e868d3486d2de109c94aef8a7de16110a3a8326
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd support for ARM exception unwinding
Simon Hausmann [Mon, 11 Mar 2013 12:02:59 +0000 (13:02 +0100)]
Add support for ARM exception unwinding

This is used only on Linux/ARM. iOS uses setjmp/longjmp.

Change-Id: I06f907ce702c1b8e06a50ac31b5486d11ef392ec
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMake it possible to debug exception handling with libunwind
Simon Hausmann [Sat, 9 Mar 2013 11:51:12 +0000 (12:51 +0100)]
Make it possible to debug exception handling with libunwind

Run qmake with CONFIG+=debug-with-libunwind.

Change-Id: I02f5820a1c8ee9132dac521d182007800c250103
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoInline the two most common parameter fetch cases.
Erik Verbruggen [Mon, 11 Mar 2013 11:00:13 +0000 (12:00 +0100)]
Inline the two most common parameter fetch cases.

By inlining temp and local fetching, the interpreter is 30% faster
on x86 on crypto.js. x86_64 gains about 35%.

As the comment in the source already indicates: this might need some
tweaking for QML.

Change-Id: I9aa51036d42d2749f9aeec39a479d9e5f6233a23
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMark asm math functions as const.
Erik Verbruggen [Mon, 11 Mar 2013 10:29:01 +0000 (11:29 +0100)]
Mark asm math functions as const.

This allows gcc to inline slightly better, gaining 1% in the
interpreter.

Change-Id: Ia0ebc9eb698f12de4ff7860e9f62a62dbd782ccd
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCatch more exceptions in the v8 API layer
Lars Knoll [Sun, 10 Mar 2013 17:43:06 +0000 (18:43 +0100)]
Catch more exceptions in the v8 API layer

Change-Id: I7af3abbbf8cae86abe31a0d55d3d4c7e8c91a803
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoWrite properties back to the qml Object
Lars Knoll [Sun, 10 Mar 2013 16:53:29 +0000 (17:53 +0100)]
Write properties back to the qml Object

The object acts as a replacement for the QML scope chain.
We need to write values to it even if __hasProperty__ returns
false.

Change-Id: I97856ab8cc3a7a728bb244f40b9f230a415b5a33
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd a proper constructor to v8::FunctionTemplate
Lars Knoll [Sun, 10 Mar 2013 13:59:44 +0000 (14:59 +0100)]
Add a proper constructor to v8::FunctionTemplate

Change-Id: I59b414484c05d8292ee7300860ef9e0611da49e6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoProperly mark objects at the beginning of a chunk
Lars Knoll [Sun, 10 Mar 2013 13:58:35 +0000 (14:58 +0100)]
Properly mark objects at the beginning of a chunk

Objects at the beginning of a chunk didn't get marked
properly as qLowerBound in the mark() method returned an
even number for them. Fix this by subtracting one to the
beginning of the chunk.

Change-Id: I1abd7e24f5b7f374fc0776b7d891a3124fee7270
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix v8::Persistent
Lars Knoll [Sat, 9 Mar 2013 22:18:25 +0000 (23:18 +0100)]
Fix v8::Persistent

Implement it in a similar way as PersistentValue

Change-Id: If4adba61a8bfedce657f07ee24662c3b13384fd9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd exception handling support to the v8 API
Lars Knoll [Fri, 8 Mar 2013 21:52:55 +0000 (22:52 +0100)]
Add exception handling support to the v8 API

Not all calls are yet propertly protected by try/catch
statements, but it should work in principle.

Change-Id: I5ddaf433b0a454106dc2743fe2ccfc5822fb3926
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement more missing bits & pieces including a fake "QML mode"
Simon Hausmann [Fri, 8 Mar 2013 14:48:50 +0000 (15:48 +0100)]
Implement more missing bits & pieces including a fake "QML mode"

Change-Id: Ifbbc5004ada03b6efa7a9884938ff5d59220c5fb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix name lookup for named function expressions
Simon Hausmann [Fri, 8 Mar 2013 13:11:42 +0000 (14:11 +0100)]
Fix name lookup for named function expressions

Change-Id: Ia36b2b5c5b40475450fe369c7d6cb5e3965a4488
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented a whole more API...
Simon Hausmann [Fri, 8 Mar 2013 12:02:26 +0000 (13:02 +0100)]
Implemented a whole more API...

Change-Id: Ica73c21e58b406abd6310c59ec0f541ae2cc9155
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented invocation callback on FunctionTemplate
Simon Hausmann [Fri, 8 Mar 2013 10:47:26 +0000 (11:47 +0100)]
Implemented invocation callback on FunctionTemplate

Change-Id: I718f10f28a053eda78e086407183706e8fad317b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented v8::Arguments
Simon Hausmann [Fri, 8 Mar 2013 09:53:41 +0000 (10:53 +0100)]
Implemented v8::Arguments

Change-Id: I02f7072c13c319b1bdf77471360308bd0d0d3d2a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplemented Template::Set
Simon Hausmann [Fri, 8 Mar 2013 09:47:18 +0000 (10:47 +0100)]
Implemented Template::Set

Change-Id: I237fdf6acdfad9805306e4fc5f437457efa8eb7f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMinor API change for easier implementation
Simon Hausmann [Fri, 8 Mar 2013 09:41:38 +0000 (10:41 +0100)]
Minor API change for easier implementation

Change v8::Template::Set to take Handle<Value> instead of Handle<Data>
and remove incorrect Data inheritance from Value

Change-Id: Iaa71d4437c9913c7a79bc5322f05dafce6e3c89c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoVarious fixes
Simon Hausmann [Fri, 8 Mar 2013 09:34:19 +0000 (10:34 +0100)]
Various fixes

* Make V4V8 object a template in preparation for future changes
* Fix handle <> local conversions
* Implemented v8::External

Change-Id: I27b57c767a31393e1b8b05f3150c16158b178f0d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemaining implementation of ObjectTemplate
Simon Hausmann [Thu, 7 Mar 2013 15:35:46 +0000 (16:35 +0100)]
Remaining implementation of ObjectTemplate

Change-Id: I299b252346b2c5696fb11eb7b8dc527d94dbaf3b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFirst implementation of ObjectTemplate::SetAccessor
Simon Hausmann [Thu, 7 Mar 2013 13:59:25 +0000 (14:59 +0100)]
First implementation of ObjectTemplate::SetAccessor

Change-Id: Iee403e3b542423726f95a0b516a4e2d5938ea2ed
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix use/def for exception var.
Erik Verbruggen [Fri, 8 Mar 2013 11:17:33 +0000 (12:17 +0100)]
Fix use/def for exception var.

A try defines the exception var, because it is the first time it is
mentioned. It might also use it, but that could be seen as
an initialization.

Change-Id: Ibacd12edc02f99c8049003655373122d7916978b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix liveness analysis.
Erik Verbruggen [Fri, 8 Mar 2013 09:44:04 +0000 (10:44 +0100)]
Fix liveness analysis.

When a move has a temp that is either a scoped local or a formal,
then instead of "returning" from the visit, the source expr still has
to be visited. It might contain a use.

Change-Id: Ibd54fdc3488b1348e63ecd5a0c1b1036ae111c8a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix MSVC build.
Erik Verbruggen [Fri, 8 Mar 2013 08:57:33 +0000 (09:57 +0100)]
Fix MSVC build.

Suppress error for methods that have to return a value, but are marked
as Q_UNIMPLEMENTED by adding a Q_UNREACHABLE.

Change-Id: I2f7d3027fd5a8949b7c330d8cab3f3f095e11450
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCompile fixes for MSVC.
Erik Verbruggen [Fri, 8 Mar 2013 08:56:44 +0000 (09:56 +0100)]
Compile fixes for MSVC.

When a class is dllexported, the methods cannot also be marked as such.
They are exported automatically. The error message is:

d:\dev\v4vm\src\v4\qv4v8.h(1525) : error C2487: 'New' : member of dll interface class may not be declared with dll interface

Change-Id: Ib44ee401e35c723b20c8c9f2dceab02736c77a3f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years ago"Fix" llvm build.
Erik Verbruggen [Thu, 7 Mar 2013 16:00:17 +0000 (17:00 +0100)]
"Fix" llvm build.

In a way that it the compiler doesn't complain anymore.

Change-Id: I877b1a051b2ffcbd63a04cf219733b2b21cb9128
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix exception handling on Mac OS X
Simon Hausmann [Thu, 7 Mar 2013 11:53:34 +0000 (12:53 +0100)]
Fix exception handling on Mac OS X

Re-introduce the old register_frame and deregister_frame approach
on Mac OS X until we have something faster.

Change-Id: Idf524857c91175535184b29c11265c7d26f064a7
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
11 years agoSimple but effective dead-assignment removal.
Erik Verbruggen [Wed, 6 Mar 2013 10:48:05 +0000 (11:48 +0100)]
Simple but effective dead-assignment removal.

At the moment we only generate a dead assignment when initializing the
return value to undefined (and subsequently assign to it). With upcoming
patches, esp. constant propagation, there will be more dead assignments.

Change-Id: I423ed77fb0693ca6c2855d1e0200e6a205d01f4f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix String::get and start using it
Lars Knoll [Thu, 7 Mar 2013 12:41:21 +0000 (13:41 +0100)]
Fix String::get and start using it

Change-Id: I80cc7533effad2a1fa3fe60c2596ed9d27e843c9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAnd use the vtbl methods for delete as well.
Lars Knoll [Thu, 7 Mar 2013 12:14:34 +0000 (13:14 +0100)]
And use the vtbl methods for delete as well.

Change-Id: I7632382ccb8aa2f8ae733f638bb42eddbc739c6a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement Object::query/queryIndexed
Lars Knoll [Thu, 7 Mar 2013 11:57:49 +0000 (12:57 +0100)]
Implement Object::query/queryIndexed

Change-Id: I7feea63d0e9eb7c1e633536aea4c4a4dbd03b462
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup put and properly implement it for strings
Lars Knoll [Thu, 7 Mar 2013 11:55:02 +0000 (12:55 +0100)]
Cleanup put and properly implement it for strings

Change-Id: I10dda09c8a087bc7ef34c0315c698e08c35ec28d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix build with clang
Simon Hausmann [Thu, 7 Mar 2013 07:40:36 +0000 (08:40 +0100)]
Fix build with clang

It suggests a template keyword here to make it clear that As() is template dependent

Change-Id: I0a228ad51b7a7a09e3774465f7118e3e6e247e93
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFirst part of moving get/put etc. into the Managed vtbl.
Lars Knoll [Thu, 7 Mar 2013 11:25:59 +0000 (12:25 +0100)]
First part of moving get/put etc. into the Managed vtbl.

Change-Id: I6fe14b02205901dbffa25c6c1b4883fb99586417
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake Object::hasProperty() inline
Lars Knoll [Thu, 7 Mar 2013 09:57:48 +0000 (10:57 +0100)]
Make Object::hasProperty() inline

Simply call getPropertyDescriptor instead

Change-Id: I9e156a45dd10bf250fa156820ec2f3d5bbe80bbc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement v8::AccessorInfo
Lars Knoll [Thu, 7 Mar 2013 09:31:29 +0000 (10:31 +0100)]
Implement v8::AccessorInfo

Change-Id: I72598ad9941b35e7268f6a90c26c91f37593bed4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove v8 internal namespace
Lars Knoll [Thu, 7 Mar 2013 09:26:03 +0000 (10:26 +0100)]
Remove v8 internal namespace

Change-Id: I78d0ddb1b5b790cb74cfa2d115e7dd47ebb30ab1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoA few more API methods implemented
Lars Knoll [Wed, 6 Mar 2013 21:21:26 +0000 (22:21 +0100)]
A few more API methods implemented

Change-Id: I4168ad5bb934a74e6957969417fdcf491a7374a1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMore v8 API
Lars Knoll [Wed, 6 Mar 2013 20:43:58 +0000 (21:43 +0100)]
More v8 API

Change-Id: If62d4a0dbe8f59d62bef2cce0bb9002be47957bc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement more of the v8 API
Lars Knoll [Wed, 6 Mar 2013 20:28:03 +0000 (21:28 +0100)]
Implement more of the v8 API

Change-Id: Ibc8feb95b9473712105cf79e98fc0cef8c3b0fe7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix slowness in unwind table registration
Simon Hausmann [Wed, 6 Mar 2013 19:04:47 +0000 (20:04 +0100)]
Fix slowness in unwind table registration

__register_frame and __deregister_frame are very slow when called
with many functions many times, like in some of the tests that use
a lot of eval(). Change the approach to interposing a function symbol
that is called in libgcc whenever a PC -> FDE lookup is required.

This also changes the code to create the unwind info on-demand.

Change-Id: I99dfcc921b087831ad00f79bad9e7bcfb0cc8c33
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMake sure that the value stored in the Exception object is not garbage collected
Simon Hausmann [Wed, 6 Mar 2013 19:04:43 +0000 (20:04 +0100)]
Make sure that the value stored in the Exception object is not garbage collected

Change-Id: I7e3c4e0d1d9a23a54922a3254962ac2dc42bf67b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoGet rid of 'Value ExecutionEngine::exception' member
Simon Hausmann [Wed, 6 Mar 2013 19:04:39 +0000 (20:04 +0100)]
Get rid of 'Value ExecutionEngine::exception' member

Instead the JS exception value is now part of the C++ Exception object.

This also allows getting rid of some run-time functions.

Change-Id: I43ff773cacd5e925ba96601f3633ccf3b62273be
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoGet rid of the builtin_get_exception call in the IR
Simon Hausmann [Wed, 6 Mar 2013 19:04:36 +0000 (20:04 +0100)]
Get rid of the builtin_get_exception call in the IR

Instead allocate a temp to hold the exception to rethrow and pass the address
of that to the TRY statement. Then it can be set in the run-time.

Change-Id: Ic15869e8e5ab5119b26f98fc45dbdb1a2ad9d21e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup: Get rid of calls to builtin_{push,pop}_catch_scope in the IR
Simon Hausmann [Wed, 6 Mar 2013 19:04:31 +0000 (20:04 +0100)]
Cleanup: Get rid of calls to builtin_{push,pop}_catch_scope in the IR

These calls aren't needed anymore and can easily be done on the run-time level
instead right before and after calling the catch block.

Change-Id: I445361688782d12269764578e83ebb21ae184190
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplement a few mere methods in the v8 API
Lars Knoll [Wed, 6 Mar 2013 17:12:39 +0000 (18:12 +0100)]
Implement a few mere methods in the v8 API

Change-Id: Ia95866060e27c4311ce819c7aec04f328fa8eca1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoOptimize exception throwing
Simon Hausmann [Wed, 6 Mar 2013 19:04:21 +0000 (20:04 +0100)]
Optimize exception throwing

Introduce a try statement in the IR that allows the back-end to jump to the try
and catch blocks directly instead of having a conditional jump for each entry.

For the case where we have no catch but only try { ... } finally { ... } we
create a synthetic catch block that sets hasException to true, to ensure that
when an exception is thrown during try we execute finally and then rethrow the
exception.

Change-Id: If4be5421f9731522beab80e843283b517d4aa41c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImplement most of the New() methods in the v8 API
Lars Knoll [Wed, 6 Mar 2013 13:54:30 +0000 (14:54 +0100)]
Implement most of the New() methods in the v8 API

Change-Id: Icf88354656ae12ae38a24eaebfd1b1d22e755c52
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement external object comparison
Lars Knoll [Wed, 6 Mar 2013 13:01:07 +0000 (14:01 +0100)]
Implement external object comparison

Change-Id: Ieec34aa1b410766510919a99c5964c288b4addc1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement the various v8 Cast methods
Lars Knoll [Wed, 6 Mar 2013 11:31:46 +0000 (12:31 +0100)]
Implement the various v8 Cast methods

Change-Id: I056fbcb229ef3b487e28e14c6d58007aeb7ba8a0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a bug in Persistent::New
Lars Knoll [Wed, 6 Mar 2013 10:19:02 +0000 (11:19 +0100)]
Fix a bug in Persistent::New

Change-Id: Iac13aa897e64bca6b50ea90bd5e2804e2212e008
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanups
Lars Knoll [Wed, 6 Mar 2013 10:18:56 +0000 (11:18 +0100)]
Cleanups

Change-Id: Ifbe085eea9f1f605af0b802f299f82f24a14e9b1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd stubs for all the methods in the v8 API
Lars Knoll [Wed, 6 Mar 2013 08:55:15 +0000 (09:55 +0100)]
Add stubs for all the methods in the v8 API

Qt Qml and Qt Quick now link against V4 :)

Change-Id: I8320875bdeab91d800fbf530b0d57a67dc872188
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSimplify conversion between VM::Value and V8::Value
Lars Knoll [Tue, 5 Mar 2013 21:41:49 +0000 (22:41 +0100)]
Simplify conversion between VM::Value and V8::Value

Also implement the Exception class and ThrowException.

Change-Id: Ib9ca804cb82288d9da8b74f6cd3c38ecd61dbc1b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement v8::Undefined/Null/True/False
Lars Knoll [Tue, 5 Mar 2013 21:21:40 +0000 (22:21 +0100)]
Implement v8::Undefined/Null/True/False

Change-Id: I831e3b5e53d06edcbce57d37fc43995154b26305
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove API not used by Qml
Lars Knoll [Tue, 5 Mar 2013 19:28:06 +0000 (20:28 +0100)]
Remove API not used by Qml

Change-Id: Ibd202369f320c2db501d7a900941f0734326db7d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMake a V8 hello world actually work.
Lars Knoll [Tue, 5 Mar 2013 16:13:15 +0000 (17:13 +0100)]
Make a V8 hello world actually work.

Change-Id: Ia80004d2104e72e7c871be3582cab26ca9e493bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoImplement v8::Script::Run()
Simon Hausmann [Tue, 5 Mar 2013 15:37:08 +0000 (16:37 +0100)]
Implement v8::Script::Run()

Change-Id: I7456e0a5e389216aac84d3ca9d66cc1e7f688008
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMove function execution into a little ExecutionEngine::run helper function
Simon Hausmann [Tue, 5 Mar 2013 15:11:22 +0000 (16:11 +0100)]
Move function execution into a little ExecutionEngine::run helper function

This will allow for re-use from the v8 wrapper API.

Change-Id: I2330432dad43d7fd7af6147e96a0cbbb340cd917
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoInitial v8'ish API wrappers for QML integration
Simon Hausmann [Fri, 15 Feb 2013 13:59:34 +0000 (14:59 +0100)]
Initial v8'ish API wrappers for QML integration

The goal is for these wrappers to exist only for a limited period
of time until all of QML is ported to use pure v4vm.

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