summaryrefslogtreecommitdiff
path: root/Userland
AgeCommit message (Collapse)Author
2021-06-09LibJS: Store strings in a string tableGunnar Beutner
Instead of using Strings in the bytecode ops this adds a global string table to the Executable struct which individual operations can refer to using indices. This brings bytecode ops one step closer to being pointer free.
2021-06-09LookupServer: Watch /etc/hosts for changes during runtimeMax Wipfli
This adds a FileWatcher to the LookupServer which watches '/etc/hosts' for changes during runtime and reloads its contents. If the file is deleted, m_etc_hosts will be cleared. Since we now need to access '/etc/hosts' later during runtime, it needs to be unveiled with read permissions.
2021-06-09LookupServer: Check for hostname after /etc/hostsMax Wipfli
If the hostname is not in /etc/hosts, looking it up should return 127.0.0.1.
2021-06-09LookupServer: Make DNSName::operator== ignore caseMax Wipfli
2021-06-09LookupServer: Modernize load_etc_hosts()Max Wipfli
This reworks the LookupServer::load_etc_hosts() method to use the IPv4Address APIs instead of trying to parse an IPv4 address itself. It also adds a few error checks for invalid entries in /etc/hosts, trims away leading and trailing whitespace from lines and tries to use StringView over String.
2021-06-09LibAudio: Make Loader::seek() treat its input as a sample indexNick Miller
This fixes a bug where if you try to play a Wave file a second time (or loop with `aplay -l`), the second time will be pure noise. The function `Audio::Loader::seek` is meant to seek to a specific audio sample, e.g. seek(0) should go to the first audio sample. However, WavLoader was interpreting seek(0) as the beginning of the file or stream, which contains non-audio header data. This fixes the bug by capturing the byte offset of the start of the audio data, and offseting the raw file/stream seek by that amount.
2021-06-09LibJS: Add the SetIterator built-in and Set.prototype.{values, entries}Idan Horowitz
While this implementation should be complete it is based on HashTable's iterator, which currently follows bucket-order instead of the required insertion order. This can be simply fixed by replacing the underlying HashTable member in Set with an enhanced one that maintains a linked list in insertion order.
2021-06-09LibJS: Add most of the Set.prototype methodsIdan Horowitz
Specifically all aside from "values" and "entries" which require an implementation of the SetIterator object.
2021-06-09LibJS: Add the Set built-in objectIdan Horowitz
2021-06-09LibCrypto: Add hash methods to {Signed, Unsigned}BigIntegerIdan Horowitz
These just use hash the underlying bytes that make up the integer words
2021-06-09LibJS: Implement bytecode generation for UpdateExpression :^)Andreas Kling
Added Increment and Decrement bytecode ops to support this. Postfix updates use a temporary register to preserve the original value. Note that this patch only implements Identifier updates. Member expression updates are a TODO.
2021-06-09LibJS: Simplify the way we stringify bytecode instructionsAndreas Kling
For instructions that only have a single operand, omit the operand name since it's implied anyway.
2021-06-09LibGL: Implement very basic version of glGetFloatvErik Biederstadt
This is a very basic implementation of glGetfloatv. It will only give a result when used with GL_MODELVIEW_MATRIX. In the future we can update and extend it's functionality.
2021-06-09LibJS: Print the name of AST nodes that are missing generate_bytecode()Andreas Kling
This way you know which one it is right away. :^)
2021-06-09LibCore: Fix building LibCore on FreeBSDGunnar Beutner
2021-06-09LibJS: Move Instruction::length() to the Op.h headerAndreas Kling
Make sure this gets inlined as well, as it's used by the bytecode stream iterator and thus extremely hot.
2021-06-09LibJS: Move Bytecode::Instruction::execute() to the Op.h headerAndreas Kling
..and make sure it always gets inlined in the interpreter loop.
2021-06-09LibJS: Rename Bytecode::ExecutionUnit => Bytecode::ExecutableAndreas Kling
2021-06-09LibJS: Only set element in array literal to an empty value if it's nullLuke
This avoids an unnecessary empty load that immediately gets overridden. For example, `[1,,]` would appear as: [ 0] EnterScope [ 10] LoadImmediate value:<empty> [ 28] LoadImmediate value:1 [ 40] Store dst:$1 [ 48] LoadImmediate value:<empty> [ 60] Store dst:$2 [ 68] NewArray, elements:[$1,$2] But now appears as: [ 0] EnterScope [ 10] LoadImmediate value:1 [ 28] Store dst:$1 [ 30] LoadImmediate value:<empty> [ 48] Store dst:$2 [ 50] NewArray, elements:[$1,$2]
2021-06-09LibJS: Generate bytecode in basic blocks instead of one big blockAli Mohammad Pur
This limits the size of each block (currently set to 1K), and gets us closer to a canonical, more easily analysable bytecode format. As a result of this, "Labels" are now simply entries to basic blocks. Since there is no more 'conditional' jump (as all jumps are always taken), JumpIf{True,False} are unified to JumpConditional, and JumpIfNullish is renamed to JumpNullish. Also fixes #7914 as a result of reimplementing the loop logic.
2021-06-09Utilities: Do not allow creating users with existing usernamesbrapru
Previously useradd would not check if a username already existed on the system, and would instead add the user anyway and just increment the uid. useradd should instead return an error when the user attempts to create already existing users.
2021-06-09LibJS: Fix not executing the expression of a return statementMatthew Olsson
2021-06-09LibJS: Generate bytecode for array expressionsGunnar Beutner
2021-06-09Revert "LibJS: Add bytecode instruction handles"Andreas Kling
This reverts commit a01bd35c67e35e9f0e33f46bb3a4431e49af1b60. This broke simple programs like: function sum(a, b) { return a + b; } console.log(sum(1, 2));
2021-06-09LibJS: Add bytecode instruction handlesMatthew Olsson
This change removes the mmap inside of Block in favor of a growing vector of bytes. This is favorable for two reasons: - We don't take more space than we need - There is no limit to the growth of the vector (previously, if the Block overstepped its 64kb boundary, it would just crash) However, if that vector happens to resize, any pointer pointing into that vector would become invalid. To avoid this, this commit adds an InstructionHandle<Op> class which just stores a block and an offset into that block.
2021-06-08LibJS: Handle Proxy with Array target in IsArray() abstract operationLinus Groh
This was missing from Value::is_array(), which is equivalent to the spec's IsArray() abstract operation - it treats a Proxy value with an Array target object as being an Array. It can throw, so needs both the global object and an exception check now.
2021-06-08LibJS: Implement Proxy.revocable()Linus Groh
2021-06-08LibJS: Remove Proxy() argument count checkLinus Groh
Let's just treat missing arguments as undefined and throw with 'target/handler must be object' - this is more JavaScript-y.
2021-06-08LibJS: Make sure loop results are initializedGunnar Beutner
This ensures that "while", do...while, "for" expressions have a properly initialized result value even if the user terminated the loop body via break or the loop body wasn't executed at all.
2021-06-08LibJS: Make SwitchStatement::execute() return undefined for empty blocksMarcin Gasperowicz
Previously SwitchStatement::execute() would return <empty> when hitting break, continue or empty consequent block. This was not in line with the standard.
2021-06-08LibJS: Remove the seal/unseal of Bytecode::Block againAndreas Kling
This partially reverts c6ce7c9326f8e745e29ede503ea011f10c76fc5f. 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-08LibJS: Introduce an accumulator register to Bytecode::InterpreterMatthew Olsson
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-08LibJS: Add @@toStringTag to ReflectLinus Groh
2021-06-08LibJS: Add @@toStringTag to Promise.prototypeLinus Groh
2021-06-08LibJS: Replace two instances of 'global_object.vm()' with just 'vm'Linus Groh
2021-06-08LibJS: Generate bytecode for template literalsGunnar Beutner
2021-06-08gron: Handle invalid input gracefullySam Atkins
Print an error and return 1, instead of asserting.
2021-06-08gron: Make gron read from stdin if no file is providedSam Atkins
2021-06-08Everywhere: Replace Vector<T*> with nonnull entries with Vector<T&>Ali Mohammad Pur
2021-06-08LibSQL: Limit the number of nested subqueriesTimothy Flynn
SQLite hasn't documented a limit on https://www.sqlite.org/limits.html for the maximum number of nested subqueries. However, its parser is generated with Yacc and has an internal limit of 100 for general nested statements. Fixes https://crbug.com/oss-fuzz/35022.
2021-06-08LibM: Implement nearbyint, nearbyintl and nearbyintfGunnar Beutner
These are used by the ultima engine for scummvm.
2021-06-08LibC+AK: Remove our custom macros from <assert.h>Gunnar Beutner
Other software might not expect these to be defined and behave differently if they _are_ defined, e.g. scummvm which checks if the TODO macro is defined and fails to build if it is.
2021-06-08LibJS: Seal Bytecode Blocks and munmap them (#7919)Leon Albrecht
2021-06-08LibJS: Support deleting local variables with operator deleteIdan Horowitz
To make this cleaner i also moved the logic into Reference::delete_.
2021-06-08LibJS: Return undefined from a with statement if no value was generatedIdan Horowitz
Co-authored-by: Linus Groh <mail@linusgroh.de>
2021-06-08LibJS: Return the last value from a with statementIdan Horowitz
2021-06-08LibJS: Add for loop bytecode generationLinus Groh
2021-06-08LibJS: Implement bytecode generation for BigIntsGunnar Beutner
2021-06-08LibJS: Make if yield undefined for the else branch if it is missingGunnar Beutner
2021-06-08LibJS: Remove redundant jump for IfStatementsGunnar Beutner