Commit graph

34260 commits

Author SHA1 Message Date
Timothy Flynn
bfe1bd9726 LibSQL: Convert binary SQL operations to be fallible
Now that expression evaluation can use TRY, we can allow binary operator
methods to fail as well. This also fixes a few instances of converting a
Value to a double when we meant to convert to an integer.
2022-02-13 21:30:38 +00:00
Timothy Flynn
b15db851fe LibSQL: Short-circuit single-element tuple comparisons
If a tuple has a single value, perform a comparison using that singular
value. This allows, for example, comparisons of the form "(1) < 4",
where (1) is a single element tuple.
2022-02-13 21:30:38 +00:00
Timothy Flynn
e13c96157c LibSQL: Implement converting float and tuple values to a boolean 2022-02-13 21:30:38 +00:00
Timothy Flynn
8fab99e920 LibSQL: Use absolute value when comparing against floating point epsilon
Otherwise, any value that is less than another value would be considered
about equal by mistake.
2022-02-13 21:30:38 +00:00
Timothy Flynn
e649ff5d31 LibSQL: Return a not-yet-implemented error for unimplemented expressions
Easier to debug than returning a NULL value.
2022-02-13 21:30:38 +00:00
Timothy Flynn
5c90aa357b Base: Restart the SQL server if it crashes
There's a fair amount of VERIFY/TODO calls in LibSQL that will crash the
SQL server if we hit an unimplemented feature or some bug. Restart the
server if this happens to help with debugging / development.
2022-02-13 21:30:38 +00:00
Lenny Maiorani
f2d8c488ec Userland/Applets: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-13 21:27:17 +00:00
Jamie Mansfield
04c5bc5e55 LibJS: Add spec comments to ArrayBuffer.prototype.byteLength 2022-02-13 21:26:15 +00:00
Jamie Mansfield
7aa4c22f6b LibJS: Add spec comments to ArrayBuffer.prototype.slice 2022-02-13 21:26:15 +00:00
Filiph Sandström
8b7987be86 LibGfx: Allow changing the default font path 2022-02-13 21:25:59 +00:00
electrikmilk
62102e3130 Base+HexEditor: Add icons 2022-02-13 21:24:46 +00:00
electrikmilk
adf6be45fb Base+Calculator: Add icons
Adds icons for Pi and Euler's Constant to the Constants menu.
2022-02-13 22:09:18 +01:00
electrikmilk
9e81f60a2f Base: Flip elephant's feet around in PHP file icon
I noticed that the elephant's feet in this icon look like they are
backwards. Slight oversight on my part.
2022-02-13 22:08:14 +01:00
electrikmilk
861efc520e Base: Add C file type icon
Add 16x16 and 32x32 file icons for C files.
2022-02-13 22:07:12 +01:00
u9g
7b223fa51a Base: Add Spreadsheet alias to shellrc 2022-02-14 00:01:35 +03:30
electrikmilk
91d27bd484 Magnifier: Add missing icons
Add icons for 'Next Frame' and 'Previous Frame'.
2022-02-13 15:17:09 -05:00
Andrew Kaster
b4a7d148b1 Kernel: Expose maximum argument limit in sysconf
Move the definitions for maximum argument and environment size to
Process.h from execve.cpp. This allows sysconf(_SC_ARG_MAX) to return
the actual argument maximum of 128 KiB to userspace.
2022-02-13 22:06:54 +02:00
Max Wipfli
b0df096298 Kernel/VFS: Add FIXMEs about error codes leaking data from veiled paths
Error codes can leak information about veiled paths, if the path
resolution fails with e.g. EACCESS.

This is non-trivial to fix, as there is a group of error codes we want
to propagate to the caller, such as ENOMEM.
2022-02-13 21:58:26 +02:00
Max Wipfli
f3cf1b33d7 Tests: Add test for LibC mkdir() 2022-02-13 21:58:26 +02:00
Max Wipfli
e8f491b01d Kernel/VFS: Validate paths against process veil in mkdir()
VirtualFileSystem::mkdir() relies on resolve_path() returning an error,
since it is only interested in the out_parent passed as a pointer. Since
resolve_path_without_veil returns an error, no process veil validation
is done by resolve_path() in that case. Due to this problem, mkdir()
should use resolve_path_without_veil() and then manually validate if the
parent directory of the to-be-created directory is unveiled with 'c'
permissions.

This fixes a bug where the mkdir syscall would not respect the process
veil at all.
2022-02-13 21:58:26 +02:00
Max Wipfli
8c7010f282 Kernel/VFS: Clear out_parent if path is veiled
Previously, VirtualFileSystem::resolve_path() could return a non-null
RefPtr<Custody>* out_parent even if the function errored because the
path has been veiled.

If code relies on recieving the parent custody even if the path is
veiled, it should just call resolve_path_without_veil and do the veil
validation manually. This is because it could be that the parent is
unveiled but the child isn't or the other way round.
2022-02-13 21:58:26 +02:00
Filiph Sandström
3ebb3d9d52 LibCore: Add Darwin anon_create support 2022-02-13 17:54:34 +00:00
Timothy Flynn
7e63f0eb32 LibWeb: Update TestHTMLTokenizer's expected token hash
The output of the tokenizer changed in commit:
b193351a99.
2022-02-13 17:37:33 +00:00
Joaquim Monteiro
3243091c0d LibTLS: Add SHA-384 as supported certificate signing algorithm 2022-02-13 21:02:58 +03:30
Brian Gianforcaro
d386d3946a Toolchain: Fix QEMU build with latest gcc by disabling -fcf-protection
I noticed after upgrading my machine that the QEMU is no longer building
due to GCC enabling `-fcf-protection` by default, even for targets that
don't support it.

The included patch came from the QEMU development list, but hasn't be
included in any patch releases at the time of writing.
https://lore.kernel.org/all/20220208211937.79580-1-vineetg@rivosinc.com/

Until QEMU patches, lets fix it on our end by patching before we build.
2022-02-13 17:11:53 +00:00
Ali Mohammad Pur
b760a1a4ba Ports: Update the citron patches after upstreaming a few
This also switches to checking out a specific commit instead of just the
master HEAD, as the port linter requires a hash (which is imo pointless
in this case), and we can't provide a stable hash for the master branch
HEAD.
2022-02-13 19:03:43 +03:30
Andreas Kling
4b412e8fee Revert "LibJS: Get rid of unnecessary work from canonical_numeric_index_string"
This reverts commit 3a184f7841.

This broke a number of test262 tests under "TypedArrayConstructors".
The issue is that the CanonicalNumericIndexString AO should not fail
for inputs like "1.1", despite them not being integral indices.
2022-02-13 16:01:32 +01:00
MacDue
b193351a99 LibWeb: Fix off-by-one in HTMLTokenizer::restore_to()
The difference should be between m_utf8_iterator and the
the new position, if m_prev_utf8_iterator is used one fewer
source position is popped than required.

This issue was not apparent on most pages since restore_to
used for tokens such  <!doctype> that are normally
followed by a newline that resets the column to zero,
but it can be seen on pages with minified HTML.
2022-02-13 14:51:09 +00:00
Ali Mohammad Pur
62ad33af93 Tests: Wrap test-bytecode-js source in an IIFE
Putting everything in the global scope will lead to mayhem and failing
tests with an actually correct implementation of scoping :^)
Also adds in a tiny debug log of the exception, otherwise we'd be
staring at failing tests with no info on what failed.
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
1bbfaf8627 LibJS: More properly implement scoping rules in bytecode codegen
Now we emit CreateVariable and SetVariable with the appropriate
initialization/environment modes, much closer to the spec.
This makes a whole lot of things like let/const variables, function
and variable hoisting and some other things work :^)
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
c7e6b65fd2 LibJS: Implement ClassExpression::generate_bytecode()
...and use that in ClassDeclaration::generate_bytecode().
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
75aa900b83 LibJS: Make ASTNode::generate_bytecode() fallible
Instead of crashing on the spot, return a descriptive error that will
eventually continue its days as a javascript "InternalError" exception.
This should make random crashes with BC less likely.
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
3a5f7cb524 LibJS: Don't emit a LeaveUnwindContext after a successful handler
The handler already comes with a nice and shiny FinishUnwind, doubling
up will leave two contexts instead.
2022-02-13 14:41:33 +00:00
Ali Mohammad Pur
d7c207beb9 LibJS: Implement the NewClass opcode 2022-02-13 14:41:33 +00:00
Linus Groh
8b27917603 LibJS/Tests: Rename snake_case identifiers in string-basic.js 2022-02-13 14:33:46 +00:00
Linus Groh
b126a8b697 LibJS: Correct receiver value in GetValue's [[Get]] call 2022-02-13 14:30:26 +00:00
Linus Groh
5e2d059508 LibJS: Add spec comments to more Reference AOs 2022-02-13 14:30:03 +00:00
Andreas Kling
88e7d44cc4 LibJS+LibLine: Run clang-format 2022-02-13 14:55:23 +01:00
Andreas Kling
92e0378dbd LibJS: Always inline Lexer::current_code_point()
This gives a ~1% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
50a446a5d1 LibJS: Make more use of Token::flystring_value()
This patch makes check_identifier_name_for_assignment_validity()
take a FlyString instead of a StringView. We then exploit this by
passing FlyString in more places via flystring_value().

This gives a ~1% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
0cb0979990 LibJS: Add Token::flystring_value() to produce FlyString directly
When parsing identifiers, we ultimately want to sink the token string
into a FlyString anyway, and since Token may have a FlyString already
inside it, this allows us to bypass the costly FlyString(StringView).

This gives a ~3% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
515594c667 LibJS: Add fast_is<T>() for things that were hot in RTTI
This gives a ~4% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
1a3fa2d88b LibJS: Make Parser::ScopePusher::has_declaration() take FlyString
Everyone who calls this already has a FlyString, so we were doing *way*
more work by pessimizing it to a StringView.

This gives a ~2% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
3d9f2e2f94 LibJS: Add ASCII fast path to Lexer::current_code_point()
If the current character under the lexer cursor is ASCII, we don't need
to create a Utf8View to consume a full code point.

This gives a ~3% speedup when parsing the largest Discord JS file.
2022-02-13 14:44:36 +01:00
Andreas Kling
c74b6c06a5 AK: Use ByteBuffer::append(u8) in StringBuilder single-char append 2022-02-13 14:44:36 +01:00
Andreas Kling
22f6f0fc9e AK: Don't call memcpy() in ByteBuffer::append(u8)
We can emit way nicer code for the just-append-a-single-byte case.
2022-02-13 14:44:36 +01:00
Anonymous
34a4ce7955 LibJS: Stop eagerly creating the backing store for IndexedProperties
The vast majority of objects do not, and are unlikely to ever need
indexed property storage. By delaying the creation of the backing
store of IndexedProperties we reduce the memory used by each object
and reduce allocation and deallocation by somewhere between 20 and
30%
2022-02-13 14:44:36 +01:00
Anonymous
d1cc67bbe1 LibJS: Avoid unnecessary ToObject conversion when resolving references
When performing GetValue on a primitive type we do not need to perform
the ToObject conversion as it will resolve to a property on the
prototype object.

To avoid this we skip the initial ToObject conversion on the base value
as it only serves to get the primitive's boxed prototype. We further
specialize on PrimitiveString in order to get efficient behaviour
behaviour for the direct properties.

Depending on the tests anywhere from 20 to 60%, with significant loop
overhead.
2022-02-13 14:44:36 +01:00
Anonymous
3a184f7841 LibJS: Get rid of unnecessary work from canonical_numeric_index_string
The spec version of canonical_numeric_index_string is absurdly complex,
and ends up converting from a string to a number, and then back again
which is both slow and also requires a few allocations and a string
compare.

Instead lets use the logic we already have as that is much more
efficient.

This improves performance of all non-numeric property names.
2022-02-13 14:44:36 +01:00
Anonymous
44a2ebea00 LibJS: Correct the handling of accessors on strings 2022-02-13 14:44:36 +01:00