2020-05-06 15:40:06 +00:00
|
|
|
set(SOURCES
|
2021-06-08 21:08:47 +00:00
|
|
|
AST.cpp
|
|
|
|
Bytecode/ASTCodegen.cpp
|
|
|
|
Bytecode/BasicBlock.cpp
|
|
|
|
Bytecode/Generator.cpp
|
|
|
|
Bytecode/Instruction.cpp
|
|
|
|
Bytecode/Interpreter.cpp
|
|
|
|
Bytecode/Op.cpp
|
2021-06-13 16:10:20 +00:00
|
|
|
Bytecode/Pass/DumpCFG.cpp
|
|
|
|
Bytecode/Pass/GenerateCFG.cpp
|
|
|
|
Bytecode/Pass/MergeBlocks.cpp
|
|
|
|
Bytecode/Pass/PlaceBlocks.cpp
|
|
|
|
Bytecode/Pass/UnifySameBlocks.cpp
|
2021-06-09 08:02:01 +00:00
|
|
|
Bytecode/StringTable.cpp
|
2021-06-08 21:08:47 +00:00
|
|
|
Console.cpp
|
|
|
|
Heap/CellAllocator.cpp
|
|
|
|
Heap/BlockAllocator.cpp
|
|
|
|
Heap/Handle.cpp
|
|
|
|
Heap/HeapBlock.cpp
|
|
|
|
Heap/Heap.cpp
|
|
|
|
Interpreter.cpp
|
|
|
|
Lexer.cpp
|
|
|
|
MarkupGenerator.cpp
|
|
|
|
Parser.cpp
|
2021-06-19 20:45:00 +00:00
|
|
|
Runtime/AbstractOperations.cpp
|
2021-06-11 17:06:20 +00:00
|
|
|
Runtime/AggregateError.cpp
|
|
|
|
Runtime/AggregateErrorConstructor.cpp
|
|
|
|
Runtime/AggregateErrorPrototype.cpp
|
2021-06-28 11:26:01 +00:00
|
|
|
Runtime/ArgumentsObject.cpp
|
2021-06-08 21:08:47 +00:00
|
|
|
Runtime/Array.cpp
|
|
|
|
Runtime/ArrayBuffer.cpp
|
|
|
|
Runtime/ArrayBufferConstructor.cpp
|
|
|
|
Runtime/ArrayBufferPrototype.cpp
|
|
|
|
Runtime/ArrayConstructor.cpp
|
|
|
|
Runtime/ArrayIterator.cpp
|
|
|
|
Runtime/ArrayIteratorPrototype.cpp
|
|
|
|
Runtime/ArrayPrototype.cpp
|
|
|
|
Runtime/BigInt.cpp
|
|
|
|
Runtime/BigIntConstructor.cpp
|
2020-06-06 00:14:10 +00:00
|
|
|
Runtime/BigIntObject.cpp
|
|
|
|
Runtime/BigIntPrototype.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/BooleanConstructor.cpp
|
|
|
|
Runtime/BooleanObject.cpp
|
|
|
|
Runtime/BooleanPrototype.cpp
|
|
|
|
Runtime/BoundFunction.cpp
|
|
|
|
Runtime/ConsoleObject.cpp
|
2021-06-13 22:47:08 +00:00
|
|
|
Runtime/DataView.cpp
|
|
|
|
Runtime/DataViewConstructor.cpp
|
|
|
|
Runtime/DataViewPrototype.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/DateConstructor.cpp
|
|
|
|
Runtime/Date.cpp
|
|
|
|
Runtime/DatePrototype.cpp
|
2021-07-01 10:24:46 +00:00
|
|
|
Runtime/DeclarativeEnvironment.cpp
|
|
|
|
Runtime/Environment.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/ErrorConstructor.cpp
|
|
|
|
Runtime/Error.cpp
|
|
|
|
Runtime/ErrorPrototype.cpp
|
2020-06-10 05:48:01 +00:00
|
|
|
Runtime/ErrorTypes.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/Exception.cpp
|
2021-06-15 19:16:17 +00:00
|
|
|
Runtime/FinalizationRegistry.cpp
|
|
|
|
Runtime/FinalizationRegistryConstructor.cpp
|
|
|
|
Runtime/FinalizationRegistryPrototype.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/FunctionConstructor.cpp
|
2021-07-01 10:24:46 +00:00
|
|
|
Runtime/FunctionEnvironment.cpp
|
2021-06-27 19:48:34 +00:00
|
|
|
Runtime/FunctionObject.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/FunctionPrototype.cpp
|
2021-06-15 07:04:08 +00:00
|
|
|
Runtime/GeneratorFunctionConstructor.cpp
|
|
|
|
Runtime/GeneratorFunctionPrototype.cpp
|
2021-06-10 21:08:30 +00:00
|
|
|
Runtime/GeneratorObject.cpp
|
2021-06-15 07:04:08 +00:00
|
|
|
Runtime/GeneratorObjectPrototype.cpp
|
2021-07-01 10:24:46 +00:00
|
|
|
Runtime/GlobalEnvironment.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/GlobalObject.cpp
|
LibJS: Object index properties have descriptors; Handle sparse indices
This patch adds an IndexedProperties object for storing indexed
properties within an Object. This accomplishes two goals: indexed
properties now have an associated descriptor, and objects now gracefully
handle sparse properties.
The IndexedProperties class is a wrapper around two other classes, one
for simple indexed properties storage, and one for general indexed
property storage. Simple indexed property storage is the common-case,
and is simply a vector of properties which all have attributes of
default_attributes (writable, enumerable, and configurable).
General indexed property storage is for a collection of indexed
properties where EITHER one or more properties have attributes other
than default_attributes OR there is a property with a large index (in
particular, large is '200' or higher).
Indexed properties are now treated relatively the same as storage within
the various Object methods. Additionally, there is a custom iterator
class for IndexedProperties which makes iteration easy. The iterator
skips empty values by default, but can be configured otherwise.
Likewise, it evaluates getters by default, but can be set not to.
2020-05-27 18:35:09 +00:00
|
|
|
Runtime/IndexedProperties.cpp
|
2020-07-09 21:58:20 +00:00
|
|
|
Runtime/IteratorOperations.cpp
|
|
|
|
Runtime/IteratorPrototype.cpp
|
2020-06-10 18:01:00 +00:00
|
|
|
Runtime/JSONObject.cpp
|
2021-06-12 20:54:40 +00:00
|
|
|
Runtime/Map.cpp
|
|
|
|
Runtime/MapConstructor.cpp
|
2021-06-12 20:58:03 +00:00
|
|
|
Runtime/MapIterator.cpp
|
|
|
|
Runtime/MapIteratorPrototype.cpp
|
2021-06-12 20:54:40 +00:00
|
|
|
Runtime/MapPrototype.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/MarkedValueList.cpp
|
|
|
|
Runtime/MathObject.cpp
|
|
|
|
Runtime/NativeFunction.cpp
|
|
|
|
Runtime/NumberConstructor.cpp
|
|
|
|
Runtime/NumberObject.cpp
|
|
|
|
Runtime/NumberPrototype.cpp
|
|
|
|
Runtime/Object.cpp
|
2021-06-21 21:17:24 +00:00
|
|
|
Runtime/ObjectConstructor.cpp
|
2021-07-01 10:24:46 +00:00
|
|
|
Runtime/ObjectEnvironment.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/ObjectPrototype.cpp
|
|
|
|
Runtime/PrimitiveString.cpp
|
LibJS: Add initial support for Promises
Almost a year after first working on this, it's finally done: an
implementation of Promises for LibJS! :^)
The core functionality is working and closely following the spec [1].
I mostly took the pseudo code and transformed it into C++ - if you read
and understand it, you will know how the spec implements Promises; and
if you read the spec first, the code will look very familiar.
Implemented functions are:
- Promise() constructor
- Promise.prototype.then()
- Promise.prototype.catch()
- Promise.prototype.finally()
- Promise.resolve()
- Promise.reject()
For the tests I added a new function to test-js's global object,
runQueuedPromiseJobs(), which calls vm.run_queued_promise_jobs().
By design, queued jobs normally only run after the script was fully
executed, making it improssible to test handlers in individual test()
calls by default [2].
Subsequent commits include integrations into LibWeb and js(1) -
pretty-printing, running queued promise jobs when necessary.
This has an unusual amount of dbgln() statements, all hidden behind the
PROMISE_DEBUG flag - I'm leaving them in for now as they've been very
useful while debugging this, things can get quite complex with so many
asynchronously executed functions.
I've not extensively explored use of these APIs for promise-based
functionality in LibWeb (fetch(), Notification.requestPermission()
etc.), but we'll get there in due time.
[1]: https://tc39.es/ecma262/#sec-promise-objects
[2]: https://tc39.es/ecma262/#sec-jobs-and-job-queues
2021-04-01 20:13:29 +00:00
|
|
|
Runtime/Promise.cpp
|
|
|
|
Runtime/PromiseConstructor.cpp
|
|
|
|
Runtime/PromiseJobs.cpp
|
|
|
|
Runtime/PromisePrototype.cpp
|
|
|
|
Runtime/PromiseReaction.cpp
|
|
|
|
Runtime/PromiseResolvingFunction.cpp
|
LibJS: Add new PropertyDescriptor class and related abstract operations
This is an implementation of 'The Property Descriptor Specification
Type' and related abstract operations, namely:
- IsAccessorDescriptor
- IsDataDescriptor
- IsGenericDescriptor
- FromPropertyDescriptor
- ToPropertyDescriptor
- CompletePropertyDescriptor
It works with Optional<T> to enable omitting certain fields, which will
eventually replace the Attribute::Has{Getter,Setter,Configurable,
Enumerable,Writable} bit flags, which are awkward to work with - being
able to use an initializer list with any of the possible attributes is
much more convenient.
Parts of the current PropertyAttributes implementation as well as the
much simpler PropertyDescriptor struct in Object.h will eventually be
replaced with this and completely go away.
Property storage will still use the PropertyAttributes bit flags, this
is for the layers above.
Note that this is currently guarded behind an #if 0 as if conflicts with
the existing PropertyDescriptor struct, but it's known to compile and
work just fine - I simply want to have this in a separate commit, the
primary object rewrite commit will be large enough as is.
2021-07-03 21:57:21 +00:00
|
|
|
Runtime/PropertyDescriptor.cpp
|
2020-06-03 21:34:52 +00:00
|
|
|
Runtime/ProxyConstructor.cpp
|
|
|
|
Runtime/ProxyObject.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/Reference.cpp
|
|
|
|
Runtime/ReflectObject.cpp
|
2020-06-03 23:05:49 +00:00
|
|
|
Runtime/RegExpConstructor.cpp
|
|
|
|
Runtime/RegExpObject.cpp
|
|
|
|
Runtime/RegExpPrototype.cpp
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 17:14:16 +00:00
|
|
|
Runtime/OrdinaryFunctionObject.cpp
|
2021-06-08 21:08:47 +00:00
|
|
|
Runtime/Set.cpp
|
|
|
|
Runtime/SetConstructor.cpp
|
2021-06-08 21:17:17 +00:00
|
|
|
Runtime/SetIterator.cpp
|
|
|
|
Runtime/SetIteratorPrototype.cpp
|
2021-06-08 21:08:47 +00:00
|
|
|
Runtime/SetPrototype.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/Shape.cpp
|
|
|
|
Runtime/StringConstructor.cpp
|
2020-07-12 03:23:01 +00:00
|
|
|
Runtime/StringIterator.cpp
|
|
|
|
Runtime/StringIteratorPrototype.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/StringObject.cpp
|
|
|
|
Runtime/StringPrototype.cpp
|
2020-04-30 06:25:21 +00:00
|
|
|
Runtime/Symbol.cpp
|
|
|
|
Runtime/SymbolConstructor.cpp
|
|
|
|
Runtime/SymbolObject.cpp
|
|
|
|
Runtime/SymbolPrototype.cpp
|
2021-07-11 18:04:11 +00:00
|
|
|
Runtime/Temporal/AbstractOperations.cpp
|
|
|
|
Runtime/Temporal/Calendar.cpp
|
2021-07-07 16:41:37 +00:00
|
|
|
Runtime/Temporal/Instant.cpp
|
|
|
|
Runtime/Temporal/InstantConstructor.cpp
|
|
|
|
Runtime/Temporal/InstantPrototype.cpp
|
2021-07-06 18:33:20 +00:00
|
|
|
Runtime/Temporal/Now.cpp
|
2021-07-11 18:04:11 +00:00
|
|
|
Runtime/Temporal/PlainDate.cpp
|
|
|
|
Runtime/Temporal/PlainDateTime.cpp
|
|
|
|
Runtime/Temporal/PlainTime.cpp
|
2021-07-06 18:14:47 +00:00
|
|
|
Runtime/Temporal/Temporal.cpp
|
2021-07-06 22:53:27 +00:00
|
|
|
Runtime/Temporal/TimeZone.cpp
|
|
|
|
Runtime/Temporal/TimeZoneConstructor.cpp
|
|
|
|
Runtime/Temporal/TimeZonePrototype.cpp
|
2020-12-01 20:05:25 +00:00
|
|
|
Runtime/TypedArray.cpp
|
2020-12-02 00:23:40 +00:00
|
|
|
Runtime/TypedArrayConstructor.cpp
|
|
|
|
Runtime/TypedArrayPrototype.cpp
|
2020-09-20 17:24:44 +00:00
|
|
|
Runtime/VM.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Runtime/Value.cpp
|
2021-06-12 02:28:30 +00:00
|
|
|
Runtime/WeakMap.cpp
|
|
|
|
Runtime/WeakMapConstructor.cpp
|
|
|
|
Runtime/WeakMapPrototype.cpp
|
2021-06-12 14:38:34 +00:00
|
|
|
Runtime/WeakRef.cpp
|
|
|
|
Runtime/WeakRefConstructor.cpp
|
|
|
|
Runtime/WeakRefPrototype.cpp
|
2021-06-09 16:23:04 +00:00
|
|
|
Runtime/WeakSet.cpp
|
|
|
|
Runtime/WeakSetConstructor.cpp
|
|
|
|
Runtime/WeakSetPrototype.cpp
|
2021-02-07 15:56:02 +00:00
|
|
|
SyntaxHighlighter.cpp
|
2020-05-06 15:40:06 +00:00
|
|
|
Token.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
serenity_lib(LibJS js)
|
2021-02-07 15:56:02 +00:00
|
|
|
target_link_libraries(LibJS LibM LibCore LibCrypto LibRegex LibSyntax)
|