Commit graph

843 commits

Author SHA1 Message Date
Timothy Flynn 95e492de59 LibWeb: Convert throw_dom_exception_if_needed() to ThrowCompletionOr
This changes Web::Bindings::throw_dom_exception_if_needed() to return a
JS::ThrowCompletionOr instead of an Optional. This allows callers to
wrap the invocation with a TRY() macro instead of making a follow-up
call to should_return_empty(). Further, this removes all invocations to
vm.exception() in the generated bindings.
2021-10-31 18:51:07 +01:00
Ben Wiederhake f20a42e871 Kernel: Write test that crashes ProcFS 2021-10-31 18:44:12 +01:00
Idan Horowitz ae510db72c FuzzilliJS: Convert native functions to ThrowCompletionOr 2021-10-31 18:20:37 +02:00
Timothy Flynn c19c306744 LibWeb: Convert all generated bindings to ThrowCompletionOr
This also required converting URLSearchParams::for_each and the callback
function it invokes to ThrowCompletionOr. With this, the ReturnType enum
used by WrapperGenerator is removed as all callers would be using
ReturnType::Completion.
2021-10-31 15:48:36 +01:00
Brendan Coles 91de60d912 Lagom/Fuzzers: Add fuzzer for PDF document 2021-10-30 10:33:56 -07:00
Andreas Kling 34cc4803af Websites: Import serenityos.org website changes
I hadn't synced this for a while. The repo copy now matches the live
site once again.
2021-10-30 17:42:26 +02:00
Idan Horowitz 2882a90dec Kernel: Add the IFF_* SIOCGIFFLAGS flag macros 2021-10-28 11:24:36 +02:00
Ben Wiederhake a6ccf6659a Meta: Reimplement license checker in python
On my machine, this script took about 3.4 seconds, and was responsible
for essentially all of the time taken by the precommit hook.

The script is a faithful 1:1 reimplementation, even the regexes are
identical. And yet, it takes about 0.02 seconds, making the pre-commit
hook lightning fast again. Apparently python is just faster in this
case.

Fun fact:
- Just reading all ~4000 files took bash about 1.2 seconds
- Checking the license took another 1.8 seconds in total
- Checking for math.h took another 0.4 seconds in total
- Checking for '#pragma once' took another 0.4 seconds in total

The timing is highly load-dependent, so they don't exactly add up to 3.4
seconds. However, it's good enough to determine that bash is no longer
fit for the purpose of this script.
2021-10-27 11:35:47 -07:00
Ben Wiederhake 8d13f6ddce Kernel+SystemServer: Change bootmode to system_mode
'bootmode' now only controls which set of services are started by
SystemServer, so it is more appropriate to rename it to system_mode, and
no longer validate it in the Kernel.
2021-10-25 23:38:28 +02:00
Ben Wiederhake 09432a8241 Kernel: Separate panic behavior from bootmode
Bootmode used to control panic behavior and SystemServer.
This patch factors panic behavior control into a separate flag.
2021-10-25 23:38:28 +02:00
Ben Wiederhake 542a88a7be Kernel: Separate framebuffers from bootmode
Bootmode used to control framebuffers, panic behavior, and SystemServer.
This patch factors framebuffer control into a separate flag.
Note that the combination 'bootmode=self-test fbdev=on' leads to
unexpected behavior, which can only be fixed in a later commit.
2021-10-25 23:38:28 +02:00
Andreas Kling 398c181c79 LibJS: Rename PropertyName to PropertyKey
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Ben Wiederhake fc519d43ba Fuzzing: Update build instructions
The project needs clang-12, which is not on all systems the default
(e.g. Debian Testing).
2021-10-23 19:29:59 +01:00
Ben Wiederhake 20bfd549e9 man.serenityos.org: Make section titles more descriptive 2021-10-22 19:49:28 +03:00
Ben Wiederhake dad47a3dd1 man.serenityos.org: Use pandoc for listings and landing page
This makes all pages look and feel the same, because they all use the
default CSS generated by pandoc. Also, it inserts the banner everywhere
at the top, not only into the top-level index.html.

Credit to @xSlendiX for suggesting that `-B` works here.
2021-10-22 19:49:28 +03:00
Ben Wiederhake 2e613db999 man.serenityos.org: Fix links to man(1), avoid unnecessary shells
This fixes the current bug at the end of less(1), which links to the
wrong file ".html" instead of "man.html".
2021-10-22 19:49:28 +03:00
Ben Wiederhake 7e52b6fa24 man.serenityos.org: Simplify local builds
I simply extracted the script from .github/workflows/manpages.yml,
without significant modification.
2021-10-22 19:49:28 +03:00
Ben Wiederhake 5c04a2d4b3 man.serenityos.org: Add section descriptions to overview page 2021-10-22 19:49:28 +03:00
Idan Horowitz db5df26841 LibJS: Convert Array AOs to ThrowCompletionOr 2021-10-22 15:07:04 +03:00
Liav A cf0dbc9069 Tests: Add a unit test to ensure the /dev/mem device works correctly
To ensure everything works as expected, a unit test was added with
multiple scenarios.
This binary has to have the SetUID flag, and we also bind-mount the
/usr/Tests directory to allow running of SetUID binaries.
2021-10-22 13:13:00 +02:00
Timothy Flynn 8a57885494 Meta: Enable ccache for Lagom by default 2021-10-21 04:35:10 -07:00
Linus Groh 5832de62fe LibJS: Convert NativeFunction::{call,construct}() to ThrowCompletionOr
Both at the same time because many of them call construct() in call()
and I'm not keen on adding a bunch of temporary plumbing to turn
exceptions into throw completions.
Also changes the return value of construct() to Object* instead of Value
as it always needs to return an object; allowing an arbitrary Value is a
massive foot gun.
2021-10-21 09:02:23 +01:00
Idan Horowitz 40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz 20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00
Ben Wiederhake 8de696bdd0 HeaderCheck: It checks some of your headers 2021-10-20 09:20:18 +01:00
Sam Atkins 04c0c103e0 LibWeb: Distinguish between integer and number when checking StyleValues 2021-10-19 19:12:09 +02:00
Sam Atkins 450b782c18 LibWeb: Distinguish between length and percentage values
Though most CSS properties accept either, some do not, so distinguishing
between them lets us catch some invalid values at parse time.
2021-10-19 19:12:09 +02:00
Timothy Flynn d24ae8063b LibWeb: Implement DOMTokenList for managing space-separated tokens lists
DOMTokenList is used as the return type of, e.g., the Element.classList
property.
2021-10-18 23:33:56 +02:00
Timothy Flynn 4d8320a49a LibWeb: Add initial support for IDL methods with variadic parameters
Adds support for methods whose last parameter is a variadic DOMString.
We constructor a Vector<String> of the remaining arguments to pass to
the C++ implementation.
2021-10-18 23:33:56 +02:00
Brian Gianforcaro 8c2a88e492 Meta: Add a gdb pretty printer for AK::Array 2021-10-18 03:27:27 -07:00
Timothy Flynn b11a34330a CI: Build the Clang toolchain a single time for both onboard pipelines
As of the Clang 13 upgrade, we only need to build the toolchain once and
can use that toolchain for both x86_64 and i686. To do this, this breaks
the main Azure configuration into 3 "stages" (Lagom, Toolchain, and
Serenity), where the Serenity stage depends on the Toolchain stage.

This has the added benefit of uploading a new prebuilt toolchain cache
sooner than before, which should help alleviate pressure from PRs.
2021-10-18 03:25:26 -07:00
Idan Horowitz 7bbb92dfe9 LibJS: Convert to_u16() to ThrowCompletionOr 2021-10-18 08:01:38 +03:00
Idan Horowitz cc94bba5c0 LibJS: Convert to_u32() to ThrowCompletionOr 2021-10-18 08:01:38 +03:00
Idan Horowitz f6a5ff7b00 LibJS: Convert to_i32() to ThrowCompletionOr 2021-10-18 08:01:38 +03:00
Daniel Bertalan 928665d3bc Meta: Support llvm-addr2line in serenity.sh
With this, the subcommands 'addr2line` and `kaddr2line` work as with the
GNU toolchain.
2021-10-17 17:09:58 +01:00
Daniel Bertalan 06fc64be13 Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.

The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.

Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.

We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.

The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-10-17 17:09:58 +01:00
Timothy Flynn 2a3ac02ef1 LibWeb: Implement (most of) NamedNodeMap to store attributes 2021-10-17 13:51:10 +01:00
Timothy Flynn e01dfaac9a LibWeb: Implement Attribute closer to the spec and with an IDL file
Note our Attribute class is what the spec refers to as just "Attr". The
main differences between the existing implementation and the spec are
just that the spec defines more fields.

Attributes can contain namespace URIs and prefixes. However, note that
these are not parsed in HTML documents unless the document content-type
is XML. So for now, these are initialized to null. Web pages are able to
set the namespace via JavaScript (setAttributeNS), so these fields may
be filled in when the corresponding APIs are implemented.

The main change to be aware of is that an attribute is a node. This has
implications on how attributes are stored in the Element class. Nodes
are non-copyable and non-movable because these constructors are deleted
by the EventTarget base class. This means attributes cannot be stored in
a Vector or HashMap as these containers assume copyability / movability.
So for now, the Vector holding attributes is changed to hold RefPtrs to
attributes instead. This might change when attribute storage is
implemented according to the spec (by way of NamedNodeMap).
2021-10-17 13:51:10 +01:00
Idan Horowitz 1639ed7e0a LibJS: Convert to_double() to ThrowCompletionOr 2021-10-17 12:12:35 +01:00
Luke Wilde cb821e1539 LibWeb: Convert ArrayFromVector wrapper to instead be sequence<T>
This adds the ParamatizedType, as `Vector<String>` doesn't encode the
full type information. It is a separate struct as you can't have
`Vector<Type>` inside of `Type`. This also makes Type RefCounted
because I had to make parse_type return a pointer to make dynamic
casting work correctly.

The reason I made it RefCounted instead of using a NonnullOwnPtr is
because it causes compiler errors that I don't want to figure out right
now.
2021-10-17 01:34:02 +03:00
Nico Weber 4d555e8b95 Lagom: Do not use -fno-sematic-interposition in fuzzer builds
Apparently it breaks the fuzzer build. There's probably a better fix
for this, but for now just unbreak the fuzzer build.
Keep this for non-fuzzer builds though since it's apparently a 17%
speedup for running test262 tests :^)
2021-10-16 14:45:06 +01:00
Nico Weber ec9488a58c Lagom: Build with -fno-no-semantic-interposition
Lagom: Build with -fno-no-semantic-interposition

We build with this in non-lagom builds, and serenity's gcc even adds it
to its CC1_SPEC. Let's use it for lagom too.

Reduces the number of dynamic relocations in liblagom-js.so.0.0.0 (per
`objdump -R`) from 15133 to 14534, and increases its size back to 91M
(95156800 bytes), probably due to more inlining being possible.
This might help perf of lagom binaries.
2021-10-15 21:59:42 +01:00
Nico Weber b11d660ff8 Lagom: Build with -fno-exceptions
We build with this in non-lagom builds, so there's no reason not
to use it in lagom builds as well.

Reduces the size of liblagom-js.so.0.0.0 from 94M to 90M
(from 98352784 to 93831056 bytes to be exact).
2021-10-15 21:59:42 +01:00
Timothy Flynn 3ad159537e LibUnicode: Use u16 for unique string indices instead of size_t
Typically size_t is used for indices, but we can take advantage of the
knowledge that there is approximately only 46K unique strings in the
generated UnicodeLocale.cpp file. Therefore, we can get away with using
u16 to store indices. There is a VERIFY that will fail if we ever exceed
the limits of u16.

On x86_64 builds, this reduces libunicode.so from 9.2 MiB to 7.3 MiB.
On i686 builds, this reduces libunicode.so from 3.9 MiB to 3.3 MiB.

These savings are entirely in the .rodata section of the shared library.
2021-10-15 00:06:18 +01:00
Timothy Flynn ebe704a03d LibWeb: Stub out a basic IntersectionObserver interface
Note there are a couple of type differences between the spec and the IDL
file added in this commit. For example, we will need to support a type
of Variant to handle spec types such as "(double or sequence<double>)".
But for now, this allows web pages to construct an IntersectionObserver
with any valid type.
2021-10-14 10:32:51 +02:00
Timothy Flynn ff66218631 LibWeb: Allow creating "any" types in IDL with integral default values
This enables defining "any" types in IDL files such as:

    any threshold = 0;

This isn't able to parse decimal values yet.
2021-10-14 10:32:51 +02:00
Timothy Flynn f91d63af83 LibUnicode: Generate enum/alias from-string methods without a HashMap
The *_from_string() and resolve_*_alias() generated methods are the last
remaining users of HashMap in the LibUnicode generated files (read: the
last methods not using compile-time structures). This converts these
methods to use an array containing pairs of hash values to the desired
lookup value.

Because this code generation is the same between GenerateUnicodeData.cpp
and GenerateUnicodeLocale.cpp, this adds a GeneratorUtil.h header to the
LibUnicode generators to contain the method that generates the methods.
2021-10-13 16:38:51 +02:00
Linus Groh 52976bfac6 LibJS: Convert to_object() to ThrowCompletionOr 2021-10-13 09:55:10 +01:00
Linus Groh 4d8912a92b LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
2021-10-13 09:55:10 +01:00
Linus Groh 44e70d1bc0 LibJS+LibWeb: Let WrapperGenerator deal with legacy_null_to_empty_string
This concept is not present in ECMAScript, and it bothers me every time
I see it.
It's only used by WrapperGenerator, and even there only relevant in two
places, so let's fully remove it from LibJS and use a simple ternary
expression instead:

    cpp_name = js_name.is_null() && legacy_null_to_empty_string
        ? String::empty()
        : js_name.to_string(global_object);
2021-10-11 23:36:03 +01:00