mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
LibJS: Keep cached this
value in a call frame register
Just moving more things to call frame registers..
This commit is contained in:
parent
3887b840a3
commit
c833885fb5
5 changed files with 13 additions and 9 deletions
|
@ -252,7 +252,7 @@ private:
|
||||||
NonnullOwnPtr<IdentifierTable> m_identifier_table;
|
NonnullOwnPtr<IdentifierTable> m_identifier_table;
|
||||||
NonnullOwnPtr<RegexTable> m_regex_table;
|
NonnullOwnPtr<RegexTable> m_regex_table;
|
||||||
|
|
||||||
u32 m_next_register { 3 };
|
u32 m_next_register { Register::reserved_register_count };
|
||||||
u32 m_next_block { 1 };
|
u32 m_next_block { 1 };
|
||||||
u32 m_next_property_lookup_cache { 0 };
|
u32 m_next_property_lookup_cache { 0 };
|
||||||
u32 m_next_global_variable_cache { 0 };
|
u32 m_next_global_variable_cache { 0 };
|
||||||
|
|
|
@ -179,8 +179,6 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable& executa
|
||||||
else
|
else
|
||||||
push_call_frame(make<CallFrame>(), executable.number_of_registers);
|
push_call_frame(make<CallFrame>(), executable.number_of_registers);
|
||||||
|
|
||||||
TemporaryChange restore_this_value { m_this_value, {} };
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
auto pc = InstructionStreamIterator { m_current_block->instruction_stream(), m_current_executable };
|
auto pc = InstructionStreamIterator { m_current_block->instruction_stream(), m_current_executable };
|
||||||
TemporaryChange temp_change { m_pc, Optional<InstructionStreamIterator&>(pc) };
|
TemporaryChange temp_change { m_pc, Optional<InstructionStreamIterator&>(pc) };
|
||||||
|
|
|
@ -90,8 +90,6 @@ public:
|
||||||
auto& instruction_stream_iterator() const { return m_pc; }
|
auto& instruction_stream_iterator() const { return m_pc; }
|
||||||
DeprecatedString debug_position() const;
|
DeprecatedString debug_position() const;
|
||||||
|
|
||||||
Optional<Value>& this_value() { return m_this_value; }
|
|
||||||
|
|
||||||
void visit_edges(Cell::Visitor&);
|
void visit_edges(Cell::Visitor&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -116,7 +114,6 @@ private:
|
||||||
Span<Value> m_current_call_frame;
|
Span<Value> m_current_call_frame;
|
||||||
Optional<BasicBlock const*> m_pending_jump;
|
Optional<BasicBlock const*> m_pending_jump;
|
||||||
BasicBlock const* m_scheduled_jump { nullptr };
|
BasicBlock const* m_scheduled_jump { nullptr };
|
||||||
Optional<Value> m_this_value;
|
|
||||||
Optional<Value> m_return_value;
|
Optional<Value> m_return_value;
|
||||||
Executable* m_current_executable { nullptr };
|
Executable* m_current_executable { nullptr };
|
||||||
BasicBlock const* m_current_block { nullptr };
|
BasicBlock const* m_current_block { nullptr };
|
||||||
|
|
|
@ -767,13 +767,14 @@ ThrowCompletionOr<void> Jump::execute_impl(Bytecode::Interpreter& interpreter) c
|
||||||
|
|
||||||
ThrowCompletionOr<void> ResolveThisBinding::execute_impl(Bytecode::Interpreter& interpreter) const
|
ThrowCompletionOr<void> ResolveThisBinding::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||||
{
|
{
|
||||||
if (!interpreter.this_value().has_value()) {
|
auto& cached_this_value = interpreter.reg(Register::this_value());
|
||||||
|
if (cached_this_value.is_empty()) {
|
||||||
// OPTIMIZATION: Because the value of 'this' cannot be reassigned during a function execution, it's
|
// OPTIMIZATION: Because the value of 'this' cannot be reassigned during a function execution, it's
|
||||||
// resolved once and then saved for subsequent use.
|
// resolved once and then saved for subsequent use.
|
||||||
auto& vm = interpreter.vm();
|
auto& vm = interpreter.vm();
|
||||||
interpreter.this_value() = TRY(vm.resolve_this_binding());
|
cached_this_value = TRY(vm.resolve_this_binding());
|
||||||
}
|
}
|
||||||
interpreter.accumulator() = interpreter.this_value().value();
|
interpreter.accumulator() = cached_this_value;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,14 @@ public:
|
||||||
return Register(exception_index);
|
return Register(exception_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr Register this_value()
|
||||||
|
{
|
||||||
|
constexpr u32 this_value_index = 3;
|
||||||
|
return Register(this_value_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr u32 reserved_register_count = 4;
|
||||||
|
|
||||||
constexpr explicit Register(u32 index)
|
constexpr explicit Register(u32 index)
|
||||||
: m_index(index)
|
: m_index(index)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue