summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Contrib
AgeCommit message (Collapse)Author
2022-08-30LibJS: Implement $262.evalScript() according to the given algorithmLinus Groh
test262's INTERPRETING.md specifies the exact steps for this function, so let's shuffle some things around and add "spec" comments. Most importantly this now returns the result of the evaluated script, which at least one test relies on: https://github.com/tc39/test262/blob/main/test/built-ins/Proxy/revocable/tco-fn-realm.js
2022-08-29LibJS: Properly initialize the global object for $262.createRealmdavidot
2022-08-29LibJS: Hide all the constructors!Andreas Kling
Now that the GC allocator is able to invoke Cell subclass constructors directly via friendship, we no longer need to keep them public. :^)
2022-08-28LibJS: Turn initialize_global_object() into a regular initialize()Linus Groh
There's nothing special about global object initialization anymore, this can just work the same way as for any other object now.
2022-08-27LibJS: Remove GlobalObject::{set_,}associated_realm()Linus Groh
2022-08-27LibJS: Move intrinsics to the realmLinus Groh
Intrinsics, i.e. mostly constructor and prototype objects, but also things like empty and new object shape now live on a new heap-allocated JS::Intrinsics object, thus completing the long journey of taking all the magic away from the global object. This represents the Realm's [[Intrinsics]] slot in the spec and matches its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of architecture. In the majority of cases it should now be possibly to fully allocate a regular object without the global object existing, and in fact that's what we do now - the realm is allocated before the global object, and the intrinsics between both :^)
2022-08-23LibJS: Pass Realm to define_native_{accessor,function}()Linus Groh
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-23LibJS: Pass Realm to GlobalObject::initialize_global_object()Linus Groh
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-23LibJS: Replace GlobalObject with VM in ArrayBuffer AOs [Part 11/19]Linus Groh
2022-08-23LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]Linus Groh
This is where the fun begins. :^)
2022-08-23LibJS: Remove GlobalObject from VM::throw_completion()Linus Groh
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-23LibJS+LibWeb: Replace GlobalObject with Realm in Heap::allocate<T>()Linus Groh
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-23LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functionsLinus Groh
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-23LibJS+LibWeb: Replace GlobalObject with Realm in object constructorsLinus Groh
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-20LibJS: Make IsHTMLDDA non-constructibledavidot
2022-08-06LibJS+LibWeb: Restore type safety of Realm::set_global_object()Linus Groh
The changes from 8a03b17 to allow any JS::Value aren't a good fit, as shown by the excessive amount of verify_cast needed :^)
2022-08-05LibJS: Actually create a new Realm in $262.createRealm()Andreas Kling
2022-08-05LibJS: Let Shape store a Realm instead of a GlobalObjectAndreas Kling
This is a cautious first step towards being able to create JS objects before a global object has been instantiated.
2022-05-03LibJS: Remove implicit wrapping/unwrapping of completion recordsLinus Groh
This is an editorial change in the ECMA-262 spec, with similar changes in some proposals. See: - https://github.com/tc39/ecma262/commit/7575f74 - https://github.com/tc39/proposal-array-grouping/commit/df899eb - https://github.com/tc39/proposal-shadowrealm/commit/9eb5a12 - https://github.com/tc39/proposal-shadowrealm/commit/c81f527
2022-04-08LibJS: Move DetachArrayBuffer implementation to the ArrayBuffer objectTimothy Flynn
The spec notes that this AO is unused by ECMA-262, but is provided for ECMAScript hosts. Move the definition to a common location to allow test-js to also use it.
2022-03-29LibJS: Import C++ sources from libjs-test262 :^)Linus Groh
This commit upstreams most of the C++ bits of the LibJS test262 runner at https://github.com/linusg/libjs-test262/, specifically everything but the main.cpp file serving as the actual executable. Since all of these are just regular JS objects, I opted to put them in LibJS itself, in a new Contrib/ directory like many other projects have one. Other code that can end up there in the future is the runtime for esvu, which might even share some functionality with test262's $262 object. The code has been copied verbatim, and only a small number of changes have been made: - Putting everything into the JS::Test262 namespace - Removing now redundant JS namespace prefixes - Updating includes to use absolute <LibJS/...> paths - Updating the SPDX-License-Identifier comments from MIT to BSD-2-Clause I gained permission to change the license and upstream these changes from all the major contributors to this code: Ali, Andrew, David, Idan. The removal of the code from the source repository is here: https://github.com/linusg/libjs-test262/pull/54 This is only the first step, the goal is to eventually upstream the actual libjs-test262-runner executable and supporting Python scripts into SerenityOS as well.