1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:08:11 +00:00
serenity/Userland/Libraries/LibJS/Tests/builtins
Linus Groh cf168fac50 LibJS: Implement [[Call]] and [[Construct]] internal slots properly
This patch implements:

- Spec compliant [[Call]] and [[Construct]] internal slots, as virtual
  FunctionObject::internal_{call,construct}(). These effectively replace
  the old virtual FunctionObject::{call,construct}(), but with several
  advantages:
  - Clear and consistent naming, following the object internal methods
  - Use of completions
  - internal_construct() returns an Object, and not Value! This has been
    a source of confusion for a long time, since in the spec there's
    always an Object returned but the Value return type in LibJS meant
    that this could not be fully trusted and something could screw you
    over.
  - Arguments are passed explicitly in form of a MarkedValueList,
    allowing manipulation (BoundFunction). We still put them on the
    execution context as a lot of code depends on it (VM::arguments()),
    but not from the Call() / Construct() AOs anymore, which now allows
    for bypassing them and invoking [[Call]] / [[Construct]] directly.
    Nothing but Call() / Construct() themselves do that at the moment,
    but future additions to ECMA262 or already existing web specs might.
- Spec compliant, standalone Call() and Construct() AOs: currently the
  closest we have is VM::{call,construct}(), but those try to cater to
  all the different function object subclasses at once, resulting in a
  horrible mess and calling AOs with functions they should never be
  called with; most prominently PrepareForOrdinaryCall and
  OrdinaryCallBindThis, which are only for ECMAScriptFunctionObject.

As a result this also contains an implicit optimization: we no longer
need to create a new function environment for NativeFunctions - which,
worth mentioning, is what started this whole crusade in the first place
:^)
2021-10-09 14:29:20 +01:00
..
AggregateError LibJS: Implement the Error Cause proposal 2021-06-11 21:34:05 +01:00
Array LibJS: Prevent stack overflow in flatten_into_array() 2021-08-15 11:24:30 +01:00
ArrayBuffer LibJS: ArrayBuffer.prototype.slice 2021-04-03 16:24:44 +02:00
Atomics LibJS: Implement Atomics.isLockFree 2021-07-14 22:13:15 +01:00
BigInt LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
Boolean LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
DataView LibJS: Use Checked<T> for offsets in the SetViewValue AO 2021-08-11 22:56:58 +01:00
Date LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
Error LibJS: Implement the Error Cause proposal 2021-06-11 21:34:05 +01:00
FinalizationRegistry test-js: Add a mark_as_garbage method to force GC to collect that object 2021-09-08 08:53:02 +01:00
Function LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
functions LibJS: Add the global escape() & unescape() methods 2021-06-05 18:55:08 +01:00
Infinity Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Intl LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
JSON LibJS: Dont try to serialize symbol-keyed properties 2021-04-16 19:22:29 +02:00
Map LibJS/Tests: Test iteration order of Map.prototype.entries() 2021-08-13 23:54:08 +01:00
Math LibJS: Correctly handle mixing +0 and -0 in Math.{min,max}() 2021-04-23 20:51:48 +02:00
NaN Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Number LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
Object LibJS/Tests: Remove two leftover console.log() calls 2021-07-28 21:57:30 +01:00
Promise LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
Proxy LibJS: Prevent stack overflow if Proxy handler's __proto__ is the Proxy 2021-09-05 22:17:09 +01:00
Reflect LibJS: Implement [[Call]] and [[Construct]] internal slots properly 2021-10-09 14:29:20 +01:00
RegExp LibJS: Implement RegExp.prototype.compile 2021-08-20 19:16:33 +02:00
Set LibJS: Add the SetIterator built-in and Set.prototype.{values, entries} 2021-06-09 11:48:04 +01:00
String LibJS: Implement ECMA-402 String.prototype.toLocale{Lower,Upper}Case 2021-09-06 15:24:27 +01:00
Symbol LibJS: Rename OrdinaryFunctionObject to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Temporal LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
TypedArray LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
WeakMap test-js: Add a mark_as_garbage method to force GC to collect that object 2021-09-08 08:53:02 +01:00
WeakRef LibJS: Add the WeakRef.prototype.deref method 2021-06-12 18:39:23 +01:00
WeakSet test-js: Add a mark_as_garbage method to force GC to collect that object 2021-09-08 08:53:02 +01:00