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>
Lars Knoll [Sun, 2 Dec 2012 18:58:35 +0000 (10:58 -0800)]
Pass the ExecutionContext into the code generator
Use the contexts strict mode flag to correctly parse
eval code inside strict mode sections.
Add code to allow the code generator to throw syntax
errors.
Change-Id: I4e4258b0d0b88952f4d609ec51bbe8db9a1c66a9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Sun, 2 Dec 2012 19:10:09 +0000 (20:10 +0100)]
Fix clobber list for inline add/sub/mul instructions
These inline asm blocks do also change flags, therefore we need to add the
condition code register to the list of clobbered pseudo registers.
Change-Id: Iea7b2557813bbb2fa86d7506e6416092fdc14702
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Sun, 2 Dec 2012 18:29:59 +0000 (10:29 -0800)]
Fix code generation for try statements
The old code was not correctly handling statements as
try { return; } finally {...}
and others. In addition it was hard to read an maintain.
We now keep a stack of try statements inside the code
generator. Loops know about their surrounding try statement.
Whenever a break, continue or return statement is encountered
we now generate code for the finally statements and exception
handlers we need to cleanup.
Change-Id: I53bcc0587f1e923be00fea9b562453ef1e96b2de
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Sun, 2 Dec 2012 18:04:57 +0000 (19:04 +0100)]
[masm] Clean up binop code generation
Instead of a gigantic switch and that duplicated across regular binop
and in-place binop, let's use one table where we can store all sorts
of meta-information about various aspects of the op implementations.
Then we can centralize the code for generating the inline operation
as well as the call to the fallback in one helper function.
Change-Id: I13b6dae7fd2a1490ae315689fa5f813eee83dd7b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Sat, 1 Dec 2012 19:08:26 +0000 (20:08 +0100)]
Remove the callFunction() method
Give Object a virtual call() method, that simply throws
a type error. FunctionObject reimplements this to do the
right thing.
Change-Id: I5a11a4de0302ad86b9ad3a822501224e11692b70
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 18:57:26 +0000 (19:57 +0100)]
Fix qmljs_call_property
Change-Id: Ic32fc8815704ed201a3b50eae05ff2705372210d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 18:39:57 +0000 (19:39 +0100)]
Throw when trying to set an undefined variable in strict mode
Change-Id: Ia4cbe302b96e53147aa7857dcded811e73136329
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 13:25:54 +0000 (14:25 +0100)]
Further clean up the ExecutionContext
remove the distinction between initCallContext and
initConstructorContext. Since the context now has a
pointer to the current function, we can also simplify
the wireupPrototype method.
Change-Id: I06cbaced2438b01b3033182e136e1504c087c8c0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Sat, 1 Dec 2012 13:05:07 +0000 (14:05 +0100)]
Remove the DeclarativeEnvironment class again
The class is a specification detail that we can implement
in a more performant way. ExecutionContext now contains
everything needed again.
Change-Id: Ideb5f04eeeecaf2b8543676c626e3943e4d6d7a1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Fri, 30 Nov 2012 22:15:55 +0000 (23:15 +0100)]
Remove the outer member in declarativeEnvironment
The function already has it as the scope parameter, so
don't duplicate the data.
Change-Id: Iadd0418cafa9ad273db11c06c44086ac64b1e5bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Simon Hausmann [Sun, 2 Dec 2012 00:04:34 +0000 (01:04 +0100)]
[masm] First implementation of inline addition / subtraction
Change-Id: I4e54ae0feded8d99737245c870e0dfbb9b80247e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Simon Hausmann [Sat, 1 Dec 2012 22:59:53 +0000 (23:59 +0100)]
Simplify push(IR::Const*)
Use the convertToValue() function instead of manually trying to
convert the IR::Const to a VM::Value.
Change-Id: Ib669def3c2ef3dfba6cabb0b0c0b3c1d014a13ca
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Fri, 30 Nov 2012 08:48:46 +0000 (09:48 +0100)]
Clean up the DeclarativeEnvironment
Add a pointer to the FunctionObject in there, and remove the
duplication of the formal and local variable names.
Change-Id: Id8017b3e167228292b5d351e02b8927f0bfb41eb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Thu, 29 Nov 2012 21:37:25 +0000 (22:37 +0100)]
Get rid of variableEnvironment
Found out that the variableEnv is only required
for two use cases: To expose the exception in the
catch statement, and to create temporary
environments for the with() statment. Both can be
better handled differently and don't require the
overhead of two environments.
Change-Id: I149e1fd7bdfc3267544b141b6f94e46e42cf641b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Thu, 29 Nov 2012 21:25:21 +0000 (22:25 +0100)]
Give primeIds the amount of bits it requires
Also mark the prime number array as const
Change-Id: Ieae3e5d13decb0edf0d086780b323a12351a55d8
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:41:26 +0000 (14:41 +0100)]
Add some debugging infrastructure to the interpreter.
This currently mainly intended to be useful in a C++ debugger. The
infrastructure makes it a lot easier to access (parent) contexts, find
function names, etc.
Change-Id: I0493d3a3bd4bf5c3a03379c1a2b545ed76862cd5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:39:19 +0000 (14:39 +0100)]
Set the name of a function in more (most?) cases.
Change-Id: I1c2b9d61b6d97e3c2a8cb976fb6be8b68d51ae28
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:36:16 +0000 (14:36 +0100)]
Fix missing code generation for inplace operations on locals.
Change-Id: I8fe7d87eabf2566f251319e8dae005aacc27eb0d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Thu, 29 Nov 2012 13:35:18 +0000 (14:35 +0100)]
Fix outgoing argument start position.
Change-Id: Ie1b86746dc578ce479f5c072e2e1190826a7739c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Wed, 28 Nov 2012 22:26:26 +0000 (23:26 +0100)]
Implement Object.keys and obj.proto.propertyIsEnumerable
Change-Id: I30df135ad95f24246e43553b2711ad1008319d56
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 28 Nov 2012 22:10:03 +0000 (23:10 +0100)]
Implement Object.seal/freeze/preventExtensions
And the corresponding getters.
Change-Id: I5038ec3f87f932d65c67cafd36ec00b9970a5f51
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Lars Knoll [Wed, 28 Nov 2012 21:45:43 +0000 (22:45 +0100)]
Add defineGetter and defineSetter methods to Object
These methods are de-facto standard (every engine implements
them), and also allow testing of accessor properties.
Change-Id: I1fcaa7467f7be56ea758bf511e843385f74b9641
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 13:59:42 +0000 (14:59 +0100)]
Fix copy-paste coding error. "m" is null in the else part.
Change-Id: I5ef62c984f169b9a50ec1d90bd02c5593fde3745
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 13:16:21 +0000 (14:16 +0100)]
Tune the message property (value) of SytaxError a bit.
Change-Id: I231eb1eeb8f01461ea61b3989743bbd01256e251
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:47:20 +0000 (13:47 +0100)]
Replace qIsNaN usage with std::isnan, which is often faster.
Change-Id: Ie4d16fcdb575ca168d5b58978c5a510acf0cd1ca
std::isnan is often a compiler intrinsic.
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:44:26 +0000 (13:44 +0100)]
Tune the bucket count a bit to be a prime upto 68000 entries.
The ECMA test suite has some tests that throw in vars with all possible
unicode names. So, this should make it safer for longer.
Change-Id: I4a65ab7d09a357d7665509d38e401098ab6e4607
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:39:14 +0000 (13:39 +0100)]
Introduce a simple string pool to speed up lookups.
This change uniques string pointers, so the String::isEqualTo will more
often succeed in the pointer-equality case.
Change-Id: I1d4f1a70147c48bc75359642a56a0446b5fbf199
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 12:35:53 +0000 (13:35 +0100)]
Stop leaking the DeclarativeEnvironment and ExecutionContext.
Also fixes non-POD warnings with Clang, as the constructor of the
DeclarativeEnvironment is now gone.
Change-Id: I15e02aabb195243415b088a8b030f0064a7e84a3
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Wed, 28 Nov 2012 10:00:23 +0000 (11:00 +0100)]
Throw a SyntaxError instead of printing an error message.
Change-Id: I94ef8a4f2bea80bc3689b104e381a9dc134439fa
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Tue, 27 Nov 2012 23:12:33 +0000 (00:12 +0100)]
Fix a bug in Object::__put__()
The method was always throwing in strict mode, due to
a missing return statement.
Change-Id: I85e44f8067d1f2aea76d03e42abf31a0d5a2d180
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Tue, 27 Nov 2012 22:23:04 +0000 (23:23 +0100)]
Obey strict mode for property getters and setters
Change-Id: I6f51cd72c2607989c55373dfee53130381f5ef75
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Tue, 27 Nov 2012 21:59:51 +0000 (22:59 +0100)]
Remove unused methods
Change-Id: I4b0553b1fb6522131a05a66f8cba44bce5192e55
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Lars Knoll [Tue, 27 Nov 2012 21:42:20 +0000 (22:42 +0100)]
Implement the first parts of strict mode.
Tested with eval() which now obeys strict mode
semantics.
Change-Id: Ib3c7f31047e43c1ef0fa74261f23ec4f2ea4244f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Erik Verbruggen [Tue, 27 Nov 2012 15:46:04 +0000 (16:46 +0100)]
Check for strict mode, and store it.
Change-Id: I88e48a982eb6d4041aed085de0420d98cf96d406
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Tue, 27 Nov 2012 11:17:19 +0000 (12:17 +0100)]
Add more built-ins to the interpreter.
Change-Id: I6a1656a8a2042b0a02d6e3bb8e59c9db52f6fd5d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Lars Knoll [Mon, 26 Nov 2012 22:26:39 +0000 (23:26 +0100)]
Correctly instantiate variables in the local scope
This fixes cases where eval() would create variables
in the wrong scope.
Change-Id: Ie93ec2d1fb125e588c1b6ffa2ca8ca4b6e3112c9
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Simon Hausmann [Mon, 26 Nov 2012 21:49:35 +0000 (22:49 +0100)]
Fix constant value parameter passing on ia32
Fix the order of tag and value when pushing constants onto the stack, given
that the stack grows in reverse order.
This fixes crypto.js and all sorts of other tests.
Change-Id: I1f6aa546e5453f890db582283fd4da609292f22b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Erik Verbruggen [Mon, 26 Nov 2012 13:38:14 +0000 (14:38 +0100)]
Fix: do not rune codegen when there is no program.
Happens in valid cases like an empty JS file (or one only containing
comments).
Change-Id: I553f57503b46da29276b06532a14e2a74395d84c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>