Idan Horowitz
bad2108d3c
LibJS: Add the String.prototype.matchAll method
...
This is only the String.prototype side of matchAll, for full
functionality Symbol.matchAll has to be implemented in our RegExp
built-in object.
2021-06-16 20:05:18 +01:00
Idan Horowitz
8e05b49089
LibJS: Add the String.prototype.codePointAt() method
...
This commit also brings charAt & charCodeAt closer to the specification
2021-06-16 20:05:18 +01:00
Idan Horowitz
9f71e3cab4
LibJS: Handle UTF whitespace characters in String's trim{,Start,End}
...
This helps a bit, but doesnt handle UTF-16 surrogates in the strings.
2021-06-16 20:05:18 +01:00
Idan Horowitz
9127d83927
LibJS: Rename Value::{is_integer => is_integral_number}
...
The implementation matches the specification, so lets match the name
as well. :^)
2021-06-16 12:57:55 +01:00
Idan Horowitz
07992c8da6
LibJS: Throw when delete-ing a non-configurable property in strict mode
2021-06-16 12:57:48 +01:00
Idan Horowitz
c619ad4fec
LibJS: Allow no-op define property calls on non-configurable objects
...
This brings us slightly closer to the specification's 10.1.6.3
ValidateAndApplyPropertyDescriptor.
2021-06-16 12:57:48 +01:00
Idan Horowitz
2299be474b
LibJS: Add the String.fromCodePoint() method
2021-06-16 10:29:10 +01:00
Idan Horowitz
e1b0719435
LibJS: Add all of the FinalizationRegistry.prototype methods
...
More specifically: cleanupSome, register & unregister.
FinalizationRegistery.prototype.cleanupSome is actually still a stage 2
proposal, but since test262 test cases already exist for it, i decided
to go for it :)
2021-06-15 23:59:21 +01:00
Idan Horowitz
de9fa6622a
LibJS: Add the FinalizationRegistry built-in object
...
As well as the needed functionality in VM to enqueue and run cleanup
jobs for the FinalizationRegistry instances.
2021-06-15 23:59:21 +01:00
Idan Horowitz
08ff148bc3
LibJS: Use OrderedHashTable instead of HashTable in the Set built-in
...
This ensures insertion-order iteration.
2021-06-15 23:51:20 +01:00
Idan Horowitz
a27fbfd45f
LibJS: Use OrderedHashMap instead of HashMap in the Map built-in
...
This ensures insertion-order iteration.
2021-06-15 23:51:20 +01:00
Ali Mohammad Pur
1414c7b049
LibJS: Add a basic pass manager and add some basic passes
...
This commit adds a bunch of passes, the most interesting of which is a
pass that merges blocks together, and a pass that places blocks that
flow into each other next to each other, and a very simply pass that
removes duplicate basic blocks.
Note that this does not remove the jump at the end of each block in that
pass to avoid scope creep in the passes.
2021-06-15 22:06:33 +04:30
Ali Mohammad Pur
e81fd7106b
LibJS: Rename the overridden Instruction methods to foo_impl
...
These are pretty hairy if someone forgets to override one, as the
catchall function in Instruction will keep calling itself over and over
again, leading to really hard-to-debug situations.
2021-06-15 22:06:33 +04:30
Ali Mohammad Pur
4c7c7c38e2
LibJS: Make EnterUnwindContext a terminator op
...
Otherwise a basic block could have multiple outgoing edges without
having much reason to do so.
2021-06-15 22:06:33 +04:30
Ali Mohammad Pur
e73b142a97
LibJS: Make basic block size customizable
...
And keep the default 4 KiB for the code generator.
2021-06-15 22:06:33 +04:30
Idan Horowitz
dac971b4ae
LibJS: Store and return undefined Symbol description
...
Instead of the current incorrect behaviour of just defaulting to an
empty string.
2021-06-15 18:31:52 +01:00
Andreas Kling
f20c5e1872
LibJS: Use Optional<String> in StringPrototype
2021-06-15 13:54:41 +02:00
Idan Horowitz
ba807c2d44
LibJS: Call toString on the key, not on the argument in ToPropertyKey
...
As required by the specification:
https://tc39.es/ecma262/#sec-topropertykey
2021-06-15 12:15:18 +01:00
Idan Horowitz
9a0cbcc3d1
LibJS: Add the Object.fromEntries method
2021-06-15 12:15:18 +01:00
Idan Horowitz
2100b46d02
LibJS: Implement the IteratorClose abstract op and use it where needed
2021-06-15 12:15:12 +01:00
Ali Mohammad Pur
3194177dce
LibJS: Correctly parse yield-from expressions
...
This commit implements parsing for `yield *expr`, and the multiple
ways something can or can't be parsed like that.
Also makes yield-from a TODO in the bytecode generator.
Behold, the glory of javascript syntax:
```js
// 'yield' = expression in generators.
function* foo() {
yield
*bar; // <- Syntax error here, expression can't start with *
}
// 'yield' = identifier anywhere else.
function foo() {
yield
*bar; // Perfectly fine, this is just `yield * bar`
}
```
2021-06-14 13:06:08 +01:00
Ali Mohammad Pur
d374295a26
LibJS: Parse generator functions in object literals
...
Also add some parser tests
2021-06-14 13:06:08 +01:00
Ali Mohammad Pur
2661a88108
LibJS: Add a test file for generator function parsing
...
Note that the yield-from expression tests are skipped for now since
they're not implemented yet.
2021-06-14 13:06:08 +01:00
Andreas Kling
6e0e8a8242
LibJS: Teach Reference to access call frame arguments directly
2021-06-14 11:26:12 +02:00
Andreas Kling
91fbeeab72
LibJS: Add LoadArgument bytecode instruction for fast argument access
...
This is generated for Identifier nodes that represent a function
argument variable. It loads a given argument index from the current
call frame into the accumulator.
2021-06-14 11:26:12 +02:00
Andreas Kling
848944113c
LibJS: Access function arguments directly in AST interpreter
...
Instead of doing a generic scoped variable lookup, function arguments
now go directly to the call frame arguments list.
This is a huge speedup on everything that uses arguments. :^)
2021-06-14 11:26:12 +02:00
Andreas Kling
a733a30373
LibJS: Write computed function default arguments into the call frame
...
Previously, default argument values would only show up when accessing
the argument by parameter name. This patch makes us write them back
into the call frame so they can be accessed via VM::argument() as well.
2021-06-14 11:26:12 +02:00
Andreas Kling
481cef59b6
LibJS: Track which Identifier nodes refer to function arguments
...
This patch adds an "argument index" field to Identifier AST nodes.
If the Identifier refers to a function parameter in the currently
open function scope, we stash the index of the parameter here.
This will allow us to implement much faster direct access to function
argument variables.
2021-06-14 11:26:12 +02:00
davidot
ae8b55a80a
LibJS: Add additional generic Array.prototype.slice tests
2021-06-14 09:57:06 +01:00
davidot
fc1168a3b3
LibJS: Add Array.prototype.@@unscopables
2021-06-14 09:57:06 +01:00
davidot
2d87d5dab9
LibJS: Make Array.prototype.at return undefined on empty slot
2021-06-14 09:57:06 +01:00
davidot
6c13cc67c6
LibJS: Implement Array.prototype.copyWithin generically
2021-06-14 09:57:06 +01:00
davidot
417f752306
LibJS: Implement Array.prototype.entries
2021-06-14 09:57:06 +01:00
davidot
910b803d8d
LibJS: Implement Array.prototype.flatMap
...
Also made recursive_array_flat more compliant with the spec
So renamed it to flatten_into_array
2021-06-14 09:57:06 +01:00
davidot
4152409ac5
LibJS: Make Array.prototype.concat generic
2021-06-14 09:57:06 +01:00
davidot
2ef9df989f
LibJS: Make Array.prototype.reverse generic
2021-06-14 09:57:06 +01:00
davidot
516f6240e8
LibJS: Add additional Array.prototype.reverse tests
2021-06-14 09:57:06 +01:00
davidot
d723c01af7
LibJS: Make Array.prototype.unshift generic
2021-06-14 09:57:06 +01:00
davidot
7c1e2adf8a
LibJS: Make Array.prototype.shift generic
2021-06-14 09:57:06 +01:00
Idan Horowitz
690eb3bb8a
LibJS: Add support for hex, octal & binary big integer literals
2021-06-14 01:45:04 +01:00
Idan Horowitz
e4e6e03364
LibJS: Add tests for DataView.prototype getters and setters
2021-06-14 01:45:04 +01:00
Idan Horowitz
d7a70eb77c
LibJS: Add all of the DataView.prototype.set* methods
2021-06-14 01:45:04 +01:00
Idan Horowitz
c54b9a6920
LibJS: Add all of the DataView.prototype.get* methods
2021-06-14 01:45:04 +01:00
Idan Horowitz
e4d267d4fb
LibJS: Add the DataView built-in object
2021-06-14 01:45:04 +01:00
Linus Groh
5b2255291e
LibJS: Make a couple of %TypedArray%.prototype properties accessors
...
Also use JS_DEFINE_NATIVE_GETTER and not JS_DEFINE_NATIVE_FUNCTION for
their function definitions.
2021-06-13 21:33:41 +01:00
Linus Groh
5c1af1d6f7
LibJS: Make Symbol.prototype.description an accessor
2021-06-13 21:33:41 +01:00
Linus Groh
b121837898
LibJS: Make Set.prototype.size an accessor
...
Also fix its attributes, should be just configurable.
2021-06-13 21:33:41 +01:00
Linus Groh
3ed5a0c68d
LibJS: Make a couple of RegExp.prototype properties accessors
2021-06-13 21:33:41 +01:00
Linus Groh
83d3175b13
LibJS: Make ArrayBuffer.prototype.byteLength an accessor
2021-06-13 21:33:41 +01:00
Linus Groh
c6c0c6a61a
LibJS: Add two missing missing ECMA-262 section/title/URL comments
2021-06-13 21:33:41 +01:00