Commit graph

19143 commits

Author SHA1 Message Date
Gunnar Beutner dd0a4b36fb Utilities: Fix division by zero
top crashes when sum_diff is zero.

CrashDaemon(15): --- Backtrace for thread #0 (TID 3052) ---
CrashDaemon(15): 0x96537f56: [/bin/top] main +0x4f6 (top.cpp:204)
CrashDaemon(15): 0x96538138: [/bin/top] _start +0x58 (crt0.cpp:58)
2021-04-17 09:25:06 +02:00
Andreas Kling 873da38d0e AK: Remove String-from-StringView optimization
We had an unusual optimization in AK::StringView where constructing
a StringView from a String would cause it to remember the internal
StringImpl pointer of the String.

This was used to make constructing a String from a StringView fast
and copy-free.

I tried removing this optimization and indeed we started seeing a
ton of allocation traffic. However, all of it was due to a silly
pattern where functions would take a StringView and then go on
to create a String from it.

I've gone through most of the code and updated those functions to
simply take a String directly instead, which now makes this
optimization unnecessary, and indeed a source of bloat instead.

So, let's get rid of it and make StringView a little smaller. :^)
2021-04-17 01:27:31 +02:00
Andreas Kling 94b247c5a9 LibELF: Make get_library_name() take String instead of StringView 2021-04-17 01:27:31 +02:00
Andreas Kling a1a6d30b54 LibCore: Make File take String instead of StringView 2021-04-17 01:27:31 +02:00
Andreas Kling 510aad6515 LibCore: Make DirIterator take String instead of StringView 2021-04-17 01:27:30 +02:00
Andreas Kling 0e4eb62dd8 LibGUI: Make some API's take String instead of StringView 2021-04-17 01:27:30 +02:00
Andreas Kling 36f27094d0 LibTTF: Make load_from_file() take String instead of StringView 2021-04-17 01:27:30 +02:00
Andreas Kling 0528dc9b87 FileManager: Make DirectoryView API's take String instead of StringView 2021-04-17 01:27:30 +02:00
Andreas Kling 1f684c8123 AK: Implement case-insensitive StringUtils::matches() without allocs
Previously this would create new to_lowercase()'d strings from the
needle and the haystack. This generated a huge amount of malloc
traffic in some programs.
2021-04-17 01:27:30 +02:00
Andreas Kling f7139d9422 AK: Make LexicalPath take String instead of StringView 2021-04-17 01:27:30 +02:00
Andreas Kling e873d27ab1 LibGfx: Switch a bunch of API's from taking StringView to String
These were all getting converted into String internally anyway.
2021-04-17 01:27:30 +02:00
Andreas Kling 050648b270 LibGUI: Make Window::set_title() take a String 2021-04-17 01:27:29 +02:00
Andreas Kling 942a5afd23 LibCore: Don't needlessly use StringView in Core::Object APIs
Taking a StringView parameter that gets immediately converted to
a String anyway is silly. Just take a String directly instead.

This pattern is the main reason we have the "StringView internal
StringImpl pointer" optimization, and I suspect that we can throw
that whole thing out if we make a couple more patches like this.
2021-04-17 01:27:29 +02:00
Andreas Kling 73aa59ccf1 Network.Applet: Avoid JsonObject copy and use StringBuilder::appendff() 2021-04-17 01:27:29 +02:00
Andreas Kling d33fdc925b LibGUI: Make GUI::Widget::set_tooltip() take a String
There was no reason for this to take a StringView.
2021-04-17 01:27:29 +02:00
Nicholas-Baron 4454735bf8 Kernel: Add -Wnull-dereference flag
`-Wnull-dereference` has found a lot of "possible null dereferences" in userland.
However, in the kernel, no warnings occurred. To keep it that way,
preemptivly add the flag here and remove it once it is enabled system
wide.

This flag makes the compiler check statically for a null deref. It does
not take into account any human-imposed invariants and as such, may need a
`VERIFY(ptr);`, `if(ptr)`, or `if(!ptr)` before using a pointer.
However, as long as a pointer is not reassigned,
the verify will be valid, meaning that adding `VERIFY` can be done sparingly.
2021-04-17 01:07:36 +02:00
Idan Horowitz 586f10b6e1 LibJS: Accept symbol property in the in operator
This is used by discord.com and allowed by the specification:
https://tc39.es/ecma262/#sec-relational-operators-runtime-semantics-evaluation
2021-04-17 00:59:36 +02:00
Tobias Christiansen 7744048d0f LibWeb: Fix misplaced bullet points on list items
The bullet point should not be centered in the height of the list item,
but rather stay in front of the first line.
So, instead of giving the marker the full height of the ListItemBox,
it gets the height of a single line.

This closes #6384
2021-04-17 00:28:55 +02:00
Idan Horowitz e3c634fdd0 LibJS: Implement initializing a TypedArray from an iterable object
Based on these specifications (which required IterableToList as well):
https://tc39.es/ecma262/#sec-typedarray
https://tc39.es/ecma262/#sec-initializetypedarrayfromlist
2021-04-17 00:24:09 +02:00
Idan Horowitz 06a2173586 LibJS: Implement initializing a TypedArray from an array-like object
Used by twitch.tv and based on the following specification:
https://tc39.es/ecma262/#sec-initializetypedarrayfromarraylike
2021-04-17 00:24:09 +02:00
James Triantafylos c9196995be LibGUI: Allow arbitrary font size in FontPicker
This commit adds a SpinBox to the FontPicker dialog to allow users to
set arbitrary font sizes (1 to 255 inclusive) for TTF fonts.
The SpinBox is only visible when the user is selecting a TTF font.
2021-04-16 23:54:03 +02:00
AnotherTest e4412f1f59 AK+Kernel: Make IntrusiveList capable of holding non-raw pointers
This should allow creating intrusive lists that have smart pointers,
while remaining free (compared to the impl before this commit) when
holding raw pointers :^)
As a sidenote, this also adds a `RawPtr<T>` type, which is just
equivalent to `T*`.
Note that this does not actually use such functionality, but is only
expected to pave the way for #6369, to replace NonnullRefPtrVector<T>
with intrusive lists.

As it is with zero-cost things, this makes the interface a bit less nice
by requiring the type name of what an `IntrusiveListNode` holds (and
optionally its container, if not RawPtr), and also requiring the type of
the container (normally `RawPtr`) on the `IntrusiveList` instance.
2021-04-16 22:26:52 +02:00
AnotherTest fb814ee720 AK: Avoid the unnecessarily confusing bunch of casts in IntrusiveList
And use bit_cast instead.
Also explain what it does, because it's not at all trivial
to understand :^)
2021-04-16 22:26:52 +02:00
Brendan Coles cfad6606f0 Ports: SDL2: Use correct CMAKE_TOOLCHAIN_FILE in configopts 2021-04-16 21:49:51 +02:00
AnotherTest 00e5af02be CI: Use clang-12 instead of clang-10 when building fuzzers
oss-fuzz uses clang-12 anyway, so this patch shouldn't be breaking
anything, just letting us use more modern C++ without the CI being
sad.
2021-04-16 21:48:00 +02:00
Linus Groh ba3bc6fef2 LibGUI+WindowServer: Fix some misaligned CMakeLists.txt SOURCES entries 2021-04-16 21:30:53 +02:00
Brendan Coles bb6bb7bc5e Meta: lint-ports: Check package files for required properties 2021-04-16 21:14:00 +02:00
Brendan Coles a206ab2211 Ports: Add auth_type verification to all package.sh files 2021-04-16 21:14:00 +02:00
Hendiadyoin1 6c618eb072 HexEditor: Use debgln_if 2021-04-16 20:03:35 +02:00
Hendiadyoin1 b8d381690c UserspaceEmulator: use outln_if 2021-04-16 20:03:35 +02:00
Hendiadyoin1 2e11b2d35a AK: Add outln_if and warnln_if
This uses the same gating mechanism as dbgln_if and should be equivalent
to #define flag etc
2021-04-16 20:03:35 +02:00
Jagger De Leo 2976311536 PixelPaint: Add keyboard zoom shortcuts
You can now use Ctrl+= and Ctrl+- to zoom in and out.
2021-04-16 19:57:28 +02:00
Jagger De Leo b48b8c372e PixelPaint: Add Zoom Reset button to new View Menubar.
If you lose your image while panning and zooming around, it is handy to
have a reset function to get back home. :^)
2021-04-16 19:57:28 +02:00
Idan Horowitz 223472c57f LibJS: Dont try to serialize symbol-keyed properties
As per the specification: "All Symbol-keyed properties will be
completely ignored, even when using the replacer function."
2021-04-16 19:22:29 +02:00
Idan Horowitz fff7aceb9d LibJS: Accept symbol property in ObjectPrototype::hasOwnProperty
This is used by discord.com and allowed by the specification
(https://tc39.es/ecma262/#sec-topropertykey)
2021-04-16 19:22:29 +02:00
Timothy Flynn 2381b19719 Browser+LibWeb+WebContent: Parse cookies in the OOP tab
To protect the main Browser process against nefarious cookies, parse the
cookies out-of-process and then send the parsed result over IPC to the
main process. This way, if the cookie parser blows up, only that tab
will be affected.
2021-04-16 19:19:31 +02:00
Timothy Flynn 6e10c2cdb7 LibCore+LibIPC: Add IPC coder for Core::DateTime
Since LibCore cannot depend on LibIPC, the coders are defined in LibIPC
just like they are for Core::AnonymousBuffer.
2021-04-16 19:19:31 +02:00
Timothy Flynn 99e1d8a359 AK: Add type alias for AK::Optional 2021-04-16 19:19:31 +02:00
Timothy Flynn 67884f6747 LibWeb: Impose a sane max cookie size
Drop cookies larger than 4KiB. This value is the RFC's recommendation:
https://tools.ietf.org/html/rfc6265#section-6.1
2021-04-16 19:19:31 +02:00
Gunnar Beutner da92c0e1ca Ports: Build shared libraries for a few more ports
This manually builds shared libraries for a bunch of ports. Using
libtool would be preferable but that's currently broken so I'm
linking the shared libraries manually.
2021-04-16 19:04:24 +02:00
Gunnar Beutner c9d5358685 Ports: Make sure ports are installed into /usr/local 2021-04-16 19:04:24 +02:00
Gunnar Beutner 960079b020 LibELF: Add support for loading libraries from /usr/local 2021-04-16 19:04:24 +02:00
Gunnar Beutner 594d480391 Toolchain+Ports: Move the CMake toolchain file into a subdirectory 2021-04-16 19:04:24 +02:00
Gunnar Beutner c6c1e2037b Toolchain: Add platform definition for CMake
This also ensures that pkg-config finds packages in /usr/local
and changes the install prefix to /usr/local.
2021-04-16 19:04:24 +02:00
Nicholas-Baron 73dd293ec4 Everywhere: Add -Wdouble-promotion warning
This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
2021-04-16 19:01:54 +02:00
AnotherTest 6606d70826 LibDebug/Dwarf: Use dbgln_if() instead of '#if DWARF_DEBUG' 2021-04-16 19:00:30 +02:00
Gunnar Beutner 03d705d531 UserspaceEmulator: Print stacktrace for unhandled exceptions 2021-04-16 19:00:30 +02:00
Gunnar Beutner b731db6691 LibDebug: Add support for StandardOpcodes::FixAdvancePc 2021-04-16 19:00:30 +02:00
Gunnar Beutner 4f6914a0c0 LibDebug: Add array bounds check for m_source_files 2021-04-16 19:00:30 +02:00
Linus Groh a5d4ef462c LibJS: Remove #if !defined(KERNEL)
AK::JsonValue::{is,as}_double() is not available in the kernel, but that
doesn't affect LibJS.
2021-04-16 18:57:58 +02:00