1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00
serenity/Userland/Libraries/LibJS
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
..
Bytecode LibJS: Add an optimization to avoid needless arguments object creation 2021-10-05 10:15:14 +01:00
Heap LibJS: Prune WeakContainers before freeing HeapBlocks 2021-10-08 19:47:25 +02:00
Runtime LibJS: Implement [[Call]] and [[Construct]] internal slots properly 2021-10-09 14:29:20 +01:00
Tests LibJS: Implement [[Call]] and [[Construct]] internal slots properly 2021-10-09 14:29:20 +01:00
AST.cpp LibJS: Implement [[Call]] and [[Construct]] internal slots properly 2021-10-09 14:29:20 +01:00
AST.h LibJS: Propagate "contains direct call to eval()" flag from parser 2021-10-08 12:43:38 +02:00
CMakeLists.txt LibJS: Rename OrdinaryFunctionObject to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Console.cpp LibJS: Rename CallFrame => ExecutionContext 2021-06-24 19:28:00 +02:00
Console.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Forward.h LibJS: Add ECMAScriptFunctionObject forward declaration 2021-09-25 17:51:30 +02:00
Interpreter.cpp LibJS: Pop execution context after running queued jobs in run() 2021-10-09 14:29:20 +01:00
Interpreter.h LibJS: Make scoping follow the spec 2021-09-30 08:16:32 +01:00
Lexer.cpp Libraries: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Lexer.h LibJS: Make Lexer::s_keywords store keywords as FlyString 2021-09-18 19:54:24 +02:00
MarkupGenerator.cpp LibJS: Convert Object::get() to ThrowCompletionOr 2021-10-03 20:14:03 +01:00
MarkupGenerator.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Module.cpp LibJS: Add a barebones Module class 2021-09-14 21:41:51 +02:00
Module.h LibJS: Add a barebones Module class 2021-09-14 21:41:51 +02:00
Parser.cpp LibJS: Partially revert 12b283f 2021-10-08 19:56:02 +03:30
Parser.h LibJS: Propagate "contains direct call to eval()" flag from parser 2021-10-08 12:43:38 +02:00
Script.cpp LibJS+LibWeb: Move script parse time logging from JS::Script to LibWeb 2021-09-14 21:41:51 +02:00
Script.h LibJS+LibWeb: Let JS::Script::parse() return a list of errors (on error) 2021-09-14 21:41:51 +02:00
SourceRange.h LibJS: Add missing headers 2021-10-06 23:52:40 +01:00
SourceTextModule.cpp LibJS: Add a barebones SourceTextModule class 2021-09-14 21:41:51 +02:00
SourceTextModule.h LibJS: Add a barebones SourceTextModule class 2021-09-14 21:41:51 +02:00
SyntaxHighlighter.cpp LibJS: Remove unused header includes 2021-08-01 08:10:16 +02:00
SyntaxHighlighter.h LibWeb+LibSyntax: Implement nested syntax highlighters 2021-06-07 14:45:49 +04:30
Token.cpp AK: Replace the mutable String::replace API with an immutable version 2021-09-11 20:36:43 +03:00
Token.h Libraries: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30