Commit graph

6221 commits

Author SHA1 Message Date
Idan Horowitz
e3ef241108 LibJS: Remove the non-standard put helper and replace it's usages
This removes all usages of the non-standard put helper method and
replaces all of it's usages with the specification required alternative
or with define_direct_property where appropriate.
2021-07-06 14:20:30 +01:00
Idan Horowitz
53f70e5208 LibJS: Remove the default length & attributes from define_native_*
These are usually incorrect, and people sometimes forget to add the
correct values as a result of them being optional, so they should just
be specified explicitly.
2021-07-06 14:20:30 +01:00
Idan Horowitz
a6b8291a9b LibJS: Add define_direct_property and remove the define_property helper
This removes all usages of the non-standard define_property helper
method and replaces all it's usages with the specification required
alternative or with define_direct_property where appropriate.
2021-07-06 14:20:30 +01:00
Idan Horowitz
e915155ca4 LibJS: Remove impossible check from Array's native length getter/setter
Since the object rewrite native property getters/setters are always
called with the owning object as the this_value, which in this case is
an Array object, and as such this checks are always false.
2021-07-06 14:20:30 +01:00
Idan Horowitz
6787e86a3a LibJS: Add and use the CreateNonEnumerableDataPropertyOrThrow AO 2021-07-06 14:20:30 +01:00
Idan Horowitz
6da7f43580 LibJS: Bring String.prototype.split closer to the specification
Specifically, add a couple of missing exception checks and use the
CreateDataPropertyOrThrow abstract operation.
2021-07-06 14:20:30 +01:00
Idan Horowitz
28172fde10 LibJS: Add missing exception check to the ArraySpeciesCreate AO 2021-07-06 14:20:30 +01:00
Luke
d89f539d16 LibJS: Add %TypedArray%.prototype.reverse
This fixes 13 test262 cases.
2021-07-06 13:40:27 +01:00
Luke
275092bb03 LibJS: Fix byteOffset copy-paste error in TypedArray buffer test 2021-07-06 13:40:19 +01:00
Luke
c8db607c00 LibJS: Fix byteOffset copy-paste error in TypedArray byteLength test 2021-07-06 13:40:19 +01:00
Luke
651becbfb1 LibJS: Use Number instead of parseInt in TypedArray forEach BigInt tests
The Number constructor previously didn't support converting BigInts to
regular numbers, so I used parseInt as a workaround.

Since it now supports this, this workaround is no longer needed.
2021-07-06 13:40:19 +01:00
Luke
8244d7916e LibJS: Add Uint8ClampedArray to TypedArray tests 2021-07-06 13:40:19 +01:00
Linus Groh
3faeabf1dc Revert "LibJS: Don't hoist functions under certain circumstances"
This reverts commit 3411d50737.

It was causing LeakSanitizer on CI to fail, possibly due to a circular
reference.
2021-07-06 13:25:37 +01:00
Andreas Kling
73183ee5c4 PixelPaint: Paint the area around the image with ColorRole::Tray
It didn't really make sense for the transparency grid to extend
infinitely around the image. Now the grid is only visible underneath
the image, which matches how most other editors behave.
2021-07-06 12:24:51 +02:00
Andreas Kling
b650bb602a PixelPaint: Don't repaint area outside image when image itself changed 2021-07-06 12:24:51 +02:00
Andreas Kling
e7b8f6fe48 LibGfx: Make Painter::fill_rect_with_checkerboard() faster
We now divide each scanline into prologue, aligned run, and epilogue.
Basically, we draw enough pixels one-by-one until we reach a grid
intersection. Then we draw full grid cell slices using fast memory
fills. Finally we go back to one-by-one for the epilogue.

This is roughly 2.5x faster in a microbenchmark and no longer dominates
the ImageViewer and PixelPaint resizing profiles.
2021-07-06 12:24:51 +02:00
Luke
99cb54670f LibJS: Add missing exception check in internalize_json_property
The call to enumerable_own_property_names in the non-array case was
missing an exception check.

Fixes 1 test262 case (JSON/parse/reviver-object-own-keys-err.js)
2021-07-06 01:33:52 +01:00
Hendi
3411d50737 LibJS: Don't hoist functions under certain circumstances
When a lexical declaration with the same name as a function exists,
the function is not hoisted (annex B).
2021-07-06 00:15:37 +01:00
Hendi
c194afd17c LibJS: Fix runaway let scope when parsing for-in/of statements
This requires variables that should be exported to the script host
or to other scripts to be declared as var (such as in test-common.js),
since lexically-scoped variables won't be visible.
2021-07-06 00:15:37 +01:00
Hendi
793e1bf28a LibJS: Fix variable scoping issues in two tests 2021-07-06 00:15:37 +01:00
Hendi
38fd980b0c LibJS: Improve function hoisting across blocks
The parser now keeps track of a scope chain so that it can hoist
function declarations to the closest function scope.
2021-07-06 00:15:37 +01:00
Hendi
72f8d90dc5 LibJS: Remove variables from FunctionNode
They weren't consumed anywhere outside the AST and went
against the usual concept of having declaration in ScopeNode.
2021-07-06 00:15:37 +01:00
Timothy Flynn
e0c9f58b0c LibJS: Implement and use the GetSubstitution abstract operation
Used by String.prototype.replace, String.prototype.replaceAll, and
RegExp.prototype [ @@replace ].
2021-07-05 23:26:41 +01:00
Timothy Flynn
4985d3ef42 LibJS: Fix linked specification of String.prototype.concat 2021-07-05 23:26:41 +01:00
Hendiadyoin1
b583726deb LibM: Use assembly for all atan versions 2021-07-06 00:16:45 +02:00
Hendiadyoin1
119f280f34 LibM: Use fcos for cosine
For some reason we were using sin(x+M_PI_2) instead
2021-07-06 00:16:45 +02:00
Gunnar Beutner
f3a3a63b68 LibThread: Fix formatting that was broken by the previous commit 2021-07-06 00:14:19 +02:00
Gunnar Beutner
01db5205ab LibThreading: Fix building the library on macOS 2021-07-06 00:06:32 +02:00
Andreas Kling
565796ae4e Kernel+LibC: Remove sys$donate()
This was an old SerenityOS-specific syscall for donating the remainder
of the calling thread's time-slice to another thread within the same
process.

Now that Threading::Lock uses a pthread_mutex_t internally, we no
longer need this syscall, which allows us to get rid of a surprising
amount of unnecessary scheduler logic. :^)
2021-07-05 23:30:15 +02:00
Andreas Kling
c40780d404 LibThreading: Reimplement Lock in terms of pthread_mutex_t
This class was previously a spinlock that would call sys$donate()
to donate its timeslice to whichever thread was holding the lock.

Now that pthread_mutex_t has a fast path, let's implement Lock on top
of that instead and get rid of the last remaining user of sys$donate().
2021-07-05 23:30:15 +02:00
Andreas Kling
a6f0861c7b Assistant: Add missing <unistd.h> include 2021-07-05 23:30:15 +02:00
Andreas Kling
90e5fd5b53 LibC+LibPthread: Add PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
This is a common but non-standard way of initializing a pthread_mutex_t
in recursive mode.
2021-07-05 23:30:15 +02:00
Luke
85bd454b48 LibWeb: Use is_nullish instead of is_null for nullable types
As according to: https://heycam.github.io/webidl/#es-nullable-type
Both null and undefined are treated as IDL null, but we were only
treating null as IDL null.
2021-07-05 21:36:45 +02:00
Linus Groh
339ccba354 LibJS: Make Object.prototype.toString() fully spec compliant
- Fix evaluation order: IsArray(O) should always be called and before
  Get(O, @@toStringTag), previously it was the other way around and
  IsArray would only be called if @@toStringTag is not a string
- Add missing exception checks to both function calls
- Add missing builtin tag for arguments object

Also, while we're here:
- Update variable names to match spec
- Add spec step comments
2021-07-05 20:21:26 +01:00
Marcus Nilsson
e1906d74b8 PixelPaint: Make move_selection() cycle through layers
Previously move_selection() did not work as expected. Instead store the
selected layer index in a member variable and continue to cycle through
the layers when you come to the start/end. Also use it to scroll into
view. Lastly rename the function to cycle_through_selection() to make it
clearer what it does.
2021-07-05 20:39:30 +02:00
Marcus Nilsson
8d205ae62e PixelPaint: Use layer menu as context menu in LayerListWidget
This enables the layer menu as a context menu in LayerListWidget,
setting the clicked layer as active for now, but in the future it
would be nice to have custom menu applying to the clicked layer instead
of the active layer.
2021-07-05 20:39:30 +02:00
Marcus Nilsson
9df3550e58 PixelPaint: Change color of disabled layers in LayerListWidget 2021-07-05 20:39:30 +02:00
Marcus Nilsson
36abb38f26 PixelPaint: Make LayerListWidget scrollable
Previously only a couple of layers would fit in the layer widget, this
makes it scrollable and also tweaks some sizes and coordinates.
2021-07-05 20:39:30 +02:00
Marcus Nilsson
13e526de43 PixelPaint: Change the default layer name to "Layer"
Change the default layer name to "Layer" and enable the user to press
return to quickly close the dialog.
2021-07-05 20:39:30 +02:00
Sergey Bugaev
690141ff8b LibPthread: Reimplement semaphores
This implementation does not use locking or condition variables
internally; it's purely based on atomics and futexes.

Notably, concurrent sem_wait() and sem_post() calls can run *completely
in parallel* without slowing each other down, as long as there are empty
slots for them all to succeed without blocking.

Additionally, sem_wait() never executes an atomic operation with release
ordering, and sem_post() never executes an atomic operation with acquire
ordering (unless you count the syscall). This means the compiler and the
hardware are free to reorder code *into* the critical section.
2021-07-05 20:26:01 +02:00
Sergey Bugaev
00d8dbe739 LibPthread: Reimplement condition variables
This implementation features a fast path for pthread_cond_signal() and
pthread_cond_broadcast() for the case there's no thread waiting, and
does not exhibit the "thundering herd" issue in
pthread_cond_broadcast().

Fixes https://github.com/SerenityOS/serenity/issues/8432
2021-07-05 20:26:01 +02:00
Sergey Bugaev
5536f3c277 LibC: Add __pthread_mutex_lock_pessimistic_np()
This is a private function that locks the lock much like the regular
pthread_mutex_lock(), but causes the corresponding unlock operation to
always assume there may be other waiters. This is useful in case some
waiters are made to wait on the mutex's futex directly, without going
through pthread_mutex_lock(). This is going to be used by the condition
variable implementation in the next commit.
2021-07-05 20:26:01 +02:00
Sergey Bugaev
19bef90923 LibC: Rewrite pthread_mutex
pthread_mutex is now an actual "sleeping" mutex, and not just a
spinlock! It still has a fast path that only uses atomics and (in the
successful case) returns immediately without sleeping. In case of
contention, it calls futex_wait(), which lets the kernel scheduler put
this thread to sleep, *and* lets it know exactly when to consider
scheduling it again.
2021-07-05 20:26:01 +02:00
Sergey Bugaev
8fee93d868 LibC: Add futex_wait() and futex_wake() helpers
These are convinient wrappers over the most used futex operations.
futex_wait() also does some smarts for timeout and clock handling.

Use the new futex_wait() instead of a similar private helper in
LibPthread.
2021-07-05 20:26:01 +02:00
Andreas Kling
27fecf57bd LibGUI: Don't fire visibility-tracking timers in non-visible widgets
We were already avoiding firing timers within non-visible *windows*.
This patch extends the mechanism to support timers within non-visible
*widgets*.
2021-07-05 20:03:31 +02:00
kleines Filmröllchen
9f1f3c6f37 Piano: Use AudioServer instead of /dev/audio for audio
Piano is an old application that predates AudioServer. For this reason,
it was architected to directly talk to the soundcard via the /dev/audio
device. This caused multiple problems including simultaneous playback
issues, no ability to change volume/mute for Piano and more.

This change moves Piano to use AudioServer like any well-behaved audio
application :^) The track processing and IPC communication is moved to
the main thread because IPC doesn't like multi-threading. For this, the
new AudioPlayerLoop class is utilized that should evolve into the
DSP->AudioServer interface in the future.

Because Piano's CPU utilization has gotten so low (about 3-6%), the UI
update loop is switched back to render at exactly 60fps.

This is an important commit on the road to #6528.
2021-07-05 19:33:55 +02:00
kleines Filmröllchen
9d00db618d LibAudio: Add ClientConnection::async_enqueue()
async_enqueue() is a wrapper over the async_enqueue_buffer() call
to AudioServer. This allows users to asyncronously enqueue audio
samples, when the program requires non-blocking audio streaming.

This also makes ClientConnection use east-const everywhere.
2021-07-05 19:33:55 +02:00
kleines Filmröllchen
c8ced9f11d LibAudio: Improve latency on audio queue failures
We don't know what is a good time to wait after an audio buffer fails to
be processed by AudioServer. However, it seems like decreasing the wait
time to 10ms after such a failure should improve latency and has not
caused issues in my testing. After all, 10ms is quite some time in audio
sample magnitudes.
2021-07-05 19:33:55 +02:00
Tom
96155009dd WindowServer: Fix crash removing modal windows
Calling Window::is_modal requires the window to be on a window stack,
so we need to check this before removing it from the window stack.
2021-07-05 19:31:48 +02:00
Linus Groh
598842c5b7 LibJS: Fix bogus target.[[OwnPropertyKeys]]() call in Proxy 2021-07-05 18:19:45 +01:00