summaryrefslogtreecommitdiff
path: root/Userland/Libraries
AgeCommit message (Collapse)Author
2021-06-10LibJS: Remove GlobalObject& argument from VM::construct()Andreas Kling
We can just get the global object from the constructor function.
2021-06-10LibJS: Very basic support for "new" construction in bytecode VMAndreas Kling
This patch adds a CallType to the Bytecode::Op::Call instruction, which can be either Call or Construct. We then generate Construct calls for the NewExpression AST node. When executed, these get fed into VM::construct().
2021-06-10LibJS: Generate bytecode for entering nested lexical environmentsAndreas Kling
This adds a new PushLexicalEnvironment instruction that creates a new LexicalEnvironment and pushes it on the VM's scope stack. There is no corresponding PopLexicalEnvironment instruction yet, so this will behave incorrectly with let/const scopes for example.
2021-06-10LibJS: Allocate 4 KiB for Bytecode::BasicBlockAndreas Kling
There's no reason not to, since we're using mmap() for these anyway and that gives us memory in 4 KiB increments. :^)
2021-06-10LibJS: Always keep the global object in bytecode VM register $1Andreas Kling
2021-06-10LibJS: Perform function instantiation in bytecodeAndreas Kling
This replaces Bytecode::Op::EnterScope with a new NewFunction op that instantiates a ScriptFunction from a given FunctionNode (AST). This is then used to instantiate the local functions directly from bytecode when entering a ScopeNode. :^)
2021-06-10LibJS: Add empty bytecode generation for VariableDeclarationAndreas Kling
These will be partly handled by the relevant ScopeNode due to hoisting, same basic idea as function declarations. VariableDeclaration needs to do some work, but let's stub it out first and start empty.
2021-06-10LibJS: Implement bytecode generation for try..catch..finallyGunnar Beutner
EnterUnwindContext pushes an unwind context (exception handler and/or finalizer) onto a stack. LeaveUnwindContext pops the unwind context from that stack. Upon return to the interpreter loop we check whether the VM has an exception pending. If no unwind context is available we return from the loop. If an exception handler is available we clear the VM's exception, put the exception value into the accumulator register, clear the unwind context's handler and jump to the handler. If no handler is available but a finalizer is available we save the exception value + metadata (for later use by ContinuePendingUnwind), clear the VM's exception, pop the unwind context and jump to the finalizer. ContinuePendingUnwind checks whether a saved exception is available. If no saved exception is available it jumps to the resume label. Otherwise it stores the exception into the VM. The Jump after LeaveUnwindContext could be integrated into the LeaveUnwindContext instruction. I've kept them separate for now to make the bytecode more readable. > try { 1; throw "x" } catch (e) { 2 } finally { 3 }; 4 1: [ 0] EnterScope [ 10] EnterUnwindContext handler:@4 finalizer:@3 [ 38] EnterScope [ 48] LoadImmediate 1 [ 60] NewString 1 ("x") [ 70] Throw <for non-terminated blocks: insert LeaveUnwindContext + Jump @3 here> 2: [ 0] LoadImmediate 4 3: [ 0] EnterScope [ 10] LoadImmediate 3 [ 28] ContinuePendingUnwind resume:@2 4: [ 0] SetVariable 0 (e) [ 10] EnterScope [ 20] LoadImmediate 2 [ 38] LeaveUnwindContext [ 3c] Jump @3 String Table: 0: e 1: x
2021-06-10LibJS: Let the bytecode interpreter set the VM's last valueGunnar Beutner
2021-06-10LibC: Use EX_IOERR instead of EX_IOEREgor Ananyin
2021-06-10LibJS: Implement bytecode generation for BreakStatementxyanrch
2021-06-10LibVT: Implement `DECIC`/`DECDC`Daniel Bertalan
This commit adds support for these escape sequences that are used for scrolling multiple lines at once. In the current, unoptimized implementation, these just call the `scroll_left` and `scroll_right` APIs multiple times. It's a VT420 feature.
2021-06-10Kernel+LibVT: Fix selection with scrollback wrap-aroundDaniel Bertalan
If lines are removed from the tail of the scrollback buffer, the previous line indices will refer to different lines; therefore we need to offset them.
2021-06-10LibVT: Implement `DECFI` and `DECBI`Daniel Bertalan
These escape sequences are the horizontal scrolling equivalents of `IND` and `RI`. Normally, they move the cursor forward or backward. But if they hit the margins (which we just treat as the first and last columns), they scroll the line. Another VT420 feature done.
2021-06-10Kernel+LibVT: Implement left-right scrollingDaniel Bertalan
This commit implements the left/right scrolling used in the `ICH`/`DCH` escape sequences for `VirtualConsole`. This brings us one step closer to VT420/xterm compatibility. We can now finally remove the last escape sequence related `ifdef`s.
2021-06-10Kernel+LibVT: Add function for deleting a range of charactersDaniel Bertalan
Previously, this was done by telling the client to put a space at each character in the range. This was inefficient, because a large number of function calls took place and incorrect, as the ANSI standard dictates that character attributes should be cleared as well. The newly added `clear_in_line` function solves this issue. It performs just one bounds check when it's called and can be implemented as a pretty tight loop.
2021-06-10LibVT+Kernel: Support clearing the scrollback bufferDaniel Bertalan
As per the `xterm ctlseqs` documentation, `\e3J` should clear the scrollback buffer, and leave the visible lines unchanged. This commit fixes a FIXME.
2021-06-10LibVT: Improve scrolling performanceDaniel Bertalan
Previously, we would remove lines from the buffer, create new lines and insert them into the buffer when we scrolled. Since scrolling does not always happen at the last line, this meant `Line` objects were pointlessly moved forwards, and then immediately backwards. We now swap them in-place and clear those lines that are "inserted". As a result, performance is better and scrolling is smoother in `vim` and `nano`.
2021-06-10LibVT: Fix `ECH` not clearing linesDaniel Bertalan
The `num` parameter should be treated as an offset from the cursor position, not from the beginning of the line. The previous behavior caused fragments of previous lines to be visible when moving the entire buffer in vim (e.g. with `gg` and `G`). The debug messages I used while fixing it are also included in this commit. These will help diagnose further issues if they arise.
2021-06-10LibVT+Kernel: Clean up scroll APIDaniel Bertalan
This commit cleans up some of the `#ifdef`-ed code smell in `Terminal`, by extending the scroll APIs to take a range of lines as a parameter. This makes it possible to use the same code for `IL`/`DL` as for scrolling. Note that the current scrolling implementation is very naive, and does many insertions/deletions in the middle of arrays, whereas swaps should be enough. This optimization will come in a later commit. The `linefeed` override was removed from `VirtualConsole`. Previously, it exhibited incorrect behavior by moving to column 0. Now that we use the method defined in `Terminal`, code which relied on this behavior stopped working. We go instead go through the TTY layer which handles the various output flags. Passing the input character-by-character seems a bit excessive, so a fix for it will come in another PR.
2021-06-10LibVT: Fix out-of-bounds reads in ICH/DCH escape sequencesDaniel Bertalan
Previously, entering too big counts for these commands could cause a wrap-around with the cell indices. Also, we are now correctly copying the cell attributes as well as the code point.
2021-06-10LibJS: Make removed elements in Array.prototype.splice spec compliantLuke
It wasn't using has_property, was directly appending to indexed properties and wasn't setting the length.
2021-06-10LibJS: Pass in actual_delete_count to removed array creation in spliceLuke
More specifically, Array.prototype.splice. Additionally adds a missing exception check to the array creation and a link to the spec. Fixes create-non-array-invalid-len.js in the splice tests in test262. This test timed out instead of throwing an "Invalid array length" exception.
2021-06-10LibJS: Stop asserting in {Set,Test}IntegrityLevel on missing descriptorIdan Horowitz
As per the specification (7.3.15 SetIntegrityLevel): i. Let currentDesc be ? O.[[GetOwnProperty]](k). ii. If currentDesc is not undefined, then...
2021-06-09LibJS: Use create_list_from_array_like() in Function.prototype.apply()Linus Groh
2021-06-09LibJS: Use create_list_from_array_like() in Reflect.{apply,construct}()Linus Groh
2021-06-09LibJS: Implement the CreateListFromArrayLike() abstract operationLinus Groh
We already have two separate implementations of this, so let's do it properly. The optional value type check is done by a callback function that returns Result<void, ErrorType> - value type accepted or message for TypeError, that is.
2021-06-10LibJS: Add logical assignment bytecode generationLuke
2021-06-09LibJS: Only "var" declarations go in the global object at program levelAndreas Kling
"let" and "const" go in the lexical environment. This fixes one part of #4001 (Lexically declared variables are mixed up with global object properties)
2021-06-09LibGUI/WindowServer: Add set_maximized IPC callMarcus Nilsson
Add an IPC call to enable the client to manually maximize it's own window.
2021-06-09LibJS: Notify WeakSets when heap cells are sweepedIdan Horowitz
This is an implementation of the following optional optimization: https://tc39.es/ecma262/#sec-weakref-execution
2021-06-09LibJS: Add all of the WeakSet.prototype methods (add, delete, has)Idan Horowitz
2021-06-09LibJS: Add the WeakSet built-in objectIdan Horowitz
2021-06-09LibCpp: Add test for parsing class definitionsItamar
2021-06-09LibCpp: Parse basic constructors and destructorsItamar
2021-06-09LibCpp: Handle class access-specifiers in the ParserItamar
We can now handle access-specifier tags (for example 'private:') when parsing class declarations. We currently only consume these tags on move on. We'll need to add some logic that accounts for the access level of symbols down the road.
2021-06-09LibCpp: Support non-field class membersItamar
Previously, we had a special ASTNode for class members, "MemberDeclaration", which only represented fields. This commit removes MemberDeclaration and instead uses regular Declaration nodes for representing the members of a class. This means that we can now also parse methods, inner-classes, and other declarations that appear inside of a class.
2021-06-09LibCpp: Make 'bool' a Token::Type::KnownTypeItamar
2021-06-09LibJS: Fix evaluation order for tagged template literalsGunnar Beutner
This ensures that the tag function is evaluated first.
2021-06-09LibJS: Generate bytecode for tagged template literalsGunnar Beutner
2021-06-09LibJS: Fix the return value for TemplateLiteralGunnar Beutner
This ensures that the bytecode generated for TemplateLiterals returns the correct value.
2021-06-09LibWeb: Fix logic issue when parsing CSS custom propertiesTobias Christiansen
With best wishes from De Morgan, this is the correct way to check whether the string isn't of the form "var(...)".
2021-06-09LibJS: Don't create lexical environment for native (C++) function callsAndreas Kling
This was creating a ton of pointless busywork for the garbage collector and can be avoided simply by tolerating that the current call frame has a null scope object for the duration of a NativeFunction activation.
2021-06-09LibC: Add stub implementation for sigsuspendThiago Henrique Hupner
Currently, ZSH tries to call this function and it always asserts, so adding a stub to allow ZSH at least open.
2021-06-09LibC: Make tgetnum() return -1 if capability is not availableThiago Henrique Hupner
2021-06-09LibWasm: ALWAYS_INLINE some very hot functionsAli Mohammad Pur
These function couldn't be inlined before because the compiler would've started flagging invalid paths in Variant as maybe-uninitialized.
2021-06-09Meta: Disable -Wmaybe-uninitializedAli Mohammad Pur
It's prone to finding "technically uninitialized but can never happen" cases, particularly in Optional<T> and Variant<Ts...>. The general case seems to be that it cannot infer the dependency between Variant's index (or Optional's boolean state) and a particular alternative (or Optional's buffer) being untouched. So it can flag cases like this: ```c++ if (index == StaticIndexForF) new (new_buffer) F(move(*bit_cast<F*>(old_buffer))); ``` The code in that branch can _technically_ make a partially initialized `F`, but that path can never be taken since the buffer holding an object of type `F` and the condition being true are correlated, and so will never be taken _unless_ the buffer holds an object of type `F`. This commit also removed the various 'diagnostic ignored' pragmas used to work around this warning, as they no longer do anything.
2021-06-09LibWasm: Implement saturating float truncation instructionsAli Mohammad Pur
With these, the only remaining unimplemented instructions are the following: - memory.init - data.drop - memory.copy - memory.fill - table.init - elem.drop - table.copy - table.grow - table.size - table.fill
2021-06-09LibWasm: Implement sign extension instructionsAli Mohammad Pur
2021-06-09LibWasm: Implement spec-compliant float min/max opsAli Mohammad Pur