Lars Knoll [Mon, 17 Dec 2012 14:18:38 +0000 (15:18 +0100)]
Fix a bug in catch{}finally{} and simplify code
There was a bug in the implementation of unwindException(),
that caused failures when called twice from one catch statement.
Also refactor and simplify the TryStatement code further by
introducing a rethrow builtin.
Change-Id: I77bf37f1707042f402488ef2dfaf4e59bf8dc82a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 17 Dec 2012 12:34:39 +0000 (13:34 +0100)]
Resolve argument names from right to left
Duplicated names for arguments are allowed in JS, later ones
shadow previous ones. So we need to iterate from back to front
to resolve the names correctly.
Change-Id: If427ce9d11ac561457c24e41f79c11263fa0a8dc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 17 Dec 2012 09:29:48 +0000 (10:29 +0100)]
Avoid lookup of locals and formals when possible
If we do not have a Function or the function doesn't
need activation, we directly generate code to get and
set formals and locals, so there's no need to look
these up from the execution context.
Change-Id: I888fc65fd2527f9102fab7cae2822600f87f9edc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 17 Dec 2012 09:03:37 +0000 (10:03 +0100)]
Allow the compiler to inline
use String::isEqualTo instead of qmljs_string_equal to
allow for inlining.
Change-Id: I55d41ab34f1e04cb0f752d8018e3ce9b11a90d1d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Mon, 17 Dec 2012 08:52:04 +0000 (09:52 +0100)]
Smaller cleanups and code simplifications
Change-Id: I1634ce8b105ee0d22b67fafa45962fe7c22b9f3a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sun, 16 Dec 2012 22:08:07 +0000 (23:08 +0100)]
Cleanup constructor handling
Simplify the code and unify the generic part of object construction
in FunctionObject::construct.
Change-Id: Ie430458bedaa211efba37c8283e26a9b84e6764a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Sun, 16 Dec 2012 22:00:01 +0000 (23:00 +0100)]
Fix return value corruption in masm codegeneration
In some cases, the first argument for runtime calls and the
return value where being placed in the same location on the
stack leading to corrupted return values. This mainly
happens when no local variable are defined, but other
functions are being called.
Change-Id: I93f1e518ce2998f62fb9f38c538dd718f41e522d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Fri, 14 Dec 2012 15:40:48 +0000 (16:40 +0100)]
Fix delete operator on local variable and arguments
throw in strict mode, and ignore delete operations on
arguments otherwise.
Change-Id: Icd55f1c99dc5e5c35b3fea1ce5fdf46d5295dbaf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 14 Dec 2012 13:23:55 +0000 (14:23 +0100)]
Fix a bug in the construct method of Function objects
Function objects when called as a contructor should return
the return value of the called function if the return value
is an object (see 13.2.2)
Change-Id: I9d9e52859935d62b7f949fff46cb00d257bad90f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 14 Dec 2012 13:23:21 +0000 (14:23 +0100)]
Fix a bug in the Object contructor
new Object(x) should convert x to an object and return
it if x is not null or undefined
Change-Id: Icb5547a23df83018757901bfecb5f024610e7c68
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Jędrzej Nowacki [Thu, 13 Dec 2012 14:11:21 +0000 (15:11 +0100)]
Micro optimization of StringPool
In destructor we do not need to create a copy off all pointers.
By hiding StringPool::strings in class private
section we reduce risk of it being accidentally copied.
Change-Id: I1b9df6bf9e49bd6926e84b8eac6b3d904277e50a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Jędrzej Nowacki [Thu, 13 Dec 2012 15:12:53 +0000 (16:12 +0100)]
Remove ExecutionEngine::identifiers.
The member was a duplicate of stringPool, there is no point in caching
a cache.
Change-Id: If34c80ee120dfaff1dd94326625b02d8014806dc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 14 Dec 2012 12:53:22 +0000 (13:53 +0100)]
Small cleanups for ArgumentsObject
Change-Id: Ib9a2f3ab23dd76f52bb4c41edf539f4fa0cd8929
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 14 Dec 2012 12:27:26 +0000 (13:27 +0100)]
Fixes for arguments object in non strict mode
In non strict mode, the arguments object actually
reflects the argument as it changes over the lifetime
of a function, unless you explicitly delete some of it's
properties.
The code to implement this is pretty ugly, but still better
then the specification :)
Change-Id: Ie42ed25c797513615fbc4bdee14145d953f323f3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 14 Dec 2012 10:32:52 +0000 (11:32 +0100)]
Fixes for the arguments object
We now pass most of the test cases for it.
Change-Id: Idc43a9baa75c3c1e8fe760d78cf5e6092f051c6e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 14 Dec 2012 09:25:27 +0000 (10:25 +0100)]
Cleanup getPropertyDescriptor and arguments object
The only place where getProepertyDescriptor was still being
used outside of Object itself was the arguments object. Fixed
that by reimplementing get, hasProperty, put and canPut in
the arguments object.
Change-Id: Ie44c7acf857321c65bc0f58915de0353231459c0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Fri, 14 Dec 2012 08:46:25 +0000 (09:46 +0100)]
Fix failing assertions in GC on ia32
We currently round up allocation sizes to 16-bytes on 32 and 64-bit.
When recursively calling alloc() after the allocation of a new heap chunk,
make sure to adjust the requested size parameter again to its original value,
to ensure 16 byte alignment.
Change-Id: Ie8cd29d60639bf43023a310b7be6f772305fa826
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Fri, 14 Dec 2012 08:55:10 +0000 (09:55 +0100)]
Fix execution with MM_AGGRESSIVE_GC=1
Make sure that the current context pointer is initialized to the
root context, so that early GC runs before the first function call
find an initialized pointer in MemoryManager::collectRoots.
Change-Id: I224695b253e27674913310b76d12d42bff5c1b82
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Fri, 14 Dec 2012 08:57:02 +0000 (09:57 +0100)]
Simplify/speed up retrieving of properties
The hasProperty()/get() sequence used so far is as in the
spec, but requires us to lookup the name twice. Instead add
a bool hasProperty() to Object::__get__() and use that.
Speeds up fact.2.js by ~20%
Change-Id: Ic8c84718f1a702c3da9487010c0d6dd0fee44609
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Thu, 13 Dec 2012 22:46:51 +0000 (23:46 +0100)]
Fix quadratic behavior in the memory manager
The old freeList implementation was causing quadratic
behavior in alloc(), as the free item ended up in the
highest chunk.
The new implementation uses a fixed size array for small objects
(up to 256 bytes), a QMap for large chunks, and a defaultFree
object pointing to the heap that has never been used before.
Gives around 25% performance boost on crypto.js, and bsaically
makes the memory manager invisible in kcachegrind.
Change-Id: I559fb527bcd9e21d4ac265f4d78b8376bfda2522
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Thu, 13 Dec 2012 14:52:07 +0000 (15:52 +0100)]
Fix invalid reads in valgrind during unused basic block collections
When clearing cross-references to unused basic blocks blocks, don't
delete the block right afterwards because another block might also
still reference it. Instead keep track of the ones to be deleted
and delete them afterwards in one shot.
Also replaces the existance check for the blocks from a linear
vector search to a hash set lookup which we already have around.
Change-Id: I3bd72359259065ba26bf2116bf849575e4601f32
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Thu, 13 Dec 2012 13:48:20 +0000 (14:48 +0100)]
inline some code in toInt32 and toUInt32
Speeds up crypto.js by ~5%
Change-Id: I707bd6e7dc0f13b70889955e1b90f0c436db1848
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Thu, 13 Dec 2012 12:46:49 +0000 (13:46 +0100)]
Avoid creating the activation object in most cases
it's now only being used for the global context, and
in case a non strict eval defines an additional variable
in any other context.
Change-Id: Ib6531bfce8d19634af79cc813d38c41f5348f961
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Thu, 13 Dec 2012 12:12:10 +0000 (13:12 +0100)]
Rename Unset/Set to the more readable Enabled/Disabled for the property tristate
Change-Id: I67f5a509be64b20a5fa0205779f2a67dc1ba6536
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>