Skip to content

Commit

Permalink
LibJS/Bytecode: Don't clobber accumulator in Put/Delete instructions
Browse files Browse the repository at this point in the history
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. :^)
  • Loading branch information
awesomekling committed Jun 25, 2023
1 parent 8450948 commit 317f88a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Userland/Libraries/LibJS/Bytecode/Op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,9 @@ ThrowCompletionOr<void> 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<void> PutPrivateById::execute_impl(Bytecode::Interpreter& interpreter) const
Expand All @@ -561,7 +563,9 @@ ThrowCompletionOr<void> 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<void> DeleteById::execute_impl(Bytecode::Interpreter& interpreter) const
Expand Down Expand Up @@ -981,7 +985,9 @@ ThrowCompletionOr<void> 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<void> DeleteByValue::execute_impl(Bytecode::Interpreter& interpreter) const
Expand Down

0 comments on commit 317f88a

Please sign in to comment.