mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:57:35 +00:00
LibJS+LibWeb: Devirtualize may_interfere_with_indexed_property_access()
This commit is contained in:
parent
7f501d4d8a
commit
89da731aa6
29 changed files with 51 additions and 61 deletions
|
@ -11,7 +11,7 @@
|
|||
namespace JS {
|
||||
|
||||
ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype(), MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
, m_environment(environment)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ public:
|
|||
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*) override;
|
||||
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
||||
|
||||
virtual bool may_interfere_with_indexed_property_access() const final { return true; }
|
||||
|
||||
// [[ParameterMap]]
|
||||
Object& parameter_map() { return *m_parameter_map; }
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
FunctionObject::FunctionObject(Realm& realm, Object* prototype)
|
||||
: Object(realm, prototype)
|
||||
FunctionObject::FunctionObject(Realm& realm, Object* prototype, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)
|
||||
: Object(realm, prototype, may_interfere_with_indexed_property_access)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionObject::FunctionObject(Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
FunctionObject::FunctionObject(Object& prototype, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype, may_interfere_with_indexed_property_access)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
virtual Vector<DeprecatedFlyString> const& local_variables_names() const { VERIFY_NOT_REACHED(); }
|
||||
|
||||
protected:
|
||||
explicit FunctionObject(Realm&, Object* prototype);
|
||||
explicit FunctionObject(Object& prototype);
|
||||
explicit FunctionObject(Realm&, Object* prototype, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
explicit FunctionObject(Object& prototype, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
|
||||
private:
|
||||
virtual bool is_function() const override { return true; }
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace JS {
|
||||
|
||||
ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vector<DeprecatedFlyString> exports)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype(), MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
, m_module(module)
|
||||
, m_exports(move(exports))
|
||||
{
|
||||
|
|
|
@ -31,8 +31,6 @@ public:
|
|||
virtual ThrowCompletionOr<MarkedVector<Value>> internal_own_property_keys() const override;
|
||||
virtual void initialize(Realm&) override;
|
||||
|
||||
virtual bool may_interfere_with_indexed_property_access() const final { return true; }
|
||||
|
||||
private:
|
||||
ModuleNamespaceObject(Realm&, Module* module, Vector<DeprecatedFlyString> exports);
|
||||
|
||||
|
|
|
@ -35,18 +35,21 @@ NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
|
|||
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype);
|
||||
}
|
||||
|
||||
Object::Object(GlobalObjectTag, Realm& realm)
|
||||
Object::Object(GlobalObjectTag, Realm& realm, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)
|
||||
: m_may_interfere_with_indexed_property_access(may_interfere_with_indexed_property_access == MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
{
|
||||
// This is the global object
|
||||
m_shape = heap().allocate_without_realm<Shape>(realm);
|
||||
}
|
||||
|
||||
Object::Object(ConstructWithoutPrototypeTag, Realm& realm)
|
||||
Object::Object(ConstructWithoutPrototypeTag, Realm& realm, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)
|
||||
: m_may_interfere_with_indexed_property_access(may_interfere_with_indexed_property_access == MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
{
|
||||
m_shape = heap().allocate_without_realm<Shape>(realm);
|
||||
}
|
||||
|
||||
Object::Object(Realm& realm, Object* prototype)
|
||||
Object::Object(Realm& realm, Object* prototype, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)
|
||||
: m_may_interfere_with_indexed_property_access(may_interfere_with_indexed_property_access == MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
{
|
||||
m_shape = realm.intrinsics().empty_object_shape();
|
||||
VERIFY(m_shape);
|
||||
|
@ -54,15 +57,17 @@ Object::Object(Realm& realm, Object* prototype)
|
|||
set_prototype(prototype);
|
||||
}
|
||||
|
||||
Object::Object(ConstructWithPrototypeTag, Object& prototype)
|
||||
Object::Object(ConstructWithPrototypeTag, Object& prototype, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)
|
||||
: m_may_interfere_with_indexed_property_access(may_interfere_with_indexed_property_access == MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
{
|
||||
m_shape = prototype.shape().realm().intrinsics().empty_object_shape();
|
||||
VERIFY(m_shape);
|
||||
set_prototype(&prototype);
|
||||
}
|
||||
|
||||
Object::Object(Shape& shape)
|
||||
: m_shape(&shape)
|
||||
Object::Object(Shape& shape, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access)
|
||||
: m_may_interfere_with_indexed_property_access(may_interfere_with_indexed_property_access == MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
, m_shape(&shape)
|
||||
{
|
||||
m_storage.resize(shape.property_count());
|
||||
}
|
||||
|
|
|
@ -76,6 +76,11 @@ public:
|
|||
Yes,
|
||||
};
|
||||
|
||||
enum class MayInterfereWithIndexedPropertyAccess {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
// Please DO NOT make up your own non-standard methods unless you
|
||||
// have a very good reason to do so. If any object abstract
|
||||
// operation from the spec is missing, add it instead.
|
||||
|
@ -139,7 +144,7 @@ public:
|
|||
// to customize access to indexed properties (properties where the name is a positive integer)
|
||||
// must return true for this, to opt out of optimizations that rely on assumptions that
|
||||
// might not hold when property access behaves differently.
|
||||
virtual bool may_interfere_with_indexed_property_access() const { return false; }
|
||||
bool may_interfere_with_indexed_property_access() const { return m_may_interfere_with_indexed_property_access; }
|
||||
|
||||
ThrowCompletionOr<bool> ordinary_set_with_own_descriptor(PropertyKey const&, Value, Value, Optional<PropertyDescriptor>, CacheablePropertyMetadata* = nullptr);
|
||||
|
||||
|
@ -218,11 +223,11 @@ protected:
|
|||
enum class ConstructWithoutPrototypeTag { Tag };
|
||||
enum class ConstructWithPrototypeTag { Tag };
|
||||
|
||||
Object(GlobalObjectTag, Realm&);
|
||||
Object(ConstructWithoutPrototypeTag, Realm&);
|
||||
Object(Realm&, Object* prototype);
|
||||
Object(ConstructWithPrototypeTag, Object& prototype);
|
||||
explicit Object(Shape&);
|
||||
Object(GlobalObjectTag, Realm&, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
Object(ConstructWithoutPrototypeTag, Realm&, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
Object(Realm&, Object* prototype, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
Object(ConstructWithPrototypeTag, Object& prototype, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
explicit Object(Shape&, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
|
||||
// [[Extensible]]
|
||||
bool m_is_extensible { true };
|
||||
|
@ -236,6 +241,8 @@ private:
|
|||
Object* prototype() { return shape().prototype(); }
|
||||
Object const* prototype() const { return shape().prototype(); }
|
||||
|
||||
bool m_may_interfere_with_indexed_property_access { false };
|
||||
|
||||
// True if this object has lazily allocated intrinsic properties.
|
||||
bool m_has_intrinsic_accessors { false };
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ NonnullGCPtr<ProxyObject> ProxyObject::create(Realm& realm, Object& target, Obje
|
|||
}
|
||||
|
||||
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)
|
||||
: FunctionObject(prototype)
|
||||
: FunctionObject(prototype, MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
, m_target(target)
|
||||
, m_handler(handler)
|
||||
{
|
||||
|
|
|
@ -45,8 +45,6 @@ public:
|
|||
virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override;
|
||||
virtual ThrowCompletionOr<NonnullGCPtr<Object>> internal_construct(MarkedVector<Value> arguments_list, FunctionObject& new_target) override;
|
||||
|
||||
virtual bool may_interfere_with_indexed_property_access() const final { return true; }
|
||||
|
||||
private:
|
||||
ProxyObject(Object& target, Object& handler, Object& prototype);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ NonnullGCPtr<StringObject> StringObject::create(Realm& realm, PrimitiveString& p
|
|||
}
|
||||
|
||||
StringObject::StringObject(PrimitiveString& string, Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype, MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
, m_string(string)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ private:
|
|||
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override;
|
||||
virtual ThrowCompletionOr<MarkedVector<Value>> internal_own_property_keys() const override;
|
||||
|
||||
virtual bool may_interfere_with_indexed_property_access() const final { return true; }
|
||||
|
||||
virtual bool is_string_object() const final { return true; }
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
|
|
|
@ -459,7 +459,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
} \
|
||||
\
|
||||
PrototypeName::PrototypeName(Object& prototype) \
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype) \
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype, MayInterfereWithIndexedPropertyAccess::Yes) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
protected:
|
||||
TypedArrayBase(Object& prototype, IntrinsicConstructor intrinsic_constructor)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype, MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
, m_intrinsic_constructor(intrinsic_constructor)
|
||||
{
|
||||
}
|
||||
|
@ -414,8 +414,6 @@ public:
|
|||
return { move(keys) };
|
||||
}
|
||||
|
||||
virtual bool may_interfere_with_indexed_property_access() const final { return true; }
|
||||
|
||||
ReadonlySpan<UnderlyingBufferDataType> data() const
|
||||
{
|
||||
return { reinterpret_cast<UnderlyingBufferDataType const*>(m_viewed_array_buffer->buffer().data() + m_byte_offset), m_array_length };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue