mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibJS: Optimize reading known-to-be-initialized var
bindings
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
`var` bindings are never in the temporal dead zone (TDZ), and so we know accessing them will not throw. We now take advantage of this by having a specialized environment binding value getter that doesn't check for exceptional cases. 1.08x speedup on JetStream.
This commit is contained in:
parent
ad7c1e147f
commit
bf1b754e91
Notes:
github-actions[bot]
2025-05-04 00:32:11 +00:00
Author: https://github.com/awesomekling
Commit: bf1b754e91
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4588
8 changed files with 90 additions and 15 deletions
|
@ -159,6 +159,13 @@ private:
|
|||
u32 m_tail_size { 0 };
|
||||
};
|
||||
|
||||
enum class DeclarationKind {
|
||||
None,
|
||||
Var,
|
||||
Let,
|
||||
Const,
|
||||
};
|
||||
|
||||
class Statement : public ASTNode {
|
||||
public:
|
||||
explicit Statement(SourceRange source_range)
|
||||
|
@ -702,6 +709,9 @@ public:
|
|||
bool is_global() const { return m_is_global; }
|
||||
void set_is_global() { m_is_global = true; }
|
||||
|
||||
[[nodiscard]] DeclarationKind declaration_kind() const { return m_declaration_kind; }
|
||||
void set_declaration_kind(DeclarationKind kind) { m_declaration_kind = kind; }
|
||||
|
||||
virtual void dump(int indent) const override;
|
||||
virtual Bytecode::CodeGenerationErrorOr<Optional<Bytecode::ScopedOperand>> generate_bytecode(Bytecode::Generator&, Optional<Bytecode::ScopedOperand> preferred_dst = {}) const override;
|
||||
|
||||
|
@ -712,6 +722,7 @@ private:
|
|||
|
||||
Optional<Local> m_local_index;
|
||||
bool m_is_global { false };
|
||||
DeclarationKind m_declaration_kind { DeclarationKind::None };
|
||||
};
|
||||
|
||||
struct FunctionParameter {
|
||||
|
@ -1764,12 +1775,6 @@ private:
|
|||
bool m_prefixed;
|
||||
};
|
||||
|
||||
enum class DeclarationKind {
|
||||
Var,
|
||||
Let,
|
||||
Const,
|
||||
};
|
||||
|
||||
class VariableDeclarator final : public ASTNode {
|
||||
public:
|
||||
VariableDeclarator(SourceRange source_range, NonnullRefPtr<Identifier const> id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue