Commit Graph

60743 Commits

Author SHA1 Message Date
Andreas Kling
819f2c1df6 LibWeb: Don't redundantly re-sort StyleSheetList on sheet removal
The list is already kept sorted. Removing one sheet anywhere from the
list will not make it unsorted.
2024-04-21 19:32:49 +02:00
MacDue
9d8ab826cb LibWeb: Add an initial implementation of the SVG .getBBox() method
This just reuses the layout to compute the bounding box rather than
implementing the full bounding box algorithm, which is likely the slower
option, but also much simpler to implement.

This is enough to fix the faces on https://zengm.com/facesjs/.
2024-04-21 17:30:51 +02:00
Aliaksandr Kalenik
3c33e1eba9 LibWeb: Make ChangingNavigableContinuationState be GC-allocated
This struct is captured by `after_document_populated` callback so making
it be GC-allocated results in more understandable GC-graph.
2024-04-21 16:44:05 +02:00
Aliaksandr Kalenik
2f345c4ab5 LibWeb: Use HeapFunction for update_document callback 2024-04-21 16:44:05 +02:00
Aliaksandr Kalenik
3b3816e683 LibWeb: Remove changing_navigable_continuation capture in callback
Capturing a struct that owns bunch of JS::Handle makes it very hard to
understand what keeps these handles alive in the GC-graph.

Instead let's capture only members of a struct used in the callback.
2024-04-21 16:44:05 +02:00
implicitfield
c15b473c1a Kernel/FATFS: Only read the requested blocks in read_bytes_locked()
This dramatically improves performance when working with large files,
since we no longer re-read the entire file for each read.
2024-04-21 15:34:33 +02:00
implicitfield
5bc87ad1a5 Kernel/FATFS: Free an inode's clusters upon removal 2024-04-21 15:34:33 +02:00
implicitfield
32692f032c Kernel/FATFS: Keep the FSInfo sector's free cluster count in sync 2024-04-21 15:34:33 +02:00
implicitfield
bd76dd2dc2 Kernel/FATFS: Initialize special directory entries 2024-04-21 15:34:33 +02:00
implicitfield
66e1f8812f Kernel/FATFS: Don't ignore special entries when traversing directories 2024-04-21 15:34:33 +02:00
Undefine
31174c43bf Kernel/FATFS: Implement a hacky replace_child
This is not a proper implementation, but it's good enough to get
the write support fully working.
2024-04-21 15:34:33 +02:00
Undefine
511b298a1d Kernel/FATFS: Implement remove_child 2024-04-21 15:34:33 +02:00
Undefine
3b39a2f71b Kernel/FATFS: Implement add_child 2024-04-21 15:34:33 +02:00
Undefine
5e87b78935 LibFileSystem: Ignore ENOTSUP when using chown and chmod during copy
With FAT write support copying the file would show two errors because
it does not support chown and chmod and would return ENOTSUP. After
this commit these errors are ignored in that case.
2024-04-21 15:34:33 +02:00
Undefine
2952401c58 Kernel/FATFS: Implement create_child
This is a large commit because it implements a lot of stuff to make
add_child simpler to get working. This allows us to create new files
on a FAT partition.
2024-04-21 15:34:33 +02:00
Undefine
098518cc57 Kernel/FATFS: Implement file modification
This is the first part of write support, it allows for full file
modification, but no creating or removing files yet.

Co-Authored-By: implicitfield <114500360+implicitfield@users.noreply.github.com>
2024-04-21 15:34:33 +02:00
Undefine
fde7bd9190 Kernel/FATFS: Make the debug logs nicer
They now look the same way as the ones in Ext2FS inodes which are
quite nice for debugging.
2024-04-21 15:34:33 +02:00
Undefine
33f00a7efb Kernel/FATFS: Cache the cluster list and don't cache the InodeMetadata
Caching the cluster list allows us to fill the two fields in the
InodeMetadata. While at it, don't cache the metadata as when we
have write support having to keep both InodeMetadata and FATEntry
correct is going to get very annoying.
2024-04-21 15:34:33 +02:00
Undefine
d4badfac72 Kernel/FATFS: Store cluster list instead of block list
Once we have write support, managing clusters is going to be
way easier than managing blocks.
2024-04-21 15:34:33 +02:00
Undefine
92d58a91a6 Kernel/FATFS: Read the FAT32 FSInfo structure
This structure contains information about free clusters which
is going to be useful when allocating clusters.
2024-04-21 15:34:33 +02:00
Undefine
7e251c3b4f Kernel/FATFS: Return ENOTSUP on chown and chmod 2024-04-21 15:34:33 +02:00
Undefine
eb2721d650 Kernel/FATFS: Pass the FATEntry location to FATInode constructor
This is going to be necessary to flush the metadata later on.
2024-04-21 15:34:33 +02:00
Undefine
de574b9ed9 Kernel/FATFS: Improve error propagation in FATInode 2024-04-21 15:34:33 +02:00
implicitfield
0f828768bb Kernel/FATFS: Implement fat_write 2024-04-21 15:34:33 +02:00
implicitfield
a6a1508601 Kernel/FATFS: Fix reading from large 12-bit FATs
12-bit FATs aren't necessarily block-aligned, so in the worst case
we'll have to reach into the next block to perform the read properly.
2024-04-21 15:34:33 +02:00
Undefine
1350c555f6 Kernel/FATFS: Factor out the FAT reading to a function
Move the FAT reading code to a fat_read function in FATFS and move the
required functions to FATFS too.
2024-04-21 15:34:33 +02:00
implicitfield
b9d7e2db93 Kernel/FATFS: Prefer read_block() over raw_read()
`raw_read()` has proven to be a source of subtle bugs that occur as a
result of the cache and disk contents being out of sync.
2024-04-21 15:34:33 +02:00
implicitfield
b1af97810e Kernel/FATFS: Avoid creating reference bindings to packed struct members
dbgln() will always take its arguments by reference when possible, which
causes UB when dealing with packed structs. To avoid this, we now
explicitly copy all members whose alignment requirements aren't met.
2024-04-21 15:34:33 +02:00
Aliaksandr Kalenik
23d683cf6b LibWeb: Update document url after same-document back/forward navigation
Seems like a specification bug, but other browsers update url before
popstate event is fired and so should we.

Fixes back/forward navigation on GitHub.
2024-04-21 12:41:36 +02:00
dgaston
08aaf4fb07 AK: Add methods to BufferedStream to resize the user supplied buffer
These changes allow lines of arbitrary length to be read with
BufferedStream. When the user supplied buffer is smaller than
the line, it will be resized to fit the line. When the internal
buffer in BufferedStream is smaller than the line, it will be
read into the user supplied buffer chunk by chunk with the
buffer growing accordingly.

Other behaviors match the behavior of the existing read_line method.
2024-04-21 11:46:55 +02:00
Andreas Kling
4db1712f90 LibJS+LibWeb: Make Console, ConsoleClient & subclasses GC-allocated
These objects had confusing ownership semantics. Let's just throw them
all on the GC heap and stop worrying about it.
2024-04-21 09:12:25 +02:00
Andreas Kling
44659f2f2a LibWeb+WebContent: Don't let PageClient keep documents alive
We were inadvertently keeping all documents alive by installing a
console client for them. This patch fixes the issue by adding a
finalizer to Document, and having that be the way we detach console
clients. This breaks the cycle.

With this change, we can spam set .innerHTML in a loop and memory
usage remains stable.

Fixes #14612
2024-04-21 09:12:25 +02:00
Andreas Kling
cd6a458e83 headless-browser: Add -G option to dump GC graph on exit
This will be useful in tracking down the list of GC leaks that occur
across a run of our test suite.
2024-04-21 09:12:25 +02:00
Andreas Kling
e993fb53d5 LibJS: Simplify iteration in GC heap dumping code 2024-04-21 09:12:25 +02:00
Jess
ecb7d4b40f LibJS: Throw RangeError in StringPrototype::repeat if OOM
currently crashes with an assertion failure in `String::repeated` if
malloc can't serve a `count * input_size` sized request, so add
`String::repeated_with_error` to propagate the error.
2024-04-20 19:23:46 -04:00
Jess
f4c8f1a346 Meta: Add ASAN option allocator_may_return_null=1 to CI
This stops ASAN from complaining about massive allocations.
2024-04-20 19:23:46 -04:00
Daniel Bertalan
cc92c3f551 LibCrypto+LibGfx: Fix GCC 14 compile errors
The C++ standard does not allow specifying the template parameters in
constructor declarations, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97202#c8.

Converting constructors have a higher priority that user-defined
conversion functions; let's constrain `Gfx::Size<T>(Gfx::Size<U>)` to
only be considered when `U` is convertible to `T`. This lets us fall
back to conversion operators in the case of `UISize` -> `IntSize`, for
instance. Clang is still okay without this, but MSVC would error out
similarly: https://godbolt.org/z/PTbeYPM7s

Note that a not-yet-committed patch is required for full compilation:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114784#c3
2024-04-20 15:52:29 -06:00
Kenneth Myhra
291d0e5de8 LibWeb: Let queue_fetch_task() take a JS::HeapFunction
Changes the signature of queue_fetch_task() from AK:Function to
JS::HeapFunction to be more clear to the user of the function that this
is what it uses internally.
2024-04-20 18:11:01 +02:00
Kenneth Myhra
a3661fd7f2 LibWeb: Let queue_global_task() take a JS::HeapFunction
Changes the signature of queue_global_task() from AK:Function to
JS::HeapFunction to be more clear to the user of the function that this
is what it uses internally.
2024-04-20 18:11:01 +02:00
Aliaksandr Kalenik
9540af6489 LibWeb: Fix nodesToRemove collecting traversal in Range::delete_contents
With this change children are no longer skipped in tree traversal when
start node of range equals to end node of range.

Fixes https://github.com/SerenityOS/serenity/issues/24036
2024-04-20 13:32:24 +02:00
Aliaksandr Kalenik
cedf6dd2c3 LibWeb: Remove unused blend mode param in FillEllipse painting command 2024-04-20 12:42:02 +02:00
Aliaksandr Kalenik
d3cfe35fbd LibWeb: Do not destroy document until whole subtree completed unloading
Fixes crashing when "unload" event handler tries to access active
document that has already been destroyed.
2024-04-20 10:22:14 +02:00
Sönke Holz
9881d10e38 LibELF: Add a small local-exec TLS test
Part 1 of this test uses a large array so we are more likely getting
segfaults when using an incorrect TLS layout.

The `volatile`s and `taint_for_optimiter`s should hopefully prevent the
compiler from optimizing the tests out.
2024-04-19 16:46:47 -06:00
Sönke Holz
9437b29b43 LibELF+LibC: Add support for Variant I of the TLS data structures
We currently only supported Variant II which is used by x86-64.
Variant I is used by both AArch64 (when using the traditional
non-TLSDESC model) and RISC-V, although with small differences.

The TLS layout for Variant I is essentially flipped. The static TLS
blocks are after the thread pointer for Variant I, while on Variant II
they are before it.

Some code using ELF TLS already worked on AArch64 and RISC-V even though
we only support Variant II. This is because only the local-exec model
directly uses TLS offsets, other models use relocations or
__tls_get_addr().
2024-04-19 16:46:47 -06:00
Sönke Holz
3af793abfd LibELF: Correct the comment at the top of AArch64's tls.S 2024-04-19 16:46:47 -06:00
Sönke Holz
74a51505f0 LibELF: Add headers describing the TLS layout of each architecture
All of our architectures sadly use a slightly different TLS layout.
These headers try to abstract the differences in a nice way.
2024-04-19 16:46:47 -06:00
Sönke Holz
243d7003a2 Kernel+LibC+LibELF: Move TLS handling to userspace
This removes the allocate_tls syscall and adds an archctl option to set
the fs_base for the current thread on x86-64, since you can't set that
register from userspace. enter_thread_context loads the fs_base for the
next thread on each context switch.
This also moves tpidr_el0 (the thread pointer register on AArch64) to
the register state, so it gets properly saved/restored on context
switches.

The userspace TLS allocation code is kept pretty similar to the original
kernel TLS code, aside from a couple of style changes.

We also have to add a new argument "tls_pointer" to
SC_create_thread_params, as we otherwise can't prevent race conditions
between setting the thread pointer register and signal handling code
that might be triggered before the thread pointer was set, which could
use TLS.
2024-04-19 16:46:47 -06:00
Sönke Holz
aa44fe860d LibELF: Change copy_initial_tls_data_into argument type to Bytes 2024-04-19 16:46:47 -06:00
Sönke Holz
8f0ebce404 LibELF: Reorganize TLS-related variables in DynamicLinker.cpp 2024-04-19 16:46:47 -06:00
Sönke Holz
cb48f31d79 LibELF: Add helpers for setting the thread pointer register 2024-04-19 16:46:47 -06:00