mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:17:46 +00:00
LibJS: Segregate GC-allocated objects by type
This patch adds two macros to declare per-type allocators: - JS_DECLARE_ALLOCATOR(TypeName) - JS_DEFINE_ALLOCATOR(TypeName) When used, they add a type-specific CellAllocator that the Heap will delegate allocation requests to. The result of this is that GC objects of the same type always end up within the same HeapBlock, drastically reducing the ability to perform type confusion attacks. It also improves HeapBlock utilization, since each block now has cells sized exactly to the type used within that block. (Previously we only had a handful of block sizes available, and most GC allocations ended up with a large amount of slack in their tails.) There is a small performance hit from this, but I'm sure we can make up for it elsewhere. Note that the old size-based allocators still exist, and we fall back to them for any type that doesn't have its own CellAllocator.
This commit is contained in:
parent
84a8ee01e1
commit
3c74dc9f4d
428 changed files with 723 additions and 22 deletions
13
Userland/Libraries/LibJS/Runtime/Accessor.cpp
Normal file
13
Userland/Libraries/LibJS/Runtime/Accessor.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Accessor.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Accessor);
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ namespace JS {
|
|||
|
||||
class Accessor final : public Cell {
|
||||
JS_CELL(Accessor, Cell);
|
||||
JS_DECLARE_ALLOCATOR(Accessor);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<Accessor> create(VM& vm, FunctionObject* getter, FunctionObject* setter)
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AggregateError);
|
||||
|
||||
NonnullGCPtr<AggregateError> AggregateError::create(Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<AggregateError>(realm, realm.intrinsics().aggregate_error_prototype());
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class AggregateError : public Error {
|
||||
JS_OBJECT(AggregateError, Error);
|
||||
JS_DECLARE_ALLOCATOR(AggregateError);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<AggregateError> create(Realm&);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AggregateErrorConstructor);
|
||||
|
||||
AggregateErrorConstructor::AggregateErrorConstructor(Realm& realm)
|
||||
: NativeFunction(static_cast<Object&>(*realm.intrinsics().error_constructor()))
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AggregateErrorConstructor final : public NativeFunction {
|
||||
JS_OBJECT(AggregateErrorConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(AggregateErrorConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AggregateErrorPrototype);
|
||||
|
||||
AggregateErrorPrototype::AggregateErrorPrototype(Realm& realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().error_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AggregateErrorPrototype final : public Object {
|
||||
JS_OBJECT(AggregateErrorPrototype, Object);
|
||||
JS_DECLARE_ALLOCATOR(AggregateErrorPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArgumentsObject);
|
||||
|
||||
ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype(), MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
, m_environment(environment)
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace JS {
|
|||
|
||||
class ArgumentsObject final : public Object {
|
||||
JS_OBJECT(ArgumentsObject, Object);
|
||||
JS_DECLARE_ALLOCATOR(ArgumentsObject);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Array);
|
||||
|
||||
// 10.4.2.2 ArrayCreate ( length [ , proto ] ), https://tc39.es/ecma262/#sec-arraycreate
|
||||
ThrowCompletionOr<NonnullGCPtr<Array>> Array::create(Realm& realm, u64 length, Object* prototype)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace JS {
|
|||
|
||||
class Array : public Object {
|
||||
JS_OBJECT(Array, Object);
|
||||
JS_DECLARE_ALLOCATOR(Array);
|
||||
|
||||
public:
|
||||
static ThrowCompletionOr<NonnullGCPtr<Array>> create(Realm&, u64 length, Object* prototype = nullptr);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArrayBuffer);
|
||||
|
||||
ThrowCompletionOr<NonnullGCPtr<ArrayBuffer>> ArrayBuffer::create(Realm& realm, size_t byte_length)
|
||||
{
|
||||
auto buffer = ByteBuffer::create_zeroed(byte_length);
|
||||
|
|
|
@ -48,6 +48,7 @@ struct DataBlock {
|
|||
|
||||
class ArrayBuffer : public Object {
|
||||
JS_OBJECT(ArrayBuffer, Object);
|
||||
JS_DECLARE_ALLOCATOR(ArrayBuffer);
|
||||
|
||||
public:
|
||||
static ThrowCompletionOr<NonnullGCPtr<ArrayBuffer>> create(Realm&, size_t);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArrayBufferConstructor);
|
||||
|
||||
ArrayBufferConstructor::ArrayBufferConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.ArrayBuffer.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class ArrayBufferConstructor final : public NativeFunction {
|
||||
JS_OBJECT(ArrayBufferConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(ArrayBufferConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArrayBufferPrototype);
|
||||
|
||||
ArrayBufferPrototype::ArrayBufferPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class ArrayBufferPrototype final : public PrototypeObject<ArrayBufferPrototype, ArrayBuffer> {
|
||||
JS_PROTOTYPE_OBJECT(ArrayBufferPrototype, ArrayBuffer, ArrayBuffer);
|
||||
JS_DECLARE_ALLOCATOR(ArrayBufferPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArrayConstructor);
|
||||
|
||||
ArrayConstructor::ArrayConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.Array.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class ArrayConstructor final : public NativeFunction {
|
||||
JS_OBJECT(ArrayConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(ArrayConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArrayIterator);
|
||||
|
||||
NonnullGCPtr<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, realm.intrinsics().array_iterator_prototype());
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class ArrayIterator final : public Object {
|
||||
JS_OBJECT(ArrayIterator, Object);
|
||||
JS_DECLARE_ALLOCATOR(ArrayIterator);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<ArrayIterator> create(Realm&, Value array, Object::PropertyKind iteration_kind);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArrayIteratorPrototype);
|
||||
|
||||
ArrayIteratorPrototype::ArrayIteratorPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().iterator_prototype())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class ArrayIteratorPrototype final : public PrototypeObject<ArrayIteratorPrototype, ArrayIterator> {
|
||||
JS_PROTOTYPE_OBJECT(ArrayIteratorPrototype, ArrayIterator, ArrayIterator);
|
||||
JS_DECLARE_ALLOCATOR(ArrayIteratorPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ArrayPrototype);
|
||||
|
||||
static HashTable<NonnullGCPtr<Object>> s_array_join_seen_objects;
|
||||
|
||||
ArrayPrototype::ArrayPrototype(Realm& realm)
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class ArrayPrototype final : public Array {
|
||||
JS_OBJECT(ArrayPrototype, Array);
|
||||
JS_DECLARE_ALLOCATOR(ArrayPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncFromSyncIterator);
|
||||
|
||||
NonnullGCPtr<AsyncFromSyncIterator> AsyncFromSyncIterator::create(Realm& realm, IteratorRecord sync_iterator_record)
|
||||
{
|
||||
return realm.heap().allocate<AsyncFromSyncIterator>(realm, realm, sync_iterator_record);
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace JS {
|
|||
// 27.1.4.3 Properties of Async-from-Sync Iterator Instances, https://tc39.es/ecma262/#sec-properties-of-async-from-sync-iterator-instances
|
||||
class AsyncFromSyncIterator final : public Object {
|
||||
JS_OBJECT(AsyncFromSyncIterator, Object);
|
||||
JS_DECLARE_ALLOCATOR(AsyncFromSyncIterator);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<AsyncFromSyncIterator> create(Realm&, IteratorRecord sync_iterator_record);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DECLARE_ALLOCATOR(AsyncFromSyncIteratorPrototype);
|
||||
|
||||
AsyncFromSyncIteratorPrototype::AsyncFromSyncIteratorPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().async_iterator_prototype())
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace JS {
|
|||
// 27.1.4.2 The %AsyncFromSyncIteratorPrototype% Object, https://tc39.es/ecma262/#sec-%asyncfromsynciteratorprototype%-object
|
||||
class AsyncFromSyncIteratorPrototype final : public PrototypeObject<AsyncFromSyncIteratorPrototype, AsyncFromSyncIterator> {
|
||||
JS_PROTOTYPE_OBJECT(AsyncFromSyncIteratorPrototype, AsyncFromSyncIterator, AsyncFromSyncIterator);
|
||||
JS_DECLARE_ALLOCATOR(AsyncFromSyncIteratorPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncFunctionConstructor);
|
||||
|
||||
AsyncFunctionConstructor::AsyncFunctionConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.AsyncFunction.as_string(), realm.intrinsics().function_constructor())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AsyncFunctionConstructor final : public NativeFunction {
|
||||
JS_OBJECT(AsyncFunctionConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(AsyncFunctionConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncFunctionDriverWrapper);
|
||||
|
||||
NonnullGCPtr<Promise> AsyncFunctionDriverWrapper::create(Realm& realm, GeneratorObject* generator_object)
|
||||
{
|
||||
auto top_level_promise = Promise::create(realm);
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace JS {
|
|||
|
||||
class AsyncFunctionDriverWrapper final : public Promise {
|
||||
JS_OBJECT(AsyncFunctionDriverWrapper, Promise);
|
||||
JS_DECLARE_ALLOCATOR(AsyncFunctionDriverWrapper);
|
||||
|
||||
public:
|
||||
enum class IsInitialExecution {
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncFunctionPrototype);
|
||||
|
||||
AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AsyncFunctionPrototype final : public Object {
|
||||
JS_OBJECT(AsyncFunctionPrototype, Object);
|
||||
JS_DECLARE_ALLOCATOR(AsyncFunctionPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncGenerator);
|
||||
|
||||
ThrowCompletionOr<NonnullGCPtr<AsyncGenerator>> AsyncGenerator::create(Realm& realm, Value initial_value, ECMAScriptFunctionObject* generating_function, ExecutionContext execution_context, Bytecode::CallFrame frame)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace JS {
|
|||
// 27.6.2 Properties of AsyncGenerator Instances, https://tc39.es/ecma262/#sec-properties-of-asyncgenerator-intances
|
||||
class AsyncGenerator final : public Object {
|
||||
JS_OBJECT(AsyncGenerator, Object);
|
||||
JS_DECLARE_ALLOCATOR(AsyncGenerator);
|
||||
|
||||
public:
|
||||
enum class State {
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncGeneratorFunctionConstructor);
|
||||
|
||||
AsyncGeneratorFunctionConstructor::AsyncGeneratorFunctionConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.AsyncGeneratorFunction.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AsyncGeneratorFunctionConstructor final : public NativeFunction {
|
||||
JS_OBJECT(AsyncGeneratorFunctionConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(AsyncGeneratorFunctionConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncGeneratorFunctionPrototype);
|
||||
|
||||
AsyncGeneratorFunctionPrototype::AsyncGeneratorFunctionPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AsyncGeneratorFunctionPrototype final : public PrototypeObject<AsyncGeneratorFunctionPrototype, AsyncGeneratorFunction> {
|
||||
JS_PROTOTYPE_OBJECT(AsyncGeneratorFunctionPrototype, AsyncGeneratorFunction, AsyncGeneratorFunction);
|
||||
JS_DECLARE_ALLOCATOR(AsyncGeneratorFunctionPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncGeneratorPrototype);
|
||||
|
||||
// 27.6.1 Properties of the AsyncGenerator Prototype Object, https://tc39.es/ecma262/#sec-properties-of-asyncgenerator-prototype
|
||||
AsyncGeneratorPrototype::AsyncGeneratorPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().async_iterator_prototype())
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace JS {
|
|||
|
||||
class AsyncGeneratorPrototype final : public PrototypeObject<AsyncGeneratorPrototype, AsyncGenerator> {
|
||||
JS_PROTOTYPE_OBJECT(AsyncGeneratorPrototype, AsyncGenerator, AsyncGenerator)
|
||||
JS_DECLARE_ALLOCATOR(AsyncGeneratorPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AsyncIteratorPrototype);
|
||||
|
||||
AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AsyncIteratorPrototype final : public Object {
|
||||
JS_OBJECT(AsyncIteratorPrototype, Object)
|
||||
JS_DECLARE_ALLOCATOR(AsyncIteratorPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(AtomicsObject);
|
||||
|
||||
// 25.4.2.1 ValidateIntegerTypedArray ( typedArray [ , waitable ] ), https://tc39.es/ecma262/#sec-validateintegertypedarray
|
||||
static ThrowCompletionOr<ArrayBuffer*> validate_integer_typed_array(VM& vm, TypedArrayBase& typed_array, bool waitable = false)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class AtomicsObject : public Object {
|
||||
JS_OBJECT(AtomicsObject, Object);
|
||||
JS_DECLARE_ALLOCATOR(AtomicsObject);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BigInt);
|
||||
|
||||
NonnullGCPtr<BigInt> BigInt::create(VM& vm, Crypto::SignedBigInteger big_integer)
|
||||
{
|
||||
return vm.heap().allocate_without_realm<BigInt>(move(big_integer));
|
||||
|
|
|
@ -11,11 +11,13 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/CellAllocator.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class BigInt final : public Cell {
|
||||
JS_CELL(BigInt, Cell);
|
||||
JS_DECLARE_ALLOCATOR(BigInt);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static NonnullGCPtr<BigInt> create(VM&, Crypto::SignedBigInteger);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BigIntConstructor);
|
||||
|
||||
static const Crypto::SignedBigInteger BIGINT_ONE { 1 };
|
||||
|
||||
BigIntConstructor::BigIntConstructor(Realm& realm)
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class BigIntConstructor final : public NativeFunction {
|
||||
JS_OBJECT(BigIntConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(BigIntConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BigIntObject);
|
||||
|
||||
NonnullGCPtr<BigIntObject> BigIntObject::create(Realm& realm, BigInt& bigint)
|
||||
{
|
||||
return realm.heap().allocate<BigIntObject>(realm, bigint, realm.intrinsics().bigint_prototype());
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class BigIntObject final : public Object {
|
||||
JS_OBJECT(BigIntObject, Object);
|
||||
JS_DECLARE_ALLOCATOR(BigIntObject);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<BigIntObject> create(Realm&, BigInt&);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BigIntPrototype);
|
||||
|
||||
BigIntPrototype::BigIntPrototype(Realm& realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class BigIntPrototype final : public Object {
|
||||
JS_OBJECT(BigIntPrototype, Object);
|
||||
JS_DECLARE_ALLOCATOR(BigIntPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BooleanConstructor);
|
||||
|
||||
BooleanConstructor::BooleanConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.Boolean.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class BooleanConstructor final : public NativeFunction {
|
||||
JS_OBJECT(BooleanConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(BooleanConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BooleanObject);
|
||||
|
||||
NonnullGCPtr<BooleanObject> BooleanObject::create(Realm& realm, bool value)
|
||||
{
|
||||
return realm.heap().allocate<BooleanObject>(realm, value, realm.intrinsics().boolean_prototype());
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class BooleanObject : public Object {
|
||||
JS_OBJECT(BooleanObject, Object);
|
||||
JS_DECLARE_ALLOCATOR(BooleanObject);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<BooleanObject> create(Realm&, bool);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BooleanPrototype);
|
||||
|
||||
BooleanPrototype::BooleanPrototype(Realm& realm)
|
||||
: BooleanObject(false, realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class BooleanPrototype final : public BooleanObject {
|
||||
JS_OBJECT(BooleanPrototype, BooleanObject);
|
||||
JS_DECLARE_ALLOCATOR(BooleanPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(BoundFunction);
|
||||
|
||||
// 10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs ), https://tc39.es/ecma262/#sec-boundfunctioncreate
|
||||
ThrowCompletionOr<NonnullGCPtr<BoundFunction>> BoundFunction::create(Realm& realm, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class BoundFunction final : public FunctionObject {
|
||||
JS_OBJECT(BoundFunction, FunctionObject);
|
||||
JS_DECLARE_ALLOCATOR(BoundFunction);
|
||||
|
||||
public:
|
||||
static ThrowCompletionOr<NonnullGCPtr<BoundFunction>> create(Realm&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ConsoleObject);
|
||||
|
||||
ConsoleObject::ConsoleObject(Realm& realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
||||
, m_console(make<Console>(realm))
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class ConsoleObject final : public Object {
|
||||
JS_OBJECT(ConsoleObject, Object);
|
||||
JS_DECLARE_ALLOCATOR(ConsoleObject);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DataView);
|
||||
|
||||
NonnullGCPtr<DataView> DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset)
|
||||
{
|
||||
return realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, realm.intrinsics().data_view_prototype());
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace JS {
|
|||
|
||||
class DataView : public Object {
|
||||
JS_OBJECT(DataView, Object);
|
||||
JS_DECLARE_ALLOCATOR(DataView);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<DataView> create(Realm&, ArrayBuffer*, size_t byte_length, size_t byte_offset);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DataViewConstructor);
|
||||
|
||||
DataViewConstructor::DataViewConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.DataView.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class DataViewConstructor final : public NativeFunction {
|
||||
JS_OBJECT(DataViewConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(DataViewConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DataViewPrototype);
|
||||
|
||||
DataViewPrototype::DataViewPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class DataViewPrototype final : public PrototypeObject<DataViewPrototype, DataView> {
|
||||
JS_PROTOTYPE_OBJECT(DataViewPrototype, DataView, DataView);
|
||||
JS_DECLARE_ALLOCATOR(DataViewPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Date);
|
||||
|
||||
static Crypto::SignedBigInteger const s_one_billion_bigint { 1'000'000'000 };
|
||||
static Crypto::SignedBigInteger const s_one_million_bigint { 1'000'000 };
|
||||
static Crypto::SignedBigInteger const s_one_thousand_bigint { 1'000 };
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace JS {
|
|||
|
||||
class Date final : public Object {
|
||||
JS_OBJECT(Date, Object);
|
||||
JS_DECLARE_ALLOCATOR(Date);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<Date> create(Realm&, double date_value);
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DateConstructor);
|
||||
|
||||
// 21.4.3.2 Date.parse ( string ), https://tc39.es/ecma262/#sec-date.parse
|
||||
static double parse_simplified_iso8601(DeprecatedString const& iso_8601)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class DateConstructor final : public NativeFunction {
|
||||
JS_OBJECT(DateConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(DateConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DatePrototype);
|
||||
|
||||
DatePrototype::DatePrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class DatePrototype final : public PrototypeObject<DatePrototype, Date> {
|
||||
JS_PROTOTYPE_OBJECT(DatePrototype, Date, Date);
|
||||
JS_DECLARE_ALLOCATOR(DatePrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DeclarativeEnvironment);
|
||||
|
||||
DeclarativeEnvironment* DeclarativeEnvironment::create_for_per_iteration_bindings(Badge<ForStatement>, DeclarativeEnvironment& other, size_t bindings_size)
|
||||
{
|
||||
auto bindings = other.m_bindings.span().slice(0, bindings_size);
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace JS {
|
|||
|
||||
class DeclarativeEnvironment : public Environment {
|
||||
JS_ENVIRONMENT(DeclarativeEnvironment, Environment);
|
||||
JS_DECLARE_ALLOCATOR(DeclarativeEnvironment);
|
||||
|
||||
struct Binding {
|
||||
static FlatPtr value_offset() { return OFFSET_OF(Binding, value); }
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DisposableStack);
|
||||
|
||||
DisposableStack::DisposableStack(Vector<DisposableResource> stack, Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_disposable_resource_stack(move(stack))
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class DisposableStack final : public Object {
|
||||
JS_OBJECT(DisposableStack, Object);
|
||||
JS_DECLARE_ALLOCATOR(DisposableStack);
|
||||
|
||||
public:
|
||||
virtual ~DisposableStack() override = default;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DisposableStackConstructor);
|
||||
|
||||
DisposableStackConstructor::DisposableStackConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.DisposableStack.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class DisposableStackConstructor final : public NativeFunction {
|
||||
JS_OBJECT(DisposableStackConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(DisposableStackConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DisposableStackPrototype);
|
||||
|
||||
DisposableStackPrototype::DisposableStackPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class DisposableStackPrototype final : public PrototypeObject<DisposableStackPrototype, DisposableStack> {
|
||||
JS_PROTOTYPE_OBJECT(DisposableStackPrototype, DisposableStack, DisposableStack);
|
||||
JS_DECLARE_ALLOCATOR(DisposableStackPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ECMAScriptFunctionObject);
|
||||
|
||||
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
|
||||
{
|
||||
Object* prototype = nullptr;
|
||||
|
|
|
@ -24,6 +24,7 @@ void async_function_start(VM&, PromiseCapability const&, T const& async_function
|
|||
// 10.2 ECMAScript Function Objects, https://tc39.es/ecma262/#sec-ecmascript-function-objects
|
||||
class ECMAScriptFunctionObject final : public FunctionObject {
|
||||
JS_OBJECT(ECMAScriptFunctionObject, FunctionObject);
|
||||
JS_DECLARE_ALLOCATOR(ECMAScriptFunctionObject);
|
||||
|
||||
public:
|
||||
enum class ConstructorKind : u8 {
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Error);
|
||||
|
||||
SourceRange const& TracebackFrame::source_range() const
|
||||
{
|
||||
if (auto* unrealized = source_range_storage.get_pointer<UnrealizedSourceRange>()) {
|
||||
|
@ -156,6 +158,7 @@ String Error::stack_string(CompactTraceback compact) const
|
|||
}
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
JS_DEFINE_ALLOCATOR(ClassName); \
|
||||
NonnullGCPtr<ClassName> ClassName::create(Realm& realm) \
|
||||
{ \
|
||||
return realm.heap().allocate<ClassName>(realm, realm.intrinsics().snake_name##_prototype()); \
|
||||
|
|
|
@ -29,6 +29,7 @@ enum CompactTraceback {
|
|||
|
||||
class Error : public Object {
|
||||
JS_OBJECT(Error, Object);
|
||||
JS_DECLARE_ALLOCATOR(Error);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<Error> create(Realm&);
|
||||
|
@ -57,6 +58,7 @@ private:
|
|||
#define DECLARE_NATIVE_ERROR(ClassName, snake_name, PrototypeName, ConstructorName) \
|
||||
class ClassName final : public Error { \
|
||||
JS_OBJECT(ClassName, Error); \
|
||||
JS_DECLARE_ALLOCATOR(ClassName); \
|
||||
\
|
||||
public: \
|
||||
static NonnullGCPtr<ClassName> create(Realm&); \
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ErrorConstructor);
|
||||
|
||||
ErrorConstructor::ErrorConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.Error.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
@ -62,6 +64,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObje
|
|||
}
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
JS_DEFINE_ALLOCATOR(ConstructorName); \
|
||||
ConstructorName::ConstructorName(Realm& realm) \
|
||||
: NativeFunction(realm.vm().names.ClassName.as_string(), realm.intrinsics().error_constructor()) \
|
||||
{ \
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class ErrorConstructor final : public NativeFunction {
|
||||
JS_OBJECT(ErrorConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(ErrorConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
@ -30,6 +31,7 @@ private:
|
|||
#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \
|
||||
class ConstructorName final : public NativeFunction { \
|
||||
JS_OBJECT(ConstructorName, NativeFunction); \
|
||||
JS_DECLARE_ALLOCATOR(ConstructorName); \
|
||||
\
|
||||
public: \
|
||||
virtual void initialize(Realm&) override; \
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ErrorPrototype);
|
||||
|
||||
ErrorPrototype::ErrorPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace JS {
|
|||
|
||||
class ErrorPrototype final : public PrototypeObject<ErrorPrototype, Error> {
|
||||
JS_PROTOTYPE_OBJECT(ErrorPrototype, Error, Error);
|
||||
JS_DECLARE_ALLOCATOR(ErrorPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(FinalizationRegistry);
|
||||
|
||||
FinalizationRegistry::FinalizationRegistry(Realm& realm, JobCallback cleanup_callback, Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, WeakContainer(heap())
|
||||
|
|
|
@ -21,6 +21,7 @@ class FinalizationRegistry final
|
|||
: public Object
|
||||
, public WeakContainer {
|
||||
JS_OBJECT(FinalizationRegistry, Object);
|
||||
JS_DECLARE_ALLOCATOR(FinalizationRegistry);
|
||||
|
||||
public:
|
||||
virtual ~FinalizationRegistry() override = default;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(FinalizationRegistryConstructor);
|
||||
|
||||
FinalizationRegistryConstructor::FinalizationRegistryConstructor(Realm& realm)
|
||||
: NativeFunction(realm.vm().names.FinalizationRegistry.as_string(), realm.intrinsics().function_prototype())
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace JS {
|
|||
|
||||
class FinalizationRegistryConstructor final : public NativeFunction {
|
||||
JS_OBJECT(FinalizationRegistryConstructor, NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(FinalizationRegistryConstructor);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(FinalizationRegistryPrototype);
|
||||
|
||||
FinalizationRegistryPrototype::FinalizationRegistryPrototype(Realm& realm)
|
||||
: PrototypeObject(realm.intrinsics().object_prototype())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace JS {
|
|||
|
||||
class FinalizationRegistryPrototype final : public PrototypeObject<FinalizationRegistryPrototype, FinalizationRegistry> {
|
||||
JS_PROTOTYPE_OBJECT(FinalizationRegistryPrototype, FinalizationRegistry, FinalizationRegistry);
|
||||
JS_DECLARE_ALLOCATOR(FinalizationRegistryPrototype);
|
||||
|
||||
public:
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue