summaryrefslogtreecommitdiff
path: root/Userland/Libraries
AgeCommit message (Collapse)Author
2021-06-07LibJS: Add bytecode generation for BinaryOp::InstanceOfLinus Groh
2021-06-07LibJS: Add bytecode generation for BinaryOp::InLinus Groh
2021-06-07LibJS: Make sure that if expressions yield the correct valueGunnar Beutner
When evaluated as an expression "if (true) { 3 } else { 5 }" should yield 3. This updates the bytecode interpreter to make it so.
2021-06-07LibJS: Make sure scope expressions yield the correct valueGunnar Beutner
When evaluated as an expression "{ 3 }" should yield 3. This updates the bytecode interpreter to make it so.
2021-06-08LibAudio: WavLoader: Avoid reading partial samplesNick Miller
When samples are requested in `Audio::Loader::get_more_samples`, the request comes in as a max number of bytes to read. However, the requested number of bytes may not be an even multiple of the bytes per sample of the loaded file. If this is the case, and the bytes are read from the file/stream, then the last sample will be a partial/runt sample, which then offsets the remainder of the stream, causing white noise in playback. This bug was discovered when trying to play 24-bit Wave files, which happened to have a sample size that never aligned with the number of requested bytes. This commit fixes the bug by only reading a multiple of "bytes per sample" for the loaded file.
2021-06-08LibAudio+LibCore: Remove unnecessary IODeviceStreamReader.hNick Miller
IODeviceStreamReader isn't pulling its weight. It's essentially a subset of InputFileStream with only one user (WavLoader). This refactors WavLoader to use InputFileStream instead.
2021-06-08LibGUI+SoundPlayer: Add Slider option to jump to cursorNick Miller
When the cursor is clicked outside of the slider knob, the current behavior is that it will step up or down by the Slider page step amount. This commit adds an option to jump the slider knob directly to the where the mouse cursor is on mouse down events. This behavior is disabled by default. It must be enabled with `Slider::set_jump_to_cursor()`. Jump to cursor is enabled in SoundPlayer since most music players have this behavior.
2021-06-07LibJS: Add <<, >> and >>> assignment operatorsRyan Chandler
2021-06-07LibJS: Add bytecode ops for <<, >> and >>>Luke
2021-06-07LibJS: Add support for various assignment operatorsRyan Chandler
2021-06-07LibJS: Add support for typed equality checksRyan Chandler
2021-06-07LibJS: Add bytecode generation for EmptyStatementGunnar Beutner
2021-06-07LibJS: Add bytecode generation for DebuggerStatementLinus Groh
No-op. :^)
2021-06-07LibJS: Add bytecode instructions for a bunch of unary operatorsLinus Groh
~, !, +, -, typeof, and void.
2021-06-07LibJS: Remove redundant Value() from bytecode bitwise ops execute()Linus Groh
2021-06-07LibJS: Add bytecode ops for loading boolean and null valuesGunnar Beutner
2021-06-07LibJS: Fix AbstractInequals returning result of AbstractEqualsRyan Chandler
2021-06-07LibJS: Add bytecode ops for &, | and ^Luke
2021-06-07LibJS: Add bytecode ops for >, >= and <=Gunnar Beutner
2021-06-07LibJS: Add bytecode instructions for modulo and exponentiationGunnar Beutner
2021-06-07LibJS: Add bytecode instructions for multiplication and divisionGunnar Beutner
2021-06-07LibJS: Remove unused Bytecode::Block::m_buffer_endAndreas Kling
2021-06-07LibJS: Add placeholder bytecode block sealing mechanismAndreas Kling
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-07LibJS: Cache generated bytecode for ScriptFunctionAndreas Kling
It's silly to generate new bytecode every time you call a function. Let's just cache the code instead. :^)
2021-06-07LibJS: Move bytecode debug spam behind JS_BYTECODE_DEBUG :^)Andreas Kling
2021-06-07LibJS: Devirtualize and pack the bytecode stream :^)Andreas Kling
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-07LibJS: Reset Bytecode::Interpreter's m_return_value when leaving run()Andreas Kling
Otherwise it will cause complete unwind since all parent run() loops will see the same m_return_value being non-empty and break out.
2021-06-07LibJS: Make sure the global CallFrame doesn't go out of scopeAndreas Kling
The Bytecode::Interpreter will push a global call frame if needed, and it needs to make sure that call frame survives until the end of the Interpreter::run() function.
2021-06-07LibJS: Add AbstractEquals bytecode instruction for == comparison :^)Andreas Kling
2021-06-07LibJS: Add basic support for "continue" in the bytecode VMAndreas Kling
Unlike the convoluted unwind-until-scope-type mechanism in the AST interpreter, "continue" maps to a simple Bytecode::Op::Jump here. :^) We know where to jump based on a stack of "continuable scopes" that we now maintain on the Bytecode::Generator as we go. Note that this only supports bare "continue", not continue-with-label.
2021-06-07LibJS: Add basic "if" statement support to the bytecode VM :^)Andreas Kling
This also required making Bytecode::Op::Jump support lazy linking to a target label. I left a FIXME here about having the "if" statement return the result value from the taken branch statement. That's what the AST interpreter does but I'm not sure if it's actually required.
2021-06-07LibJS: Compile ScriptFunctions into bytecode and run them that way :^)Andreas Kling
If there's a current Bytecode::Interpreter in action, ScriptFunction will now compile itself into bytecode and execute in that context. This patch also adds the Return bytecode instruction so that we can actually return values from called functions. :^) Return values are propagated from callee to caller via the caller's $0 register. Bytecode::Interpreter now keeps a stack of register "windows". These are not very efficient, but it should be pretty straightforward to convert them to e.g a sliding register window architecture later on. This is pretty dang cool! :^)
2021-06-07LibJS: Support basic function calls in the bytecode world :^)Andreas Kling
This patch adds the Call bytecode instruction which is emitted for the CallExpression AST node. It's pretty barebones and doesn't handle 'this' values properly, etc. But it can perform basic function calls! :^) Note that the called function will *not* execute as bytecode, but will simply fall back into the old codepath and use the AST interpreter.
2021-06-07LibJS: Add a new EnterScope bytecode instructionAndreas Kling
This is intended to perform the same duties as enter_scope() does in the AST tree-walk interpreter: - Hoisted function declaration processing - Hoisted variable declaration processing - ... maybe more This first cut only implements the function declaration processing.
2021-06-07LibJS: Create a global/outermost CallFrame for Bytecode::InterpreterAndreas Kling
Note that we don't yet support nested calls using bytecode.
2021-06-07LibJS: Add GetById bytecode instruction for object property retrievalAndreas Kling
Same as PutById but in the other direction. :^)
2021-06-07LibJS: Add PutById bytecode instruction for object property assignmentAndreas Kling
Note that this is only used for non-computed accesses. Computed access is not yet implemented. :^)
2021-06-07LibJS: Add a NewObject bytecode instruction for ObjectExpression :^)Andreas Kling
2021-06-07LibJS: Generate bytecode for do...while statements :^)Andreas Kling
This was quite straightforward using the same label/jump machinery that we added for while statements. The main addition here is a new JumpIfTrue bytecode instruction.
2021-06-07LibJS: Add AbstractInequals bytecode instruction :^)Andreas Kling
2021-06-07LibJS: Add basic support for while loops in the bytecode engineAndreas Kling
This introduces two new instructions: Jump and JumpIfFalse. Jumps are made to a Bytecode::Label, which is a simple object that represents a location in the bytecode stream. Note that you may not always know the target of a jump when adding the jump instruction itself, but we can just update the instruction later on during codegen once we know where the jump target is. The Bytecode::Interpreter now implements jumping via a jump slot that gets checked after each instruction to see if a jump is pending. If not, we just increment the PC as usual.
2021-06-07LibJS: Add LessThan bytecode instruction :^)Andreas Kling
2021-06-07LibJS: Print bytecode registers with format "$num" instead of "rnum"Andreas Kling
2021-06-07LibJS: Make Bytecode::Generator::emit() return the created instructionAndreas Kling
This will be useful for instructions that need to be modified later on during code generation, e.g jumps. :^)
2021-06-07LibJS: Move AST bytecode generation virtuals to separate cpp fileAndreas Kling
This will hopefully make it a bit more pleasant to edit this, as things will just get larger and larger.
2021-06-07LibJS: Add Sub bytecode instruction (subtract values)Andreas Kling
2021-06-07LibJS: Add formatting helper for Bytecode::RegisterAndreas Kling
2021-06-07LibJS: Some more opcodes for the bytecode VMAndreas Kling
- NewString (allocates a new PrimitiveString from the GC heap) - GetVariable (retrieves a variable in the current scope) - SetVariable (assigns a variable in the current scope)
2021-06-07LibJS: Add a VM accessor to Bytecode::Interpreter :^)Andreas Kling
2021-06-07LibJS: Start fleshing out a bytecode for the JavaScript engine :^)Andreas Kling
This patch begins the work of implementing JavaScript execution in a bytecode VM instead of an AST tree-walk interpreter. It's probably quite naive, but we have to start somewhere. The basic idea is that you call Bytecode::Generator::generate() on an AST node and it hands you back a Bytecode::Block filled with instructions that can then be interpreted by a Bytecode::Interpreter. This first version only implements two instructions: Load and Add. :^) Each bytecode block has infinity registers, and the interpreter resizes its register file to fit the block being executed. Two new `js` options are added in this patch as well: `-d` will dump the generated bytecode `-b` will execute the generated bytecode Note that unless `-d` and/or `-b` are specified, none of the bytecode related stuff in LibJS runs at all. This is implemented in parallel with the existing AST interpreter. :^)