[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: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49640}
This commit is contained in:
Clemens Hammacher 2017-11-27 16:31:31 +01:00 committed by Commit Bot
parent 9d906310e1
commit 617e285cd4
2 changed files with 14 additions and 12 deletions

View File

@ -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)

View File

@ -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 = {});