Commit Graph

6243 Commits

Author SHA1 Message Date
Linus Groh
83f61748a5 LibJS: Don't treat 2^32 - 1 as numeric PropertyName
10.4.2 Array Exotic Objects
    https://tc39.es/ecma262/#sec-array-exotic-objects

    A String property name P is an array index if and only if
    ToString(ToUint32(P)) equals P and ToUint32(P) is not the same value
    as 𝔽(2^32 - 1).
2021-07-06 17:29:12 +01:00
Linus Groh
47bd25a2f1 LibJS: Make Value::as_u32() slightly less broken
Still a horrible mess, but at least it can actually return numbers > i32
max now.
2021-07-06 17:29:12 +01:00
Linus Groh
30fe0529bd LibJS: Fix second argument passed to Proxy [[Call]] trap (thisArgument) 2021-07-06 17:29:12 +01:00
LuK1337
f15ad9523d LibGUI: Fix go_upwards_instead check in ComboBox
This change addresses an issue where ComboBox list window would always
be drawn upwards if the number of elements is lower or equal 3.
2021-07-06 17:26:50 +02:00
Sergey Bugaev
d91119ba78 test-pthread: Add semaphore tests 2021-07-06 17:25:34 +02:00
Sergey Bugaev
5aa629717e LibPthread: Fix some assertions 2021-07-06 17:25:34 +02:00
Sergey Bugaev
78f5c4a4c2 LibPthread: Fix ordering
It would be enough to use relaxed ordering here if it weren't for
the mutex, which we also need to store and retrieve. To ensure the
pthread_cond_broadcast() call sees the store, use release and acquire
as appropriate. Thankfully, both of these are on the slow paths.
2021-07-06 17:25:34 +02:00
Sergey Bugaev
30caa33f7e LibC: Only set owner on recursive mutexes
This lets us skip the gettid() calls on fast paths.

Also, verify that futex_wake() succeeds.
2021-07-06 17:25:34 +02:00
Andrew Kaster
f0d562131f Tests: Generate data in memory for TestXSV benchmark case
The actual data file for this benchmark was never actually committed to
the repository, so let's generate 100k identical lines in memory to be
the fairly large data for this test instead.
2021-07-06 17:22:45 +02:00
Andrew Kaster
b7ae561945 LibTest: Clear core dump flag for CrashTest child processes
Because these processes are expected to crash, generating a core dump
from them and throwing up a CrashReporter window is less helpful than
it is distracting while running many tests at a time.

Use the prctl for controlling the core dump-able flag to tell the kernel
we don't want core dumps from these processes. Note that because we also
build LibTest for Lagom, we have to check for MacOS which doesn't
support prctl(PR_SET_DUMPABLE).
2021-07-06 17:22:45 +02:00
Timothy Flynn
8fcdc57ae1 LibJS: Coerce named captures to an object before calling GetSubstitution
Per the spec, before invoking the GetSubstitution abstraction, the named
capture groups (if not undefined) should be coerced to an object via the
ToObject abstraction.
2021-07-06 15:07:26 +01:00
Timothy Flynn
424c7eaa40 LibJS: Fix replaceAll crash for overlapping search string positions
The implementation of String.prototype.replaceAll cannot use AK's
implementation of String::find_all when finding the indices of the
search string in the source string. String::find_all will return indices
[0, 1] for String("aaa").find_all("aa") - i.e. it returns overlapping
results. This is not allowed by the JavaScript specification for
replaceAll.
2021-07-06 15:07:26 +01:00
Linus Groh
30615ac2bb LibJS: Do s/define_property/define_direct_property/ in a comment 2021-07-06 14:36:00 +01:00
Linus Groh
0ba81dc0b7 LibJS: Remove Object::is_array() in favor of Value::is_array() and RTTI
It's way too easy to get this wrong: for the IsArray abstract operation,
Value::is_array() needs to be called. Since we have RTTI, the virtual
Object::is_array() method is not needed anymore - if we need to know
whether something is *actually* a JS::Array (we currently check in more
cases than we should, I think) and not a Proxy with an Array target, we
should do that in a way that doesn't look like an abstract operation.
2021-07-06 14:26:18 +01:00
Ali Mohammad Pur
06ffc0c4db LibWasm: Don't create useless temporary strings for trap reasons
These strings are only used when execution traps, so there's no reason
to create actual strings until that happens; instead switch to using
StringViews.
2021-07-06 17:55:00 +04:30
Ali Mohammad Pur
2fc0040ceb LibWasm: Tweak the implementation-defined limits a bit 2021-07-06 17:55:00 +04:30
Ali Mohammad Pur
5636f8143d LibWasm: Allow overflow in normal 64-bit arithmetic instructions 2021-07-06 17:55:00 +04:30
Ali Mohammad Pur
c4d4c657d0 LibWasm: Limit module memory to 65536 pages
The spec mentions this, and anything past that can't be correctly
addressed by the 32-bit indices anyhow.
2021-07-06 17:55:00 +04:30
Ali Mohammad Pur
03fe50d5e7 LibWasm: Fix data section initialization bounds checking 2021-07-06 17:55:00 +04:30
Ali Mohammad Pur
d2212a1f51 LibWasm: Jump to the default label in br_table with negative values
Also adds a forgotten Wasm::Printer implementation for printing table
branch arguments.
2021-07-06 17:55:00 +04:30
Ali Mohammad Pur
0b08392e54 LibWasm: Use the number of bytes when comparing memory limits
...instead of comparing page count with byte count.
2021-07-06 17:55:00 +04:30
Ali Mohammad Pur
4bdb0ad132 LibWasm: Guard stack accesses with checks
If the stack is empty, let's just trap.
2021-07-06 17:55:00 +04:30
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