From 617e285cd43071aaeac0c4b99e24b99fad1f57c2 Mon Sep 17 00:00:00 2001 From: Clemens Hammacher Date: Mon, 27 Nov 2017 16:31:31 +0100 Subject: [PATCH] [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 Reviewed-by: Ben Titzer Cr-Commit-Position: refs/heads/master@{#49640} --- src/wasm/baseline/liftoff-assembler.cc | 14 ++++---------- src/wasm/baseline/liftoff-assembler.h | 12 ++++++++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/wasm/baseline/liftoff-assembler.cc b/src/wasm/baseline/liftoff-assembler.cc index 915e127572..80f0775b32 100644 --- a/src/wasm/baseline/liftoff-assembler.cc +++ b/src/wasm/baseline/liftoff-assembler.cc @@ -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) diff --git a/src/wasm/baseline/liftoff-assembler.h b/src/wasm/baseline/liftoff-assembler.h index 20c8433acf..8099fe7353 100644 --- a/src/wasm/baseline/liftoff-assembler.h +++ b/src/wasm/baseline/liftoff-assembler.h @@ -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 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 = {});