Commit Graph

20158 Commits

Author SHA1 Message Date
Luke Wilde
5bc3371226 LibJS: Perform received abrupt generator completions in the generator
Previously, throw and return completions would not be executed inside
the generator. This is incorrect, as throw and return need to perform
unwinds which can potentially execute more code inside the generator,
such as finally blocks.

This is done by also passing the completion type alongside the passed
in value. The continuation block will immediately extract and type and
value and perform the appropriate operation for the given type.

For normal completions, this is continuing as normal.
For throw completions, it will perform `throw <value>`.
For return completions, it will perform `return <value>`, which is a
`Yield return` in this case due to being inside a generator.

This also refactors GeneratorObject to properly send across the
completion type and value to the generator inside of trying to operate
on the completions itself.

This is a prerequisite for yield*, as it performs special iterator
operations when receiving a throw/return completion and does not
complete the generator like the regular yield would.

There's still more work to be done to make GeneratorObject::execute
be closer to the spec. It's mostly a restructuring of the existing
GeneratorObject::next_impl.
2022-11-26 12:55:59 +01:00
Luke Wilde
277132f70d LibJS/Bytecode: Store unwind contexts inside RegisterWindow
Unwind contexts need to be preserved as we exit and re-enter a
generator.

For example, this would previously crash when returning from the try
statement after yielding as we lost the unwind context when yielding,
but still have a LeaveUnwindContext instruction from running
`perform_needed_unwinds` when generating the return statement.
```js
function* a() {
    try {
        return (yield 1);
    } catch {}
}

iter = a();
iter.next();
iter.next();
```
2022-11-26 12:55:59 +01:00
Luke Wilde
b914680f0c LibJS/Bytecode: Make yield by itself yield undefined 2022-11-26 12:55:59 +01:00
Simon Wanner
0c8da1478a LibX86: Use '+' format parameter to include signs for displacements 2022-11-26 12:50:38 +01:00
Simon Wanner
2ae228dac7 LibX86: Add basic x86-64 support
Most of the 64-bit instructions default to 32-bit operands and select
64-bit using REX.W prefixes. Because of that instead of defining new
instruction formats, this reuses the 32-bit formats and changes them
to take the REX prefixes into account when necessary.

Additionally this removes, adds or modifies the instruction
descriptors in the 64-bit table, where they are different from 32-bit.

Using 'disasm' these changes seem to cover pretty much all of our
64-bit binaries (except for AVX) :^)

Note that UserspaceEmulator will need to account for these prefixed
versions in its 32-bit instruction handlers before being usable on
x86-64.
2022-11-26 12:50:38 +01:00
Simon Wanner
735fd5f5db LibX86: Split up the ModRM and SIB bytes into multiple members
This will allow adding extra bits with REX prefixes
2022-11-26 12:50:38 +01:00
Simon Wanner
4041ea835c LibX86: Add OP_regW_immW
This is a variation of OP_reg32_imm32 that turns into
"OP_reg64_imm64" with a REX.W prefix.
2022-11-26 12:50:38 +01:00
Simon Wanner
bf768ed215 Profiler: Don't stop disassembly on invalid instructions 2022-11-26 12:50:38 +01:00
Simon Wanner
6b5e4cdfbc disasm: Demangle symbols 2022-11-26 12:50:38 +01:00
Simon Wanner
4076619655 disasm: Print virtual offsets with pointer semantics
Instead of assuming the virtual offset will be 8 hex digits (which is OK
for 32 bit values), just use the ":p" modifier to ensure it prints the
virtual offset as a pointer, so if the code is compiled for 64 bit CPUs,
it will use 16 hex digits accordingly.
2022-11-26 12:50:38 +01:00
Simon Wanner
c5681e06c6 LibX86: Make Instruction::length work for invalid instructions 2022-11-26 12:50:38 +01:00
Simon Wanner
ab1f28d566 LibX86: Templatize the opcode table builders 2022-11-26 12:50:38 +01:00
Simon Wanner
06ece474e9 LibX86: Add {Address,Operand}Size::Size64
For now the opcode tables for OperandSize::Size64 are empty
2022-11-26 12:50:38 +01:00
Simon Wanner
a7268c3c74 LibX86+UserspaceEmulator: Introduce AddressSize and OperandSize enums
These replace the bools a32 and o32, which will make implementing
64-bit sizes possible. :^)
2022-11-26 12:50:38 +01:00
Eli Youngs
7cd43deb28 hexdump: Replace Core::File with Core::Stream::File
Previously, hexdump used Core::File to read input into a fixed buffer.
This PR rewrites the file handling to use the more modern
Core::Stream::File, which reads data into spans. By using spans, we
can also simplify the rest of the code, which previously used memcpy
for array manipulation and relied on manual bookkeeping to keep track of
offsets.
2022-11-26 11:07:00 +01:00
Baitinq
f1205b608f Browser: Replace history entry if loading URL because of a redirect
We now replace the current history entry if the page-load has been
caused because of a redirect. This makes it able to traverse the
history if one of the entries redirects you, which previously
caused an infinite history traversion loop.
2022-11-26 11:03:24 +01:00
Baitinq
b447e486b5 Browser: Add History::replace_current() function
This function replaces the current history entry with a new history
entry.
2022-11-26 11:03:24 +01:00
Baitinq
45214fdb1a LibWeb+WebContent: Label redirects with new FrameLoader::Type::Redirect
Previously we labeled redirects as normal FrameLoader::Type::Navigation,
now we introduce a new FrameLoader::Type::Redirect and label redirects
with it. This will allow us to handle redirects in the browser
differently (such as for overwritting the latest history entry when a
redirect happens) :^)
2022-11-26 11:03:24 +01:00
Jelle Raaijmakers
45a59b4d7e Taskbar: Unbreak SDL2 port by changing include path
Ports would not be able to find `QuickLaunchWidget.h` this way.
2022-11-26 10:34:19 +01:00
Arda Cinar
7f20e7324c Taskbar: Removed the awkward window reference struct 2022-11-26 09:51:11 +01:00
Arda Cinar
7afb7e65d5 Taskbar: Made it possible to add a system menu to taskbar later
This makes it possible to construct the taskbar before the system
menu and remove the awkward reference in Taskbar/main.cpp
2022-11-26 09:51:11 +01:00
Arda Cinar
7456a84e68 Taskbar: Rename start_menu to system_menu
The main menu in GUI (the one in the lower left side of screen by
default) was called start_menu in some parts of the code and system_menu
in others. In the documentation, it was referred to as "system menu".
So, in order to be consistent, these variables are all renamed to
system_menu
2022-11-26 09:51:11 +01:00
Liav A
9f571e0dae Userland: Enhance jail-attach utility to support existing and new jails
The Core::System::create_jail function already provided the new jail
index as a result, so it was just a matter of using it when calling the
LibCore join_jail function to use the new jail.
2022-11-26 01:47:50 -07:00
cflip
b83181ef93 LibGL: Use buffers in vertex pointer functions and glDrawElements
Many of these functions will treat the 'pointer' parameter as an offset
into a buffer if one is currently bound.

This makes it possible to run ClassiCube with OpenGL 1.5 support!
2022-11-26 09:38:13 +01:00
cflip
59df2e62ee LibGL: Add simple implementation of buffer objects
For now, buffers are only implemented on the LibGL side, however in the
future buffer objects should be stored in LibGPU.
2022-11-26 09:38:13 +01:00
cflip
892006218a LibGL: Refactor TextureNameAllocator to a more general NameAllocator
This functionality can also be used for other types of objects.
2022-11-26 09:38:13 +01:00
Timothy Flynn
e86e59699d LibJS: Use Object's new deferred instrinsic storage for GlobalObject 2022-11-26 09:36:22 +01:00
Timothy Flynn
12f9f3d9ef LibJS: Support instrinsic Object properties with deferred evaluation
For performance, it is desirable to defer evaluation of intrinsics that
are stored on the GlobalObject for every created Realm. To support this,
Object now maintains a global storage map to store lambdas that will
return the associated intrinsic when evaluated. Once accessed, the
instrinsic is moved from this global map to normal Object storage.

To prevent this flow from becoming observable, when a deferred intrinsic
is stored, we still place an empty object in the normal Object storage.
This is so we still create the metadata for the object, and in doing so,
can preserve insertion order of the Object storage. Otherwise, this will
be observable by way of Object.getOwnPropertyDescriptors.
2022-11-26 09:36:22 +01:00
Timothy Flynn
4f08f2f581 LibJS: Lazily initialize most Realm instrinsic contructors/prototypes
This changes Intrinsics to not initialize most of its constructors and
prototype right away. We still initialize a few that are needed before
some others are created, though we may eventually be able to "link"
dependencies at compile time to avoid this.
2022-11-26 09:36:22 +01:00
Jelle Raaijmakers
70a7bca920 LibSQL: Fix BTree corruption in TreeNode::split
After splitting a node, the new node was written to the same pointer as
the current node - probably a copy / paste error. This new code requires
a `.pointer() -> u32` to exist on the object to be serialized,
preventing this issue from happening again.

Fixes #15844.
2022-11-26 09:15:34 +01:00
Jelle Raaijmakers
e5e00a682b LibSQL: Remove unused method Heap::has_block 2022-11-26 09:15:34 +01:00
Jelle Raaijmakers
0460a654d4 LibSQL: Remove superfluous VERIFYs for Vector accessing
Remove some `[]` operators' out-of-bounds checks which are already
performed by the underlying `Vector`.
2022-11-26 09:15:34 +01:00
Sam Atkins
234bc0c237 LibGfx: Prevent calling to_type<T>() on Line/Point/Rect/Size<T>
Also, add `Line::to_type<T>()` since that was missing.

Calling to_type() with the same type as the existing object accomplishes
nothing except wasting some cycles and making the code more verbose,
and it is hard to spot. Nobody does this in the code currently
(yay!) but I made this mistake repeatedly when doing my step-by-step
CSS Pixels conversion, so let's make it easier to catch them.
2022-11-26 09:14:49 +01:00
Timothy Flynn
34fd5cb206 SoundPlayer+VideoPlayer: Set the play/pause action text on state change 2022-11-26 09:02:25 +01:00
Timothy Flynn
4addad67d1 LibGUI: Propagate changing an action's text to its associated buttons
All other action state changes are already propagated to the action's
buttons. Do the same for text.
2022-11-26 09:02:25 +01:00
Timothy Flynn
234ae3a2ae LibGUI: Allow buttons to control the behavior when their text changes
Some buttons control how their text is set in unique ways. For example,
GUI::ToolbarButton will set only its tooltip instead of its text if it
has an icon. So when the text changes, ToolbarButton will want to change
its tooltip instead.
2022-11-26 09:02:25 +01:00
Timothy Flynn
62cbfc68b9 Revert "LibGUI: Update buttons' text/tooltips in Action::set_text"
This reverts commit e20756f9f7.

Some buttons, e.g. GUI::ToolbarButton, set text to be used only as a
tooltip instead of text on the button itself. This commit forced those
buttons to have text on them when their action became set. For most
toolbars, this was an invisible side effect; the button icons covered
the whole button rect. But the toolbar for EmojiInputDialog has slightly
smaller icons, causing an ellipsis to be displayed next to the icon.
2022-11-26 09:02:25 +01:00
Rodrigo Tobar
d04613d252 LibPDF: Fix path coordinates calculation
Paths rendering was buggy because the map() function that translates
points from user space to bitmap space applied the vertical flip
conversion that the current transformation matrix already considers;
Hence, all paths were upside down. The only exception was the "re"
instruction, which manually adjusted the Y coordinate of its points to
be flipped again (and had a FIXME saying that this should be
unnecessary).

This commit fixes the map() function that maps userspace points to
bitmap coordinates. The "re" operator implementation has also been
simplified creating a rectangle first and mapping *that* instead of
mapping each point individually.
2022-11-26 08:56:35 +01:00
kleines Filmröllchen
d9c1eb860f AudioServer: Detect improperly detached audio clients
Because IPC is used very little in audio server communication, a
ping-pong method like WindowServer is neither a good nor a reliable way
of detecting detached audio clients. AudioServer was previously doing
nothing to detect the kinds of clients that never closed their
connection properly, which happens e.g. when a program is force-closed.
Due to reference-counting cycles, the associated client connection
queues were being kept alive. However, the is_open method of local
sockets reliably detects all kinds of disconnected sockets and can
easily be adapted for this use case. With this fix, we no longer get
"Audio client can't keep up" spam on improperly disconnected clients,
and the client queues don't fill up indefinitely, reducing processing
and memory usage in AudioServer.
2022-11-25 17:43:16 -07:00
Jelle Raaijmakers
441555ea56 LibVT: Prevent u16 underflow when resizing terminal to a height of 1
Resizing the Terminal window to its smallest size no longer crashes.

Fixes #7296.
2022-11-26 01:28:05 +01:00
implicitfield
19e6befddc FuzzTar+tar: Advance the stream before continuing
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53733
This bug was caused by a regression introduced in c88d8a2.
2022-11-26 01:24:12 +01:00
Baitinq
73e87d694e LibWeb: Don't collapse TextNode if it's editable
Fixes #16127
2022-11-26 01:21:02 +01:00
MacDue
76de41c3b7 LibGfx: Add draw_line_for_path() and remove AntiAliasPolicy
draw_line_for_path() is the same as the standard antialiased
draw_line() but with a few few small hacks to improve the look of
paths.

AntiAliasPolicy is also removed as it's now unused.
2022-11-26 01:17:04 +01:00
MacDue
f7a680f30a LibGfx: Implement nicer antialiased lines
This is not any 'proper' algorithm, this was just a shower thought
idea. There probably is a better algorithm to achieve the same effect
out there, if someone knows of one please replace this code :^).

This works by rendering the line a scanline at a time, which avoids
repainting over any pixel on the line (so opacity now works with AA
lines). This generally seems to achieve a much nicer looking line.

I've not done any proper benchmarking of this, but some little messing
around showed that this new implementation was a little faster than
the old one too, so that's a nice little bonus.

With the inclusion of a few minor hacks this also goes a surprisingly
far way in improving our SVG rendering too (for both filled and stroked
paths). :^)
2022-11-26 01:17:04 +01:00
kleines Filmröllchen
c948777ec4 aplay: Preload more audio
This reduces glitching, but it is in no way a good solution. We should
really do the loading on another thread, but that's out of scope.
2022-11-25 17:01:44 -07:00
kleines Filmröllchen
9b819a0dc9 LibAudio: Set asynchronous audio enqueuer thread to maximum priority
Anything that handles audio in this way should run at maximum priority.
2022-11-25 17:01:44 -07:00
Lucas CHOLLET
4219d50a21 LibGfx: Use the Midpoint Ellipse Algorithm
It is only used to draw non-antialiased and non-filled ellipses.
2022-11-26 00:49:05 +01:00
Daniel Ehrenberg
09841f56ed LibWeb: Add initial implementation of structured clone
This implementation only works for cloning Numbers, and does not try to
do all the spec steps for structured serialize and deserialize.

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2022-11-26 00:47:23 +01:00
Sam Atkins
d94d60219c LibWebView+WebContent: Propagate unconsumed input events out of OOPWV
Since 9e2bd9d261a8c0c1b5eeafde95ca310efc667204, the OOPWV has been
consuming all mouse and keyboard events, preventing action shortcuts
from working. So let's fix that. :^)

OOPWV now queues up input events, sending them one at a time to the
WebContent process and waiting for the new
`did_finish_handling_input_event(bool event_was_accepted) =|` IPC call
before sending the next one. If the event was not accepted, OOPWV
imitates the usual event bubbling: first passing the event to its
superclass, then to its parent widget, and finally propagating to any
Action shortcuts.

With this, shortcuts like Ctrl+I to open Browser's JS console work
again, except when a contenteditable field is selected. That's a
whole separate stack of yaks.

Co-authored-by: Zaggy1024 <zaggy1024@gmail.com>
2022-11-26 00:44:49 +01:00
Sam Atkins
2654bfead4 LibWebView: Define the OOPWV's superclass in one place
This lets us change it later without having to remember to update a
bunch of uses. (More are coming in the next commit.)
2022-11-26 00:44:49 +01:00