mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:57:35 +00:00
LibJS/JIT: Compile the DeleteByValueWithThis instruction
This commit is contained in:
parent
0776404e03
commit
6a7b9b85a4
6 changed files with 35 additions and 8 deletions
|
@ -646,4 +646,15 @@ ThrowCompletionOr<Value> delete_by_value(Bytecode::Interpreter& interpreter, Val
|
||||||
return Value(TRY(reference.delete_(vm)));
|
return Value(TRY(reference.delete_(vm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThrowCompletionOr<Value> delete_by_value_with_this(Bytecode::Interpreter& interpreter, Value base, Value property_key_value, Value this_value)
|
||||||
|
{
|
||||||
|
auto& vm = interpreter.vm();
|
||||||
|
|
||||||
|
auto property_key = TRY(property_key_value.to_property_key(vm));
|
||||||
|
bool strict = vm.in_strict_mode();
|
||||||
|
auto reference = Reference { base, property_key, this_value, strict };
|
||||||
|
|
||||||
|
return Value(TRY(reference.delete_(vm)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,5 +41,6 @@ ThrowCompletionOr<NonnullGCPtr<Array>> iterator_to_array(VM&, Value iterator);
|
||||||
ThrowCompletionOr<void> append(VM& vm, Value lhs, Value rhs, bool is_spread);
|
ThrowCompletionOr<void> append(VM& vm, Value lhs, Value rhs, bool is_spread);
|
||||||
ThrowCompletionOr<Value> delete_by_id(Bytecode::Interpreter&, Value base, IdentifierTableIndex identifier);
|
ThrowCompletionOr<Value> delete_by_id(Bytecode::Interpreter&, Value base, IdentifierTableIndex identifier);
|
||||||
ThrowCompletionOr<Value> delete_by_value(Bytecode::Interpreter&, Value base, Value property_key_value);
|
ThrowCompletionOr<Value> delete_by_value(Bytecode::Interpreter&, Value base, Value property_key_value);
|
||||||
|
ThrowCompletionOr<Value> delete_by_value_with_this(Bytecode::Interpreter&, Value base, Value property_key_value, Value this_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1117,16 +1117,12 @@ ThrowCompletionOr<void> DeleteByValue::execute_impl(Bytecode::Interpreter& inter
|
||||||
|
|
||||||
ThrowCompletionOr<void> DeleteByValueWithThis::execute_impl(Bytecode::Interpreter& interpreter) const
|
ThrowCompletionOr<void> DeleteByValueWithThis::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||||
{
|
{
|
||||||
auto& vm = interpreter.vm();
|
|
||||||
|
|
||||||
// NOTE: Get the property key from the accumulator before side effects have a chance to overwrite it.
|
// NOTE: Get the property key from the accumulator before side effects have a chance to overwrite it.
|
||||||
auto property_key_value = interpreter.accumulator();
|
auto property_key_value = interpreter.accumulator();
|
||||||
|
|
||||||
auto base_value = interpreter.reg(m_base);
|
auto base_value = interpreter.reg(m_base);
|
||||||
auto property_key = TRY(property_key_value.to_property_key(vm));
|
auto this_value = interpreter.reg(m_this_value);
|
||||||
bool strict = vm.in_strict_mode();
|
interpreter.accumulator() = TRY(delete_by_value_with_this(interpreter, base_value, property_key_value, this_value));
|
||||||
auto reference = Reference { base_value, property_key, interpreter.reg(m_this_value), strict };
|
|
||||||
interpreter.accumulator() = Value(TRY(reference.delete_(vm)));
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -850,6 +850,9 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Register base() const { return m_base; }
|
||||||
|
Register this_value() const { return m_this_value; }
|
||||||
|
|
||||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||||
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
|
||||||
|
|
||||||
|
|
|
@ -1366,6 +1366,21 @@ void Compiler::compile_delete_by_value(Bytecode::Op::DeleteByValue const& op)
|
||||||
check_exception();
|
check_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value cxx_delete_by_value_with_this(VM& vm, Value base_value, Value property_key_value, Value this_value)
|
||||||
|
{
|
||||||
|
return TRY_OR_SET_EXCEPTION(Bytecode::delete_by_value_with_this(vm.bytecode_interpreter(), base_value, property_key_value, this_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Compiler::compile_delete_by_value_with_this(Bytecode::Op::DeleteByValueWithThis const& op)
|
||||||
|
{
|
||||||
|
load_vm_register(ARG1, op.base());
|
||||||
|
load_vm_register(ARG2, Bytecode::Register::accumulator());
|
||||||
|
load_vm_register(ARG3, op.this_value());
|
||||||
|
native_call((void*)cxx_delete_by_value_with_this);
|
||||||
|
store_vm_register(Bytecode::Register::accumulator(), RET);
|
||||||
|
check_exception();
|
||||||
|
}
|
||||||
|
|
||||||
void Compiler::jump_to_exit()
|
void Compiler::jump_to_exit()
|
||||||
{
|
{
|
||||||
m_assembler.jump(m_exit_label);
|
m_assembler.jump(m_exit_label);
|
||||||
|
|
|
@ -116,7 +116,8 @@ private:
|
||||||
O(IteratorToArray, iterator_to_array) \
|
O(IteratorToArray, iterator_to_array) \
|
||||||
O(Append, append) \
|
O(Append, append) \
|
||||||
O(DeleteById, delete_by_id) \
|
O(DeleteById, delete_by_id) \
|
||||||
O(DeleteByValue, delete_by_value)
|
O(DeleteByValue, delete_by_value) \
|
||||||
|
O(DeleteByValueWithThis, delete_by_value_with_this)
|
||||||
|
|
||||||
# define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \
|
# define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \
|
||||||
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue