Andreas Kling
50d951aea2
LibJS: Let Shape store a Realm instead of a GlobalObject
...
This is a cautious first step towards being able to create JS objects
before a global object has been instantiated.
2022-08-05 12:42:46 +02:00
Linus Groh
9f3f3b0864
LibJS: Remove implicit wrapping/unwrapping of completion records
...
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-05-03 01:09:29 +02:00
Linus Groh
ce659e5eeb
LibJS: Remove assertions that are now part of structured headers
...
This is an editorial change in the ECMA-262 spec.
See: https://github.com/tc39/ecma262/commit/4fde514
2022-05-01 22:13:21 +02:00
Linus Groh
86e3840202
LibJS: Add missing comment in OrdinaryToPrimitive
2022-05-01 22:13:21 +02:00
Linus Groh
e815d3f9ce
LibJS: De-duplicate ClassFieldDefinition Records
...
This was defined twice, despite being the very same thing:
- ClassElement::ClassFieldDefinition
- ECMAScriptFunctionObject::InstanceField
Move the former to a new header and use it everywhere. Also update the
define_field() AO to take a single field instead of separate name and
initializer arguments.
2022-04-20 00:08:32 +02:00
Idan Horowitz
086969277e
Everywhere: Run clang-format
2022-04-01 21:24:45 +01:00
Idan Horowitz
9cfbbfd8d8
LibJS: Implement the EnumerateObjectProperties AO
2022-03-29 14:34:08 +03:00
Lenny Maiorani
d00b79568f
Libraries: Use default constructors/destructors in LibJS
...
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules
"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-16 16:19:40 +00:00
Linus Groh
47cdd90836
LibJS: Use new NativeFunction::create() in most places
...
Resolves one FIXME where we can now pass a realm, and sets the length
correctly in a bunch of places that previously didn't.
Also reduces the number of "format function name string from arbitrary
PropertyKey" implementations, although two more remain present in the
AST (used with ECMAScriptFunctionObjects, which is a different beast).
2022-02-20 23:21:40 +00:00
Linus Groh
368af9ad6e
LibJS: Add Object constructor allowing null prototype
2022-02-09 23:31:34 +00:00
Linus Groh
bc183dbbcb
LibJS: Replace uses of MarkedValueList with MarkedVector<Value>
...
This is effectively a drop-in replacement.
2022-02-09 12:25:27 +00:00
davidot
9264f9d24e
LibJS+Everywhere: Remove VM::exception() and most related functions
...
This commit removes all exception related code:
Remove VM::exception(), VM::throw_exception() etc. Any leftover
throw_exception calls are moved to throw_completion.
The one method left is clear_exception() which is now a no-op. Most of
these calls are just to clear whatever exception might have been thrown
when handling a Completion. So to have a cleaner commit this will be
removed in a next commit.
It also removes the actual Exception and TemporaryClearException classes
since these are no longer used.
In any spot where the exception was actually used an attempt was made to
preserve that behavior. However since it is no longer tracked by the VM
we cannot access exceptions which were thrown in previous calls.
There are two such cases which might have different behavior:
- In Web::DOM::Document::interpreter() the on_call_stack_emptied hook
used to print any uncaught exception but this is now no longer
possible as the VM does not store uncaught exceptions.
- In js the code used to be interruptable by throwing an exception on
the VM. This is no longer possible but was already somewhat fragile
before as you could happen to throw an exception just before a VERIFY.
2022-02-08 09:12:42 +00:00
Linus Groh
6f20f49b21
Everywhere: Rename JS::PropertyKey variables from property_{name => key}
...
PropertyKey used to be called PropertyName, but got renamed. Let's
update all the variables of this type as well.
2022-02-06 22:02:45 +00:00
mjz19910
1ef633472b
Everywhere: Convert VM::call() to JS::call()
2022-01-23 15:24:45 +00:00
Linus Groh
29e96eceeb
LibJS: Convert PropertyKey::from_value() to ThrowCompletionOr
...
Lots of MUST() - perhaps we'll eventually come up with a better API for
the common case where it can't fail.
2022-01-04 23:37:26 +00:00
Timothy Flynn
d69f5ca128
LibJS: Update spec numbers for Operations on Objects AOs
...
The error cause proposal was merged, so some spec numbers were bumped.
2021-12-21 14:56:28 +01:00
Andreas Kling
212319b25e
LibJS: Only allocate space for Object private elements if needed
...
Most JavaScript objects don't have private elements, so this reduces the
size of typical JS::Object instances by two pointers.
2021-12-08 10:29:54 +01:00
Linus Groh
a20b189eab
LibJS: Fix incorrectly formatted section comments
...
A couple of missing URLs, spaces, and a stray comma.
2021-11-24 17:37:27 +00:00
Idan Horowitz
ba55d77665
LibJS: Remove leftover exception check in OrdinaryHasProperty
2021-11-09 20:32:51 +02:00
Idan Horowitz
2eaed880b1
LibJS: Remove old Native Functions
...
Now that all the usages were updated to the new ThrowCompletionOr based
version we can remove the legacy version.
2021-10-31 18:20:37 +02:00
Andreas Kling
7ccb8c8609
LibJS: Provide default hash traits for JS::PropertyKey
...
Let's not require people to use PropertyNameTraits everywhere when we
can just specialize AK::Traits<JS::PropertyKey> instead. :^)
2021-10-24 17:18:09 +02:00
Andreas Kling
398c181c79
LibJS: Rename PropertyName to PropertyKey
...
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Linus Groh
0881f8160f
LibJS: Use implicit ThrowCompletionOr<T> constructor where possible
...
Luckily this is not very widespread yet as most of it would happen in
the various JS functions instead of AOs.
2021-10-21 09:02:23 +01:00
davidot
d94b5e511f
LibJS: Add slot [[PrivateElements]] and related methods to Object
2021-10-20 23:19:17 +01:00
Idan Horowitz
40eb3a39d4
LibJS: Rename define_native_function => define_old_native_function
...
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz
ca27e5eff5
LibJS: Convert NativeFunction callback to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Linus Groh
52976bfac6
LibJS: Convert to_object() to ThrowCompletionOr
2021-10-13 09:55:10 +01:00
Andreas Kling
6108bac606
LibJS: Only do a single property lookup in internal_get_own_property()
...
Instead of checking storage_has(), followed by storage_get(), we can do
storage_get() directly and avoid a redundant property lookup.
This exposed a bug in SimpleIndexedPropertyStorage::get() which would
previously succeed for array holes.
2021-10-05 15:15:29 +02:00
Linus Groh
d7d73f9100
LibJS: Convert to_property_descriptor() to ThrowCompletionOr
...
Also add spec step comments to it while we're here.
2021-10-04 09:52:15 +01:00
Linus Groh
2f42675ebd
LibJS: Convert ordinary_set_with_own_descriptor() to ThrowCompletionOr
2021-10-04 09:52:15 +01:00
Linus Groh
3b59a4577d
LibJS: Convert define_properties() to ThrowCompletionOr
2021-10-04 09:52:15 +01:00
Linus Groh
0a49a2db60
LibJS: Convert set_immutable_prototype() to ThrowCompletionOr
2021-10-04 09:52:15 +01:00
Linus Groh
1f7068ace9
LibJS: Remove unused TemporaryChange include from Object.cpp
2021-10-03 21:40:07 +01:00
Linus Groh
e5b8544762
LibJS: Convert enumerable_own_property_names() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
3af559ee8a
LibJS: Convert test_integrity_level() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
ed5a9aa038
LibJS: Convert set_integrity_level() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
3be26f56db
LibJS: Convert has_own_property() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
f38a5957bf
LibJS: Convert has_property() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
a29b7a3ec7
LibJS: Convert delete_property_or_throw() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
fe86b04b42
LibJS: Convert define_property_or_throw() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
ebf57df431
LibJS: Convert create_non_enum_data_p_or_throw() to ThrowCompletionOr
...
The actual name is a bit longer, but you know what I mean :^)
2021-10-03 20:14:03 +01:00
Linus Groh
364dd42fc8
LibJS: Convert create_data_property_or_throw() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
bb2499cd7a
LibJS: Convert create_method_property() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
fb443b3fb4
LibJS: Convert create_data_property() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
1d45541278
LibJS: Convert Object::set() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
b7e5f08e56
LibJS: Convert Object::get() to ThrowCompletionOr
...
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
2021-10-03 20:14:03 +01:00
Linus Groh
9b6c09e2c4
LibJS: Convert is_extensible() to ThrowCompletionOr
2021-10-03 20:14:03 +01:00
Linus Groh
fa2ac5b759
LibJS: Convert ordinary_to_primitive() to ThrowCompletionOr
...
Also add spec step comments to it while we're here.
2021-10-03 20:14:03 +01:00
Linus Groh
ba6e4c7ae1
LibJS+LibWeb: Use Object::set_prototype() in more places
2021-10-02 14:53:06 +01:00
Linus Groh
84c9f3e0d0
LibJS: Add Object::set_prototype()
...
This is just factoring out step "9. Set O.[[Prototype]] to V." of
10.1.2 [[SetPrototypeOf]] into its own method so that we don't have to
use internal_set_prototype_of() for setting an object prototype in all
cases.
2021-10-02 14:53:06 +01:00