Commit Graph

28600 Commits

Author SHA1 Message Date
Andreas Kling
e67155638c LibJS: Take advantage of Value::Type::Int32 in a bunch of functions
If a JS::Value has type Int32, we know it's a finite, 32-bit integer.
Use this information to avoid converting it to a double if possible.
2021-10-07 19:27:30 +02:00
Andreas Kling
5b1f697460 AK+Kernel: Make automatically locking RefPtr & co a kernel-only thing
Some time ago, automatic locking was added to the AK smart pointers to
paper over various race conditions in the kernel. Until we've actually
solved the issues in the kernel, we're stuck with the locking.

However, we don't need to punish single-threaded userspace programs with
the high cost of locking. This patch moves the thread-safe variants of
RefPtr, NonnullRefPtr, WeakPtr and RefCounted into Kernel/Library/.
2021-10-07 19:27:30 +02:00
Luke Wilde
ca060d8566 Base: Use requestAnimationFrame in Game of Life WASM demo
Since OOPWV now supports RAF, we can use it in the GOL WASM demo :^)
2021-10-07 19:13:34 +02:00
Alex Major
d4a0ecac31 PixelPaint: Close tab now prompts for a save 2021-10-07 18:35:56 +02: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
Luke Wilde
eb774aadbf PixelPaint: Use reorderable tabs 2021-10-07 17:04:12 +02:00
Linus Groh
ef004c6b98 LibJS: Use round_number_to_increment(double) in round_time()
Much nicer :^)
2021-10-07 13:00:24 +01:00
Linus Groh
8b07453bce LibJS: Add non-BigInt overload of round_number_to_increment()
Unlike the spec we chose BigInt for the input and output types here as
it was being used with ℝ(ns), ns being of type BigInt, in one place and
a conversion to double would not be safe.
Since in many places we'll have double input values, let's add a double
overload of this function to avoid awkward conversions and expensive
allocations.
2021-10-07 13:00:24 +01:00
Peter Elliott
da804d95f7 Browser: Use reorderable tabs 2021-10-07 12:19:27 +02:00
Peter Elliott
e1684860a3 LibGUI: Support drag-to-reorder in TabWidget 2021-10-07 12:19:27 +02:00
Andreas Kling
df674023d6 LibJS: Add fast_is<T>() for FunctionExpression and ClassExpression
Spotted RTTI for these two above 1% in a profile.
2021-10-07 12:05:13 +02:00
Andreas Kling
41a072bded LibJS: Fast non-local variable access :^)
This patch introduces the "environment coordinate" concept, which
encodes the distance from a variable access to the binding it ends up
resolving to.

EnvironmentCoordinate has two fields:

    - hops:  The number of hops up the lexical environment chain we have
             to make before getting to the resolved binding.

    - index: The index of the resolved binding within its declarative
             environment record.

Whenever a variable lookup resolves somewhere inside a declarative
environment, we now cache the coordinates and reuse them in subsequent
lookups. This is achieved via a coordinate cache in JS::Identifier.

Note that non-strict direct eval() breaks this optimization and so it
will not be performed if the resolved environment has been permanently
screwed by eval().

This makes variable access *significantly* faster. :^)
2021-10-07 11:53:18 +02:00
Andreas Kling
421845b0cd LibJS: Taint variable environment chain after non-strict direct eval()
Since non-strict direct eval() can insert new bindings into a
surrounding var scope, we cannot safely cache some assumptions about
environment chain layout after eval() has taken place.

Since eval() is rare, let's do what other engines do and simply
deoptimize in its presence. This patch adds a new "permanently screwed"
flag to JS::Environment that will be set on the entire variable
environment chain upon non-strict direct eval().
2021-10-07 11:53:18 +02:00
Rodrigo Tobar
96a67d24e9 Strace: Add formatting for misc syscalls
These are exit, realpath and getrandom. This required a bit of extra
infrastructure to deal with exit's void return type.
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
8125edfe79 Strace: Add formatting for main memory-related syscalls
These include mmap, munmap, mprotect and mmap_set_name.
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
9394cfcaf3 Strace: Add formatting for main socket syscalls
The formatting of these functions is not complete, but gives already
very good information to the user.
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
a09b1879ca Strace: Add main infrastructure and formatting of main I/O operations
This commit introduces the main infrastructure used for turning register
values into user-facing values that can be printed by strace. This
includes the ability to copy data from a particular memory address in
the traced process. On top of this, (partial) formatting has been added
for the most common I/O operations (open, read, write, lseek, close,
stat, fstat).
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
f7a0196764 Strace: Move output formatting to separate function
Moving the formatting of strace's output into a separate function will
allow us to introduce more complexity into the formatting logic without
touching the main body of the program.

The new function uses a switch statement to select how to format the
arguments and result depending on the syscall. At this point we only
include the default formatting, where the registers are simply dumped,
but later on we can add specializations for each system call we want to
support.
2021-10-07 08:47:49 +03:30
Mart G
5f53dc6a45 SpaceAnalyzer: Fix rendering bug when dealing with large file systems 2021-10-07 08:46:15 +03:30
Ben Wiederhake
c569ed7e8b LibWebSocket: Add missing headers to Message.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake
c602db1620 LibWeb: Add missing headers 2021-10-06 23:52:40 +01:00
Ben Wiederhake
7619dbdbb4 LibWeb: Clean up static function in header
'static' for a function means that the symbol shall not be made public
for the result of the current compilation unit. This does not make sense
in a header, especially not if it's a large function that is used in
more than one place and not that performance-sensitive.
2021-10-06 23:52:40 +01:00
Ben Wiederhake
21ba485fd3 LibWeb: Resolve cyclic dependency: Length and CalculatedStyleValue
Previously: Length (and all nearly all of its inline method
definitions) depended on the definition of class CalculatedStyleValue.
Meanwhile, CalculatedStyleValue (and nearly all of its namespaced
structs) depended on the definition of class Length.

Thus, a compilation unit that (for example) only contains
    #include <Userland/Libraries/LibWeb/CSS/Length.h>
would fail to compile.

This patch resolves this issue by pushing the inline definition of
various Web::CSS::Length methods into a different file.
2021-10-06 23:52:40 +01:00
Ben Wiederhake
0db6ca4065 LibWeb: Resolve cyclic dependency between StyleSheet and ImportRule
Previously: CSSImportRule::loaded_style_sheet() (and others) depend on
the definition of class CSSStyleSheet. Meanwhile,
CSSStyleSheet::template for_each_effective_style_rule (and others)
depend on the definition of class CSSImportRule.

This hasn't caused any problems so far because CSSStyleSheet.h happened
to be always included after CSSImportRule.h (in part due to alphabetical
ordering).

However, a compilation unit that (for example) only contains
    #include <Userland/Libraries/LibWeb/CSSImportRule.h>
would fail to compile.

This patch resolves this issue by pushing the inline definition of
Web::CSS::CSSStyleSheet::for_each_effective_style_rule and
for_first_not_loaded_import_rule into a different file, and adding the
missing headers.
2021-10-06 23:52:40 +01:00
Ben Wiederhake
0f35ae13fb LibWasm: Add missing forward declaration to Printer/Printer.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake
fd7e8f16f2 LibVT: Add missing headers 2021-10-06 23:52:40 +01:00
Ben Wiederhake
d9a0d2182d LibThreading: Add missing headers to Mutex.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake
5e4739e371 LibTLS: Add missing headers to CipherSuite.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake
e6ea13af61 LibSyntax: Add missing headers to HighlighterClient.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake
9d89b64d59 LibSQL: Resolve cyclic dependency
Previously, class SQL::Key
depends on def class SQL::IndexDef (because inline def index())
depends on def class SQL::KeyPartDef (inline def key_definition())
depends on def class SQL::ColumnDef (because base class)
depends on def class SQL::Relation (because base class)
depends on def class SQL::Key (because inline def hash()).

This hasn't caused any problems so far because Meta.h happened to be
always included after Key.h (in part due to alphabetical ordering).

However, a compilation that for example only contains
    #include <Userland/Libraries/LibSQL/Key.h>
would fail to compile.

This patch resolves this issue by pushing the inline definition of
SQL::Relation::hash() into a different file. Yes, this might reduce
performance marginally, but this gets it to compile again.
2021-10-06 23:52:40 +01:00
Ben Wiederhake
a95b321bf1 LibJS: Add missing headers 2021-10-06 23:52:40 +01:00
Ben Wiederhake
9d2e06b039 LibGUI: Add missing headers 2021-10-06 23:52:40 +01:00
Ben Wiederhake
5f25182cd5 LibCrypto: Add missing header to EMSA_PSS.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake
ce1313fbdc LibCompress: Add missing header to DeflateTables.h 2021-10-06 23:52:40 +01:00
Ben Wiederhake
f9a4f4f7e6 LibC: Fix redeclaration in x86_64/regs.h
In QtCreator (and under weird configurations with gcc), this used to
fail with the error messages like: "error: member of anonymous union
redeclares '___'".

This patch gives each member a unique name.
2021-10-06 23:52:40 +01:00
Ben Wiederhake
8ba572d650 LibC: Make sure ARCH macro is available before use 2021-10-06 23:52:40 +01:00
Ben Wiederhake
7cd0440571 Base: Fix idempotency in 'little' example 2021-10-06 23:52:40 +01:00
Ben Wiederhake
f8d7b4daea AK: Add missing headers
Example failure:

IDAllocator.h only pulls in AK/Hashtable.h, so any compilation unit that
includes AK/IDAllocator.h without including AK/Traits.h before it used
to be doomed to fail with the cryptic error message "In instantiation of
'AK::HashTable<T, TraitsForT, IsOrdered>::Iterator AK::HashTable<T,
TraitsForT, IsOrdered>::find(const T&) [with T = int; TraitsForT =
AK::Traits: incomplete type 'AK::Traits<int>' used in nested name
specifier".
2021-10-06 23:52:40 +01:00
sin-ack
c330ad27b6 SystemMonitor: Use u64 for all GraphWidget values
Turns out size_t is not guaranteed to be 64-bit on i686 and trying to
set the max value using a u64 caused a narrowing conversion.
2021-10-07 00:42:24 +02:00
Andreas Kling
4444bcabde LibJS: Make Reference aware of DeclarativeEnvironment indices
VM::resolve_binding() can now return a Reference that knows the exact
binding index if it's pointing into a DeclarativeEnvironment.

Reading/writing through the Reference will now use direct environment
access when possible.
2021-10-07 00:23:36 +02:00
Andreas Kling
540ce075b6 LibJS: Add direct (indexed) binding accessors to DeclarativeEnvironment
This patch adds two DeclarativeEnvironment APIs:

- get_binding_value_direct()
- set_mutable_binding_direct()

These work identically to their non-direct-suffixed counterparts, but
take an index instead of a bound name. This will allow someone who has
a binding index to get/set that binding directly without any additional
hash lookups.
2021-10-07 00:23:36 +02:00
Andreas Kling
cb696eff08 LibJS: Make Environment::has_binding() optionally return binding index
If the caller wants to use the binding index for anything, if there is
such a thing, it can now be obtained via an optional out-parameter.
2021-10-07 00:23:36 +02:00
Andreas Kling
6ef5464015 LibJS: Make DeclarativeEnvironment store bindings in a Vector
The previous storage for DeclarativeEnvironment looked like this:

    HashMap<FlyString, Binding> m_bindings;

This patch changes that to:

    HashMap<FlyString, size_t> m_names;
    Vector<Binding> m_bindings;

The main goal here is to give each binding an index that can ultimately
be cached and used for optimized environment accesses.
2021-10-07 00:23:36 +02:00
sin-ack
7aa3cfda09 SystemMonitor: Use size_t for graph values
The memory and CPU graphs fail to display anything when the memory size
is larger than 2**31 bytes, because of the small range of int. This
commit makes replaces the type with size_t. Hopefully nobody will have
18 quintillion bytes of memory before this gets replaced. :^)
2021-10-07 00:04:05 +02:00
Andreas Kling
f73aa8e2bd LibWeb: Move line boxes from Layout::Box to BlockContainer
Per the spec, only a BlockContainer" can have line boxes, so let's not
clutter up every Layout::Box with line boxes.

This also allows us to establish an invariant that BFC and IFC always
operate on a Layout::BlockContainer.

Note that if BlockContainer has all block-level children, its line boxes
are not used for anything. They are only used in the all inline-level
children scenario.
2021-10-06 21:53:25 +02:00
Andreas Kling
a0bea52a5f LibWeb: Mark Layout::ListItemMarkerBox as never having children
List item markers will never have children, so let's mark them as such,
which now allows our layout system to skip over their "insides" and
going straight to positioning instead.
2021-10-06 21:49:09 +02:00
Andreas Kling
dfeb4550d5 LibWeb: Don't attempt to layout the inside of childless boxes
Some boxes cannot have children (most commonly replaced elements),
and so there is nothing meaningful inside them to layout.

We now use the can_have_children() flag to quickly skip over such boxes
instead of creating a formatting context and other pointless busywork.
2021-10-06 21:47:57 +02:00
Andreas Kling
d9e0fd8823 LibWeb: Rename Layout::Node::is_block_box() => is_block_container() 2021-10-06 20:10:36 +02:00
Andreas Kling
fa45b905bf LibWeb: Remove unused local in FormattingContext::layout_inside() 2021-10-06 20:10:36 +02:00
Andreas Kling
c4826eae4f LibWeb: Rename Layout::BlockBox => BlockContainer
There's a subtle difference here. A "block box" in the spec is a
block-level box, while a "block container" is a box whose children are
either all inline-level boxes in an IFC, or all block-level boxes
participating in a BFC.

Notably, an "inline-block" box is a "block container" but not a "block
box" since it is itself inline-level.
2021-10-06 20:10:36 +02:00