summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-10-11AK: Add support for ARCH(AARCH64) to Platform.hJames Mintram
2021-10-10AK: Implement a way to resolve relative paths lexicallyBen Wiederhake
2021-10-08AK: Always inline the RefCountedBase functionsAndreas Kling
2021-10-08AK: Calculate CircularQueue::end() correctly (for real this time)Peter Elliott
Both my approach and the previous approach were wrong for different cases. I've changed the Iterators index from storage-relative to queue-relative, and it's much simpler and more obviously correct. fixes #10383
2021-10-07Kernel: Note if the page fault address is a destroyed smart pointerLuke Wilde
While I was working on LibWeb, I got a page fault at 0xe0e0e0e4. This indicates a destroyed RefPtr if compiled with SANITIZE_PTRS defined. However, the page fault handler didn't print out this indication. This makes the page fault handler print out a note if the faulting address looks like a recently destroyed RefPtr, OwnPtr, NonnullRefPtr, NonnullOwnPtr, ThreadSafeRefPtr or ThreadSafeNonnullRefPtr. It will only do this if SANITIZE_PTRS is defined, as smart pointers don't get scrubbed without it being defined.
2021-10-07AK+Kernel: Make automatically locking RefPtr & co a kernel-only thingAndreas Kling
Some time ago, automatic locking was added to the AK smart pointers to paper over various race conditions in the kernel. Until we've actually solved the issues in the kernel, we're stuck with the locking. However, we don't need to punish single-threaded userspace programs with the high cost of locking. This patch moves the thread-safe variants of RefPtr, NonnullRefPtr, WeakPtr and RefCounted into Kernel/Library/.
2021-10-06AK: Add missing headersBen Wiederhake
Example failure: IDAllocator.h only pulls in AK/Hashtable.h, so any compilation unit that includes AK/IDAllocator.h without including AK/Traits.h before it used to be doomed to fail with the cryptic error message "In instantiation of 'AK::HashTable<T, TraitsForT, IsOrdered>::Iterator AK::HashTable<T, TraitsForT, IsOrdered>::find(const T&) [with T = int; TraitsForT = AK::Traits: incomplete type 'AK::Traits<int>' used in nested name specifier".
2021-10-06AK: Calculate CircularQueue::end() correctlyPeter Elliott
Previously end() was only correct when m_head == 0.
2021-10-05AK: Expand to_int<i64> to to_int<long> and to_int<long long>Peter Elliott
This change also applys to to_uint On i686 u64 == long long but on x86_64 u64 == long. Therefor on either arch, one of the instantiations is missed. This change makes sure that all integer types have an instantiation.
2021-10-03AK: Add a basic formatter for wchar_tTim Schumacher
2021-10-02AK: Simplify Utf16View::operator==(Utf16View)Andreas Kling
2021-10-02LibJS+AK: Use Vector<u16, 1> for UTF-16 string storageAndreas Kling
It's very common to encounter single-character strings in JavaScript on the web. We can make such strings significantly lighter by having a 1-character inline capacity on the Vectors.
2021-10-01RequestServer: Don't hide the SIGINFO state dump behind a debug macroAndreas Kling
Until we're confident that RequestServer doesn't need this runtime debug dump helper, it's much nicer if everyone has it built in, so they can simply send a SIGINFO if they see it acting up.
2021-10-01AK: Fix typosNico Weber
2021-09-29RequestServer: Use an OwnPtr for cached connectionsAli Mohammad Pur
Otherwise we'd end up trying to delete the wrong connection if a connection made before us is deleted. Fixes _some_ RequestServer spins (though not all...). This commit also adds a small debug mechanism to RequestServer (which can be enabled by turning REQUEST_SERVER_DEBUG on), that can dump all the current active connections in the cache, what they're doing, and how long they've been doing that by sending it a SIGINFO.
2021-09-28AK: Accept StringView in LexicalPath::joinRodrigo Tobar
The first argument for LexicalPath::join was a String const&, which resulted in an unnecessary memory copy when invoked with a StringView. Changing the type of the parameter to StringView avoids the extra cost. This was noticed while working on #10230.
2021-09-28AK: Eliminate avoidable strlen call in String::matchesIdan Horowitz
We already know the length of these substrings, so there's no need to check their lengths using strlen in the StringView(char*) constructor. This patch also removes an accidental 1-byte OOB read that was left over from when this method received null-terminated char pointers instead of string views, as well removes the unnecessary lambda call (two of the checks were impossible, and this was only called in one place, so we can just inline it)
2021-09-21AK: Introduce ability to default-initialize a VariantBen Wiederhake
I noticed that Variant<Empty, …> is a somewhat common pattern while working on #10080, and this will simplify a few use-cases. :^)
2021-09-20AK: Remove unnecessary include of <new> for non-`__serenity__` buildsAndrew Kaster
We already include `<new>` in AK/kmalloc.h when KERNEL is not defined, which applies to all non-`__serenity__` builds.
2021-09-20AK+LibC: Remove SERENITY_LIBC_BUILD guard around `<initializer_list>`Andrew Kaster
This was required before commit 5f724b6ca1aae3a5a8c7189069649e8a9347cca2 when we were building LibC before libstdc++ headers were available in the sysroot. However as noted in that commit, we never actually needed to be building LibC before libstdc++, so we can go ahead and remove this ancient hack.
2021-09-20AK: Remove unused ifdef for BUILDING_SERENITY_TOOLCHAINAndrew Kaster
The only use of this define was removed in commit 5f724b6ca1aae3a5a8c7189069649e8a9347cca2, over a year ago. The define was there to prevent the LibC build we built before libstdc++ from complaining about missing libgcc symbols. However, as noted in that commit, we never actually needed to build LibC at all.
2021-09-18AK: Inline all the trivial Utf8View functionsAndreas Kling
This improves parsing time on a large chunk of JS by ~3%.
2021-09-18AK: Make Utf8View constructors inline and remove C string constructorAndreas Kling
Using StringView instead of C strings is basically always preferable. The only reason to use a C string is because you are calling a C API.
2021-09-17AK/Vector: Add `Vector::reverse()` methodMustafa Quraish
This reverses the contents of the vector in-place.
2021-09-16AK: Reduce the scope of fraction_string to where it's neededBrian Gianforcaro
pvs-studio flagged this a potential optimization, as we only need to really construct the fraction_string if is_double is true.
2021-09-16AK: Use default constructor/destructor instead of declaring an empty oneBrian Gianforcaro
Default implementations allow for more optimizations. See: https://pvs-studio.com/en/docs/warnings/v832/
2021-09-15AK: Rename the local variable in the TRY() macro to avoid name clashesLinus Groh
"result" is a tad bit too generic to provide a clash-free experience - we found instances in LibJS where this breaks already. Essentially this doesn't work: auto foo = TRY(bar(result)); Because it expands to the following within the TRY() scope: { auto result = bar(result); ... } And that of course fails: error: use of ‘result’ before deduction of ‘auto’ The simple solution here is to use a name that is much less likely to clash with anything used in the expression ("_temporary_result"). :^)
2021-09-14AK: Add an abstraction over multiple disjoint buffersAli Mohammad Pur
DisjointChunks<T> provides a nice interface over multiple sequential Vector<T>'s, allowing the user to iterate over/index into/slice from said buffers as if they were a single contiguous buffer. To work with views on such objects, DisjointSpans<T> is provided, which has the same behaviour but does not own the underlying objects.
2021-09-14AK: Move the path argument of URL::append_path instead of copying itIdan Horowitz
2021-09-14AK: Make URL::m_port an Optional<u16>, Expose raw port getterIdan Horowitz
Our current way of signalling a missing port with m_port == 0 was lacking, as 0 is a valid port number in URLs.
2021-09-14AK: Add URL::cannot_have_a_username_or_password_or_portIdan Horowitz
As defined by the URL specification: https://url.spec.whatwg.org/#cannot-have-a-username-password-port
2021-09-14AK: Change URL::cannot_be_a_base_url, URL::is_valid return type to boolIdan Horowitz
There's no need to return a const reference (8 bytes) when the value is always used as a temporary bool (1 byte).
2021-09-14AK: Accept optional url and state override parameters in URLParserIdan Horowitz
These are required in the specification and used by the web's URL built-in, this commit also removes the Badge<AK::URL> from URLParser to allow other classes that need to call the parser directly like the web's URL built-in to do so.
2021-09-14AK: Add URL::serialize_origin based on HTML's origin definitionIdan Horowitz
2021-09-13AK: Remove unimplemented method `fill_buffer` from `UUID`James Puleo
2021-09-13AK: Make Span::operator==() comply with the ISO C++ idea of operator==Ali Mohammad Pur
This should: - Accept const& on both sides - Not involve implicit conversions on either side otherwise the argument order would be deemed significant, and trip this warning.
2021-09-13AK: Switch Span.h to east-const styleAli Mohammad Pur
2021-09-13AK: Give BumpAllocator a single-block cacheAli Mohammad Pur
This avoid excessive mmap/munmap traffic in normal operation.
2021-09-13AK: Allow RBTree::find_largest_not_above_iterator() to failAli Mohammad Pur
Previously this function would've crashed if the key failed to match any entry.
2021-09-13AK+Kernel: Avoid unescaped control chars in append_escaped_for_json()Ali Mohammad Pur
Otherwise it could produce invalid JSON.
2021-09-13AK: Make traits for NonnullOwnPtr use ptr_hash instead of int_hashAli Mohammad Pur
Otherwise they'd be truncating the pointer in 64-bit builds.
2021-09-13AK: Add secure_zero() implementation so it can be used on all platformsBrian Gianforcaro
Serenity has explicit_bzero() in LibC with the same implementation, however we need to be able to use this from Lagom on all platforms that we support building serenity on. I've implemented it in AK for this reason.
2021-09-12AK+LibCore: Standardize on AK_OS_MACOS instead of __APPLE__Brian Gianforcaro
We use our custom platform definitions in most places, remove the few remaining places we weren't using `AK_OS_MACOS`.
2021-09-12AK: Add the ability to hash the contents of a AK::HashMapBrian Gianforcaro
2021-09-12AK: Escape '"' in escape_html_entitiesPeter Elliott
2021-09-11AK: Replace the mutable String::replace API with an immutable versionIdan Horowitz
This removes the awkward String::replace API which was the only String API which mutated the String and replaces it with a new immutable version that returns a new String with the replacements applied. This also fixes a couple of UAFs that were caused by the use of this API. As an optimization an equivalent StringView::replace API was also added to remove an unnecessary String allocations in the format of: `String { view }.replace(...);`
2021-09-11AK: Make String::count not use strstr and take a StringViewIdan Horowitz
This was needlessly copying StringView arguments, and was also using strstr internally, which meant it was doing a bunch of unnecessary strlen calls on it. This also moves the implementation to StringUtils to allow API consistency between String and StringView.
2021-09-11AK: Forbid creating StringView from temporary FlyStringBen Wiederhake
2021-09-11AK: Forbid creating StringView from temporary ByteBufferBen Wiederhake
2021-09-10Kernel: Add kernelearlyputstr and use it in dbgln in very-early bootIdan Horowitz
This variant of dbgputstr does not lock the global log lock, as it is called before the current or any other processor was initialized, meaning that: A) The $gs base was not setup yet, so we cannot enter into critical sections, and as a result we cannot use SpinLocks B) No other processors may try to print at the same time anyway