Commit graph

22944 commits

Author SHA1 Message Date
Daniel Bertalan fda9f394d1 Kernel: Fix always-true comparison warnings 2021-07-03 01:56:31 +04:30
Daniel Bertalan b9f30c6f2a Everywhere: Fix some alignment issues
When creating uninitialized storage for variables, we need to make sure
that the alignment is correct. Fixes a KUBSAN failure when running
kernels compiled with Clang.

In `Syscalls/socket.cpp`, we can simply use local variables, as
`sockaddr_un` is a POD type.

Along with moving the `alignas` specifier to the correct member,
`AK::Optional`'s internal buffer has been made non-zeroed by default.
GCC emitted bogus uninitialized memory access warnings, so we now use
`__builtin_launder` to tell the compiler that we know what we are doing.
This might disable some optimizations, but judging by how GCC failed to
notice that the memory's initialization is dependent on `m_has_value`,
I'm not sure that's a bad thing.
2021-07-03 01:56:31 +04:30
Daniel Bertalan 45a82b2a5b Kernel: Fix struct forward declared as class 2021-07-03 01:56:31 +04:30
Daniel Bertalan 842249aff5 LibC: Don't use C++ attribute syntax in C-visible headers
Fixes errors when building Clang's compiler-rt, which compiles in C11
more.
2021-07-03 01:56:31 +04:30
Daniel Bertalan 3162c9e214 AK: Make (Nonnull)OwnPtr work with abstract classes
Clang produced a compile error at this requires statement if `T` was an
abstract class.
2021-07-03 01:56:31 +04:30
Daniel Bertalan b97a00d4b1 Kernel: Add missing override specifiers
The `#pragma GCC diagnostic` part is needed because the class has
virtual methods with the same name but different arguments, and Clang
tries to warn us that we are not actually overriding anything with
these.

Weirdly enough, GCC does not seem to care.
2021-07-03 01:56:31 +04:30
Linus Groh 33a341f5e1 Meta: Add Gunnar to the project reviewers in CONTRIBUTING.md :^) 2021-07-02 22:04:26 +01:00
Andreas Kling fd43d1e205 LibJS: Improve ResolveBinding + add GetIdentifierReference
ResolveBinding now matches the spec, while the non-conforming parts
are moved to GetIdentifierReference.

Implementing this properly requires variable bindings.
2021-07-02 22:22:21 +02:00
Max Wipfli 4b87dd5c5c Tests: Add test for String::find with empty needle
This adds a test case for String::find and String::find_all with empty
needles. The expected behavior is in line with what the C++ standard
library (and other languages standard libraries) expect.
2021-07-02 21:54:21 +02:00
Max Wipfli 9cc35d1ba3 AK: Implement String::find_any_of() and StringView::find_any_of()
This implements StringUtils::find_any_of() and uses it in
String::find_any_of() and StringView::find_any_of(). All uses of
find_{first,last}_of have been replaced with find_any_of(), find() or
find_last(). find_{first,last}_of have subsequently been removed.
2021-07-02 21:54:21 +02:00
Max Wipfli 17eddf3ac4 AK: Add input bounds checking to String::substring()
This checks for overflow in String::substring(). It also rearranges some
declarations in the header.
2021-07-02 21:54:21 +02:00
Max Wipfli 268d81a56c AK: Add String::find_last() and inline String::find() methods
This adds the String::find_last() as wrapper for StringUtils::find_last,
which is another step in harmonizing the String and StringView APIs
where possible.

This also inlines the find() methods, as they are simple wrappers around
StringUtils functions without any additional logic.
2021-07-02 21:54:21 +02:00
Max Wipfli d7a104c27c AK: Implement StringView::find_all()
This implements the StringView::find_all() method by re-implemeting the
current method existing for String in StringUtils, and using that
implementation for both String and StringView.

The rewrite uses memmem() instead of strstr(), so the String::find_all()
argument type has been changed from String to StringView, as the null
byte is no longer required.
2021-07-02 21:54:21 +02:00
Max Wipfli 3bdaed501e AK+Everywhere: Remove StringView::find_{first,last}_of(char) methods
This removes StringView::find_first_of(char) and find_last_of(char) and
replaces all its usages with find and find_last respectively. This is
because those two methods are functionally equivalent.
find_{first,last}_of should only be used if searching for multiple
different characters, which is never the case with the char argument.

This also adds the [[nodiscard]] to the remaining find_{first,last}_of
methods.
2021-07-02 21:54:21 +02:00
Max Wipfli 56253bf389 AK: Reimplement StringView::find methods in StringUtils
This patch reimplements the StringView::find methods in StringUtils, so
they can also be used by String. The methods now also take an optional
start parameter, which moves their API in line with String's respective
methods.

This also implements a StringView::find_ast(char) method, which is
currently functionally equivalent to find_last_of(char). This is because
find_last_of(char) will be removed in a further commit.
2021-07-02 21:54:21 +02:00
Max Wipfli 3ea65200d8 AK: Implement StringView::to_{lower,upper}case_string
This patch refactors StringImpl::to_{lower,upper}case to use the new
static methods StringImpl::create_{lower,upper}cased if they have to use
to create a new StringImpl. This allows implementing StringView's
to_{lower,upper}case_string using the same methods.

It also replaces the usage of hand-written to_ascii_lowercase() and
similar methods with those from CharacterTypes.h.
2021-07-02 21:54:21 +02:00
Andreas Kling 5ce9305c5f LibJS: Implement the PrepareForOrdinaryCall abstract operation
This is used by VM::call_internal() and VM::construct() which roughly
map to function objects' [[Call]] and [[Construct]] slots in the spec.

Reorganizing this code revealed something weird: NativeFunction gets
its strictness by checking VM::in_strict_mode(). In other words,
it inherits the strict flag from the caller context. This is quite
weird, but many test-js tests rely on it, so let's preserve it until
we can think of something nicer.
2021-07-02 21:44:08 +02:00
Hediadyoin1 8ed3315dec AK: Support long doubles in format strings 2021-07-02 19:50:43 +02:00
Hediadyoin1 f4072a5038 LibM: Add long double defines of Math Constants 2021-07-02 19:50:43 +02:00
Hendiadyoin1 c74d7adac6 LibM: Implement path for negative powers 2021-07-02 19:50:43 +02:00
Andreas Kling 71fc7ac7ac LibJS: Make SuperCall a proper AST node and clean up evaluation 2021-07-02 19:39:09 +02:00
Andreas Kling d81f4d5228 LibJS: NewExpression doesn't need compute_this_and_callee()
Now that NewExpression is separated from CallExpression, it doesn't
have to use the ad-hoc compute_this_and_callee() logic.
2021-07-02 18:43:25 +02:00
Andreas Kling 814549b846 LibJS: Split out NewExpression evaluation from CallExpression
This patch adds an override for NewExpression::execute() in the AST
interpreter to separate the logic from CallExpression. As a result,
both evaluation functions are simplified.

Both expressions are still largely non-conforming, but this makes
it easier to work on improving that since we can now deal with them
separately. :^)
2021-07-02 18:25:32 +02:00
Andreas Kling bad1acf137 LibJS: Break out ArgumentListEvaluation AO from CallExpression 2021-07-02 17:54:34 +02:00
Marcus Nilsson 05e8bea736 PixelPaint: Reset layer widgets when closing last tab
When closing the last tab the layer list widget and layer properties
widget did not reset since they still had a pointer to the image.
2021-07-02 17:54:01 +02:00
Marcus Nilsson 54d4df668a PixelPaint: Add layer to image before setting properties
Previously when opening an image with layers that had properties like
visibility set, PixelPaint would crash when trying to trigger
layer_did_modify_properties() without in image. Avoid this by
adding the layer to the image before setting the properties.
2021-07-02 17:54:01 +02:00
Spencer Dixon dd3996e207 Tests+LibThreading: Add new tests for LibThreading for detach() 2021-07-02 17:52:45 +02:00
Spencer Dixon 48731e9f17 LibThreading: Add new detach() API to Thread
Sometimes you don't care about `joining()` the result of a thread. The
underlying pthread implementation already existed for detaching and
now we expose it to the higher level API.
2021-07-02 17:52:45 +02:00
Gunnar Beutner 5666809889 Kernel: Fix building the kernel with LTO
Fixes #8383.
2021-07-02 17:51:26 +02:00
Idan Horowitz 311b2c0720 CI: Increase ccache size limit for on-target builds
It turns out that ccache caches are highly compressible (total size is
reduced by about 65%), so we should be able to increase the cache limit
for some free speedups. :^)
2021-07-02 17:51:13 +02:00
Idan Horowitz f8f3ff65fe LibJS: Bring %TypedArray%.prototype.set slightly closer to spec
Specifically, instead of using the internal {get, put}_by_index methods
we now use the GetValueFromBuffer and SetValueInBuffer abstract
operations, as required by the specification.

While i was here i also replaced a couple custom detached array buffer
error messages with the existing ErrorType::DetachedArrayBuffer.
2021-07-02 15:53:51 +01:00
Spencer Dixon e6f0b2d817 Assistant: Add a new FileProvider to assist in searching the filesystem
When searching in Assistant, we now dispatch some background jobs to
query the whole filesystem. Activating a result will use the Desktop
launcher's default way of opening that file or directory.
2021-07-02 16:47:14 +02:00
Spencer Dixon 00f93b2545 LibThreading: Add ability to cancel ongoing BackgroundActions
Handlers of the BackgroundAction are responsible for checking if the
action has been cancelled and returning early.
2021-07-02 16:47:14 +02:00
Spencer Dixon 4a3958c8ae Assistant: Remove Result::Kind in favor of native typeid
I was unaware of the `typeid` construct in C++ which can be used to
achieve the same thing I was doing with this extra Kind enum.
2021-07-02 16:47:14 +02:00
Ali Mohammad Pur ccbc54358d LibJS: Allow patterns in parenthesized arrow function parameters 2021-07-02 14:59:03 +02:00
Ali Mohammad Pur 2e00731ddb LibJS: Allow 'yield' and 'await' as function expression names
The spec says so, and test262 checks for this too.
2021-07-02 14:59:03 +02:00
Ali Mohammad Pur a6fe27423a LibJS: Allow binding patterns as for in/of targets 2021-07-02 14:59:03 +02:00
Ali Mohammad Pur bd9f28bba6 LibJS: Allow 'yield' as a variable name outside of generator functions 2021-07-02 14:59:03 +02:00
Ali Mohammad Pur 0292ad33eb LibJS: Make a slash after a curly close mean not-division
There's no grammar rule that allows this.
2021-07-02 14:59:03 +02:00
Ali Mohammad Pur 46ef333e9c LibJS: Parse generator functions in class expressions too 2021-07-02 14:59:03 +02:00
Spencer Dixon 609a0aa75d Assistant: Change to home directory when spawning applications
When launching Terminal via Taskbar we change to the users home
directory. For consistency, let's also `chdir` to `/home/anon` when
launching apps via Assistant's AppProvider.
2021-07-02 14:16:56 +02:00
Liav A acd2604a31 Revert "Revert "Revert "Kernel: Fix PCI layout of i440fx QEMU machine"""
This reverts commit a808fff2ec.

I highly suspect the reason it was not working before was fixed in
017c5fc7d9, so the SB16 DMA can work even
if we initialize another E1000 network adapter.
2021-07-02 13:16:12 +02:00
Liav A 32a4a4ac19 Kernel/ProcFS: Lazily allocate all sub components of a PID folder 2021-07-02 13:16:12 +02:00
Liav A 6282df3066 Kernel/ACPI: Don't ask from TypedMapping to map 2 pages if unnecessary 2021-07-02 13:16:12 +02:00
Liav A 4499b0418c Kernel/TypedMapping: Round up length with offset_in_page
Fixes #6948.
2021-07-02 13:16:12 +02:00
Liav A 3344f91fc4 Kernel/ProcFS: Clean dead processes properly
Now we use WeakPtrs to break Ref-counting cycle. Also, we call the
prepare_for_deletion method to ensure deleted objects are ready for
deletion. This is necessary to ensure we don't keep dead processes,
which would become zombies.

In addition to that, add some debug prints to aid debug in the future.
2021-07-02 13:16:12 +02:00
Liav A 5073bf8e75 Kernel/USB: Move the USB components as a subfolder to the Bus directory 2021-07-02 13:16:12 +02:00
Liav A 6568bb47cb Kernel/PCI: Move the PCI components as a subfolder to the Bus directory 2021-07-02 13:16:12 +02:00
Tom 26e9140ea1 WindowServer: Fix redrawing menu window that already existed
This fixes redrawing a menu where the window menu is reused at a
different location or with different content.
2021-07-02 13:12:29 +02:00
Brian Gianforcaro 179d8f6815 LibELF: Use StringView literal to avoid string allocations 2021-07-02 10:51:20 +04:30