mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK+LibJS: Remove OFFSET_OF and its users
With the LibJS JIT removed, let's not expose pointers to internal members.
This commit is contained in:
parent
4646a87eba
commit
d878975f95
Notes:
sideshowbarker
2024-07-17 11:30:54 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/d878975f95 Pull-request: https://github.com/SerenityOS/serenity/pull/23392
14 changed files with 0 additions and 53 deletions
|
@ -318,9 +318,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static FlatPtr value_offset() { return OFFSET_OF(Optional, m_storage); }
|
||||
static FlatPtr has_value_offset() { return OFFSET_OF(Optional, m_has_value); }
|
||||
|
||||
private:
|
||||
alignas(T) u8 m_storage[sizeof(T)];
|
||||
bool m_has_value { false };
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
|
||||
#define OFFSET_OF(class, member) __builtin_offsetof(class, member)
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<typename T, typename U>
|
||||
|
|
|
@ -811,8 +811,6 @@ public:
|
|||
AK::swap(at(i), at(size() - i - 1));
|
||||
}
|
||||
|
||||
static FlatPtr outline_buffer_offset() { return OFFSET_OF(Vector, m_outline_buffer); }
|
||||
|
||||
private:
|
||||
void reset_capacity()
|
||||
{
|
||||
|
|
|
@ -42,8 +42,6 @@ public:
|
|||
|
||||
void revoke() { m_ptr = nullptr; }
|
||||
|
||||
static FlatPtr ptr_offset() { return OFFSET_OF(WeakLink, m_ptr); }
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
explicit WeakLink(T& weakable)
|
||||
|
|
|
@ -22,16 +22,11 @@
|
|||
namespace JS::Bytecode {
|
||||
|
||||
struct PropertyLookupCache {
|
||||
static FlatPtr shape_offset() { return OFFSET_OF(PropertyLookupCache, shape); }
|
||||
static FlatPtr property_offset_offset() { return OFFSET_OF(PropertyLookupCache, property_offset); }
|
||||
|
||||
WeakPtr<Shape> shape;
|
||||
Optional<u32> property_offset;
|
||||
};
|
||||
|
||||
struct GlobalVariableCache : public PropertyLookupCache {
|
||||
static FlatPtr environment_serial_number_offset() { return OFFSET_OF(GlobalVariableCache, environment_serial_number); }
|
||||
|
||||
u64 environment_serial_number { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -20,9 +20,6 @@ class DeclarativeEnvironment : public Environment {
|
|||
JS_DECLARE_ALLOCATOR(DeclarativeEnvironment);
|
||||
|
||||
struct Binding {
|
||||
static FlatPtr value_offset() { return OFFSET_OF(Binding, value); }
|
||||
static FlatPtr initialized_offset() { return OFFSET_OF(Binding, initialized); }
|
||||
|
||||
DeprecatedFlyString name;
|
||||
Value value;
|
||||
bool strict { false };
|
||||
|
@ -71,9 +68,6 @@ public:
|
|||
|
||||
[[nodiscard]] u64 environment_serial_number() const { return m_environment_serial_number; }
|
||||
|
||||
static FlatPtr bindings_offset() { return OFFSET_OF(DeclarativeEnvironment, m_bindings); }
|
||||
static FlatPtr environment_serial_number_offset() { return OFFSET_OF(DeclarativeEnvironment, m_environment_serial_number); }
|
||||
|
||||
private:
|
||||
ThrowCompletionOr<Value> get_binding_value_direct(VM&, Binding&, bool strict);
|
||||
ThrowCompletionOr<void> set_mutable_binding_direct(VM&, Binding&, Value, bool strict);
|
||||
|
|
|
@ -57,9 +57,6 @@ public:
|
|||
bool is_permanently_screwed_by_eval() const { return m_permanently_screwed_by_eval; }
|
||||
void set_permanently_screwed_by_eval();
|
||||
|
||||
static FlatPtr is_permanently_screwed_by_eval_offset() { return OFFSET_OF(Environment, m_permanently_screwed_by_eval); }
|
||||
static FlatPtr outer_environment_offset() { return OFFSET_OF(Environment, m_outer_environment); }
|
||||
|
||||
protected:
|
||||
explicit Environment(Environment* parent);
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@ struct EnvironmentCoordinate {
|
|||
u32 hops { invalid_marker };
|
||||
u32 index { invalid_marker };
|
||||
|
||||
static FlatPtr hops_offset() { return OFFSET_OF(EnvironmentCoordinate, hops); }
|
||||
static FlatPtr index_offset() { return OFFSET_OF(EnvironmentCoordinate, index); }
|
||||
|
||||
bool is_valid() const { return hops != invalid_marker && index != invalid_marker; }
|
||||
|
||||
static constexpr u32 invalid_marker = 0xfffffffe;
|
||||
|
|
|
@ -30,10 +30,6 @@ struct ExecutionContext {
|
|||
|
||||
void visit_edges(Cell::Visitor&);
|
||||
|
||||
static FlatPtr realm_offset() { return OFFSET_OF(ExecutionContext, realm); }
|
||||
static FlatPtr lexical_environment_offset() { return OFFSET_OF(ExecutionContext, lexical_environment); }
|
||||
static FlatPtr variable_environment_offset() { return OFFSET_OF(ExecutionContext, variable_environment); }
|
||||
|
||||
private:
|
||||
ExecutionContext(Heap&);
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ public:
|
|||
ThrowCompletionOr<void> create_global_var_binding(DeprecatedFlyString const& name, bool can_be_deleted);
|
||||
ThrowCompletionOr<void> create_global_function_binding(DeprecatedFlyString const& name, Value, bool can_be_deleted);
|
||||
|
||||
static FlatPtr object_record_offset() { return OFFSET_OF(GlobalEnvironment, m_object_record); }
|
||||
static FlatPtr declarative_record_offset() { return OFFSET_OF(GlobalEnvironment, m_declarative_record); }
|
||||
|
||||
private:
|
||||
GlobalEnvironment(Object&, Object& this_value);
|
||||
|
||||
|
|
|
@ -46,8 +46,6 @@ public:
|
|||
|
||||
bool is_simple_storage() const { return m_is_simple_storage; }
|
||||
|
||||
static FlatPtr is_simple_storage_offset() { return OFFSET_OF(IndexedPropertyStorage, m_is_simple_storage); }
|
||||
|
||||
protected:
|
||||
explicit IndexedPropertyStorage(IsSimpleStorage is_simple_storage)
|
||||
: m_is_simple_storage(is_simple_storage == IsSimpleStorage::Yes) {};
|
||||
|
@ -76,9 +74,6 @@ public:
|
|||
|
||||
Vector<Value> const& elements() const { return m_packed_elements; }
|
||||
|
||||
static FlatPtr array_size_offset() { return OFFSET_OF(SimpleIndexedPropertyStorage, m_array_size); }
|
||||
static FlatPtr elements_offset() { return OFFSET_OF(SimpleIndexedPropertyStorage, m_packed_elements); }
|
||||
|
||||
private:
|
||||
friend GenericIndexedPropertyStorage;
|
||||
|
||||
|
@ -177,8 +172,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static FlatPtr storage_offset() { return OFFSET_OF(IndexedProperties, m_storage); }
|
||||
|
||||
private:
|
||||
void switch_to_generic_storage();
|
||||
void ensure_storage();
|
||||
|
|
|
@ -204,8 +204,6 @@ public:
|
|||
Value get_direct(size_t index) const { return m_storage[index]; }
|
||||
void put_direct(size_t index, Value value) { m_storage[index] = value; }
|
||||
|
||||
static FlatPtr storage_offset() { return OFFSET_OF(Object, m_storage); }
|
||||
|
||||
IndexedProperties const& indexed_properties() const { return m_indexed_properties; }
|
||||
IndexedProperties& indexed_properties() { return m_indexed_properties; }
|
||||
void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); }
|
||||
|
@ -213,18 +211,12 @@ public:
|
|||
Shape& shape() { return *m_shape; }
|
||||
Shape const& shape() const { return *m_shape; }
|
||||
|
||||
static FlatPtr shape_offset() { return OFFSET_OF(Object, m_shape); }
|
||||
|
||||
template<typename T>
|
||||
bool fast_is() const = delete;
|
||||
|
||||
void set_prototype(Object*);
|
||||
|
||||
static FlatPtr may_interfere_with_indexed_property_access_offset() { return OFFSET_OF(Object, m_may_interfere_with_indexed_property_access); }
|
||||
static FlatPtr indexed_properties_offset() { return OFFSET_OF(Object, m_indexed_properties); }
|
||||
|
||||
[[nodiscard]] bool has_magical_length_property() const { return m_has_magical_length_property; }
|
||||
static FlatPtr has_magical_length_property_offset() { return OFFSET_OF(Object, m_has_magical_length_property); }
|
||||
|
||||
[[nodiscard]] bool is_typed_array() const { return m_is_typed_array; }
|
||||
void set_is_typed_array() { m_is_typed_array = true; }
|
||||
|
|
|
@ -42,8 +42,6 @@ public:
|
|||
// [[IsWithEnvironment]], Indicates whether this Environment Record is created for a with statement.
|
||||
bool is_with_environment() const { return m_with_environment; }
|
||||
|
||||
static FlatPtr binding_object_offset() { return OFFSET_OF(ObjectEnvironment, m_binding_object); }
|
||||
|
||||
private:
|
||||
ObjectEnvironment(Object& binding_object, IsWithEnvironment, Environment* outer_environment);
|
||||
|
||||
|
|
|
@ -62,9 +62,6 @@ public:
|
|||
return *m_builtins[to_underlying(builtin)];
|
||||
}
|
||||
|
||||
static FlatPtr global_environment_offset() { return OFFSET_OF(Realm, m_global_environment); }
|
||||
static FlatPtr builtins_offset() { return OFFSET_OF(Realm, m_builtins); }
|
||||
|
||||
private:
|
||||
Realm() = default;
|
||||
|
||||
|
|
Loading…
Reference in a new issue