Skip to content

Commit

Permalink
Avoid copying interp-values in EvalCreateTuple
Browse files Browse the repository at this point in the history
This could cause significant memory use.

Fixes: #1897
PiperOrigin-RevId: 721862074
  • Loading branch information
allight authored and copybara-github committed Jan 31, 2025
1 parent bcdfc12 commit 432f5e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xls/dslx/bytecode/bytecode_interpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,12 @@ absl::Status BytecodeInterpreter::EvalCreateTuple(const Bytecode& bytecode) {
elements.reserve(tuple_size.value());
for (int64_t i = 0; i < tuple_size.value(); i++) {
XLS_ASSIGN_OR_RETURN(InterpValue value, Pop());
elements.push_back(value);
elements.push_back(std::move(value));
}

std::reverse(elements.begin(), elements.end());

stack_.Push(InterpValue::MakeTuple(elements));
stack_.Push(InterpValue::MakeTuple(std::move(elements)));
return absl::OkStatus();
}

Expand Down

0 comments on commit 432f5e6

Please sign in to comment.