Commit graph

32861 commits

Author SHA1 Message Date
Ali Mohammad Pur cdd6d68b2a Ports: Remove some config.sub patches and download a fresh one if needed
All of these patches did the same thing, which is already in upstream
config.sub.
With this change, we need only add `use_fresh_config_sub=true` to
the package.sh file.
Note that this is not done automatically in case the port has a modified
config.sub file.
2022-01-16 10:32:50 +03:30
Matt Jacobson 87630c5fd5 LibVT: Don't clip TerminalWidget's drawing to avoid scroller
The scroller might be hidden or (in theory) non-opaque.
2022-01-15 19:47:53 -08:00
Linus Groh e8519156bc LibJS: Implement create_dynamic_function() according to the spec
The three major changes are:

- Parsing parameters, the function body, and then the full assembled
  function source all separately. This is required by the spec, as
  function parameters and body must be valid each on their own, which
  cannot be guaranteed if we only ever parse the full function.
- Returning an ECMAScriptFunctionObject instead of a FunctionExpression
  that needs to be evaluated separately. This vastly simplifies the
  {Async,AsyncGenerator,Generator,}Function constructor implementations.
  Drop '_node' from the function name accordingly.
- The prototype is now determined via GetPrototypeFromConstructor and
  passed to OrdinaryFunctionCreate.
2022-01-16 01:54:48 +01:00
Linus Groh 13fe4e8c64 LibJS: Allow passing prototype to ECMAScriptFunctionObject::create()
This should have been the default as it roughly represents the
OrdinaryFunctionCreate AO.
For now, keep two overloads and continue to guess the required prototype
from the function kind in most cases. The prototype needs to be passed
in explicitly when it may be derived from user code, such as in the
CreateDynamicFunction AO.
2022-01-16 01:54:48 +01:00
Linus Groh f0b2179bd7 LibJS: Don't require ParenClose in Parser::parse_formal_parameters()
The parentheses are dealt with outside this function, so we shouldn't
use the (non)existence of one as the condition for consuming another
comma and then parameter. Just check for a comma instead. This becomes
relevant when parsing standalone function parameters as per the spec in
the CreateDynamicFunction AO.
2022-01-16 01:54:48 +01:00
Linus Groh e730ada07d LibJS: Consume curly braces outside of Parser::parse_function_body()
The curly braces are not part of the FunctionBody production. This
becomes relevant when parsing a standalone function body as per the spec
in the CreateDynamicFunction AO.
2022-01-16 01:54:48 +01:00
Linus Groh 710de821e7 LibJS: Add VM::active_function_object() 2022-01-16 01:54:48 +01:00
Linus Groh 0c73fbbba5 LibJS: Rename FunctionKind::{Regular => Normal}
This is what CreateDynamicFunction calls it.
2022-01-16 01:54:48 +01:00
Tom 0d65af5e0f Kernel: Wait for NVMe controller to change enabled state
We need to wait up to CAP.TO units of 500ms when changing CC.EN to
enable or disable the controller.
2022-01-15 16:45:56 -08:00
Idan Horowitz 8a879e205b AK: Mark the error branch of the TRY() macro as unlikely
This results in a measurable (and free!) 2% improvement in test-js
run time.
2022-01-16 02:01:23 +02:00
Idan Horowitz 309d71a66b Kernel: Use kernelputstr instead of dbgln when printing backtraces
This will allow us to eventually switch dbgln in the kernel to an
allocation-free (although length-bounded) formatter.
2022-01-16 01:01:08 +02:00
Idan Horowitz 0142f33ddc Kernel: Make Processor::capture_stack_trace fallible using ErrorOr 2022-01-16 01:01:08 +02:00
Idan Horowitz 03b7352286 Kernel: Specify inline capacity of return type in capture_stack_trace
Since the inline capacity of the Vector return type was not specified
explicitly, the vector was automatically copied to a 0-length inline
capacity one, essentially eliminating the optimization.
2022-01-16 01:01:08 +02:00
Olivier De Cannière d3dfb957a6 PixelPaint: Add delete selection behavior
The delete key can now be used to erase the pixels on the active layer
contained within the selection rectangle.

Closes #11861
2022-01-15 23:38:00 +01:00
Idan Horowitz d3e7ec5a56 Kernel: Remove useless return value from procfs_get_thread_stack 2022-01-16 00:04:24 +02:00
creator1creeper1 4869dda79f AK: Explicitly name types in Iterator.h
In this particular case, auto is a footgun, because we are very
certain about the type that we want to return. const-correctness
could have been violated (as Vector did), because Iterator did not
enforce that the returned pointer was actually const if the Iterator
was an Iterator over a const container.
2022-01-16 00:38:21 +03:30
creator1creeper1 6484d42933 AK: Make Vector more const-correct by using RemoveReference<T>
Methods marked as const should always only return Foo const&, never
Foo&. Previously, this only worked correctly with Foo, but not with
Foo&: If someone fetched a T const&, this would have been expanded
to Foo& const& which is just Foo&. Therefore, they were able to modify
the elements of the Vector, even though it was marked as const.
This commit fixes that by introducing VisibleType as an alias for
RemoveReference<T> and using it throughout Vector.

There are also other cases where we don't require a mutable reference
to the underlying type, only a const reference (for example in a find
operation). In these cases, we now also correctly expand the type
to Foo const&.
2022-01-16 00:38:21 +03:30
creator1creeper1 19d9d5bfe1 Everywhere: Mark Vector of mutable references as mutable
The point of a reference type is to behave just like the referred-to
type. So, a Foo& should behave just like a Foo.

In these cases, we had a const Vector. If it was a const Vector of Foo,
iterating over the Vector would only permit taking const references to
the individual Foos.

However, we had a const Vector of Foo&. The behavior should not
change. We should still only be permitted to take const references to
the individual Foos. Otherwise, we would be allowed to mutate the
individual Foos, which would mutate the elements of the const Vector.
This wouldn't modify the stored pointers, but it would modify the
objects that the references refer to. Since references should be
transparent, this should not be legal.

So it should be impossible to get mutable references into a const
Vector. Since we need mutable references in these cases to call the
mutating member functions, we need to mark the Vector as mutable as
well.
2022-01-16 00:38:21 +03:30
Kenneth Myhra 294cbb7108 nc: Port to LibMain 2022-01-15 22:01:07 +01:00
Mateusz Krajewski ae71d2b70e PixelPaint: Restrict "crop to selection" to image boundaries 2022-01-15 21:55:41 +01:00
Rummskartoffel a610d9a3d1 Assistant: Fix crash in FileProvider background thread upon exit
If the Threading::BackgroundAction for filesystem indexing in
FileProvider hadn't finished by the time the main thread exited, it
would still try to access the FileProvider object that lived in the main
thread, thereby causing a segfault and crashing. This commit prevents
FileProvider from being destroyed while the background thread is still
running by giving the background thread a strong reference to its
FileProvider.
2022-01-15 21:45:03 +01:00
Rummskartoffel ada1d4906e Assistant: Make Provider ref-counted 2022-01-15 21:45:03 +01:00
Rummskartoffel 5fe619de99 Documentation: Update names of RefPtr helper functions
This seems to have been missed when these functions were renamed.
2022-01-15 21:33:04 +01:00
Rummskartoffel 4aaab80649 unzip: Don't fail from mmap when trying to decompress empty files
Given an empty file, unzip would try to create a zero-size memory
mapping of that file, which would fail with EINVAL. With this commit,
attempting to unzip an empty file of course still fails, since that's
not a valid PKZIP file, but it now fails for the correct reason and with
the correct error message.
2022-01-15 22:24:19 +02:00
creator1creeper1 1a2f71581b Kernel: Remove infallible VMObject resource factory functions
These infallible resource factory functions were only there to ease the
conversion to the new factory functions. Since all child classes of
VMObject now use the fallible resource factory functions, we don't
need the infallible versions anymore.
2022-01-15 22:16:00 +02:00
creator1creeper1 2a4e410b63 Kernel: Make SharedInodeVMObject construction OOM-aware
This commit moves the allocation of the resources required for
SharedInodeVMObject from its constructors to its factory functions.

We're making this change to expose the fallibility of the allocation.
2022-01-15 22:16:00 +02:00
creator1creeper1 9a1dfe70fe Kernel: Make PrivateInodeVMObject construction OOM-aware
This commit moves the allocation of the resources required for
PrivateInodeVMObject from its constructors to its factory functions.

We're making this change to expose the fallibility of the allocation.
2022-01-15 22:16:00 +02:00
creator1creeper1 ad480ff18b Kernel: Make InodeVMOBject construction OOM-aware
This commit moves the allocation of the resources required for
InodeVMObject from its constructors to the constructors of its child
classes.

We're making this change to give the child classes the chance to expose
the fallibility of the allocation.
2022-01-15 22:16:00 +02:00
creator1creeper1 3879e70447 Kernel: Make AnonymousVMObject construction OOM-aware
This commit moves the allocation of the resources required for
AnonymousVMObject from its constructors to its factory functions.

We're making this change to expose the fallibility of the allocation.
2022-01-15 22:16:00 +02:00
creator1creeper1 d1f265e851 Kernel: Make VMOBject construction OOM-aware
This commit moves the allocation of the resources required for VMObject
from its constructors to the constructors of its child classes.

We're making this change to give the child classes the chance to expose
the fallibility of the allocation.
2022-01-15 22:16:00 +02:00
creator1creeper1 64778f9e69 AK: Add a constructor from Span for FixedArray
This is particularly useful in the Kernel, where the physical pages of
a VMObject are stored as a FixedArray but often passed around as a Span
from which a new FixedArray should be cloned.
2022-01-15 22:16:00 +02:00
creator1creeper1 0362b15895 AK: Add a constructor from C-style arrays for FixedArray
We really want to be able to construct FixedArray from a list of
non-copyable but movable objects. This constructor is useful for
such things.
2022-01-15 22:16:00 +02:00
Timothy Flynn 6576d0291c LibJS: Implement Date.prototype.getTimezoneOffset 2022-01-15 20:13:48 +01:00
Timothy Flynn 032664332b LibJS: Implement MakeDay without using AK::years_to_days_since_epoch
Implementing years_to_days_since_epoch without a loop will be tricky.
The TimeFromYear AO gives a good enough approximation for MakeDay until
we figure that out.
2022-01-15 20:13:48 +01:00
Timothy Flynn 11d7c7ebbd LibJS: Move time conversion constants to the Date header
These are needed outside of the Date object .cpp file, so move them to
the header.
2022-01-15 20:13:48 +01:00
Timothy Flynn 34a1dd4257 LibJS: Remove Core::DateTime logic from the Date object :^) 2022-01-15 20:13:48 +01:00
Timothy Flynn 58ccca6a9d LibJS+js: Pretty-print Date objects using the ToDateString AO 2022-01-15 20:13:48 +01:00
Timothy Flynn d83ce7dd0b LibJS: Re-implement the Date constructor / prototype for spec compliance
First, this adds a constructor to the Date object to be created from a
plain double. This is a first step to removing Core::DateTime as the
basis for the Date object. A subsequent commit will remove the now-
unused data from the object.

Next, this implements the constructor in accordance to the spec. The
constructor when NewTarget is undefined no longer allocates a Date on
the heap. The other constructor properly uses recently created AOs to
handle time zone and ensure the created [[DateValue]] is valid. Other
methods on the constructor (Date.now) have not been touched yet.

Last, the prototype is reimplemented. Again, we use other AOs to handle
time zones and time clipping. Not all prototypes are fixed; most of them
are, but a few (e.g. Date.prototype.getTimezoneOffset) were not fixed,
but left in a mostly unimplemented state for another commit.

In all of the above, spec comments are added. This is a rather large
change; but it's tough to do any of these parts individually without
breaking everything else.
2022-01-15 20:13:48 +01:00
Timothy Flynn d31e6b9391 LibJS: Make the thisTimeValue AO public
It will be needed by the Date constructor.
2022-01-15 20:13:48 +01:00
Timothy Flynn a488ec1ad0 LibJS: Implement spec-compliant ToDateString and its underlying AOs 2022-01-15 20:13:48 +01:00
Timothy Flynn 62dc9958f5 LibJS: Protect LocalTZA against non-finite times
It is undefined behavior to cast from a double to an integer if the
value does not fit in the limits of the integer.
2022-01-15 20:13:48 +01:00
Timothy Flynn b2aa3c9f84 LibJS: Do not negate offset in LocalTZA for isUTC=false
In commmit 7d2834344a, I think I combined
the definitions of the LocalTZA and UTC AOs in my head, and thought the
offset should be negated within LocalTZA. Instead, the offset should be
left untouched, and the UTC AO is responsible for doing the subtraction.
2022-01-15 20:13:48 +01:00
Timothy Flynn d93713b874 LibJS: Implement the LocalTime, UTC, and TimeWithinDay AOs 2022-01-15 20:13:48 +01:00
Timothy Flynn 5f5bcd549e LibJS: Sort Date.prototype methods by spec order
When viewing the code side-by-side with the spec, it's much nicer when
everything is in the same order.

Also fixes the spec link for Date.prototype.getMilliseconds (it pointed
at setMilliseconds by mistake).
2022-01-15 20:13:48 +01:00
Timothy Flynn 247caac7a8 LibTimeZone: Canonicalize the current time zone and fall back to UTC
If the tzname is unknown, fall back to UTC for now. Unknown time zones
are most likely due to not parsing RULE entries yet, but at the very
least, it only makes sense for current_time_zone to return a time zone
that LibTimeZone actually knows about.
2022-01-15 20:13:48 +01:00
Andreas Kling 094b88e6a5 Kernel: Don't remap already non-writable regions when they become CoW
The only purpose of the remap() in Region::try_clone() is to ensure
non-writable page table entries for CoW regions. If a region is already
non-writable, there's no need to waste time updating the page tables.
2022-01-15 19:51:16 +01:00
Andreas Kling c6adefcfc0 Kernel: Don't bother with page tables for PROT_NONE mappings
When mapping or unmapping completely inaccessible memory regions,
we don't need to update the page tables at all. This saves a bunch of
time in some situations, most notably during dynamic linking, where we
make a large VM reservation and immediately throw it away. :^)
2022-01-15 19:51:16 +01:00
Andreas Kling 9ddccbc6da Kernel: Use move() in Region::try_clone() to avoid a VMObject::unref() 2022-01-15 19:51:15 +01:00
Andreas Kling c482508aa1 LibELF: Use shared memory mapping when loading ELF objects
There's no reason to make a private read-only mapping just for reading
(and validating) the ELF headers, and copying out the data segments.
2022-01-15 19:51:15 +01:00
Andreas Kling 8e0387e674 Kernel: Only register kernel regions with MemoryManager
We were already only tracking kernel regions, this patch just makes it
more clear by having it reflected in the name of the registration
helpers.

We also stop calling them for userspace regions, avoiding some spinlock
action in such cases.
2022-01-15 19:51:15 +01:00