From 317f88a3762a652e234342e1df1b8c43f538c7f5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 25 Jun 2023 18:54:04 +0200 Subject: [PATCH] LibJS/Bytecode: Don't clobber accumulator in Put/Delete instructions The fact that side effects clobbers the accumulator isn't just annoying inside the instruction handler, but also really counter-intuitive in the bytecode program itself. 17 new passes on test262. :^) --- Userland/Libraries/LibJS/Bytecode/Op.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 431846b2a57661..3a1197339791f4 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -550,7 +550,9 @@ ThrowCompletionOr PutById::execute_impl(Bytecode::Interpreter& interpreter auto value = interpreter.accumulator(); auto object = TRY(interpreter.reg(m_base).to_object(vm)); PropertyKey name = interpreter.current_executable().get_identifier(m_property); - return put_by_property_key(vm, object, value, name, m_kind); + TRY(put_by_property_key(vm, object, value, name, m_kind)); + interpreter.accumulator() = value; + return {}; } ThrowCompletionOr PutPrivateById::execute_impl(Bytecode::Interpreter& interpreter) const @@ -561,7 +563,9 @@ ThrowCompletionOr PutPrivateById::execute_impl(Bytecode::Interpreter& inte auto object = TRY(interpreter.reg(m_base).to_object(vm)); auto name = interpreter.current_executable().get_identifier(m_property); auto private_reference = make_private_reference(vm, object, name); - return private_reference.put_value(vm, value); + TRY(private_reference.put_value(vm, value)); + interpreter.accumulator() = value; + return {}; } ThrowCompletionOr DeleteById::execute_impl(Bytecode::Interpreter& interpreter) const @@ -981,7 +985,9 @@ ThrowCompletionOr PutByValue::execute_impl(Bytecode::Interpreter& interpre auto object = TRY(interpreter.reg(m_base).to_object(vm)); auto property_key = TRY(interpreter.reg(m_property).to_property_key(vm)); - return put_by_property_key(vm, object, value, property_key, m_kind); + TRY(put_by_property_key(vm, object, value, property_key, m_kind)); + interpreter.accumulator() = value; + return {}; } ThrowCompletionOr DeleteByValue::execute_impl(Bytecode::Interpreter& interpreter) const