Commit graph

34385 commits

Author SHA1 Message Date
Sam Atkins
aa2f20fb60 LibGfx: Add Path::[horizontal,vertical]_path_to()
The SVG spec describes some path operations using these, so we might as
well have them. :^)
2022-02-11 21:38:27 +01:00
Sam Atkins
9424c67ed5 LibWeb: Expose SVG length/coordinate parsing methods
This is all still quite ad-hoc. Eventually these will both need to
support units (like with CSS Lengths) but for now we can continue only
using numbers.
2022-02-11 21:38:27 +01:00
Sam Atkins
82308fb71a LibWeb: Move SVG::PathDataParser into its own file and rename it
I've chosen the name `AttributeParser` since it parses data from
attributes. Rather than duplicate the parsing of numbers and other
basic types, let's make use of this existing parsing code for parsing
the data for `<line>`, `<polyline>`, etc.
2022-02-11 21:38:27 +01:00
Sam Atkins
784c3183f7 LibWeb: Rename SVGPathBox -> SVGGeometryBox
This fits better since it's now used by all SVGGeometryElements.
2022-02-11 21:38:27 +01:00
Sam Atkins
326a5a82eb LibWeb: Move SVGPathElement methods into SVGGeometryElement
From the spec:

> Interface SVGGeometryElement represents SVG elements whose rendering
> is defined by geometry with an equivalent path, and which can be
> filled and stroked. This includes paths and the basic shapes.

- https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement

Making them all create an SVGPathBox, and return a Path from get_path(),
means we can implement the "basic shapes" using the path system we
already have. :^)
2022-02-11 21:38:27 +01:00
Sam Atkins
49fe232bc7 LibWeb: Add const versions of SVGBox::dom_node() and friends 2022-02-11 21:38:27 +01:00
Andreas Kling
5f5fe103eb LibHTTP: Don't copy payload slices in flush_received_buffers()
Instead of using ByteBuffer::slice() to carve off the remaining part of
the payload every time we flush a part of it, we now keep a sliding
span (ReadonlyBytes) over it.
2022-02-11 20:25:15 +01:00
Daniel Bertalan
ba5bbde7ee Meta: Enable RELR relocations
Also add a check to serenity.sh to ensure that the toolchain is new
enough for this feature to work.
2022-02-11 18:07:53 +01:00
Daniel Bertalan
7ab6816b49 Ports: Update binutils to version 2.38 2022-02-11 18:07:53 +01:00
Daniel Bertalan
85780fafcd Toolchain: Update binutils to version 2.38
This version comes with general fixes and, more importantly, introduces
support for the packed RELR relocation format.
2022-02-11 18:07:53 +01:00
Daniel Bertalan
10c629055f Utilities/readelf: Add printing for RELR relocations 2022-02-11 18:07:53 +01:00
Daniel Bertalan
3974cac148 LibELF: Implement support for DT_RELR relative relocations
The DT_RELR relocation is a relatively new relocation encoding designed
to achieve space-efficient relative relocations in PIE programs.

The description of the format is available here:
https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Pi9aSwwABgAJ

It works by using a bitmap to store the offsets which need to be
relocated. Even entries are *address* entries: they contain an address
(relative to the base of the executable) which needs to be relocated.
Subsequent even entries are *bitmap* entries: "1" bits encode offsets
(in word size increments) relative to the last address entry which need
to be relocated.

This is in contrast to the REL/RELA format, where each entry takes up
2/3 machine words. Certain kinds of relocations store useful data in
that space (like the name of the referenced symbol), so not everything
can be encoded in this format. But as position-independent executables
and shared libraries tend to have a lot of relative relocations, a
specialized encoding for them absolutely makes sense.

The authors of the format suggest an overall 5-20% reduction in the file
size of various programs. Due to our extensive use of dynamic linking
and us not stripping debug info, relative relocations don't make up such
a large portion of the binary's size, so the measurements will tend to
skew to the lower side of the spectrum.

The following measurements were made with the x86-64 Clang toolchain:

- The kernel contains 290989 relocations. Enabling RELR decreased its
  size from 30 MiB to 23 MiB.
- LibUnicodeData contains 190262 relocations, almost all of them
  relative. Its file size changed from 17 MiB to 13 MiB.
- /bin/WebContent contains 1300 relocations, 66% of which are relative
  relocations. With RELR, its size changed from 832 KiB to 812 KiB.

This change was inspired by the following blog post:
https://maskray.me/blog/2021-10-31-relative-relocations-and-relr
2022-02-11 18:07:53 +01:00
Vitaly Dyachkov
32b8795091 LibConfig: Rename pledge_domains(String) => pledge_domain(String)
pledge_domains() that takes only one String argument was specifically
added as a shortcut for pledging a single domain. So, it makes sense to
use singular here.
2022-02-11 18:06:39 +01:00
Idan Horowitz
873f4d5de6 RequestServer: Recreate socket if it reached EOF
This ensures we don't continue using a socket that has EOF'ed (meaning
the protocol has disconnected in the case of TCP) for new requests.
2022-02-11 18:11:32 +02:00
Idan Horowitz
75fe51a9ca Kernel: Stop trying to write unmapped Process regions into CoreDumps
If we crashed in the middle of mapping in Regions, some of the regions
may not have a page directory yet, and will result in a crash when
Region::remap() is called.
2022-02-11 17:49:46 +02:00
Idan Horowitz
57bce8ab97 Kernel: Set up Regions before adding them to a Process's AddressSpace
This reduces the amount of time in which not fully-initialized Regions
are present inside an AddressSpace's region tree.
2022-02-11 17:49:46 +02:00
Idan Horowitz
d9d3362722 Kernel: Make SharedInodeVMObject pages Bitmap allocation OOM-fallible 2022-02-11 17:49:46 +02:00
Idan Horowitz
8030e2a88f Kernel: Make AnonymousVMObject COW-Bitmap allocation OOM-fallible 2022-02-11 17:49:46 +02:00
Idan Horowitz
871a53db76 AK: Make Bitmap construction OOM-fallible 2022-02-11 17:49:46 +02:00
Andreas Kling
1667a80ade LibWeb: Remove CascadeOrigin::Any enum value
Looks like I removed all uses of this value, but not the value itself!
Thanks to Idan for pointing that out. :^)
2022-02-11 15:21:56 +01:00
Andreas Kling
c797eaa9f8 Kernel/Net: Don't update TCP socket "last sent ACK" field too early
Defer updating this field until after the last fallible operation has
succeeded.
2022-02-11 12:45:38 +01:00
Andreas Kling
06cf01cd1e Kernel/E1000: Bump RX/TX buffer count to 256/256
We were frequently dropping packets when downloading large files.
Then we had to wait for TCP retransmission which slowed things down.

This patch dramatically improves E1000 throughput by increasing the
number of RX/TX buffers from 32/8 to 256/256.

The largest chunk of JavaScript from Discord now downloads in roughly
1 second instead of 7 seconds. :^)
2022-02-11 12:45:38 +01:00
Andreas Kling
2ff9db0245 Kernel: Make contiguous VM objects use "user physical pages" by default
If someone specifically wants contiguous memory in the low-physical-
address-for-DMA range ("super pages"), they can use the
allocate_dma_buffer_pages() helper.
2022-02-11 12:45:38 +01:00
Andreas Kling
5ff816abbf LibWeb: Remove unused CascadeOrigin::Any
This was an ad-hoc concept from before we implemented the CSS cascade.
2022-02-11 12:45:38 +01:00
Idan Horowitz
1aad64fbe4 Kernel: Workaround QEMU hypervisor.framework CPUID max leaf bug
This works around issue #10382 until it is fixed on QEMU's side.
Patch from Anonymous.
2022-02-11 02:45:34 +02:00
Timothy Flynn
b683e8ab77 LibSQL: Return unimplemented errors from unimplemented MATCH expressions
A bit friendlier than crashing the entire SQLService process.
2022-02-10 23:11:13 +01:00
Timothy Flynn
df2ddcafd4 LibSQL: Remove the now-unused ExecutionContext::result object
The INSERT and SELECT statements set up this object for any expression
evaluation to indicate errors. This is no longer needed.
2022-02-10 23:11:13 +01:00
Timothy Flynn
f3c6cb40d7 LibSQL: Convert SQL expression evaluation to use ResultOr
Instead of setting an error in the execution context, we can directly
return that error or the successful value. This lets all callers, who
were already TRY-capable, simply TRY the expression evaluation.
2022-02-10 23:11:13 +01:00
Timothy Flynn
2397836f8e LibSQL+SQLServer: Introduce and use ResultOr<ValueType>
The result of a SQL statement execution is either:
    1. An error.
    2. The list of rows inserted, deleted, selected, etc.

(2) is currently represented by a combination of the Result class and
the ResultSet list it holds. This worked okay, but issues start to
arise when trying to use Result in non-statement contexts (for example,
when introducing Result to SQL expression execution).

What we really need is for Result to be a thin wrapper that represents
both (1) and (2), and to not have any explicit members like a ResultSet.
So this commit removes ResultSet from Result, and introduces ResultOr,
which is just an alias for AK::ErrorOrr. Statement execution now returns
ResultOr<ResultSet> instead of Result. This further opens the door for
expression execution to return ResultOr<Value> in the future.

Lastly, this moves some other context held by Result over to ResultSet.
This includes the row count (which is really just the size of ResultSet)
and the command for which the result is for.
2022-02-10 23:11:13 +01:00
kleines Filmröllchen
6409618413 LibCore: Convert AnonymousBuffer to use System::anon_create 2022-02-10 21:35:17 +01:00
kleines Filmröllchen
cf1f58d51c LibCore/System: Add anon_create syscall wrapper
This wrapper is particularly helpful as we use a combination of similar
syscalls on Linux to simulate the behavior of the Serenity-exclusive
anon_create syscall. Users therefore won't have to worry about the
platform anymore :^)
2022-02-10 21:35:17 +01:00
Andreas Kling
05eb68d452 LibWeb: Make :root selector match <html> element only
We were matching every HTML element, instead of just the root (<html>)
2022-02-10 20:52:58 +01:00
Andreas Kling
b68c51379e LibWeb: Add "tag name" buckets to StyleComputer::RuleCache
We can skip rules that require a specific tag name when matching against
any element with a different tag name. :^)
2022-02-10 20:52:11 +01:00
Andreas Kling
031296cf7b LibWeb: Add "ID" buckets to StyleComputer::RuleCache
We can skip rules that require a specific ID when matching against any
element that doesn't have that ID.
2022-02-10 20:52:11 +01:00
Andreas Kling
646b37d1a9 LibWeb: Cache CSS rules in buckets to reduce number of rules checked
This patch introduces the StyleComputer::RuleCache, which divides all of
our (author) CSS rules into buckets.

Currently, there are two buckets:
- Rules where a specific class must be present.
- All other rules.

This allows us to check a significantly smaller set of rules for each
element, since we can skip over any rule that requires a class attribute
not present on the element.

This takes the typical numer of rules tested per element on Discord from
~16000 to ~550. :^)

We can definitely improve the cache invalidation. It currently happens
too often due to media queries. And we also need to make sure we
invalidate when mutating style through CSSOM APIs.
2022-02-10 20:52:11 +01:00
Andreas Kling
8d104b7de2 LibWeb: Perform CSS custom property cascade once instead of per-property
Previously we would re-run the entire CSS selector machinery for each
property resolved. Instead of doing that, we now resolve a final set of
custom property key/value pairs at the start of the cascade.
2022-02-10 20:52:11 +01:00
Andreas Kling
b248661f11 LibWeb: Fix a bunch of trivial clang-tidy warnings in StyleComputer
- Replace "auto" with "auto const" where appropriate.
- Remove an unused struct.
- Make sort_matching_rules() a file-local static function.
- Remove some unnecessary includes.
2022-02-10 20:51:44 +01:00
Andreas Kling
31695e1695 LibWeb: Rename a CascadeOrigin parameter in StyleComputer 2022-02-10 20:51:44 +01:00
Daste
542e18b367 HackStudio: Fix error handling logic in delete_action
The `result.is_error()` check was inverted, causing a crash.
2022-02-10 21:41:05 +02:00
Daste
11c53a1944 HackStudio: Don't save file when filename is empty
When saving a new file, save_as_action will return if the filename
input was empty, but save_action would still try to save the file.
Added a guard to make sure we never try to save files with empty
filenames.
2022-02-10 18:42:45 +01:00
Riccardo Arena
a9b387a1bf pgrep: Port to LibMain
Use unveil to allow access only to required paths. 
Switch to new pledge format.
2022-02-10 14:10:58 +00:00
Riccardo Arena
5c63537ae9 pidof: Port to LibMain
Use pledge/unveil to allow access only to required paths and syscalls.
2022-02-10 14:10:58 +00:00
Timothy Flynn
a78058bc79 LibJS: Do not refer to moved-from completions / values
In the ThrowCompletionOr constructors, the VERIFY statements are using
moved-from objects. We should not rely on those objects still being
valid after being moved.
2022-02-10 14:10:34 +00:00
davidot
821ae3a479 LibJS: Add tests for Set.prototype.keys which is an alias for values 2022-02-10 14:09:39 +00:00
davidot
45646eee43 LibJS: Fix Map Iterators when elements are deleted during iteration
Before this would assume that the element found in operator++ was still
valid when dereferencing it in operator*.
Since any code can have been run since that increment this is not always
valid.
To further simplify the logic of the iterator we no longer store the
index in an optional.
2022-02-10 14:09:39 +00:00
davidot
fdbfe85a87 AK: Clear minimum when removing last node of RedBlackTree 2022-02-10 14:09:39 +00:00
davidot
2bddf157b1 AK: Fix RedBlackTree::find_smallest_not_below_iterator
Before this was incorrectly assuming that if the current node `n` was at
least the key and the left child of `n` was below the key that `n` was
always correct.
However, the right child(ren) of the left child of `n` could still be
at least the key.

Also added some tests which produced the wrong results before this.
2022-02-10 14:09:39 +00:00
Liav A
41dae9b3c7 Kernel: Convert i8042 code to use the ErrorOr pattern more broadly
Not only does it makes the code more robust and correct as it allows
error propagation, it allows us to enforce timeouts on waiting loops so
we don't hang forever, by waiting for the i8042 controller to respond to
us.

Therefore, it makes the i8042 more resilient against faulty hardware and
bad behaving chipsets out there.
2022-02-10 15:42:56 +02:00
Liav A
dc41a0b830 Kernel: Check i8042 existence before trying to use it
If we don't do so, we just hang forever because we assume there's i8042
controller in the system, which is not a valid assumption for modern PC
hardware.
2022-02-10 15:42:56 +02:00
Timothy Flynn
f1f0770d68 LibSQL: Do not crash when SELECTing from an empty table
The crash was caused by getting the first element of an empty vector.
2022-02-10 12:20:35 +00:00