Andreas Kling
949ceedaed
LibJS: Remove the seal/unseal of Bytecode::Block again
...
This partially reverts c6ce7c9326
.
The munmap part of that change was good, but we can't seal the blocks
since that breaks NewString and other ops that have String members.
2021-06-08 21:39:50 +02:00
Matthew Olsson
9bed2e4f4a
LibJS: Introduce an accumulator register to Bytecode::Interpreter
...
This commit introduces the concept of an accumulator register to
LibJS's bytecode interpreter. The accumulator register is always
register 0, and most simple instructions use it for reading and
writing.
Not only does this slim down the AST, but it also simplifies a lot of
the code. For example, the generate_bytecode methods no longer need
to return an Optional<Register>, as any opcode which has a "return"
value will always put it into the accumulator.
This also renames the old Op::Load to Op::LoadImmediate, and uses
Op::Load to load from a register into the accumulator. There is
also an Op::Store to put the value in the accumulator into another
register.
2021-06-08 21:00:12 +02:00
Linus Groh
6c256bb400
LibJS: Add @@toStringTag to Reflect
2021-06-08 19:13:14 +01:00
Linus Groh
b377777208
LibJS: Add @@toStringTag to Promise.prototype
2021-06-08 19:13:14 +01:00
Linus Groh
ed64a69fb2
LibJS: Replace two instances of 'global_object.vm()' with just 'vm'
2021-06-08 19:13:14 +01:00
Gunnar Beutner
75a12bc2b7
LibJS: Generate bytecode for template literals
2021-06-08 19:47:32 +02:00
Leon Albrecht
c6ce7c9326
LibJS: Seal Bytecode Blocks and munmap them ( #7919 )
2021-06-08 17:21:48 +02:00
Idan Horowitz
064ed8279e
LibJS: Support deleting local variables with operator delete
...
To make this cleaner i also moved the logic into Reference::delete_.
2021-06-08 15:31:46 +01:00
Idan Horowitz
af58779def
LibJS: Return undefined from a with statement if no value was generated
...
Co-authored-by: Linus Groh <mail@linusgroh.de>
2021-06-08 15:31:46 +01:00
Idan Horowitz
98897ff676
LibJS: Return the last value from a with statement
2021-06-08 15:31:46 +01:00
Linus Groh
68ce69db88
LibJS: Add for loop bytecode generation
2021-06-08 11:59:32 +02:00
Gunnar Beutner
50ece3dd1b
LibJS: Implement bytecode generation for BigInts
2021-06-08 10:57:28 +01:00
Gunnar Beutner
0975e08285
LibJS: Make if yield undefined for the else branch if it is missing
2021-06-08 11:38:48 +02:00
Gunnar Beutner
d9989fd259
LibJS: Remove redundant jump for IfStatements
2021-06-08 11:38:48 +02:00
Gunnar Beutner
ef83872f62
LibJS: Make JumpIf{True,False,Nullish} inherit from Jump
...
This saves a few lines in LogicalExpression::generate_bytecode.
2021-06-08 11:38:48 +02:00
Luke
1dc31842cb
LibJS: Add sequence expression bytecode generation
2021-06-08 11:20:10 +02:00
Luke
de3ee701ce
LibJS: Add conditional expression bytecode generation
...
Or, by its more common name, the ternary operator :^)
2021-06-08 09:53:56 +01:00
Gunnar Beutner
6da587b59b
LibJS: Implement bytecode ops for logical expressions
2021-06-08 10:42:45 +02:00
Gunnar Beutner
216d27d4c1
LibJS: Convert values to boolean for JumpIfTrue/JumpIfFalse
...
Value::as_bool() might fail if the underlying value isn't already a
boolean value.
2021-06-08 10:42:45 +02:00
Idan Horowitz
aefb7995f1
LibJS: Add the Symbol.species getter to the appropriate built-ins
2021-06-08 09:09:51 +01:00
Linus Groh
39c3aefe5d
LibJS: Use to_property_key() a bunch in ReflectObject
...
Yay for correctness. :^)
2021-06-07 23:11:08 +01:00
Linus Groh
7565bf0590
LibJS: Remove redundant exception checks
2021-06-07 23:09:06 +01:00
Linus Groh
3fdad563e2
LibJS: Never omit setter/getter attributes in accessor descriptor object
...
These should not be omitted, an accessor with out getter or setter still
yields an undefined for the attribute in its descriptor object.
2021-06-07 23:07:13 +01:00
Linus Groh
8c964ef9f8
LibJS: Fix get_own_property_descriptor_object() field name order
...
This is defined by the spec: enumerable and configurable come last.
2021-06-07 23:02:52 +01:00
Linus Groh
4e555fae22
LibJS: Add missing cyclic prototype check to Object.setPrototypeOf()
2021-06-07 22:56:16 +01:00
Andreas Kling
ebb40e7d7b
LibJS: Use macros to generate the common unary/binary bytecode ops
2021-06-07 23:20:48 +02:00
Linus Groh
e0a2c1544f
LibJS: Fix whitespace errors in ASTCodegen.cpp
2021-06-07 21:19:12 +01:00
Linus Groh
9c0d83d11d
LibJS: Add bytecode generation for BinaryOp::InstanceOf
2021-06-07 21:18:35 +01:00
Linus Groh
5e996de8c6
LibJS: Add bytecode generation for BinaryOp::In
2021-06-07 21:18:35 +01:00
Gunnar Beutner
93eae063a1
LibJS: Make sure that if expressions yield the correct value
...
When evaluated as an expression "if (true) { 3 } else { 5 }"
should yield 3. This updates the bytecode interpreter to make
it so.
2021-06-07 22:10:57 +02:00
Gunnar Beutner
2c10bd72f2
LibJS: Make sure scope expressions yield the correct value
...
When evaluated as an expression "{ 3 }" should yield 3. This updates
the bytecode interpreter to make it so.
2021-06-07 22:10:57 +02:00
Ryan Chandler
6612e026ba
LibJS: Add <<, >> and >>> assignment operators
2021-06-07 21:23:11 +02:00
Luke
1e10965e61
LibJS: Add bytecode ops for <<, >> and >>>
2021-06-07 21:18:34 +02:00
Ryan Chandler
6681415f58
LibJS: Add support for various assignment operators
2021-06-07 21:18:19 +02:00
Ryan Chandler
18ac7fde12
LibJS: Add support for typed equality checks
2021-06-07 21:17:29 +02:00
Gunnar Beutner
9e69ffc1b1
LibJS: Add bytecode generation for EmptyStatement
2021-06-07 20:06:46 +01:00
Linus Groh
2b8a2542a0
LibJS: Add bytecode generation for DebuggerStatement
...
No-op. :^)
2021-06-07 20:05:50 +01:00
Linus Groh
fa9bad912e
LibJS: Add bytecode instructions for a bunch of unary operators
...
~, !, +, -, typeof, and void.
2021-06-07 19:53:47 +01:00
Linus Groh
54fc7079c6
LibJS: Remove redundant Value() from bytecode bitwise ops execute()
2021-06-07 19:53:22 +01:00
Gunnar Beutner
8ed5b7dcfa
LibJS: Add bytecode ops for loading boolean and null values
2021-06-07 20:26:45 +02:00
Ryan Chandler
6e2b266534
LibJS: Fix AbstractInequals returning result of AbstractEquals
2021-06-07 20:25:56 +02:00
Luke
ae763f1ade
LibJS: Add bytecode ops for &, | and ^
2021-06-07 20:17:24 +02:00
Gunnar Beutner
4be3374b24
LibJS: Add bytecode ops for >, >= and <=
2021-06-07 20:09:23 +02:00
Gunnar Beutner
55f0791b13
LibJS: Add bytecode instructions for modulo and exponentiation
2021-06-07 19:40:27 +02:00
Gunnar Beutner
3c5ce9b5b7
LibJS: Add bytecode instructions for multiplication and division
2021-06-07 19:21:36 +02:00
Andreas Kling
4776c50d5f
LibJS: Remove unused Bytecode::Block::m_buffer_end
2021-06-07 18:30:39 +02:00
Andreas Kling
312297ac38
LibJS: Add placeholder bytecode block sealing mechanism
...
After compiling bytecode, we should mark the memory read-only.
This currently does not work because it breaks instruction destruction.
I'm adding this anyway with a FIXME so we don't forget about it. :^)
2021-06-07 18:11:59 +02:00
Andreas Kling
4ba2eb8fe5
LibJS: Cache generated bytecode for ScriptFunction
...
It's silly to generate new bytecode every time you call a function.
Let's just cache the code instead. :^)
2021-06-07 18:11:59 +02:00
Andreas Kling
7cbe4daa7c
LibJS: Move bytecode debug spam behind JS_BYTECODE_DEBUG :^)
2021-06-07 18:11:59 +02:00
Andreas Kling
e7d69c5d3c
LibJS: Devirtualize and pack the bytecode stream :^)
...
This patch changes the LibJS bytecode to be a stream of instructions
packed one-after-the-other in contiguous memory, instead of a vector
of OwnPtr<Instruction>. This should be a lot more cache-friendly. :^)
Instructions are also devirtualized and instead have a type field
using a new Instruction::Type enum.
To iterate over a bytecode stream, one must now use
Bytecode::InstructionStreamIterator.
2021-06-07 18:11:59 +02:00