Commit graph

17143 commits

Author SHA1 Message Date
Brian Gianforcaro
31e1b08e15 AK: Add support for AK::StringView literals with operator""sv
A new operator, operator""sv was added as of C++17 to support
string_view literals. This allows string_views to be constructed
from string literals and with no runtime cost to find the string
length.

See: https://en.cppreference.com/w/cpp/string/basic_string_view/operator%22%22sv

This change implements that functionality in AK::StringView.
We do have to suppress some warnings about implementing reserved
operators as we are essentially implementing STL functions in AK
as we have no STL :).
2021-02-24 14:38:31 +01:00
Andreas Kling
a48d54dfc5 Kernel: Don't dereference untrusted userspace pointer in sys$uname()
Instead of writing to the userspace utsname struct one field at a time,
build up a utsname on the kernel stack and copy it out to userspace
once it's finished. This is both simpler and gets validity checking
built-in for free.

Found by KUBSAN! :^)

Fixes #5499.
2021-02-24 14:37:36 +01:00
Andreas Kling
99cd0d3ffb Kernel: Improve KUBSAN logging for "type mismatch" errors
Parse out some more information about the error from the data we get.
2021-02-24 14:27:06 +01:00
Linus Groh
6ad3454bfb AK: Rename {DBGLN_NO => ENABLE}_COMPILETIME_FORMAT_CHECK
This is no longer limited to dbgln(). Also invert it to match all the
other ENABLE_FOO options.
2021-02-24 13:07:57 +01:00
AnotherTest
857cdee0d0 AK: Make dbgln_if() avoid evaluating the arguments when disabled
Naturally, this makes the `enabled` flag on dbgln() obsolete.
2021-02-24 13:07:28 +01:00
AnotherTest
71de5433f8 LibLine: Note that the search() call modifies the buffer
Fixes #5465.
2021-02-24 12:19:20 +01:00
AnotherTest
dd87b14f52 LibLine: Update the drawn cursor value when updating lazily 2021-02-24 12:19:20 +01:00
AnotherTest
21cbcdd7da LibLine: Properly update the main editor when clearing the search editor
This broke after the lazy update change :P
2021-02-24 12:19:20 +01:00
Sahan Fernando
bf68939bcc Profiler: Make sure rendered timestamps don't overflow
If you drag-select a slice of the profile off of the side of the
Profiler window, the profiler will try to render a negative start time,
which will overflow. This commit fixes that bug by clamping timestamps
to the start/end of the profile before rendering.
2021-02-24 12:19:01 +01:00
Linus Groh
7dd233b2b6 LibJS: Use const references to avoid some copies in the parser 2021-02-24 11:43:05 +01:00
Andreas Kling
692bfc6ba2 Kernel: Fix some number typos in Arch/i386/boot.S 2021-02-24 11:40:31 +01:00
Andreas Kling
f27eb315fc Build: Build Userland with -O2, Kernel with -Os
For some reason I don't yet understand, building the kernel with -O2
produces a way-too-large kernel on some people's systems.

Since there are some really nice performance benefits from -O2 in
userspace, let's do a compromise and build Userland with -O2 but
put Kernel back into the -Os box for now.
2021-02-24 11:38:52 +01:00
Brian Gianforcaro
0817ea01c2 CMake: Fix build incrementality for boot.S
Due to the non-standard way the boot assembler code is linked into
the kernel (not and actual dependency, but linked via linker.ld script)
both make and ninja weren't re-linking the kernel when boot.S was
changed. This should theoretically work since we use the cmake
`add_dependencies(..)` directive to express a manual dependency
on boot from Kernel, but something is obviously broken in cmake.

We can work around that with a hack, which forces a dependency on
a file we know will always exist in the kernel (init.cpp). So if
boot.S is rebuilt, then init.cpp is forced to be rebuilt, and then
we re-link the kernel. init.cpp is also relatively small, so it
compiles fast.
2021-02-24 10:28:59 +01:00
Brian Gianforcaro
90adfcad3a Toolchain: Upgrade BuildQemu.sh to the latest 5.2.0 release 2021-02-24 10:28:15 +01:00
Linus Groh
e640fdd395 LibJS: Let RegExpPrototype inherit from Object directly
https://tc39.es/ecma262/#sec-properties-of-the-regexp-prototype-object

The RegExp prototype object:
- is an ordinary object.
- is not a RegExp instance and does not have a [[RegExpMatcher]]
  internal slot or any of the other internal slots of RegExp instance
  objects.

In other words: no need to have RegExpPrototype inherit from
RegExpObject (we weren't even calling its initialize()).
2021-02-24 10:22:17 +01:00
Linus Groh
a72276407b LibJS: Make ArrayPrototype an Array object
https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object

The Array prototype object: [...] is an Array exotic object and has the
internal methods specified for such objects.

NOTE: The Array prototype object is specified to be an Array exotic
object to ensure compatibility with ECMAScript code that was created
prior to the ECMAScript 2015 specification.
2021-02-24 10:22:17 +01:00
Andreas Kling
84996c6567 Everywhere: Okay let's try that -O2 build again :^)
Now that the issue with the kernel outgrowing its slot is patched,
we should be able to boot a slightly larger kernel without trouble.
2021-02-23 21:52:26 +01:00
Andreas Kling
8cd5477e54 Kernel: Expand the kernel memory slot from 8 MiB to 16 MiB
We were only 448 KiB away from filling up the old slot size we reserve
for the kernel above the 3 GiB mark. This expands the slot to 16 MiB,
which allows us to continue booting the kernel until somebody takes
the time to improve our loader.
2021-02-23 21:50:18 +01:00
Andreas Kling
4ba36c6a49 Build: Revert back to building with -Os
-O2 kernels are failing to boot on other people's machines for some
reason that we need to investigate. In the meantime, let's revert.
2021-02-23 21:22:20 +01:00
Andreas Kling
679cc154e6 Everywhere: Remove unused RELEASE_ASSERT macro 2021-02-23 21:11:53 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
b33a6a443e LibELF: Inline DynamicObject::hash_section()
This was high up in profiles and gets almost entirely optimized out
when inlined, so let's do that.
2021-02-23 20:33:32 +01:00
Andreas Kling
4ed85e9b9e LibELF: Don't build barely-used section lookup table in ELF::Image
The name-to-section lookup table was only used in a handful of places,
and none of them were calling it nearly enough to justify building
a cache for it in the first place. So let's get rid of it and reduce
startup time by a little bit. :^)
2021-02-23 19:45:29 +01:00
Andreas Kling
06919d189b Kernel: Enable three missing KUBSAN options :^)
With the kernel command line issue fixed, we can now enable these
KUBSAN options without getting triple faults on startup:

* alignment
* null
* pointer-overflow
2021-02-23 19:43:44 +01:00
Andreas Kling
bc029a6314 Everywhere: Build with -O2 :^)
Let's try going faster instead of smaller.
2021-02-23 19:43:44 +01:00
Andreas Kling
5100dabb96 Kernel: Copy the kernel command line to a good location at boot
When building the kernel with -O2, we somehow ended up with the kernel
command line outside of the lower 8MB of physical memory. Since we don't
map that area in our initial page table setup, we would triple fault
when trying to parse the command line.

This patch sidesteps the issue by copying the (first 4KB of) the kernel
command line to a buffer in a known safe location at boot.
2021-02-23 19:43:44 +01:00
Andreas Kling
4172a46fb5 LibDebug: Fix build with -O2
It turns out that LibDebug was the only thing that couldn't be built
with -O2. We were neglecting to deal with some stream read errors.
2021-02-23 19:43:44 +01:00
Andreas Kling
22b8110554 LibELF: Avoid doing strlen() on everything while iterating GNU hash
It's a lot faster to iterate the GNU hash tables if we don't have to
compute the length of every symbol name before rejecting it anyway while
comparing the first character. :^)
2021-02-23 19:43:44 +01:00
Andreas Kling
46a94a9a9e LibELF: Rename lookup_elf_symbol() => lookup_sysv_symbol()
We have two kinds of lookup, SYSV and GNU hash. Both are ELF lookups.
2021-02-23 19:43:44 +01:00
Andreas Kling
cc00df0f0f LibELF: Avoid calling strlen() in DynamicObject::hash_section()
The long-term fix here is to make StringView recognize compile-time
string literals and do the right thing automatically.
2021-02-23 19:43:44 +01:00
Andreas Kling
d6af3302e8 LibELF: Don't recompute the same ELF hashes over and over
When performing a global symbol lookup, we were recomputing the symbol
hashes once for every dynamic object searched. The hash function was
at the very top of a profile (15%) of program startup.

With this change, the hash function is no longer visible among the top
stacks in the profile. :^)
2021-02-23 19:43:44 +01:00
Andreas Kling
af6a633468 LibELF: Remove an ungodly amount of DYNAMIC_LOAD_DEBUG logging
This logging mode was unusable anyway since it spams way too much.
The dynamic loader is in a pretty good place now anyway, so I think
it's okay for us to drop some of the bring-up debug logging. :^)

Also, we have to be careful with dbgln_if(FOO_DEBUG, "{}", foo())
where foo() is something expensive, since it might get evaluated
even if !FOO_DEBUG.
2021-02-23 19:43:44 +01:00
Andreas Kling
37420f1baf LibELF: Move ELF hash functions to their own file (and make constexpr) 2021-02-23 19:43:44 +01:00
Andreas Kling
145923bdc9 AK: Slap Optional with the ALWAYS_INLINE stick
I saw some Optional constructors when profiling the dynamic loader
and that seemed silly since we can inline them at no/little cost.
2021-02-23 17:42:05 +01:00
Andreas Kling
de52fe6156 Kernel: Only build with -fsanitize=* if using GCC
Clangd (CLion) was choking on some of the -fsanitize options, and since
we're not building the kernel with Clang anyway, let's just disable
the options for non-GCC compilers for now.
2021-02-23 17:41:34 +01:00
Andreas Kling
31ac93d051 AK: Optimize StringView::operator==(const char*) a little bit
Don't compute the strlen() of the string we're comparing against first.
This can save a lot of time if we're comparing against something that
already fails to match in the first few characters.
2021-02-23 17:41:18 +01:00
Andreas Kling
87bb00f6ab Build: Only use -fstack-clash-protection with GCC
This is not yet supported by Clang, so let's disable it for non-GCC
compilers for now. (CLion was whining about it.)
2021-02-23 17:41:03 +01:00
Brandon Scott
99e6c9b23d Browser: Implement view source for out of process mode
Implemented view source functionality for out of process mode
and moved view source dialog creation into seperate static
method.
2021-02-23 16:23:56 +01:00
Brandon Scott
2f56a86a4e LibWeb: Added get source functionality and hook event 2021-02-23 16:23:56 +01:00
Brandon Scott
306501fd4a WebContent: Added IPC calls for getting source 2021-02-23 16:23:56 +01:00
Brendan Coles
a032c836c4 HexEditor: Add menu icons for search menu items 2021-02-23 15:56:11 +01:00
AnotherTest
7c2754c3a6 AK+Kernel+Userland: Enable some more compiletime format string checks
This enables format string checks for three more functions:
- String::formatted()
- Builder::appendff()
- KBufferBuilder::appendff()
2021-02-23 13:59:33 +01:00
AnotherTest
c989e55195 LibWeb: Fix a tiny appendff() format issue
This would've just left the colour on for a few characters, nothing _too_ bad.
2021-02-23 13:59:33 +01:00
AnotherTest
347d741afb AK+Userland: Extend the compiletime format string check to other functions
Thanks to @trflynn89 for the neat implicit consteval ctor trick!
This allows us to basically slap `CheckedFormatString` on any
formatting function, and have its format argument checked at compiletime.

Note that there is a validator bug where it doesn't parse inner replaced
fields like `{:~>{}}` correctly (what should be 'left align with next
argument as size' is parsed as `{:~>{` following a literal closing
brace), so the compiletime checks are disabled on these temporarily by
forcing them to be StringViews.

This commit also removes the now unused `AK::StringLiteral` type (which
was introduced for use with NTTP strings).
2021-02-23 13:59:33 +01:00
AnotherTest
29c8d34be7 HackStudio: Fix a misuse of dbgln() intended as dbgln_if()
This currently works accidentally, just because there's an overload for
`dbgln<bool>(...)` - it just bypasses the compiletime checks.
2021-02-23 13:59:33 +01:00
AnotherTest
644d981b2b AK: Untangle TestSuite assertions a bit 2021-02-23 13:59:33 +01:00
AnotherTest
531d72fdfd Kernel: Fix a dmesgln() format error 2021-02-23 13:59:33 +01:00
AnotherTest
1c4e15117d UserspaceEmulator: Fix an outln() format bug 2021-02-23 13:59:33 +01:00
Brendan Coles
501834ba45 Inspector: Add help documentation 2021-02-23 13:52:16 +01:00
Andreas Kling
82278d632f LibWeb: Only scroll BlockBox on wheel event if overflow==scroll
We implement this by adding a BlockBox::is_scrollable() helper,
and then ignoring wheel events for non-scrollable boxes.

Thanks to FireFox317 for pointing this out! :^)
2021-02-22 23:44:51 +01:00