Commit Graph

40370 Commits

Author SHA1 Message Date
Linus Groh
b345a0acca LibJS+LibWeb: Reduce use of GlobalObject as an intermediary
- Prefer VM::current_realm() over GlobalObject::associated_realm()
- Prefer VM::heap() over GlobalObject::heap()
- Prefer Cell::vm() over Cell::global_object()
- Prefer Wrapper::vm() over Wrapper::global_object()
- Inline Realm::global_object() calls used to access intrinsics as they
  will later perform a direct lookup without going through the global
  object
2022-08-23 13:58:30 +01:00
Linus Groh
e3895e6c80 LibJS: Pass Realm to define_native_{accessor,function}()
This is needed so that the allocated NativeFunction receives the correct
realm, usually forwarded from the Object's initialize() function, rather
than using the current realm.
2022-08-23 13:58:30 +01:00
Linus Groh
7c468b5a77 LibJS: Pass Realm to GlobalObject::initialize_global_object()
Global object initialization is tightly coupled to realm creation, so
simply pass it to the function instead of relying on the non-standard
'associated realm' concept, which I'd like to remove later.

This works essentially the same way as regular Object::initialize() now.

Additionally this allows us to forward the realm to GlobalObject's
add_constructor() / initialize_constructor() helpers, so they set the
correct realm on the allocated constructor function object.
2022-08-23 13:58:30 +01:00
Linus Groh
b465f46e00 LibJS: Remove GlobalObject parameter from native functions 2022-08-23 13:58:30 +01:00
Linus Groh
7b990c27a1 LibWeb: Replace GlobalObject with VM in remaining AOs [Part 4/4] 2022-08-23 13:58:30 +01:00
Linus Groh
2d69a3b266 LibWeb: Replace GlobalObject with VM in Window AOs [Part 3/4] 2022-08-23 13:58:30 +01:00
Linus Groh
f8fb985b05 LibWeb: Replace GlobalObject with VM in CrossOrigin AOs [Part 2/4] 2022-08-23 13:58:30 +01:00
Linus Groh
5f1fe4b012 LibWeb: Replace GlobalObject with VM in WebAssembly AOs [Part 1/4] 2022-08-23 13:58:30 +01:00
Linus Groh
40a70461a0 LibWeb: Replace GlobalObject with Realm in wrapper functions
Similar to create() in LibJS, wrap() et al. are on a low enough level to
warrant passing a Realm directly instead of relying on the current realm
from the VM, as a wrapper may need to be allocated while no JS is being
executed.
2022-08-23 13:58:30 +01:00
Linus Groh
56b2ae5ac0 LibJS: Replace GlobalObject with VM in remaining AOs [Part 19/19] 2022-08-23 13:58:30 +01:00
Linus Groh
25849f8a6d LibJS: Replace GlobalObject with VM in common AOs [Part 18/19] 2022-08-23 13:58:30 +01:00
Linus Groh
7856886ed5 LibJS: Replace GlobalObject with VM in String AOs [Part 17/19] 2022-08-23 13:58:30 +01:00
Linus Groh
ab6796691f LibJS: Replace GlobalObject with VM in ShadowRealm AOs [Part 16/19] 2022-08-23 13:58:30 +01:00
Linus Groh
d69eaf8be9 LibJS: Replace GlobalObject with VM in Array AOs [Part 15/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f13f3f9fbe LibJS: Replace GlobalObject with VM in Date AOs [Part 14/19] 2022-08-23 13:58:30 +01:00
Linus Groh
9930302efb LibJS: Replace GlobalObject with VM in JSON AOs [Part 13/19] 2022-08-23 13:58:30 +01:00
Linus Groh
90bf33241d LibJS: Replace GlobalObject with VM in Atomics AOs [Part 12/19] 2022-08-23 13:58:30 +01:00
Linus Groh
26366d5930 LibJS: Replace GlobalObject with VM in ArrayBuffer AOs [Part 11/19] 2022-08-23 13:58:30 +01:00
Linus Groh
b037894287 LibJS: Replace GlobalObject with VM in TypedArray AOs [Part 10/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f0b793db74 LibJS: Replace GlobalObject with VM in RegExp AOs [Part 9/19] 2022-08-23 13:58:30 +01:00
Linus Groh
d74f8039eb LibJS: Replace GlobalObject with VM in Promise AOs [Part 8/19] 2022-08-23 13:58:30 +01:00
Linus Groh
ccdfa2320c LibJS: Replace GlobalObject with VM in Iterator AOs [Part 7/19] 2022-08-23 13:58:30 +01:00
Linus Groh
ae9e031f56 LibJS: Replace GlobalObject with VM in Reference AOs [Part 6/19] 2022-08-23 13:58:30 +01:00
Linus Groh
275a7a0c0a LibJS: Replace GlobalObject with VM in Environment AOs [Part 5/19] 2022-08-23 13:58:30 +01:00
Linus Groh
a022e548b8 LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]
This is where the fun begins. :^)
2022-08-23 13:58:30 +01:00
Linus Groh
f6c4a0f5d0 LibJS: Replace GlobalObject with VM in PrototypeObject AOs [Part 3/19] 2022-08-23 13:58:30 +01:00
Linus Groh
694f66b5ca LibJS: Replace GlobalObject with VM in Temporal AOs [Part 2/19] 2022-08-23 13:58:30 +01:00
Linus Groh
f9705eb2f4 LibJS: Replace GlobalObject with VM in Intl AOs [Part 1/19]
Instead of passing a GlobalObject everywhere, we will simply pass a VM,
from which we can get everything we need: common names, the current
realm, symbols, arguments, the heap, and a few other things.

In some places we already don't actually need a global object and just
do it for consistency - no more `auto& vm = global_object.vm();`!

This will eventually automatically fix the "wrong realm" issue we have
in some places where we (incorrectly) use the global object from the
allocating object, e.g. in call() / construct() implementations. When
only ever a VM is passed around, this issue can't happen :^)

I've decided to split this change into a series of patches that should
keep each commit down do a somewhat manageable size.
2022-08-23 13:58:30 +01:00
Linus Groh
999da617c5 LibJS: Remove GlobalObject from VM::this_value()
This is a continuation of the previous six commits.

The global object is only needed to return it if the execution context
stack is empty, but that doesn't seem like a useful thing to allow in
the first place - if you're not currently executing JS, and the
execution context stack is empty, there is no this value to retrieve.
2022-08-23 13:58:30 +01:00
Linus Groh
f3117d46dc LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits.

A first big step into the direction of no longer having to pass a realm
(or currently, a global object) trough layers upon layers of AOs!
Unlike the create() APIs we can safely assume that this is only ever
called when a running execution context and therefore current realm
exists. If not, you can always manually allocate the Error and put it in
a Completion :^)

In the spec, throw exceptions implicitly use the current realm's
intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23 13:58:30 +01:00
Linus Groh
5398dcc55e LibJS: Remove GlobalObject from execute() and related AST functions
This is a continuation of the previous four commits.

Passing a global object here is largely redundant, we definitely need
the interpreter but can get the VM and (later) current active realm from
there - and also the global object while we still need it, although I'd
like to remove Interpreter::global_object() in the future.

This now matches the bytecode interpreter's execute_impl() functions.
2022-08-23 13:58:30 +01:00
Linus Groh
e992a9f469 LibJS+LibWeb: Replace GlobalObject with Realm in Heap::allocate<T>()
This is a continuation of the previous three commits.

Now that create() receives the allocating realm, we can simply forward
that to allocate(), which accounts for the majority of these changes.
Additionally, we can get rid of the realm_from_global_object() in one
place, with one more remaining in VM::throw_completion().
2022-08-23 13:58:30 +01:00
Linus Groh
b99cc7d050 LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits.

As allocating a JS cell already primarily involves a realm instead of a
global object, and we'll need to pass one to the allocate() function
itself eventually (it's bridged via the global object right now), the
create() functions need to receive a realm as well.
The plan is for this to be the highest-level function that actually
receives a realm and passes it around, AOs on an even higher level will
use the "current realm" concept via VM::current_realm() as that's what
the spec assumes; passing around realms (or global objects, for that
matter) on higher AO levels is pointless and unlike for allocating
individual objects, which may happen outside of regular JS execution, we
don't need control over the specific realm that is being used there.
2022-08-23 13:58:30 +01:00
Linus Groh
5dd5896588 LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functions
This is a continuation of the previous commit.

Calling initialize() is the first thing that's done after allocating a
cell on the JS heap - and in the common case of allocating an object,
that's where properties are assigned and intrinsics occasionally
accessed.
Since those are supposed to live on the realm eventually, this is
another step into that direction.
2022-08-23 13:58:30 +01:00
Linus Groh
ecd163bdf1 LibJS+LibWeb: Replace GlobalObject with Realm in object constructors
No functional changes - we can still very easily get to the global
object via `Realm::global_object()`. This is in preparation of moving
the intrinsics to the realm and no longer having to pass a global
object when allocating any object.
In a few (now, and many more in subsequent commits) places we get a
realm using `GlobalObject::associated_realm()`, this is intended to be
temporary. For example, create() functions will later receive the same
treatment and are passed a realm instead of a global object.
2022-08-23 13:58:30 +01:00
Linus Groh
4c300cc5e8 LibJS: Fix the prototype of AsyncFunctionDriverWrapper's Promise base 2022-08-23 13:58:30 +01:00
Linus Groh
8ceef031e8 LibWeb: Fix the prototype of a couple of WebAssembly prototype objects
Like any other regular, non-inheriting web platform prototype, the
prototype's prototype should be Object.prototype, not the global object.

Another reason to get rid of "global object (an object) + prototype
object (also an object)"-style APIs for allocation :^)
2022-08-23 13:58:30 +01:00
huttongrabiel
4806567f05 NetworkServer: Use Core::Stream instead of Core::File
As per the FIXME.
2022-08-23 13:37:21 +01:00
Hendiadyoin1
4e9313fa73 PixelPaint: Use Sqrt1_2 constant in EllipseTool instead of 1/1.41
This also demotes the constant to floats instead of doubles, because we
truncate it to int anyways and don't need the extra accuracy.
2022-08-23 13:35:15 +01:00
Tim Schumacher
a0820b205c Ports/SDL2_ttf: Update to 2.20.1 2022-08-23 13:30:48 +01:00
Tim Schumacher
4678028842 Ports/SDL2_net: Update to 2.2.0 2022-08-23 13:30:48 +01:00
Tim Schumacher
ebf713da60 Ports/SDL2_mixer: Update to 2.6.2 2022-08-23 13:30:48 +01:00
Tim Schumacher
1ce3b9ea48 Ports/SDL2_image: Update to 2.6.2 2022-08-23 13:30:48 +01:00
Tim Schumacher
831afe3c3d Ports/SDL2: Update to 2.24.0 2022-08-23 13:30:48 +01:00
Tim Schumacher
2e31a479c4 Ports/SDL2: Do an out-of-tree build
SDL 2.24.0 starts having include loops if we try to do an in-tree build
against its wishes, so let's not do that anymore.
2022-08-23 13:30:48 +01:00
Seal Sealy
ffe9a862f0 Ports: Add aclock port 2022-08-23 13:29:32 +01:00
djwisdom
f3cec9de75 Base: Add five new emojis
 - U+26A1 HIGH VOLTAGE
 - U+26AA WHITE CIRCLE
 - U+26AB BLACK CIRCLE
 - U+26BE BASEBALL
✉ - U+2709 ENVELOPE

Coverage: https://emoji.serenityos.net
2022-08-23 13:27:58 +01:00
Ryan Liptak
b4856a4070 Base: Add 5 new emojis
🌡 - U+1F321 THERMOMETER
🌞 - U+1F31E SUN WITH FACE
 - U+26C5 SUN BEHIND CLOUD
⛈ - U+26C8 CLOUD WITH LIGHTNING AND RAIN
🌪 - U+1F32A TORNADO
2022-08-23 13:27:40 +01:00
MacDue
50ab2de10e LibWeb: Remove done TODO and fix typo 2022-08-23 13:27:02 +01:00
MacDue
40ad8b793d LibWeb: Avoid infinite loops in background painting
Previously if `background-size` was 0px in any dimension we would
go into in infinite loop whilst painting.
2022-08-23 13:27:02 +01:00