Commit Graph

25787 Commits

Author SHA1 Message Date
Timothy Flynn
a0b72f5ad3 LibRegex: Remove (mostly) unused regex::MatchOutput
This struct holds a counter for the number of executed operations, and
vectors for matches, captures groups, and named capture groups. Each of
the vectors is unused. Remove the struct and just keep a separate
counter for the executed operations.
2021-08-15 11:43:45 +01:00
Timothy Flynn
f1ce998d73 LibRegex+LibJS: Combine named and unnamed capture groups in MatchState
Combining these into one list helps reduce the size of MatchState, and
as a result, reduces the amount of memory consumed during execution of
very large regex matches.

Doing this also allows us to remove a few regex byte code instructions:
ClearNamedCaptureGroup, SaveLeftNamedCaptureGroup, and NamedReference.
Named groups now behave the same as unnamed groups for these operations.
Note that SaveRightNamedCaptureGroup still exists to cache the matched
group name.

This also removes the recursion level from the MatchState, as it can
exist as a local variable in Matcher::execute instead.
2021-08-15 11:43:45 +01:00
Timothy Flynn
fea181bde3 LibRegex: Reduce RegexMatcher's BumpAllocator chunk size
Before the BumpAllocator OOB access issue was understood and fixed, the
chunk size was increased to 8MiB as a workaround in commit:
27d555bab0.

The issue is now resolved by: 0f1425c895.

We can reduce the chunk size to 2MiB, which has the added benefit of
reducing runtime of the RegExp.prototype.exec test.
2021-08-15 11:43:45 +01:00
Timothy Flynn
1a173be29d LibRegex: Disallow unescaped quantifiers in Unicode mode 2021-08-15 11:43:45 +01:00
Timothy Flynn
c3e1f1f687 LibRegex: Use correct source characters for Unicode identity escapes 2021-08-15 11:43:45 +01:00
Timothy Flynn
6a485f612f LibRegex: Implement legacy octal escape parsing closer to the spec
The grammar for the ECMA-262 CharacterEscape is:

  CharacterEscape[U, N] ::
    ControlEscape
    c ControlLetter
    0 [lookahead ∉ DecimalDigit]
    HexEscapeSequence
    RegExpUnicodeEscapeSequence[?U]
    [~U]LegacyOctalEscapeSequence
    IdentityEscape[?U, ?N]

It's important to parse the standalone "\0 [lookahead ∉ DecimalDigit]"
before parsing LegacyOctalEscapeSequence. Otherwise, all standalone "\0"
patterns are parsed as octal, which are disallowed in Unicode mode.

Further, LegacyOctalEscapeSequence should also be parsed while parsing
character classes.
2021-08-15 11:43:45 +01:00
Timothy Flynn
83ca8c7e38 LibRegex: Convert LibRegex tests to use StringView in place of C-strings
A subsequent commit will add tests that require a string containing only
"\0". As a C-string, this will be interpreted as the null terminator. To
make the diff for that commit easier to grok, this commit converts all
tests to use StringView without any other functional changes.
2021-08-15 11:43:45 +01:00
Timothy Flynn
0c8f2f5aca LibRegex: Ensure escaped hexadecimals are exactly 2 digits in length 2021-08-15 11:43:45 +01:00
Timothy Flynn
2e4b6fd1ac LibRegex: Ensure escaped code points are exactly 4 digits in length 2021-08-15 11:43:45 +01:00
Timothy Flynn
e887314472 LibRegex: Fix ECMA-262 parsing of invalid identity escapes
* Only alphabetic (A-Z, a-z) characters may be escaped with \c. The loop
  currently parsing \c includes code points between the upper/lower case
  groups.
* In Unicode mode, all invalid identity escapes should cause a parser
  error, even in browser-extended mode.
* Avoid an infinite loop when parsing the pattern "\c" on its own.
2021-08-15 11:43:45 +01:00
Carlos César Neves Enumo
51b3fb5532 Assistant: Bundle UI updates to avoid flickering
While typing, we get the results from each provider asynchronously.

Previously, we were updating the UI for each result size,
which was causing a lot of flickering.

This fix creates a small timer to bundle the results
and reduce the number of UI updates per input.
2021-08-15 12:24:57 +02:00
Robert Stefanic
e26cfd313e LibJS: Prevent stack overflow in flatten_into_array()
The check for stack space in VM from push_execution_context has been
moved to a method on VM called did_reach_stack_space_limit. This
allows us to check the stack size in other places besides
push_execution_context.

We can now verify that we have enough space on the stack before calling
flatten_into_array to ensure that we don't cause a stack overflow error
when calling the function with a large depth.
2021-08-15 11:24:30 +01:00
Brian Gianforcaro
da51b8f39d LibCore: Move EventLoop to AK::Time 2021-08-15 12:20:38 +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
Brian Gianforcaro
188e5f018f ddate: Use DateTime::now() for time 2021-08-15 12:20:38 +02:00
Brian Gianforcaro
3870f4160d date: Use DateTime::now() for time, cleanup duplicate returns 2021-08-15 12:20:38 +02:00
sin-ack
98408b8920 Kernel: Don't hold the process list lock while destructing the process
Once we remove the process from the process list, we're free to do
whatever we want without any locks.
2021-08-15 12:17:29 +02:00
Linus Groh
4520863c0e LibJS/Tests: Add test for PlainMonthDay default reference year 2021-08-15 10:36:36 +01:00
Linus Groh
8f7a9e1e5c LibJS/Tests: Add test for PlainYearMonth default reference day 2021-08-15 10:36:36 +01:00
Linus Groh
1549845389 LibJS: Implement Temporal.PlainMonthDay.prototype.getISOFields() 2021-08-15 10:36:36 +01:00
Linus Groh
7fb05eb878 LibJS: Implement Temporal.PlainMonthDay.prototype.valueOf() 2021-08-15 10:36:36 +01:00
Linus Groh
c2ed3ad66b LibJS: Implement Temporal.PlainMonthDay.prototype.day 2021-08-15 10:36:36 +01:00
Linus Groh
9551aa17d3 LibJS: Implement Temporal.PlainMonthDay.prototype.monthCode 2021-08-15 10:36:36 +01:00
Linus Groh
1382be1707 LibJS: Implement Temporal.PlainMonthDay.prototype.calendar 2021-08-15 10:36:36 +01:00
Linus Groh
37b5a0715e LibJS: Implement Temporal.PlainMonthDay.prototype[@@toStringTag] 2021-08-15 10:36:36 +01:00
Linus Groh
0cf526d0c4 LibJS: Handle PlainMonthDay in the Calendar.prototype getters 2021-08-15 10:36:36 +01:00
Linus Groh
b76bae13fd LibJS: Handle PlainMonthDay in ISO{Year,Month,MonthCode,Day} 2021-08-15 10:36:36 +01:00
Linus Groh
ec00d4729a LibJS: Handle PlainMonthDay in GetTemporalCalendarWithISODefault 2021-08-15 10:36:36 +01:00
Linus Groh
1e54e37228 LibJS: Handle PlainMonthDay in ToTemporalCalendar 2021-08-15 10:36:36 +01:00
Linus Groh
be07e2e91b LibJS: Start implementing Temporal.PlainMonthDay
This commit adds the PlainMonthDay object itself, its constructor and
prototype (currently empty), and the CreateTemporalMonthDay abstract
operations.
2021-08-15 10:36:36 +01:00
Linus Groh
301d622b46 LibJS/Tests: Tweak PlainYearMonth Infinity test values
Since we want to test that +/- Infinity fails as an argument, we should
provide valid arguments for everything else - 0 for month isn't :^)
2021-08-15 10:36:36 +01:00
sin-ack
24fcff45ae Kernel: Make Process final
This silences a clangd diagnostic about Process holding virtual
functions but having a non-virtual destructor.
2021-08-15 02:27:13 +02:00
sin-ack
18f260b78b Kernel: Handle removal of Process from list before unref
This makes the following scenario impossible with an SMP setup:

1) CPU A enters unref() and decrements the link count to 0.
2) CPU B sees the process in the process list and ref()s it.
3) CPU A removes the process from the list and continues destructing.
4) CPU B is now holding a destructed Process object.

By holding the process list lock before doing anything with it, we
ensure that other CPUs can't find this process in the middle of it being
destructed.
2021-08-15 02:27:13 +02:00
sin-ack
2830a0ecda Kernel: Move ProcFS related overrides in Process to ProcessProcFSTraits
This allows us to 1) let go of the Process when an inode is ref'ing for
ProcFSExposedComponent related reasons, and 2) change our ref/unref
implementation.
2021-08-15 02:27:13 +02:00
sin-ack
748938ea59 Kernel: Handle allocation failure in ProcFS and friends
There were many places in which allocation failure was noticed but
ignored.
2021-08-15 02:27:13 +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
Nico Weber
f25be94487 LibCore: Make --version print same version as in LibGUI's About dialogs
Making every binary's behavior depend on the current git hash seems a
bit questionable to me, but we should be self-consistent about this.
2021-08-15 01:22:45 +02:00
Nico Weber
faa2c74b49 LibGUI: Simplify AboutDialog::version_string()
No behavior change.
2021-08-15 01:22:45 +02:00
Nico Weber
a45b6dbc07 LibCore: Include math.h instead of defining isnan() in ArgsParser.cpp 2021-08-15 01:22:45 +02:00
Linus Groh
87b2a6004f CI: Add a hello world step to azure-pipelines.yml so it stops failing 2021-08-14 22:43:34 +01:00
Linus Groh
6f9b87948b CI: Add required stages parameter to azure-pipelines.yml 2021-08-14 22:35:24 +01:00
Idan Horowitz
04359995a7 LibJS: Exclude FinalizationRegistries with queued cleanup jobs from GC
This is done by just adding them to the list of GC roots, which
prevents the VM from trying to run cleanup job of garbage collected
registries.
2021-08-14 22:32:31 +01:00
Kenneth Myhra
df176ca2d9 Ports: Add glib version 2.69.0 2021-08-14 22:32:00 +01:00
Kenneth Myhra
cb10c62327 LibC: Add SOCK_RDM and SOCK_SEQPACKET to socket.h 2021-08-14 22:32:00 +01:00
Kenneth Myhra
3875e8bd4b LibC: Add IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP to netin/in.h 2021-08-14 22:32:00 +01:00
Kenneth Myhra
f8d27303d0 LibC: Add stubs for several functions in xattr.h
The following functions are stubbed out:
- getxattr
- lgetxattr
- fgetxattr
- setxattr
- lsetxattr
- fsetxattr
- listxattr
- llistxattr
- flistxattr
2021-08-14 22:32:00 +01:00
Kenneth Myhra
04733ccb56 LibC: Add stub for res_query 2021-08-14 22:32:00 +01:00
Kenneth Myhra
8abfcb976d LibC: Add stub for fnmatch and a set of defined values
This adds a stub for fnmatch and the following defined values:
- FNM_PATHNAME
- FNM_NOESCAPE
- FNM_PERIOD
- FNM_FILE_NAME
- FNM_LEADING_DIR
- FNM_CASEFOLD
- FNM_EXTMATCH
2021-08-14 22:32:00 +01:00