Commit 617e285c authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] [cleanup] Use default copy and move semantics

Just use the default operators instead of reimplementing them for
{Steal} and {Split}.

Drive-by: Remove unactionable TODO.

R=titzer@chromium.org

Bug: v8:6600
Change-Id: I7556cbf7264cf271b2e8966a5e96ca8e41eb3e73
Reviewed-on: https://chromium-review.googlesource.com/789862
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49640}
parent 9d906310
......@@ -242,19 +242,13 @@ void LiftoffAssembler::CacheState::InitMerge(const CacheState& source,
}
void LiftoffAssembler::CacheState::Steal(CacheState& source) {
stack_state.swap(source.stack_state);
used_registers = source.used_registers;
memcpy(register_use_count, source.register_use_count,
sizeof(register_use_count));
last_spilled_reg = source.last_spilled_reg;
// Just use the move assignment operator.
*this = std::move(source);
}
void LiftoffAssembler::CacheState::Split(const CacheState& source) {
stack_state = source.stack_state;
used_registers = source.used_registers;
memcpy(register_use_count, source.register_use_count,
sizeof(register_use_count));
last_spilled_reg = source.last_spilled_reg;
// Call the private copy assignment operator.
*this = source;
}
LiftoffAssembler::LiftoffAssembler(Isolate* isolate)
......
......@@ -127,9 +127,11 @@ class LiftoffAssembler : public TurboAssembler {
static_assert(IS_TRIVIALLY_COPYABLE(VarState),
"VarState should be trivially copyable");
// TODO(clemensh): Make this a proper class.
struct CacheState {
MOVE_ONLY_WITH_DEFAULT_CONSTRUCTORS(CacheState);
// Allow default construction, move construction, and move assignment.
CacheState() = default;
CacheState(CacheState&&) = default;
CacheState& operator=(CacheState&&) = default;
// TODO(clemensh): Improve memory management here; avoid std::vector.
std::vector<VarState> stack_state;
......@@ -208,6 +210,12 @@ class LiftoffAssembler : public TurboAssembler {
Register::from_code(base::bits::CountTrailingZeros(remaining_regs));
return last_spilled_reg;
}
private:
// Make the copy assignment operator private (to be used from {Split()}).
CacheState& operator=(const CacheState&) = default;
// Disallow copy construction.
CacheState(const CacheState&) = delete;
};
Register PopToRegister(ValueType, PinnedRegisterScope = {});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment