mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
LibJS/JIT: Add fast path for cached GetVariable accesses
We can now stay in machine code for environment variable read accesses as long as they are cached and initialized. 20% speed-up on Octane/zlib.js :^)
This commit is contained in:
parent
7826c006c1
commit
1d8ec677a3
6 changed files with 147 additions and 3 deletions
|
@ -19,6 +19,9 @@ class DeclarativeEnvironment : public Environment {
|
|||
JS_ENVIRONMENT(DeclarativeEnvironment, Environment);
|
||||
|
||||
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 };
|
||||
|
@ -67,6 +70,8 @@ public:
|
|||
|
||||
[[nodiscard]] u64 environment_serial_number() const { return m_environment_serial_number; }
|
||||
|
||||
static FlatPtr bindings_offset() { return OFFSET_OF(DeclarativeEnvironment, m_bindings); }
|
||||
|
||||
private:
|
||||
ThrowCompletionOr<Value> get_binding_value_direct(VM&, Binding&, bool strict);
|
||||
ThrowCompletionOr<void> set_mutable_binding_direct(VM&, Binding&, Value, bool strict);
|
||||
|
|
|
@ -57,6 +57,9 @@ 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,6 +15,9 @@ 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,6 +30,8 @@ struct ExecutionContext {
|
|||
|
||||
void visit_edges(Cell::Visitor&);
|
||||
|
||||
static FlatPtr lexical_environment_offset() { return OFFSET_OF(ExecutionContext, lexical_environment); }
|
||||
|
||||
private:
|
||||
explicit ExecutionContext(MarkedVector<Value> existing_arguments, MarkedVector<Value> existing_local_variables);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue