mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 06:44:58 +00:00

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.
34 lines
1 KiB
C++
34 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Contrib/Test262/IsHTMLDDA.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
namespace JS::Test262 {
|
|
|
|
JS_DEFINE_ALLOCATOR(IsHTMLDDA);
|
|
|
|
IsHTMLDDA::IsHTMLDDA(Realm& realm)
|
|
// NativeFunction without prototype is currently not possible (only due to the lack of a ctor that supports it)
|
|
: NativeFunction("IsHTMLDDA", realm.intrinsics().function_prototype())
|
|
{
|
|
}
|
|
|
|
ThrowCompletionOr<Value> IsHTMLDDA::call()
|
|
{
|
|
auto& vm = this->vm();
|
|
if (vm.argument_count() == 0)
|
|
return js_null();
|
|
if (vm.argument(0).is_string() && vm.argument(0).as_string().is_empty())
|
|
return js_null();
|
|
// Not sure if this really matters, INTERPRETING.md simply says:
|
|
// * IsHTMLDDA - (present only in implementations that can provide it) an object that:
|
|
// a. has an [[IsHTMLDDA]] internal slot, and
|
|
// b. when called with no arguments or with the first argument "" (an empty string) returns null.
|
|
return js_undefined();
|
|
}
|
|
|
|
}
|