Commit graph

2115 commits

Author SHA1 Message Date
Idan Horowitz 6704961c82 AK: Replace the mutable String::replace API with an immutable version
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-11 20:36:43 +03:00
Idan Horowitz 6d2b003b6e AK: Make String::count not use strstr and take a StringView
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-11 20:36:43 +03:00
Ben Wiederhake 9413dddb8b AK: Forbid creating StringView from temporary FlyString 2021-09-11 13:22:51 +03:00
Ben Wiederhake f6d0955a46 AK: Forbid creating StringView from temporary ByteBuffer 2021-09-11 13:22:51 +03:00
Idan Horowitz 6348b63476 Kernel: Add kernelearlyputstr and use it in dbgln in very-early boot
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
2021-09-10 22:58:08 +03:00
Idan Horowitz 18d2a74e62 AK: Only try and get the Processor::current_id when it was initialized
This caused a null pointer dereference on early boot, since the gs_base
was not set yet.
2021-09-10 22:58:08 +03:00
Ali Mohammad Pur 14c8373eb0 AK+Kernel: Reduce the number of template parameters of IntrusiveRBTree
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
2021-09-10 18:05:46 +03:00
Ali Mohammad Pur 5a0cdb15b0 AK+Everywhere: Reduce the number of template parameters of IntrusiveList
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
2021-09-10 18:05:46 +03:00
Hendiadyoin1 93cf01ad7d AK: Mark HashTable::size_in_bytes() as constexpr 2021-09-10 14:33:53 +00:00
Hediadyoin1 1aa527f5b6 AK: Add OOM safe interface to HashTable/Map
This adds a new HashSetResult only returned by try_set, to signal
allocation failure during setting.
2021-09-10 14:33:53 +00:00
Idan Horowitz 679bde06ed AK: Remove a redundant double find-call in HashMap::ensure
If the value was found there's no reason to search for it again.
2021-09-10 15:26:41 +03:00
Idan Horowitz 0279fb4dd3 AK: Add key getter to IntrusiveRedBlackTreeNode 2021-09-08 19:17:07 +03:00
Idan Horowitz cb9720baab AK: Set IntrusiveRBTree Node key on insertion instead of construction
This makes the API look much nicer.
2021-09-08 19:17:07 +03:00
Idan Horowitz 1db9250766 AK: Make IntrusiveRedBlackTree capable of holding non-raw pointers
This is completely based on e4412f1f59
and will allow us to convert some AK::HashMap users in the kernel.
2021-09-08 19:17:07 +03:00
sin-ack f633fb706e AK: Add note about an internal compile error with Optional in GCC 10.3+
This bit me because I accidentally made the destructor for a class which
was wrapped in an Optional private. This causes none of the Optional
destructors to be able to be deduced, which when combined with concepts
causes an internal compile error in GCC 10.3.0+. This commit adds a note
here to make sure that future encounters of this bug does not surprise
people.
2021-09-08 00:37:19 +02:00
Andreas Kling 6ad427993a Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
Ali Mohammad Pur d4e425e52e AK: Use the full name of 'integer_sequence_generate_array' in Variant.h
c27abaabc4 moved this out of the global
namespace, but did not qualify its users.
While this seems to be fine (sometimes, somehow), let's qualify it to
avoid random breakage.
2021-09-06 21:26:47 +02:00
Andreas Kling b096e85777 AK: Make Json{Array,Object}Serializer ignore append() return values
This is in preparation for making KBufferBuilder::append() and friends
return a KResult. Long-term we should come up with a solution that works
for both kernel and userspace clients of the JSON API.
2021-09-06 18:56:51 +02:00
Ali Mohammad Pur 97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Ali Mohammad Pur 3a9f00c59b Everywhere: Use OOM-safe ByteBuffer APIs where possible
If we can easily communicate failure, let's avoid asserting and report
failure instead.
2021-09-06 01:53:26 +02:00
Ali Mohammad Pur 6606993432 AK: Add OOM-safe ByteBuffer::try_{resize,append,ensure_capacity}() APIs 2021-09-06 01:53:26 +02:00
Brian Gianforcaro 112de58fe0 AK: Add AssertSize utility template to provide rich type size assertions
This type is useful, as the sizes will be visible in the compiler error
messages, as they will be part of the template parameters. This is not
possible with a normal static_assert of the sizeof a type.
2021-09-05 20:08:57 +02:00
Andreas Kling b4d8e166d8 AK: Add a TRY(expression) macro to simplify the unwrap-or-return pattern
The way we use classes like Kernel::KResultOr<T> and AK::Result<T, E>
makes checking for errors (and short-circuiting returns) quite verbose.

This patch adds a new TRY(expression) macro that either evaluates to
the released result of the expression if successful, or returns the
error if not.

Before:

    auto foo_or_error = get_foo();
    if (foo_or_error.is_error())
        return foo_or_error.release_error();
    auto foo = foo_or_error.release_value();

After:

    auto foo = TRY(get_foo());

The macro uses a GNU C++ extension which is supported by GCC, Clang,
Intel C++, and possibly others. It's not *ideal*, but since it makes our
codebase considerably nicer, let's try(!) it out. :^)

Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
2021-09-05 14:08:12 +02:00
sin-ack 566c5d1e99 AK+Kernel: Move KResult.h to Kernel/API for userspace access
This commit moves the KResult and KResultOr objects to Kernel/API to
signify that they may now be freely used by userspace code at points
where a syscall-related error result is to be expected. It also exposes
KResult and KResultOr to the global namespace to make it nicer to use
for userspace code.
2021-09-05 12:54:48 +02:00
Idan Horowitz e8f6840471 AK+LibRegex: Disable construction of views from temporary Strings 2021-09-04 21:01:15 +02:00
Andreas Kling 1a71e20f93 AK: Add HashMap::ensure(key, callback)
This function ensures that a key is present in the HashMap.
If it's not present, it is inserted, and the corresponding value
is initialized with whatever the callback returns.

It allows us to express this:

    auto it = map.find(key);
    if (it == map.end()) {
        map.set(it, make_a_value());
        it = map.find(key);
    }
    auto& value = it->value;

Like this:

    auto& value = map.ensure(key, [] { return make_a_value(); });

Note that the callback is only invoked if we have to insert a missing
key into the HashMap. This is important in case constructing the default
value is expensive or otherwise undesirable.
2021-09-04 20:30:56 +02:00
Stephan Unverwerth a595345e7c AK: Make declaration of std::move and std::forward optional
This introduces a new define AK_DONT_REPLACE_STD that disables our own
implementation of std::move and std::forward. Some ports include both
STL and AK headers which causes conflicts when trying to resolve those
functions. The port can define AK_DONT_REPLACE_STD before including
Serenity headers in that case.
2021-09-04 16:32:54 +02:00
Andreas Kling 7dda773426 AK: Add rvalue-ref qualifiers for Optional's value() and value_or()
This avoids a value copy when calling value() or value_or() on a
temporary Optional. This is very common when using the HashMap::get()
API like this:

    auto value = hash_map.get(key).value_or(fallback_value);
2021-09-04 03:02:08 +02:00
Andreas Kling 0b36499f46 AK: Convert Optional.h to east-const style 2021-09-04 03:02:08 +02:00
Daniel Bertalan d7b6cc6421 Everywhere: Prevent risky implicit casts of (Nonnull)RefPtr
Our existing implementation did not check the element type of the other
pointer in the constructors and move assignment operators. This meant
that some operations that would require explicit casting on raw pointers
were done implicitly, such as:
- downcasting a base class to a derived class (e.g. `Kernel::Inode` =>
  `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp),
- casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>`
  in LibIMAP/Client.cpp)

This, of course, allows gross violations of the type system, and makes
the need to type-check less obvious before downcasting. Luckily, while
adding the `static_ptr_cast`s, only two truly incorrect usages were
found; in the other instances, our casts just needed to be made
explicit.
2021-09-03 23:20:23 +02:00
Andreas Kling eaf88cc78a AK: Rename create<T> => make_ref_counted<T>
And also try_create<T> => try_make_ref_counted<T>.

A global "create" was a bit much. The new name matches make<T> better,
which we've used for making single-owner objects since forever.
2021-09-03 02:36:09 +02:00
Andreas Kling f4c4b42db9 AK: Move forward() into the std namespace
Same as we already did with move(). This allows compiler diagnostics
and static analyzers like SonarCloud to detect more issues.
2021-09-01 23:02:18 +02:00
Brian Gianforcaro fee2a03ba9 AK: Pass AK::Format TypeErasedFormatParams by reference in AK::String
This silences a overeager warning in sonar cloud, warning that
slicing could occur with `VariadicFormatParams` which derives from
`TypeErasedFormatParams`.

Reference:
https://sonarcloud.io/project/issues?id=SerenityOS_serenity&issues=AXuVPBW3k92xXUF3qXTE&open=AXuVPBW3k92xXUF3qXTE

This is a continuation of f0b3aa0331.
2021-09-01 18:06:14 +02:00
Brian Gianforcaro 10f5a046c4 AK: Remove dead store from Time:operator+
This is written, but never read again, and is thus useless.
2021-09-01 01:22:14 +02:00
Tobias Christiansen dcf06a4f40 AK: Add Statistics helper
This patch adds a helper to AK which allows for basic statistical
analysis of values.
The median algorithm is very naive and slow, but it works.
2021-08-31 16:38:22 +02:00
Ali Mohammad Pur 60d43d6969 AK: Don't perform the shift when it's too large when decoding LEB128
Prior to this, we calculated whether the shift was too large for the
result, and then did the shift regardless.
Found by OSS-Fuzz: https://oss-fuzz.com/testcase-detail/6046441716973568
2021-08-31 16:37:49 +02:00
kleines Filmröllchen 8f4b577405 AK: Make SinglyLinkedList::remove() public
This is a nice API to have outside of the class, and it is convenient
for LibDSP.
2021-08-31 17:03:55 +04:30
Hediadyoin1 fdef6e5f76 AK: Add FixedPoint arithmetic helper
Co-authored-by: Hendiadyoin1 <leon2002.la@gmail.com>
Co-authored-by: kleines Filmröllchen <malu.bertsch@gmail.com>
2021-08-31 17:03:55 +04:30
Timothy Flynn 587d4663a3 AK: Return early from swap() when swapping the same object
When swapping the same object, we could end up with a double-free error.
This was found while quick-sorting a Vector of Variants holding complex
types, reproduced by the new swap_same_complex_object test case.
2021-08-30 19:42:40 +01:00
Andreas Kling 9fd58fd6d8 AK: Use get_random() in IDAllocator
Also generate a new random ID on collision, instead of using
the old ID + 1. :^)

SonarCloud: https://sonarcloud.io/project/security_hotspots?id=SerenityOS_serenity&hotspots=AXuVPBMNk92xXUF3qWZd
2021-08-30 18:35:36 +02:00
Brian Gianforcaro 1f68b1f768 AK: Add operator delete stub to all AK_MAKE_ETERNAL objects
Static analysis correctly flags that we are missing an implementation
for `operator delete` for all classes which are annotated with
AK_MAKE_ETERNAL. To appease static analysis define an implementation
which asserts to make sure no one ever calls delete on the object.
2021-08-30 16:44:16 +02:00
Brian Gianforcaro f0b3aa0331 Everywhere: Pass AK::Format TypeErasedFormatParams by reference
This silences a overeager warning in sonar cloud, warning that
slicing could occur with `VariadicFormatParams` which derives from
`TypeErasedFormatParams`.

Reference:
https://sonarcloud.io/project/issues?id=SerenityOS_serenity&issues=AXuVPBO_k92xXUF3qWsm&open=AXuVPBO_k92xXUF3qWsm
2021-08-30 15:50:00 +04:30
kleines Filmröllchen f99e6507ee AK: Add Traits for Enums
Enums can be hashed as their underlying integral type. This allows enum
keys in hash maps etc.
2021-08-27 23:35:27 +04:30
Timothy Flynn 262e412634 AK: Implement method to convert a String/StringView to title case
This implementation preserves consecutive spaces in the orginal string.
2021-08-26 22:04:09 +01:00
Ali Mohammad Pur 355c2eef57 AK: Make explode_byte depend on sizeof(FlatPtr) instead of ARCH(...)
The assumption that FlatPtr is 64-bit on every platform except i686 is
not correct, and also makes the definition of explode_byte() less nice
to look at.
2021-08-26 22:00:17 +02:00
Andreas Kling c915174563 Userland: Remove IRC Client
The IRC Client application made some sense while our main communication
hub was an IRC channel. Now that we've moved on, IRC is just a random
protocol with no particular relevance to this project.

This also has the benefit of removing one major client of the single-
process Web::InProcessWebView class.
2021-08-24 16:37:28 +02:00
Hendiadyoin1 607bddac96 AK: Use explode_byte for pointer sanitization 2021-08-23 12:30:29 +04:30
Andreas Kling dea93a8bb9 Kernel: Rename Processor::id() => current_id()
And let id() be the non-static version that gives you the ID of a
Processor object.
2021-08-23 00:02:09 +02:00
Richard Wurth 4b2953125b AK: Use POSIX specified types for Time::to_timespec and to_timeval
The previous implementation assumed 64-bit time_t and 32-bit long,
which is not true on some 32-bit systems
2021-08-22 17:07:11 +02:00
Jesse Buhagiar 2fe5f1528f AK: Use __builtin_bit_cast if available
We now use the compiler's buitin version of bitcast if it's available
instead of just resorting to using the builtin `memcpy`.
2021-08-21 13:48:59 +04:30
Timothy Flynn fd8ccedf2b AK: Add GenericLexer API to consume an escaped Unicode code point
This parsing is already duplicated between LibJS and LibRegex, and will
shortly be needed in more places in those libraries. Move it to AK to
prevent further duplication.

This API will consume escaped Unicode code points of the form:
    \\u{code point}
    \\unnnn (where each n is a hexadecimal digit)
    \\unnnn\\unnnn (where the two escaped values are a surrogate pair)
2021-08-19 23:49:25 +02:00
Timothy Flynn 02e3633b7f AK: Move FormatParser definition from header to implementation file
This is primarily to be able to remove the GenericLexer include out of
Format.h as well. A subsequent commit will add AK::Result to
GenericLexer, which will cause naming conflicts with other structures
named Result. This can be avoided (for now) by preventing nearly every
file in the system from implicitly including GenericLexer.

Other changes in this commit are to add the GenericLexer include to
files where it is missing.
2021-08-19 23:49:25 +02:00
Timothy Flynn e331656bb9 AK: Add GenericLexer to forwarding header 2021-08-19 23:49:25 +02:00
Idan Horowitz 95bc8e4641 LibCore: Make DateTime's members signed
Core::DateTime is essentially a C++ wrapper of the tm struct, so we
should support the same signed range as the underlying tm.
2021-08-19 19:15:00 +01:00
Brian Gianforcaro 8e41d96618 AK: Enable IntrusiveList self reference to be optimized out when empty
If a member is an empty class, the standard normally stats that it needs
to have a size of at least 1 byte in order to guarantee that the
addresses of distinct objects of the same type are always distinct.

However as of c++20, we can use [[no_unique_address]] to instruct the
compiler that if the member has an empty type, it may optimize it to
occupy no space.
2021-08-19 08:07:45 +04:30
Brian Gianforcaro e9d8f158a1 AK+Kernel: StringView hash map Traits should not set peek type to String
This typo / bug in the Traits<T> implementation for StringView caused
AK::HashMap methods to return a `String` when looking up values out of
a hash map of type HashTable<StringView,StringView>.

This change fixes the typo, and fixes the only consumer, the kernel
Commandline class.
2021-08-18 10:21:19 +02:00
Timothy Flynn c4ee576531 AK: Add Utf8View::byte_offset_of overload for code point index lookups 2021-08-18 09:47:09 +04:30
sin-ack 8269e1a197 AK: Add adopt_nonnull_own_or_enomem
This is basically a complement to adopt_nonnull_ref_or_enomem, and
simplifies boilerplate for try_create functions which just return ENOMEM
or the object based on whether it was able to allocate.
2021-08-15 15:41:02 +02:00
Lenny Maiorani c27abaabc4 AK: Stop publishing detail namespaced functions
Problem:
- `AK::Detail::integer_sequence_generate_array` is published via a
  `using` directive in the `Array.h` header, but this is a `Detail`
  function.

Solution:
- Remove the `using` declaration.
2021-08-15 15:14:19 +02:00
Andreas Kling 90c7307c6c AK: Pull RefCountedBase into the global namespace 2021-08-15 12:44:35 +02:00
Brian Gianforcaro a2a5cb0f24 AK: Add Time::is_negative() to detect negative time values 2021-08-15 12:20:38 +02:00
Brian Gianforcaro 3cbc2364a8 AK: Annotate AK::Time APIs as [[nodiscard]] 2021-08-15 12:20:38 +02:00
Brian Gianforcaro dae17ce7e3 AK: Add Time::now_<clock_id> functions for obtaining the current time
In the quest of removing as timespec / timeval usage in the Userland as
possible, we need a way to conveniently retrieving the current clock
time from the kernel and storing it in `AK::Time` format.
2021-08-15 12:20:38 +02:00
sin-ack 134dbe2607 AK: Add adopt_nonnull_ref_or_enomem
This gets rid of the ENOMEM boilerplate for handling memory allocation
failures in the kernel.
2021-08-15 02:27:13 +02:00
Lenny Maiorani 077e78a8d7 IntrusiveRedBlackTree: Remove redundant subtraction of 0
Problem:
- ToT clang will not build due to casting `nullptr` to `u8*`. This is
  redundant because it casts to get a `0` then subtracts it.

Solution:
- Remove it since subtracting `0` doesn't do anything.
2021-08-13 17:39:33 +04:30
Ali Mohammad Pur 15f95220ae AK+Everywhere: Delete Variant's default constructor
This was exposed to the user by mistake, and even accumulated a bunch of
users that didn't blow up out of sheer luck.
2021-08-13 17:31:39 +04:30
Brian Gianforcaro f2d684fc24 AK: Annotate String.count as [[nodiscard]] 2021-08-13 11:08:11 +02:00
Ali Mohammad Pur 0f1425c895 AK: Avoid OOB access in UniformBumpAllocator::destroy_all()
Otherwise we would end up calling T::~T() on some random memory right
after our mapped block, which is most likely a pretty bad thing to do :P
2021-08-13 04:42:34 +04:30
Ali Mohammad Pur c6a137dbac AK: Add a IsSpecializationOf<T, Template> type trait 2021-08-12 21:03:53 +02:00
Ali Mohammad Pur dcf795085b AK: Don't zero Variant data in the move constructor
There's no reason to zero the data that will be immediately overwritten.
2021-08-12 21:03:53 +02:00
Jean-Baptiste Boric 7a9d05c24c AK: Add contains(char) method to String 2021-08-12 00:41:13 +02:00
Timothy Flynn daf559c717 AK: Add a formatter overload for Utf16View 2021-08-10 23:07:50 +02:00
Timothy Flynn c16aca7abf AK+Kernel: Add StringBuilder::append overload for UTF-16 views
Currently, to append a UTF-16 view to a StringBuilder, callers must
first convert the view to UTF-8 and then append the copy. Add a UTF-16
overload so callers do not need to hold an entire copy in memory.
2021-08-10 23:07:50 +02:00
Timothy Flynn 5978caf96b AK: Convert StringBuilder to use east-const 2021-08-10 23:07:50 +02:00
Daniel Bertalan d000ca1ec3 AK: Add typename keyword for dependent types
This was made optional in C++20 in most cases, but Clang doesn't support
omitting it yet. See P0634R3.
2021-08-08 10:55:36 +02:00
Daniel Bertalan 1472f6d986 AK: Add formatting for infinity and NaN
Without this patch, we would end up printing garbage values when we
encountered floating point infinity or NaN values, and also triggered
UBSAN with Clang. This added code models `std::format`'s behavior: the
sign is added the same way as with normal values and the strings 'nan'
and 'inf' are printed.
2021-08-08 10:55:36 +02:00
Daniel Bertalan 5d32f543ec AK: Handle partial remainders
On x86, the `fprem` and `fmprem1` instructions may produce a 'partial
remainder', for which we should check by reading a FPU flag. If we don't
check for it, we may end up using values that are outside the expected
range of values.
2021-08-08 10:55:36 +02:00
Daniel Bertalan 653d22e21f LibSanitizer+AK: Add float cast overflow handler
This is not enabled by default in GCC, but is in Clang.
2021-08-08 10:55:36 +02:00
Daniel Bertalan 301cab188c AK: Use explode_byte in BumpAllocator.h
When compiling this code with Clang, both branches of the ternary
operator get evaluated at compile-time, triggering a warning about a
narrowing implicit conversion. We can use `explode_byte` instead.
2021-08-08 10:55:36 +02:00
Daniel Bertalan efd1aea969 AK: Make InputMemoryStream::read_LEB128_* templated
On i686, reading integers larger than `2^32 - 1` would fail as the
32-bit `size_t` parameter would overflow. This caused us to read too few
bytes in LibDebug's DWARF parser. Making this method templated solves
this issue, as we now can call this API with a `u64` parameter.
2021-08-08 10:55:36 +02:00
Andreas Kling 3609ac4cf9 AK: Use kmalloc_array() where appropriate 2021-08-08 00:03:45 +02:00
Andreas Kling 2189524cb3 AK: Add kmalloc_array() to trap multiplication overflows
This pattern is no good:

    kmalloc(elements * sizeof(T));

Since it silently swallows any multiplication overflow.
This patch adds a simple kmalloc_array() that stops the program if
overflow occurs:

    kmalloc_array(elements, sizeof(T));
2021-08-08 00:03:45 +02:00
Andreas Kling c94c15d45c Everywhere: Replace AK::Singleton => Singleton 2021-08-08 00:03:45 +02:00
Andreas Kling eb60cb156d AK: Bring Singleton into the global namespace with using 2021-08-08 00:03:45 +02:00
sin-ack a2a553b286 AK: Add RecursionDecision
Similar to IterationDecision, this can be returned from callbacks passed
to recursive traversal functions to signal how to proceed.
2021-08-07 15:21:58 +02:00
Timothy 62af82f494 AK: Use east const in MappedFile 2021-08-07 12:48:22 +02:00
Timothy bc75ca4fe5 AK: Add method to create MappedFile from fd 2021-08-07 12:48:22 +02:00
Jean-Baptiste Boric 786036820b AK: Introduce IntrusiveListRelaxedConst
This container is the same as IntrusiveList, except that it allows
modifications to the elements even if the reference to the
IntrusiveList itself is const, by returning mutable iterators. This
represents a use-case where we want to allow modifications to the
elements while keeping the list itself immutable.

This behavior is explicitely opt-in by using IntrusiveListRelaxedConst
instead of IntrusiveList. It will be useful later on when we model
shared/exclusive locks with the help of const and mutable references.
2021-08-07 11:48:00 +02:00
Lenny Maiorani 2e6fc13b1e AK: Implement any_of using common implementation
Problem:
- `any_of` is implemented in 2 different ways, one for the entire
  container and a different implementation for a partial container
  using iterators.

Solution:
- Follow the "don't repeat yourself" (DRY) idiom and implement the
  entire container version in terms of the partial version.
2021-08-06 23:57:48 +02:00
Andreas Kling a1d7ebf85a Kernel: Rename Kernel/VM/ to Kernel/Memory/
This directory isn't just about virtual memory, it's about all kinds
of memory management.
2021-08-06 14:05:58 +02:00
TheFightingCatfish 4e8e1b7b3a AK: Improve the parsing of data urls
Improve the parsing of data urls in URLParser to bring it more up-to-
spec. At the moment, we cannot parse the components of the MIME type
since it is represented as a string, but the spec requires it to be
parsed as a "MIME type record".
2021-08-06 10:45:17 +02:00
Ali Mohammad Pur 3829bf115c AK: Make StringBuilder::join() use appendff() instead of append()
`append()` is almost never going to select the overload that is desired.
e.g. it will append chars when you pass it a Vector<size_t>, which is
definitely not the right overload :)
2021-08-06 01:14:03 +02:00
Timothy Flynn 70080feab2 AK+LibJS: Implement String.from{CharCode,CodePoint} using UTF-16 strings
Most of String.prototype and RegExp.prototype is implemented with UTF-16
so this is to prevent extra copying of the string data.
2021-08-04 11:18:24 +02:00
Timothy Flynn dae7674ca9 AK: Allow configuring the BumpAllocator chunk size 2021-08-04 11:18:24 +02:00
Timothy Flynn 510bbcd8e0 AK+LibRegex: Add Utf16View::code_point_at and use it in RegexStringView
The current method of iterating through the string to access a code
point hurts performance quite badly for very large strings. The test262
test "RegExp/property-escapes/generated/Any.js" previously took 3 hours
to complete; this one change brings it down to under 10 seconds.
2021-08-04 11:18:24 +02:00
sin-ack bed51d856a AK+Kernel: Print TODO when a TODO() is executed
Previously we would just print "ASSERTION FAILED: false", which was
kinda cryptic and also didn't make it clear whether this was a TODO or
an unreachable condition. Now, we actually print "ASSERTION FAILED:
TODO", making it crystal clear.
2021-08-04 11:01:16 +02:00
Brian Gianforcaro 2dd6d2121a AK: Mark Time::max() / Time::min() / Time::zero() as constexpr
No reason for these static helper functions to not be constexpr.
2021-08-03 18:44:01 +02:00
Lenny Maiorani 97bd13264a Everywhere: Make use of container version of all_of
Problem:
- New `all_of` implementation takes the entire container so the user
  does not need to pass explicit begin/end iterators. This is unused
  except is in tests.

Solution:
- Make use of the new and more user-friendly version where possible.
2021-08-03 10:46:43 +02:00
Timothy Flynn 011514a384 AK: Fix declaration of {String,StringView}::is_one_of
The declarations need to consume the variadic parameters as "Ts&&..."
for the parameters to be forwarding references.
2021-08-02 21:02:09 +04:30
Ali Mohammad Pur b034fa9f1f AK: Add a simple bump allocator 2021-08-02 17:22:50 +04:30