mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:37:34 +00:00
LibJS: Add a bunch of fast_is<T> to avoid slow RTTI in hot code
This commit is contained in:
parent
39ad705c13
commit
095accd2b2
5 changed files with 61 additions and 0 deletions
|
@ -66,6 +66,7 @@ public:
|
|||
EnvironmentRecordType type() const { return m_environment_record_type; }
|
||||
|
||||
private:
|
||||
virtual bool is_lexical_environment() const override { return true; }
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
EnvironmentRecordType m_environment_record_type : 8 { EnvironmentRecordType::Declarative };
|
||||
|
@ -78,4 +79,7 @@ private:
|
|||
Function* m_current_function { nullptr };
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Object::fast_is<LexicalEnvironment>() const { return is_lexical_environment(); }
|
||||
|
||||
}
|
||||
|
|
|
@ -35,9 +35,13 @@ protected:
|
|||
|
||||
private:
|
||||
virtual LexicalEnvironment* create_environment() override final;
|
||||
virtual bool is_native_function() const final { return true; }
|
||||
|
||||
FlyString m_name;
|
||||
AK::Function<Value(VM&, GlobalObject&)> m_native_function;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Object::fast_is<NativeFunction>() const { return is_native_function(); }
|
||||
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@ public:
|
|||
virtual bool is_typed_array() const { return false; }
|
||||
virtual bool is_string_object() const { return false; }
|
||||
virtual bool is_global_object() const { return false; }
|
||||
virtual bool is_proxy_object() const { return false; }
|
||||
virtual bool is_native_function() const { return false; }
|
||||
virtual bool is_lexical_environment() const { return false; }
|
||||
|
||||
virtual const char* class_name() const override { return "Object"; }
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -46,10 +46,14 @@ private:
|
|||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
virtual bool is_function() const override { return m_target.is_function(); }
|
||||
virtual bool is_proxy_object() const final { return true; }
|
||||
|
||||
Object& m_target;
|
||||
Object& m_handler;
|
||||
bool m_is_revoked { false };
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Object::fast_is<ProxyObject>() const { return is_proxy_object(); }
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue