Commit graph

998 commits

Author SHA1 Message Date
Timothy Flynn 04b8b87c17 LibJS+LibUnicode: Support multiple identifiers within format pattern
This wasn't the case for compact patterns, but unit patterns can contain
multiple (up to 2, really) identifiers that must each be recognized by
LibJS.

Each generated NumberFormat object now stores an array of identifiers
parsed. The format pattern itself is encoded with the index into this
array for that identifier, e.g. the compact format string "0K" will
become "{number}{compactIdentifier:0}".
2021-11-16 23:14:09 +00:00
Timothy Flynn 3b68370212 LibJS+LibUnicode: Rename the generated compact_identifier to identifier
This field is currently used to store the StringView into the compact
name/symbol in the format string. Units will need to store a similar
field, so rename the field to be more generic, and extract the parser
for it.
2021-11-16 23:14:09 +00:00
Timothy Flynn 1f546476d5 LibJS+LibUnicode: Fix computation of compact pattern exponents
The compact scale of each formatting rule was precomputed in commit:
be69eae651

Using the formula: compact scale = magnitude - pattern scale

This computation was off-by-one.

For example, consider the format key "10000-count-one", which maps to
"00 thousand" in en-US. What we are really after is the exponent that
best represents the string "thousand" for values greater than 10000
and less than 100000 (the next format key). We were previously doing:

    log10(10000) - "00 thousand".count("0") = 2

Which clearly isn't what we want. Instead, if we do:

    log10(10000) + 1 - "00 thousand".count("0") = 3

We get the correct exponent for each format key for each locale.

This commit also renames the generated variable from "compact_scale" to
"exponent" to match the terminology used in ECMA-402.
2021-11-16 00:56:55 +00:00
Timothy Flynn 48d5684780 LibUnicode: Parse compact identifiers and replace them with a format key
For example, in en-US, the decimal, long compact pattern for numbers
between 10,000 and 100,000 is "00 thousand". In that pattern, "thousand"
is the compact identifier, and the generated format pattern is now
"{number} {compactIdentifier}". This also generates that identifier as
its own field in the NumberFormat structure.
2021-11-16 00:56:55 +00:00
Timothy Flynn 30fbb7d9cd LibUnicode: Parse and generate scientific formatting rules 2021-11-14 17:00:35 +00:00
Timothy Flynn 3645f6a0fc LibUnicode: Fix typo in percent format parser
Just by sheer luck this had no actual effect because the decimal format
prefix has the same length as the percent format prefix.
2021-11-14 17:00:35 +00:00
Timothy Flynn 3b7f5af042 LibUnicode: Generate primary and secondary number grouping sizes
Most locales have a single grouping size (the number of integer digits
to be written before inserting a grouping separator). However some have
a primary and secondary size. We parse the primary size as the size used
for the least significant integer digits, and the secondary size for the
most significant.
2021-11-14 10:35:19 +00:00
Timothy Flynn c65dea64bd LibJS+LibUnicode: Don't remove {currency} keys in GetNumberFormatPattern
In order to implement Intl.NumberFormat.prototype.formatToParts, do not
replace {currency} keys in the format pattern before ECMA-402 tells us
to. Otherwise, the array return by formatToParts will not contain the
expected currency key.

Early replacement was done to avoid resolving the currency display more
than once, as it involves a couple of round trips to search through
LibUnicode data. So this adds a non-standard method to NumberFormat to
do this resolution and cache the result.

Another side effect of this change is that LibUnicode must replace unit
format patterns of the form "{0} {1}" during code generation. These were
previously skipped during code generation because LibJS would just
replace the keys with the currency display at runtime. But now that the
currency display injection is delayed, any {0} or {1} keys in the format
pattern will cause PartitionNumberPattern to abort.
2021-11-13 19:01:25 +00:00
Timothy Flynn a701ed52fc LibJS+LibUnicode: Fully implement currency number formatting
Currencies are a bit strange; the layout of currency data in the CLDR is
not particularly compatible with what ECMA-402 expects. For example, the
currency format in the "en" and "ar" locales for the Latin script are:

    en: "¤#,##0.00"
    ar: "¤\u00A0#,##0.00"

Note how the "ar" locale has a non-breaking space after the currency
symbol (¤), but "en" does not. This does not mean that this space will
appear in the "ar"-formatted string, nor does it mean that a space won't
appear in the "en"-formatted string. This is a runtime decision based on
the currency display chosen by the user ("$" vs. "USD" vs. "US dollar")
and other rules in the Unicode TR-35 spec.

ECMA-402 shies away from the nuances here with "implementation-defined"
steps. LibUnicode will store the data parsed from the CLDR however it is
presented; making decisions about spacing, etc. will occur at runtime
based on user input.
2021-11-13 11:52:45 +00:00
Timothy Flynn e9493a2cd5 LibUnicode: Ensure UnicodeNumberFormat is aware of default content
For example, there isn't a unique set of data for the en-US locale;
rather, it defaults to the data for the en locale. See this commit for
much more detail: 357c97dfa8
2021-11-13 11:52:45 +00:00
Timothy Flynn 9421d5c0cf LibUnicode: Generate currency unit-pattern number formats
These are used when formatting a number as currency with a display
option of "name" (e.g. for USD, the name is "US Dollars" in en-US).

These patterns appear in the CLDR in a different manner than other
number formats that are pluralized. They are of the form "{0} {1}",
therefore do not undergo subpattern replacements.
2021-11-13 11:52:45 +00:00
Timothy Flynn 39e031c4dd LibJS+LibUnicode: Generate all styles of currency localizations
Currently, LibUnicode is only parsing and generating the "long" style of
currency display names. However, the CLDR contains "short" and "narrow"
forms as well that need to be handled. Parse these, and update LibJS to
actually respect the "style" option provided by the user for displaying
currencies with Intl.DisplayNames.

Note: There are some discrepencies between the engines on how style is
handled. In particular, running:

new Intl.DisplayNames('en', {type:'currency', style:'narrow'}).of('usd')

Gives:

  SpiderMoney: "USD"
  V8: "US Dollar"
  LibJS: "$"

And running:

new Intl.DisplayNames('en', {type:'currency', style:'short'}).of('usd')

Gives:

  SpiderMonkey: "$"
  V8: "US Dollar"
  LibJS: "$"

My best guess is V8 isn't handling style, and just returning the long
form (which is what LibJS did before this commit). And SpiderMoney can
handle some styles, but if they don't have a value for the requested
style, they fall back to the canonicalized code passed into of().
2021-11-13 11:52:45 +00:00
Timothy Flynn 6cfd63e5bd LibUnicode: Parse numbers in number formats a bit more leniently
The parser was previously expecting number sections within a pattern to
start with "#", but they may also begin with "0".
2021-11-13 11:52:45 +00:00
Daniel Bertalan fe1726521a Meta: Resolve cyclic dependency between LibPthread and libc++
libc++ uses a Pthread condition variable in one of its initialization
functions. This means that Pthread forwarding has to be set up in LibC
before libc++ can be initialized. Also, because LibPthread is written in
C++, (at least some) parts of the C++ standard library have to be linked
against it.

This is a circular dependency, which means that the order in which these
two libraries' initialization functions are called is undefined. In some
cases, libc++ will come first, which will then trigger an assert due to
the missing Pthread forwarding.

This issue isn't necessarily unique to LibPthread, as all libraries that
libc++ depends on exhibit the same circular dependency issue.

The reason why this issue didn't affect the GNU toolchain is that
libstdc++ is always linked statically. If we were to change that, I
believe that we would run into the same issue.
2021-11-13 11:15:33 +00:00
Andreas Kling b189c88ec2 Fuzzers: Use ImageDecoders instead of load_FORMAT_from_memory() wrappers 2021-11-13 00:55:07 +01:00
Timothy Flynn 1f2ac0ab41 LibUnicode: Move number formatting code generator to UnicodeNumberFormat 2021-11-12 20:46:38 +00:00
Timothy Flynn 04e6b43f05 LibUnicode: Move (soon-to-be) common code out of GenerateUnicodeLocale
The data used for number formatting is going to grow quite a bit when
the cldr-units package is parsed. To prevent the generated UnicodeLocale
file from growing outrageously large, the number formatting data can go
into its own file. To prepare for this, move code that will be common
between the generators for UnicodeLocale and UnicodeNumberFormat to the
utility header.
2021-11-12 20:46:38 +00:00
Ali Mohammad Pur c08bfd450b Meta: Update the gdb script for the new RefPtr layout 2021-11-12 13:01:59 +00:00
Timothy Flynn be69eae651 LibUnicode: Precompute the compact scale of each number formatting rule
This will be needed for the ComputeExponentForMagnitude AO for compact
formatting, namely step 5b:

  Let exponent be an implementation- and locale-dependent (ILD) integer
  by which to scale a number of the given magnitude in compact notation
  for the current locale.
2021-11-12 09:17:08 +00:00
Timothy Flynn 230b133ee3 LibUnicode: Parse number formats into zero/positive/negative patterns
A number formatting pattern in the CLDR contains one or two entries,
delimited by a semi-colon. Previously, LibUnicode was just storing the
entire pattern as one string. This changes the generator to split the
pattern on that delimiter and generate the 3 unique patterns expected by
ECMA-402.

The rules for generating the 3 patterns are as follows:

* If the pattern contains 1 entry, it is the zero pattern. The positive
  pattern is the zero pattern prepended with {plusSign}. The negative
  pattern is the zero pattern prepended with {minusSign}.

* If the pattern contains 2 entries, the first is the zero pattern, and
  the second is the negative pattern. The positive pattern is the zero
  pattern prepended with {plusSign}.
2021-11-12 09:17:08 +00:00
Timothy Flynn 1244ebcd4f LibUnicode: Parse and generate standard accounting formatting rules
Also known as "currency-accounting" in some CLDR documentation.
2021-11-12 09:17:08 +00:00
Timothy Flynn 967afc1b84 LibUnicode: Parse and generate standard currency formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn bffd73e0d4 LibUnicode: Parse and generate standard decimal formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn feb8c22a62 LibUnicode: Parse and generate standard percentage formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn 4317a1b552 LibUnicode: Parse and generate compact currency formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn 604a596c90 LibUnicode: Parse and generate compact decimal formatting rules 2021-11-12 09:17:08 +00:00
Timothy Flynn 12b468a588 LibUnicode: Begin parsing and generating locale number systems
The number system data in the CLDR contains information on how to format
numbers in a locale-dependent manner. Start parsing this data, beginning
with numeric symbol strings. For example the symbol NaN maps to "NaN" in
the en-US locale, and "非數值" in the zh-Hant locale.
2021-11-12 09:17:08 +00:00
Timothy Flynn d3e83c9934 LibUnicode: Parse alternate default numbering systems
Some locales in the CLDR have alternate default numbering systems listed
under "defaultNumberingSystem-alt-*", e.g.:

    "defaultNumberingSystem": "arab",
    "defaultNumberingSystem-alt-latn": "latn",
    "otherNumberingSystems": {
      "native": "arab"
    },

We were previously only parsing "defaultNumberingSystem" and
"otherNumberingSystems". This odd format appears to be an artifact of
converting from XML.
2021-11-12 09:17:08 +00:00
Timothy Flynn ae66188d43 LibUnicode: Capitialize generated identifiers in lieu of full title case
This isn't particularly important because this generates code that is
quite hidden from outside callers. But when viewing the generated code,
it's a bit nicer to read e.g. enum identifiers such as "MinusSign"
rather than "Minussign".
2021-11-12 09:17:08 +00:00
Ali Mohammad Pur 7d1142e2c8 LibWasm: Implement module validation 2021-11-11 09:20:04 +01:00
Ali Mohammad Pur d0ad7efd9b Meta: Update WebAssembly testsuite branch name
The 'master' branch is no longer updated, they've switched to 'main'.
2021-11-11 09:20:04 +01:00
Andreas Kling 8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Sam Atkins e52f987020 LibWeb: Make property_initial_value() return a NonnullRefPtr
The finale! Users can now be sure that the value is valid, which makes
things simpler.
2021-11-10 21:58:14 +01:00
Sam Atkins 4d42915485 LibWeb: Ensure that CSS initial values are always valid :^)
First off, this verifies that an initial value is always provided in
Properties.json for each property.

Second, it verifies that parsing that initial value succeeds.

This means that a call to `property_initial_value()` will always return
a valid StyleValue. :^)
2021-11-10 21:58:14 +01:00
Tim Schumacher d1eb604896 CMake: Build serenity_lib libraries with a custom SONAME
This allows libraries and binaries to explicitly link against
`<library>.so.serenity`, which avoids some confusion if there are other
libraries with the same name, such as OpenSSL's `libcrypto`.
2021-11-10 14:42:49 +01:00
Tim Schumacher 46aa477b8f CMake: Remove unused serenity_shared_lib function 2021-11-10 14:42:49 +01:00
Sam Atkins 901a990b1b LibWeb: Remove concept of CSS pseudo-properties
We don't need them any more, so they're gone. :^)
2021-11-10 14:38:49 +01:00
Timothy Flynn 03c023d7e9 LibUnicode: Upgrade to CLDR version 40.0.0
Release notes:
https://github.com/unicode-org/cldr-json/releases/tag/40.0.0
2021-11-09 20:44:52 +01:00
Timothy Flynn 357c97dfa8 LibUnicode: Parse the CLDR's defaultContent.json locale list
This file contains the list of locales which default to their parent
locale's values. In the core CLDR dataset, these locales have their own
files, but they are empty (except for identity data). For example:

https://github.com/unicode-org/cldr/blob/main/common/main/en_US.xml

In the JSON export, these files are excluded, so we currently are not
recognizing these locales just by iterating the locale files.

This is a prerequisite for upgrading to CLDR version 40. One of these
default-content locales is the popular "en-US" locale, which defaults to
"en" values. We were previously inferring the existence of this locale
from the "en-US-POSIX" locale (many implementations, including ours,
strip variants such as POSIX). However, v40 removes the "en-US-POSIX"
locale entirely, meaning that without this change, we wouldn't know that
"en-US" exists (we would default to "en").

For more detail on this and other v40 changes, see:
https://cldr.unicode.org/index/downloads/cldr-40#h.nssoo2lq3cba
2021-11-09 20:44:52 +01:00
Ben Wiederhake 3e420b7590 Meta: Remove useless lint-ipc-ids.sh script
This script was silently broken in commit
62af6cd4f9.
2021-11-05 00:17:01 +03:30
Ben Wiederhake 8f65153b03 Meta: Run IPC magic number linter during CI and pre-commit 2021-11-05 00:17:01 +03:30
Ben Wiederhake 585554a245 Meta: Implement checker for IPC magic number collisions 2021-11-05 00:17:01 +03:30
Ben Wiederhake 93356ee3df IPCCompiler: Remove now-unused ability to hardcode magic number 2021-11-05 00:17:01 +03:30
thislooksfun 03494ed6ba Meta: Add a check to ensure grep -P stays gone
grep -P does not work on macOS, but grep -E does.
2021-11-02 12:23:30 +01:00
thislooksfun a984545a94 Meta: Run find in the current dir
macOS's find requires a leading search scope. Without this change this
lint step fails.
2021-11-02 12:23:30 +01:00
thislooksfun 19bd302f6a Meta: Adhere to latest ScriptCheck standards (SC2268) 2021-11-02 12:23:30 +01:00
thislooksfun 3e32acc3e4 Meta: Add special case for macOS
macOS's `find` does not support the '-executable' flag, nor does it
support the '-perm /' syntax, but we can make it work with a special
case.
2021-11-02 12:23:30 +01:00
thislooksfun 170e956c80 Meta: Remove unnecessary -i
Using `xargs -i <cmd> {}` is just doing the default behavior of xargs,
but with extra steps that also don't work on macOS.
2021-11-02 12:23:30 +01:00
thislooksfun c2d44209a8 Meta: Use grep -E/F, not grep -P
grep -E and -F are POSIX standard, and meets all our matching needs.
2021-11-02 12:23:30 +01:00
Ben Wiederhake 686efb6737 ConfigureComponents: Reduce duplicated code 2021-11-02 11:36:23 +01:00
Linus Groh 897471c852 Meta: Don't check for toolchain if serenity.sh target is lagom
This is just silly :^)

    $ serenity run lagom js
    WARNING: unknown toolchain 'js'. Defaulting to GNU.
             Valid values are 'Clang', 'GNU' (default)
2021-11-02 11:09:05 +01:00
Idan Horowitz 19e28d5798 LibWeb: Convert is_named_property_exposed_on_object to ThrowCompletions
This is the last usage of old-style exceptions in the WrapperGenerator.
2021-11-02 10:41:25 +02:00
Ben Wiederhake 55e1edd51b Meta: Check auto-generated manpages for completeness on CI 2021-11-01 21:12:58 +01:00
Ben Wiederhake a4e805756d Meta: Add script to generate and export manpages 2021-11-01 21:12:58 +01:00
Ben Wiederhake 2caad04d23 Base: Add new system-mode that just generates manpages 2021-11-01 21:12:58 +01:00
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
Linus Groh 661dd32432 LibWeb: Add support for the Promise<T> IDL type to WrapperGenerator
This includes parsing parameterized types (foo<T>) as well as generating
the appropriate code in generate_wrap_statement() and generate_to_cpp().
2021-10-11 13:30:17 +01:00
Linus Groh 7afd215e95 LibWeb: Initialize IDL any values without default value to undefined
Previously this would generate the following code:

    JS::Value foo_value;
    if (!foo.is_undefined())
        foo_value = foo;

Which is dangerous as we're passing an empty value around, which could
be exposed to user code again. This is fine with "= null", for which it
also generates:

    else
        foo_value = JS::js_null();

So, in summary: a value of type `any`, not `required`, with no default
value and no initializer from user code will now default to undefined
instead of an empty value.
2021-10-11 13:30:17 +01:00
Linus Groh a9a7d65099 LibWeb: Replace heycam.github.io/webidl URLs with webidl.spec.whatwg.org
Web IDL is now a WHATWG standard and the specification was moved
accordingly: https://twitter.com/annevk/status/1445311275026821120

The old URLs now redirect, but let's use canonical ones.
2021-10-11 13:15:16 +01:00
Andreas Kling fdc1c15064 LibWeb: Stub out a basic ResizeObserver interface
This patch establishes scaffolding for the ResizeObserver API.
2021-10-11 00:54:01 +02:00
Andreas Kling 5c9ca5c2dc LibWeb: Stub out a basic Selection interface
This patch establishes scaffolding for the Selection API.
2021-10-11 00:32:19 +02:00
Ben Wiederhake e900f94a03 Meta: Run check-markdown as part of 'Azure Linux NoFuzz' 2021-10-10 15:18:55 -07:00
Ben Wiederhake a296f6bb8d Meta: Invoke markdown-checker if available while linting 2021-10-10 15:18:55 -07:00
Ben Wiederhake c06a0bae04 Meta: Fix broken external links
Meta/Lagom/ReadMe.md never had any other name; not sure how that typo
happened.

The link to the non-existent directory is especially vexing because the
text goes on to explain that we don't want such a directory to exist.

Found by running markdown-checker, and 'wget'ing all external links.
2021-10-10 15:18:55 -07:00
Ben Wiederhake 3f88d65b78 markdown-checker: New tool that checks document links 2021-10-10 15:18:55 -07:00
Timothy Flynn 597379e864 LibUnicode: Generate and use unique locale-related alias strings
Almost all of these are already in the unique string list.
2021-10-10 22:21:48 +02:00
Timothy Flynn acb7bd917f LibUnicode: Generate and use unique subtag and complex alias strings 2021-10-10 22:21:48 +02:00
Timothy Flynn 3d67f6bd29 LibUnicode: Generate and use unique list-format strings
The list-format strings used for Intl.ListFormat are small, but quite
heavily duplicated. For example, the string "{0}, {1}" appears 6,519
times. Generate unique strings for this data to avoid duplication.
2021-10-10 22:21:48 +02:00
Timothy Flynn f9e605397c LibUnicode: Generate and use a set of unique locale-related strings
In the generated UnicodeLocale.cpp file, there are 296,408 strings for
localizations of languages, territories, scripts, currencies & keywords.
Of these, only 43,848 (14.8%) are actually unique, so there are quite a
large number of duplicated strings.

This generates a single compile-time array to store these strings. The
arrays for the localizations now store an index into this single array
rather than duplicating any strings.
2021-10-10 22:21:48 +02:00
Timothy Flynn 3f0095b57a LibUnicode: Skip unknown languages and territories
Some CLDR languages.json / territories.json files contain localizations
for some lanuages/territories that are otherwise not present in the CLDR
database. We already don't generate anything in UnicodeLocale.cpp for
these anomalies, but this will stop us from even storing that data in
the generator's memory.

This doesn't affect the output of the generator, but will have an effect
after an upcoming commit to unique-ify all of the strings in the CLDR.
2021-10-10 22:21:48 +02:00
Ben Wiederhake 6d99b7b72e Meta: Re-enable warnings for deprecated copies also for Lagom 2021-10-10 21:21:35 +01:00
Timothy Flynn 79707d83d3 LibUnicode: Stop generating large UnicodeData hash map
The data in this hash map is now available by way of much smaller arrays
and is now unused.
2021-10-10 13:49:37 +02:00
Timothy Flynn d83b262e64 LibUnicode: Generate standalone compile-time array for combining class 2021-10-10 13:49:37 +02:00
Timothy Flynn 9f83774913 LibUnicode: Generate standalone compile-time array for special casing
There are only 112 code points with special casing rules, so this array
is quite small (compared to the size 34,626 UnicodeData hash map that is
also storing this data). Removing all casing rules from UnicodeData will
happen in a subsequent commit.
2021-10-10 13:49:37 +02:00
Timothy Flynn da4b8897a7 LibUnicode: Generate standalone compile-time arrays for simple casing
Currently, all casing information (simple and special) are stored in a
compile-time array of size 34,626, then statically copied to a hash map
at runtime. In an effort to reduce the resulting memory usage, store the
simple casing rules in standalone compile-time arrays. The uppercase map
is size 1,450 and the lowercase map is size 1,433. Any code point not in
a map will implicitly have an identity mapping.
2021-10-10 13:49:37 +02:00
Idan Horowitz 9958277317 Meta: Disable -Wmaybe-uninitialized for Lagom 2021-10-07 21:56:03 +03:00
Nico Weber a7b558bf7d Meta: Warn on rebuild-toolchain i686 clang
It's "Clang" (capitalized). Silently building gcc if the toolchain
isn't know seems a bit unfriendly. So print a warning for this
(and for other unknown toolchains).
2021-10-07 18:34:13 +03:00
Ben Wiederhake 52e9f25403 Everywhere: Change from http to https where feasible
I used "git grep -FIn http://" to find all occurrences, and looked at
each one. If an occurrence was really just a link, and if a https
version exists, and if our Browser can access it at least as well as the
http version, then I changed the occurrence to https.

I'm happy to report that I didn't run into a single site where Browser
can't deal with the https version.
2021-10-05 02:08:08 +02:00
Andreas Kling bf43b0f884 LibWeb: Make IDL-constructed objects aware of their JS wrapper
Having IDL constructors call FooWrapper::create(impl) directly was
creating a wrapper directly without telling the impl object about the
wrapper. This meant that we had wrapped C++ objects with a null
wrapper() pointer.
2021-10-04 12:13:25 +02:00
Linus Groh 2f42675ebd LibJS: Convert ordinary_set_with_own_descriptor() to ThrowCompletionOr 2021-10-04 09:52:15 +01:00
Linus Groh 3be26f56db LibJS: Convert has_own_property() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
Linus Groh fb443b3fb4 LibJS: Convert create_data_property() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
Linus Groh b7e5f08e56 LibJS: Convert Object::get() to ThrowCompletionOr
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
2021-10-03 20:14:03 +01:00
davidot ac2c3a73b1 LibJS: Add a specific test for invalid unicode characters in the lexer
Also fixes that it tried to make substrings past the end of the source
if we overran the source length.
2021-10-03 17:42:05 +02:00
Luke Wilde 8d6db36cbb LibWeb: Add support for NodeList
This introduces 3 classes: NodeList, StaticNodeList and LiveNodeList.
NodeList is the base of the static and live versions. Static is a
snapshot whereas live acts on the underlying data and thus inhibits
the same issues we have currently with HTMLCollection.

They were split into separate classes to not have them weirdly
mis-mashed together.

The create functions for static and live both return a NNRP to the base
class. This is to prevent having to do awkward casting at creation
and/or return, as the bindings expect to see the base NodeList only.
2021-10-03 00:18:52 +02:00
Luke Wilde bfd089fbd1 LibWeb: Add support for IDL value iterators
This also renames Interface::iterator_types to pair_iterator_types to
reduce confusion between value and pair iterators.
2021-10-03 00:18:52 +02:00
Linus Groh ba6e4c7ae1 LibJS+LibWeb: Use Object::set_prototype() in more places 2021-10-02 14:53:06 +01:00
Idan Horowitz a4bc3fa255 LibWeb: Initialize IDL-generated prototypes' prototype directly
Instead of setting it to the default object prototype and then
immediately setting it again via internal_set_prototype_of, we can just
set it directly in the parent constructor call.
2021-10-02 13:23:59 +01:00
Andreas Kling 77f0e57b27 RequestServer: Don't hide the SIGINFO state dump behind a debug macro
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-01 20:17:15 +02:00
Idan Horowitz 43482dfde3 LibWeb: Support dictionary-only IDL files 2021-10-01 20:14:45 +02:00
Idan Horowitz ac25c28c43 LibWeb: Add the missing UIEvent IDL constructor 2021-10-01 20:14:45 +02:00
Idan Horowitz 7b2c63fd87 LibWeb: Add support for unwrapping the WindowObject to WrapperGenerator 2021-10-01 20:14:45 +02:00
Idan Horowitz 4d71f22673 LibWeb: Add the missing ProgressEvent IDL constructor 2021-10-01 20:14:45 +02:00
Idan Horowitz 7f551d7f6a LibWeb: Use the LibWeb source directory as the IDL #import base path
This allows us to include IDL files from other base LibWeb directories
wihout using relative `../foo.idl` references.
2021-10-01 20:14:45 +02:00
Nico Weber 9ec9886b04 Meta: Fix typos 2021-10-01 01:06:40 +01:00
Idan Horowitz 2c6c9b73c8 LibWeb: Add the Web::Crypto namespace, built-in, and getRandomValues
Since we don't support IDL typedefs or unions yet, the responsibility
of verifying the type of the argument is temporarily moved from the
generated Wrapper to the implementation.
2021-09-30 20:02:09 +02:00
Timothy Flynn becbb0ea97 LibUnicode: Upgrade to Unicode version 14.0.0 2021-09-30 17:37:57 +01:00
Timothy Flynn c8dbcdb0bc LibUnicode: Do not compare generated file contents before writing
This is now covered by unicode_data.cmake after the superbuild changes.
2021-09-30 17:37:57 +01:00
Timothy Flynn a466b78bf3 LibUnicode: Remove cached UCD and CLDR files when their version changes 2021-09-30 17:37:57 +01:00
Timothy Flynn 0ec6b4f132 LibUnicode: Use consistent variable naming in unicode_data.cmake
I kept mixing these up in my head.
2021-09-30 17:37:57 +01:00
Timothy Flynn 583d703f61 LibUnicode: Functionalize extraction of CLDR data files 2021-09-30 17:37:57 +01:00