Andreas Kling
8021048bc9
LibJS/Bytecode: Throw on destructuring object assignment to nullish LHS
...
24 new passes on test262. :^)
2023-06-25 09:19:53 +02:00
Andreas Kling
1f95a40780
LibJS/Bytecode: Actually exit switch
statement's lexical scope
...
95 new passes on test262. :^)
2023-06-25 08:09:39 +02:00
Andreas Kling
4fd71e3c3a
LibJS/Bytecode: Support destructuring in try..catch
...
112 new passes in test262.
2023-06-24 21:10:07 +02:00
Aliaksandr Kalenik
331f6a9e60
LibJS: Invalidate cached environment coordinate after delete in global
...
Fixes the bug in interpreter when cached environment coordinate is not
invalidated after `delete` operator usage on global `this`.
2023-06-24 18:33:44 +02:00
Andreas Kling
06ac768c8b
LibJS/Bytecode: Add some basic codegen for ExportStatement
...
This is by no means complete, but at least a bunch of test-js and
test262 tests start working. :^)
2023-06-24 17:13:30 +02:00
Andreas Kling
5d79431859
LibJS/Bytecode: Actually generate & run bytecode for SourceTextModule
2023-06-24 17:13:30 +02:00
Andreas Kling
8a5e71256d
LibJS/Bytecode: Add codegen for ImportCall
...
Also moved most of the AST ImportCall::execute() into a helper so we can
share the code.
2023-06-24 17:13:30 +02:00
Andreas Kling
eb9298b54e
LibJS/Bytecode: Support destructuring function parameters
...
To reduce code duplication, I've added new VM::execute_ast_node()
helper that handles bytecode compilation if needed.
918 new passes on test262. :^)
2023-06-24 08:38:54 +02:00
Andreas Kling
b3a3c53007
LibJS: Fix bad indentation when dumping FunctionNode AST nodes
2023-06-24 08:38:54 +02:00
Luke Wilde
95d619943e
LibJS/Bytecode: Support private identifiers in optional chaining
...
Fixes 4 test262 tests :^)
2023-06-23 21:05:18 +02:00
Timothy Flynn
32502fceed
LibJS: Update spec numbers/steps for RegExp unicode sets flag proposal
...
This proposal has been merged into the main ECMA-262 spec. See:
26b2369
2023-06-23 20:22:45 +02:00
Timothy Flynn
9407e05a3c
LibJS: Update RegExp spec numbers to match re-ordering within the spec
...
This is an editorial change in the ECMA-262 spec. See:
abee2e6
77256bf
2023-06-23 20:22:45 +02:00
Andreas Kling
99b23fe2ad
LibJS/Bytecode: Emit GetPrivateById for private member expressions
...
This makes it possible to call private member functions.
347 new passes on test262. :^)
2023-06-23 17:51:04 +02:00
Andreas Kling
85a3a1c085
LibJS/Bytecode: Add codegen for "named evaluation if anonymous function"
...
This gives anonymous functions the name from the LHS they are being
assigned to.
171 new passes on test262. :^)
2023-06-23 16:09:33 +02:00
Andreas Kling
e5c7d8407b
LibJS/Bytecode: Support private class fields
...
This is accomplished with two new instructions:
- GetPrivateById
- PutPrivateById
Looks like 1616 new passes on test262. :^)
2023-06-23 08:53:10 +02:00
Andreas Kling
467ea86179
LibJS: Use bytecode for generator function default parameters
...
Otherwise there's a mismatch between which interpreter we use.
This fixes a regression in the AST interpreter score on test262.
2023-06-23 08:09:50 +02:00
Andreas Kling
cd08515957
LibJS/Bytecode: Support named evaluation of anonymous functions
2023-06-22 21:16:17 +02:00
Andreas Kling
f4fe9f09a1
LibJS/Bytecode: Perform ShadowRealm evaluations in bytecode when enabled
2023-06-22 21:16:17 +02:00
Andreas Kling
6537ed8fff
LibJS/Bytecode: Simplify Bytecode::Interpreter lifetime model
...
The JS::VM now owns the one Bytecode::Interpreter. We no longer have
multiple bytecode interpreters, and there is no concept of a "current"
bytecode interpreter.
If you ask for VM::bytecode_interpreter_if_exists(), it will return null
if we're not running the program in "bytecode enabled" mode.
If you ask for VM::bytecode_interpreter(), it will return a bytecode
interpreter in all modes. This is used for situations where even the AST
interpreter switches to bytecode mode (generators, etc.)
2023-06-22 21:16:17 +02:00
Timothy Flynn
396655d145
LibJS: Begin implementing console.dir
...
The intent of the spec is that the output of console.dir is interactable
within the console. Our Printer implementation currently just prints the
provided object as a string, and doesn't check the provided `options`
argument. But having console.dir defined prevents exceptions from being
thrown on real websites.
2023-06-22 06:46:27 +02:00
Timothy Flynn
9f8e5f0b1c
LibJS: Sort Console methods in spec order
...
Easier to compare to the spec side-by-side when everything is in the
same order.
2023-06-22 06:46:27 +02:00
MacDue
130ec7e5b4
LibJS: Align HeapBlock cell storage to __BIGGEST_ALIGNMENT__
...
alignas(Cell) is just the alignment requirement for the base class
(which resolves to 8-bytes). This does not necessarily hold for all
subclasses.
2023-06-19 21:59:35 +02:00
Kenneth Myhra
ce2b88e7cc
LibJS: Use copy_data_block_bytes() instead of overwrite() and copy_to()
...
Replaces usage of ByteBuffer::overwrite() and combinations of
Span::slice() + Span::copy_to() with AO CopyDataBlockBytes.
2023-06-19 17:43:18 +02:00
Kenneth Myhra
f3fb005653
LibJS: Partially implement AO CopyDataBlockBytes
...
Currently we do not support Shared Data Block so that part is not yet
implemented.
2023-06-19 17:43:18 +02:00
Luke Wilde
357174d8fd
LibJS/Bytecode: Actually get value from super base for computed property
2023-06-17 20:26:14 +02:00
Luke Wilde
1116ba191a
LibJS/Bytecode: Implement optional chaining
2023-06-17 20:26:14 +02:00
Malik Ammar Faisal
c9088fa6ec
LibJS: Add tests for new Obj
with optional chain
2023-06-17 20:01:38 +02:00
Malik Ammar Faisal
5c913d9cc4
LibJS: Correctly handle parentheses and new Object
...
Parses `new Object()?.foo`, `(new Object)?.foo`
and shows syntax error on `new Object?.foo`
2023-06-17 20:01:38 +02:00
Andreas Kling
eee4b6eca7
LibJS/Bytecode: Let var
without initializer codegen to nothing
...
Otherwise we incorrectly overwrite the binding with `undefined` at the
point where the `var` statement is.
Fixes 9 test262 tests. :^)
2023-06-17 15:37:33 +02:00
Andreas Kling
743943a042
LibJS/Bytecode: Reorder function compilation to ensure correct hoisting
...
Fixes 37 test262 tests. :^)
Co-authored-by: Luke Wilde <lukew@serenityos.org>
2023-06-17 15:37:33 +02:00
Andreas Kling
9c568282dc
Ladybird+LibJS: Add CLI option to run browser with LibJS bytecode VM
...
This required quite a bit of plumbing, but now you can run
ladybird --use-bytecode
2023-06-17 14:16:45 +02:00
Andreas Kling
d89e0b36d4
LibJS/Bytecode: Support class field initializers
...
Fixes 513 test262 tests. :^)
2023-06-17 11:00:39 +02:00
Andreas Kling
82828ad936
LibJS/Bytecode: Extract accumulator value before incurring side effects
...
Many operations in JavaScript may incur side effects, including calling
arbitrary user code. Since the user code will clobber the accumulator,
we have to take care to extract anything we need from the accumulator
before doing anything that may have side effects.
Fixes 3 test262 tests. :^)
2023-06-17 11:00:39 +02:00
Andreas Kling
61148bce5f
LibJS/Bytecode: Use the correct this
value in GetById
...
The fix for this was to port the "don't create unnecessary FooObject
for property access on primitives" optimization from Reference,
which also brings us the correct behavior.
2023-06-16 21:46:43 +02:00
Andreas Kling
dbfe1311ef
LibJS/Bytecode: Simplify creating/leaving lexical environment
...
Since we no longer need to create or leave var environments directly
in bytecode, we can streamline the two instructions by making them
always operate on the lexical environment.
2023-06-16 21:46:43 +02:00
Andreas Kling
12ce0789da
LibJS/Bytecode: Remove BlockBoundaryType::LeaveVariableEnvironment
...
We never need to manually exit a var environment from bytecode anymore.
2023-06-16 21:46:43 +02:00
Andreas Kling
ac246d764d
LibJS/Bytecode: Leave BlockDeclarationInstantiation in C++
...
Instead of implementing this AO in bytecode, we now have an instruction
for it that simply invokes the C++ implementation.
This allows us to simplify Bytecode::Generator quite a bit by removing
all the variable scope tracking.
2023-06-16 21:46:43 +02:00
Andreas Kling
4684d3fe54
LibJS: Make BlockDeclarationInstantiation take a VM&
...
There's no need for this to require an AST Interpreter.
2023-06-16 21:46:43 +02:00
Andreas Kling
d364d99cb8
LibJS/Bytecode: Perform ToNumeric on accumulator before postfix inc/dec
...
This ensures we get the expected behavior of code like:
let a = []
let b = a++
(Where b should be 0, not [], because JavaScript.)
2023-06-16 12:56:39 +02:00
Andreas Kling
c9bd324369
LibJS/Bytecode: Set "home object" of functions within object expression
...
We manage this by having a stack of home objects in Generator, and then
adding an optional home object parameter to the NewFunction instruction.
2023-06-16 12:56:39 +02:00
Andreas Kling
6f39882f11
LibJS/Bytecode: Fix multiple wrong jumps in ForStatement codegen
2023-06-16 08:40:45 +02:00
Andreas Kling
0772a23c65
LibJS/Bytecode: Add "raw" property correctly for tagged template literal
...
We were adding it to the wrong object before. :^)
2023-06-16 08:40:45 +02:00
Andreas Kling
2ac8a4bbb7
LibJS/Bytecode: Add support for direct eval()
...
This is implemented as a special mode of the Call opcode that invokes
the PerformEval AO (instead of the Call or Construct AO).
2023-06-16 08:40:45 +02:00
Andreas Kling
8a3e350321
LibJS/Bytecode: Don't choke on MemberExpression with PrivateIdentifier
2023-06-16 08:40:45 +02:00
Andreas Kling
d063f35afd
LibJS/Bytecode: Leave GlobalDeclarationInstantiation in C++
...
Don't try to implement this AO in bytecode. Instead, the bytecode
Interpreter class now has a run() API with the same inputs as the AST
interpreter. It sets up the necessary environments etc, including
invoking the GlobalDeclarationInstantiation AO.
2023-06-16 08:40:45 +02:00
Andreas Kling
32d9c8e3ca
LibJS: Make GlobalDeclarationInstantiation take a VM&
...
This doesn't need to take an AST Interpreter&.
2023-06-16 08:40:45 +02:00
Andreas Kling
872d798951
LibJS/Bytecode: Leave FunctionDeclarationInstantantiation in C++
...
Instead of trying to implement this AO in bytecode, we can just let it
be a C++ thing. Once we implement fast uncaptured locals, we won't even
be calling it super often.
2023-06-16 08:40:45 +02:00
Om Prakaash
7c66c5f12d
LibJS: Replace a DeprecatedString with String
...
Refactors Date class to use String instead of DeprecatedString.
Changes use of the Date class in DatePrototype accordingly.
2023-06-15 14:03:51 +01:00
Ben Wiederhake
a9b3aaa887
LibJS: Fix redundancy-detection when printing raw values
...
Note that this does not change cycle-detection.
This is also was an unnecessary copy, since there is an easier, less
memory-intense way to do cycle detection than copying the entire
visited_set all the time.
2023-06-15 08:09:16 +02:00
Hendiadyoin1
9300b9a364
LibJS: Don't lie about m_deprecated_string being a StringView
2023-06-13 01:49:02 +02:00