Commit Graph

51 Commits

Author SHA1 Message Date
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
Erik Verbruggen 721f2156a6 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>
2012-11-28 14:06:06 +01:00
Erik Verbruggen 4bd20c2ac3 Throw a SyntaxError instead of printing an error message.
Change-Id: I94ef8a4f2bea80bc3689b104e381a9dc134439fa
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-28 12:31:20 +01:00
Erik Verbruggen 7704d8b3b6 Keep the EvalISelFactory in the ExecutionEngine.
Also corrected the class name cApiTaliSatiOn.

Change-Id: I131566e904c8ee575686a469f16d098dd512d865
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-21 15:47:14 +01:00
Erik Verbruggen 1dab0e5904 Use an isel factory instead of MASM in FunctionCTor.
Change-Id: I070f056411f16d837ff5eac191fac11cd0bd3c47
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-20 13:31:05 +01:00
Lars Knoll 79753b8fe5 return results directly instead of using the context
The result variable in the context is not really
required, as we can return results directly in the
return value register.

Change-Id: I12554c228500aa24625ef82e31fd7f72989a71bb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-11-20 09:40:14 +01:00
Erik Verbruggen e1bbbb6cf9 Fix isel for eval and a whole bunch of other warnings.
A factory is now passed along to do the codegen for eval().

Change-Id: If15b1f28c9c0a8f8b6d18b56d6e7bc5d942927e5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-19 14:02:58 +01:00
Erik Verbruggen b072fd9317 Added isNaN and isFinite to the global context.
Change-Id: Ia85d27a6ac82fd5dbf6b0f706747afa6418626b1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-19 13:57:51 +01:00
Lars Knoll a267688480 Better handling of contexts and environments
Make the ExecutionContext standard compliant.
Move most of it's members into a new
DeclarativeEnvironment data structure that
contains locals and arguments.

Change-Id: I094f559168810dbd3717d677fe28750076015976
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-19 10:33:35 +01:00