Commit 829af6df authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][cleanup] Remove uses of DISALLOW_COPY_AND_ASSIGN

Replace by explicitly deleting the copy constructor and copy assignment
operator.

R=zhin@chromium.org

Bug: v8:11074
Change-Id: Ie36f75619243728e99dd6c7117a97f655d7c00f9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2523313Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71041}
parent 33da5683
......@@ -71,6 +71,8 @@ class StackTransferRecipe {
public:
explicit StackTransferRecipe(LiftoffAssembler* wasm_asm) : asm_(wasm_asm) {}
StackTransferRecipe(const StackTransferRecipe&) = delete;
StackTransferRecipe& operator=(const StackTransferRecipe&) = delete;
~StackTransferRecipe() { Execute(); }
void Execute() {
......@@ -343,8 +345,6 @@ class StackTransferRecipe {
}
load_dst_regs_ = {};
}
DISALLOW_COPY_AND_ASSIGN(StackTransferRecipe);
};
class RegisterReuseMap {
......
......@@ -1305,6 +1305,8 @@ void LiftoffAssembler::emit_i64_xori(LiftoffRegister dst, LiftoffRegister lhs,
class LiftoffStackSlots {
public:
explicit LiftoffStackSlots(LiftoffAssembler* wasm_asm) : asm_(wasm_asm) {}
LiftoffStackSlots(const LiftoffStackSlots&) = delete;
LiftoffStackSlots& operator=(const LiftoffStackSlots&) = delete;
void Add(const LiftoffAssembler::VarState& src, uint32_t src_offset,
RegPairHalf half) {
......@@ -1331,8 +1333,6 @@ class LiftoffStackSlots {
base::SmallVector<Slot, 8> slots_;
LiftoffAssembler* const asm_;
DISALLOW_COPY_AND_ASSIGN(LiftoffStackSlots);
};
} // namespace wasm
......
......@@ -32,6 +32,8 @@ struct WasmFunction;
class WasmInstructionBuffer final {
public:
WasmInstructionBuffer() = delete;
WasmInstructionBuffer(const WasmInstructionBuffer&) = delete;
WasmInstructionBuffer& operator=(const WasmInstructionBuffer&) = delete;
~WasmInstructionBuffer();
std::unique_ptr<AssemblerBuffer> CreateView();
std::unique_ptr<uint8_t[]> ReleaseBuffer();
......@@ -43,9 +45,6 @@ class WasmInstructionBuffer final {
// Override {operator delete} to avoid implicit instantiation of {operator
// delete} with {size_t} argument. The {size_t} argument would be incorrect.
void operator delete(void* ptr) { ::operator delete(ptr); }
private:
DISALLOW_COPY_AND_ASSIGN(WasmInstructionBuffer);
};
struct WasmCompilationResult {
......
......@@ -28,6 +28,8 @@ namespace wasm {
class V8_EXPORT_PRIVATE AsyncStreamingDecoder : public StreamingDecoder {
public:
explicit AsyncStreamingDecoder(std::unique_ptr<StreamingProcessor> processor);
AsyncStreamingDecoder(const AsyncStreamingDecoder&) = delete;
AsyncStreamingDecoder& operator=(const AsyncStreamingDecoder&) = delete;
// The buffer passed into OnBytesReceived is owned by the caller.
void OnBytesReceived(Vector<const uint8_t> bytes) override;
......@@ -218,8 +220,6 @@ class V8_EXPORT_PRIVATE AsyncStreamingDecoder : public StreamingDecoder {
// We need wire bytes in an array for deserializing cached modules.
std::vector<uint8_t> wire_bytes_for_deserializing_;
DISALLOW_COPY_AND_ASSIGN(AsyncStreamingDecoder);
};
void AsyncStreamingDecoder::OnBytesReceived(Vector<const uint8_t> bytes) {
......
......@@ -201,6 +201,8 @@ class V8_EXPORT_PRIVATE WasmCode final {
static bool ShouldBeLogged(Isolate* isolate);
void LogCode(Isolate* isolate) const;
WasmCode(const WasmCode&) = delete;
WasmCode& operator=(const WasmCode&) = delete;
~WasmCode();
void IncRef() {
......@@ -349,8 +351,6 @@ class V8_EXPORT_PRIVATE WasmCode final {
// from (3) and all (2)), the code object is deleted and the memory for the
// machine code is freed.
std::atomic<int> ref_count_{1};
DISALLOW_COPY_AND_ASSIGN(WasmCode);
};
// Check that {WasmCode} objects are sufficiently small. We create many of them,
......@@ -477,6 +477,10 @@ class V8_EXPORT_PRIVATE NativeModule final {
static constexpr bool kNeedsFarJumpsBetweenCodeSpaces = false;
#endif
NativeModule(const NativeModule&) = delete;
NativeModule& operator=(const NativeModule&) = delete;
~NativeModule();
// {AddCode} is thread safe w.r.t. other calls to {AddCode} or methods adding
// code below, i.e. it can be called concurrently from background threads.
// The returned code still needs to be published via {PublishCode}.
......@@ -613,8 +617,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
return import_wrapper_cache_.get();
}
~NativeModule();
const WasmFeatures& enabled_features() const { return enabled_features_; }
// Returns the runtime stub id that corresponds to the given address (which
......@@ -795,13 +797,13 @@ class V8_EXPORT_PRIVATE NativeModule final {
std::atomic<size_t> liftoff_bailout_count_{0};
std::atomic<size_t> liftoff_code_size_{0};
std::atomic<size_t> turbofan_code_size_{0};
DISALLOW_COPY_AND_ASSIGN(NativeModule);
};
class V8_EXPORT_PRIVATE WasmCodeManager final {
public:
explicit WasmCodeManager(size_t max_committed);
WasmCodeManager(const WasmCodeManager&) = delete;
WasmCodeManager& operator=(const WasmCodeManager&) = delete;
#ifdef DEBUG
~WasmCodeManager() {
......@@ -873,8 +875,6 @@ class V8_EXPORT_PRIVATE WasmCodeManager final {
// End of fields protected by {native_modules_mutex_}.
//////////////////////////////////////////////////////////////////////////////
DISALLOW_COPY_AND_ASSIGN(WasmCodeManager);
};
// Within the scope, the native_module is writable and not executable.
......@@ -902,6 +902,8 @@ class NativeModuleModificationScope final {
class V8_EXPORT_PRIVATE WasmCodeRefScope {
public:
WasmCodeRefScope();
WasmCodeRefScope(const WasmCodeRefScope&) = delete;
WasmCodeRefScope& operator=(const WasmCodeRefScope&) = delete;
~WasmCodeRefScope();
// Register a {WasmCode} reference in the current {WasmCodeRefScope}. Fails if
......@@ -911,8 +913,6 @@ class V8_EXPORT_PRIVATE WasmCodeRefScope {
private:
WasmCodeRefScope* const previous_scope_;
std::unordered_set<WasmCode*> code_ptrs_;
DISALLOW_COPY_AND_ASSIGN(WasmCodeRefScope);
};
// Similarly to a global handle, a {GlobalWasmCodeRef} stores a single
......@@ -925,6 +925,9 @@ class GlobalWasmCodeRef {
code_->IncRef();
}
GlobalWasmCodeRef(const GlobalWasmCodeRef&) = delete;
GlobalWasmCodeRef& operator=(const GlobalWasmCodeRef&) = delete;
~GlobalWasmCodeRef() { WasmCode::DecrementRefCount({&code_, 1}); }
// Get a pointer to the contained {WasmCode} object. This is only guaranteed
......@@ -935,7 +938,6 @@ class GlobalWasmCodeRef {
WasmCode* const code_;
// Also keep the {NativeModule} alive.
const std::shared_ptr<NativeModule> native_module_;
DISALLOW_COPY_AND_ASSIGN(GlobalWasmCodeRef);
};
const char* GetRuntimeStubName(WasmCode::RuntimeStubId);
......
......@@ -248,6 +248,9 @@ class DebugInfoImpl {
explicit DebugInfoImpl(NativeModule* native_module)
: native_module_(native_module) {}
DebugInfoImpl(const DebugInfoImpl&) = delete;
DebugInfoImpl& operator=(const DebugInfoImpl&) = delete;
int GetNumLocals(Address pc) {
FrameInspectionScope scope(this, pc);
if (!scope.is_inspectable()) return 0;
......@@ -830,8 +833,6 @@ class DebugInfoImpl {
// Isolate-specific data.
std::unordered_map<Isolate*, PerIsolateDebugData> per_isolate_data_;
DISALLOW_COPY_AND_ASSIGN(DebugInfoImpl);
};
DebugInfo::DebugInfo(NativeModule* native_module)
......
......@@ -137,6 +137,8 @@ class NativeModuleCache {
class V8_EXPORT_PRIVATE WasmEngine {
public:
WasmEngine();
WasmEngine(const WasmEngine&) = delete;
WasmEngine& operator=(const WasmEngine&) = delete;
~WasmEngine();
// Synchronously validates the given bytes that represent an encoded Wasm
......@@ -413,8 +415,6 @@ class V8_EXPORT_PRIVATE WasmEngine {
// End of fields protected by {mutex_}.
//////////////////////////////////////////////////////////////////////////////
DISALLOW_COPY_AND_ASSIGN(WasmEngine);
};
} // namespace wasm
......
......@@ -236,6 +236,8 @@ class V8_EXPORT_PRIVATE WasmFunctionBuilder : public ZoneObject {
class V8_EXPORT_PRIVATE WasmModuleBuilder : public ZoneObject {
public:
explicit WasmModuleBuilder(Zone* zone);
WasmModuleBuilder(const WasmModuleBuilder&) = delete;
WasmModuleBuilder& operator=(const WasmModuleBuilder&) = delete;
// Building methods.
uint32_t AddImport(Vector<const char> name, FunctionSig* sig,
......@@ -361,8 +363,6 @@ class V8_EXPORT_PRIVATE WasmModuleBuilder : public ZoneObject {
// Indirect functions must be allocated before adding extra tables.
bool allocating_indirect_functions_allowed_ = true;
#endif
DISALLOW_COPY_AND_ASSIGN(WasmModuleBuilder);
};
inline FunctionSig* WasmFunctionBuilder::signature() {
......
......@@ -354,9 +354,8 @@ struct V8_EXPORT_PRIVATE WasmModule {
std::unique_ptr<AsmJsOffsetInformation> asm_js_offset_information;
explicit WasmModule(std::unique_ptr<Zone> signature_zone = nullptr);
private:
DISALLOW_COPY_AND_ASSIGN(WasmModule);
WasmModule(const WasmModule&) = delete;
WasmModule& operator=(const WasmModule&) = delete;
};
// Static representation of a wasm indirect call table.
......
......@@ -63,6 +63,8 @@ template <typename T>
class Result {
public:
Result() = default;
Result(const Result&) = delete;
Result& operator=(const Result&) = delete;
template <typename S>
explicit Result(S&& value) : value_(std::forward<S>(value)) {}
......@@ -104,8 +106,6 @@ class Result {
T value_ = T{};
WasmError error_;
DISALLOW_COPY_AND_ASSIGN(Result);
};
// A helper for generating error messages that bubble up to JS exceptions.
......@@ -113,8 +113,10 @@ class V8_EXPORT_PRIVATE ErrorThrower {
public:
ErrorThrower(Isolate* isolate, const char* context)
: isolate_(isolate), context_(context) {}
// Explicitly allow move-construction. Disallow copy (below).
// Explicitly allow move-construction. Disallow copy.
ErrorThrower(ErrorThrower&& other) V8_NOEXCEPT;
ErrorThrower(const ErrorThrower&) = delete;
ErrorThrower& operator=(const ErrorThrower&) = delete;
~ErrorThrower();
PRINTF_FORMAT(2, 3) void TypeError(const char* fmt, ...);
......@@ -165,7 +167,6 @@ class V8_EXPORT_PRIVATE ErrorThrower {
// ErrorThrower should always be stack-allocated, since it constitutes a scope
// (things happen in the destructor).
DISALLOW_NEW_AND_DELETE()
DISALLOW_COPY_AND_ASSIGN(ErrorThrower);
};
// Like an ErrorThrower, but turns all pending exceptions into scheduled
......
......@@ -208,6 +208,9 @@ constexpr size_t kCodeHeaderSize = sizeof(bool) + // whether code is present
// a tag from the Address of an external reference and vice versa.
class ExternalReferenceList {
public:
ExternalReferenceList(const ExternalReferenceList&) = delete;
ExternalReferenceList& operator=(const ExternalReferenceList&) = delete;
uint32_t tag_from_address(Address ext_ref_address) const {
auto tag_addr_less_than = [this](uint32_t tag, Address searched_addr) {
return external_reference_by_tag_[tag] < searched_addr;
......@@ -263,7 +266,6 @@ class ExternalReferenceList {
#undef RUNTIME_ADDR
};
uint32_t tags_ordered_by_address_[kNumExternalReferences];
DISALLOW_COPY_AND_ASSIGN(ExternalReferenceList);
};
static_assert(std::is_trivially_destructible<ExternalReferenceList>::value,
......@@ -273,8 +275,9 @@ static_assert(std::is_trivially_destructible<ExternalReferenceList>::value,
class V8_EXPORT_PRIVATE NativeModuleSerializer {
public:
NativeModuleSerializer() = delete;
NativeModuleSerializer(const NativeModule*, Vector<WasmCode* const>);
NativeModuleSerializer(const NativeModuleSerializer&) = delete;
NativeModuleSerializer& operator=(const NativeModuleSerializer&) = delete;
size_t Measure() const;
bool Write(Writer* writer);
......@@ -287,8 +290,6 @@ class V8_EXPORT_PRIVATE NativeModuleSerializer {
const NativeModule* const native_module_;
Vector<WasmCode* const> code_table_;
bool write_called_;
DISALLOW_COPY_AND_ASSIGN(NativeModuleSerializer);
};
NativeModuleSerializer::NativeModuleSerializer(
......@@ -468,8 +469,9 @@ bool WasmSerializer::SerializeNativeModule(Vector<byte> buffer) const {
class V8_EXPORT_PRIVATE NativeModuleDeserializer {
public:
NativeModuleDeserializer() = delete;
explicit NativeModuleDeserializer(NativeModule*);
NativeModuleDeserializer(const NativeModuleDeserializer&) = delete;
NativeModuleDeserializer& operator=(const NativeModuleDeserializer&) = delete;
bool Read(Reader* reader);
......@@ -479,8 +481,6 @@ class V8_EXPORT_PRIVATE NativeModuleDeserializer {
NativeModule* const native_module_;
bool read_called_;
DISALLOW_COPY_AND_ASSIGN(NativeModuleDeserializer);
};
NativeModuleDeserializer::NativeModuleDeserializer(NativeModule* native_module)
......
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