Commit Graph

59 Commits

Author SHA1 Message Date
Lars Knoll 6fb0f5c1b8 Add escape and unescape to the global object
Change-Id: I46353c10a44856c0358e811f5356238721d4a1ec
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-22 15:30:02 +01:00
Lars Knoll 55d54a125e Add URI handling methods
Change-Id: Ieee66aa1f95e6676316c4504b4874d307f5b3564
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-22 15:29:43 +01:00
Lars Knoll bd66309251 rename qv4ecmaobjects.* to qv4objectproto.*
Change-Id: I4bf60a424542cb7e53d54011ac5d0c503453913f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:56:44 +01:00
Lars Knoll 64fda7f790 Move Boolean object into it's own file
Change-Id: Ia62b223111fa41877bc24b6320f0078a3546c55b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:56:10 +01:00
Lars Knoll 3332397292 Move Number object into it's own file
Change-Id: Ie431e653956efa35dc92523e236af1097d57bab9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:56:00 +01:00
Lars Knoll 7c8266360b Move ArrayCtor and ArrayProto into their own file
Change-Id: I304f50704dbad396abc7c6c8ae73d454ebd73e01
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:55:48 +01:00
Lars Knoll 8d3c58600a Move qmljs_object.* to qv4object.*
Change-Id: I846958875eaa2feae51e3a70290a197dd40bcb12
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:54:46 +01:00
Lars Knoll fc0ce315b3 Move math object into it's own file
Change-Id: I01f00659f01ff11a401dedf1ce27b16d31d0f4f9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:54:14 +01:00
Lars Knoll 6681dde8b7 Split Regexp object into it's own file
Change-Id: Ib24f4a42d2312291b3a10d2a02fad33a1eb4b5b5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:54:02 +01:00
Lars Knoll 6e149e2ecf Move Error Objects into their own file
Change-Id: Id45f3c38b3effb0087a4782049b5d3184d7f9891
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:53:17 +01:00
Lars Knoll f6f6f5d1d3 Further split up qv4ecmaobjects and qmljs_objects.
Change-Id: I3dbcf7f9209a2c8ff601b64ef722640181dbb6f8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 22:52:52 +01:00
Lars Knoll 11bfd4e062 Move the String object into it's own file
Change-Id: I3efc9aeaaa7c851715a996e5cbc149fa87cf5503
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 14:26:07 +01:00
Lars Knoll 659fc03c42 Move the Date Object into it's own file
Change-Id: I3f94fa1dcfc8e23414ee2b3f96cffffa1f753bc1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-21 12:23:51 +01:00
Lars Knoll 45de7baed5 Implement JSON.parse
Change-Id: Ibb5f9226aaaea8653842c5a452e006dc05210a2c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-19 08:21:24 +01:00
Simon Hausmann 8ac781f35e Get rid of __get__ implementation in ErrorObject
As a step towards making __get__ non-virtual we can implement the message
property instead using run-time initialization.

The Error.prototype object must also provide a message property with
the empty string as initial value (15.11.4.3).

Change-Id: If8a7fd828e6c6fa6e20607505b392d0bda71f90a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-01-18 16:28:16 +01:00
Lars Knoll 4a52bc9867 Remove the need for virtual __get/set__ methods in ArgumentsObject
In addition to not needing virtuals anymore, it also fixes a few
corner cases in the test suite.

Change-Id: I9f93d820aa7700c038c60a55daa57e1567d42b17
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-18 13:46:57 +01:00
Simon Hausmann e7729e28f0 Fix values of RegExp.lastIndex property
The property should be writable and also set to 0 if no match is found.

Change-Id: I4288ad239980260c7610c5de0061cc42ac38bb7a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-01-17 21:00:24 +01:00
Simon Hausmann 94f5a6ec6d Add Yarr regex engine from JSC
Only the interpreter is enabled right now, the JIT needs more compile fixes.

This is the initial port that is functionally equivalent to the
QRegularExpression based implementation except for the tests that pass now
because of the actual JS compatible regex implementation.

Change-Id: Ieb7e66e9b38071ea1d32effe045c70023b17fabd
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-01-17 14:24:04 +01:00
Erik Verbruggen 821e5806d9 Rename native functions to builtin functions.
Both the JIT and the compiler generate native code, but the functions
have to be registered as ScriptFunction objects, not NativeFunction
objects. The name BuiltinFunction prevents confusion or errors.

Change-Id: Ic6dca457362f916201b3e5178fbd36c6d754fa9c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-16 14:27:28 +01:00
Erik Verbruggen c94c140354 Fixed memory leaks.
Change-Id: I641127b0d46f88291468af767cbbeb28ce5a75d9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-15 16:27:29 +01:00
Lars Knoll 88e328b09b Make sure our error objects always have the correct prototype set
Change-Id: I26ed066d14d0fe6147bf043c35d41e6434bc8873
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-14 18:27:04 +01:00
Lars Knoll a880ef56ff Implement StringObject properly
we now pass all of 15.5.5

Change-Id: Ia72bd5f064e6edfcd440e2c2ea72459a09efd1e8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-14 16:33:03 +01:00
Lars Knoll 960e86a5c7 The prototype of error constructors is the function prototype
Change-Id: I9365d04b199f4cc7b75f347886b68ccc073564fb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-14 16:31:05 +01:00
Lars Knoll 9da2b90a3f Implement Function.prototype.bind
Change-Id: Ia63f5064d76fecfc513737a0072bf5e3cdce474c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-14 12:54:45 +01:00
Lars Knoll fdbaa9804d Fixes to the ScriptFunction constructor
We now pass all of 15.3, with the exception of
tests using the unimplemented Function.prototype.bind
method.

Change-Id: I95f6157ea99d63556c32ae7524ee5e14026bbd69
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-01-13 22:47:42 +01:00
Lars Knoll f9682cb82e Make Array.length a real property with attributes
Change-Id: Ib955e151c1d60145948eb5ac76283854dda2cefe
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-12 23:20:01 +01:00
Lars Knoll 0b7dce92b5 Add support for throwing RangeErrors
Change-Id: I15bad9d7fe33f9a906d3b2d8da94a969d54d918c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-12 23:19:00 +01:00
Jędrzej Nowacki f375d81341 Remove unused MemoryManager::Data::stringPool
Change-Id: Iffc993c2872329f055c28aefa067a81840c346e9
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-01-11 11:41:04 +01:00
Lars Knoll cbc9306f70 Fix a bug in qmljs_set_element and some related to for...in
Change-Id: Iec876f12529adeba3bc7b9c927e38100fff88042
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-11 10:05:34 +01:00
Erik Verbruggen 8f132b89eb Added parseInt (15.1.2.2) and parseFloat (15.1.2.3).
Change-Id: I0ff54a59d68596b55fb1add25c29f894b05252b9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-01-09 17:14:59 +01:00
Simon Hausmann 03573f480a Clean up memory manager ownership
Since we have now only one memory manager, we might as well let the
ExecutionEngine create and own it.

Change-Id: I908adadf64da59e0b8f4c09d4d9502785399cb99
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-01-03 14:24:52 +01:00
Jędrzej Nowacki c09b940a64 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>
2012-12-14 14:24:44 +01:00
Jędrzej Nowacki 9de4ccef6b 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>
2012-12-14 14:20:57 +01:00
Simon Hausmann b33c0ab3fa 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>
2012-12-14 12:59:43 +01:00
Jędrzej Nowacki 5d97f07d5c Use a smart pointer for ExecutionEngine::stringPool
Change-Id: I5434fbd146e9d8dcc0000327c5a5b953bc744b83
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-12-13 12:45:07 +01:00
Lars Knoll c28f8c7b40 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>
2012-12-12 16:07:18 +01:00
Lars Knoll 463ed070be 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>
2012-12-12 09:09:32 +01:00
Erik Verbruggen 5e39d56c09 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>
2012-12-11 23:16:32 +01:00
Lars Knoll 9c104bb970 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>
2012-12-10 20:08:26 +01:00
Lars Knoll df458859f4 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>
2012-12-10 20:08:21 +01:00
Lars Knoll 13ea451c4f Implement Object.create/defineProperty/defineProperties
Change-Id: I3a71597d012b5fb7d7a2f482f4a16431c71c1c22
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-12-08 17:25:02 +01:00
Erik Verbruggen 5f22fbd7fc 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>
2012-12-08 04:47:53 +01:00
Lars Knoll 46953ed4d0 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>
2012-12-05 01:04:21 +01:00
Lars Knoll 944af86fca Throw proper type and reference errors
Change-Id: I898017f3e63ada72fc2e50abfa1880f9fd7ffe37
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-12-04 20:08:43 +01:00
Erik Verbruggen 070e0d07d8 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>
2012-12-04 16:58:26 +01:00
Lars Knoll 2104e7fdcb 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>
2012-12-02 15:50:37 +01:00
Lars Knoll f26d5c36cf 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>
2012-11-30 12:28:38 +01:00
Erik Verbruggen a14e7549c4 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>
2012-11-29 22:05:49 +01:00
Erik Verbruggen 36356a4b27 Set the name of a function in more (most?) cases.
Change-Id: I1c2b9d61b6d97e3c2a8cb976fb6be8b68d51ae28
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-29 16:18:21 +01:00
Lars Knoll feafa10498 Implement Object.keys and obj.proto.propertyIsEnumerable
Change-Id: I30df135ad95f24246e43553b2711ad1008319d56
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-29 08:03:20 +01:00