Commit 8c1de9ce authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

api: Fixed TracedGlobal<T> move operators

Implement move ctor and assignment for both, the version that matches T
and the version where T and S are related in the type hierarchy.

Bug: chromium:995684
Change-Id: I21a747d706b224117c398e6feff42cc4ffc4cae8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1762296
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63325}
parent 5c4c5aa2
......@@ -841,7 +841,24 @@ class TracedGlobal {
/**
* Move constructor initializing TracedGlobal from an existing one.
*/
V8_INLINE TracedGlobal(TracedGlobal&& other);
V8_INLINE TracedGlobal(TracedGlobal&& other) {
// Forward to operator=.
*this = std::move(other);
}
/**
* Move constructor initializing TracedGlobal from an existing one.
*/
template <typename S>
V8_INLINE TracedGlobal(TracedGlobal<S>&& other) {
// Forward to operator=.
*this = std::move(other);
}
/**
* Move assignment operator initializing TracedGlobal from an existing one.
*/
V8_INLINE TracedGlobal& operator=(TracedGlobal&& rhs);
/**
* Move assignment operator initializing TracedGlobal from an existing one.
......@@ -10094,13 +10111,18 @@ void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
}
template <class T>
TracedGlobal<T>::TracedGlobal(TracedGlobal&& other) : val_(other.val_) {
if (other.val_ != nullptr) {
V8::MoveTracedGlobalReference(
reinterpret_cast<internal::Address**>(&other.val_),
reinterpret_cast<internal::Address**>(&this->val_));
other.val_ = nullptr;
TracedGlobal<T>& TracedGlobal<T>::operator=(TracedGlobal&& rhs) {
if (this != &rhs) {
this->Reset();
if (rhs.val_ != nullptr) {
this->val_ = rhs.val_;
V8::MoveTracedGlobalReference(
reinterpret_cast<internal::Address**>(&rhs.val_),
reinterpret_cast<internal::Address**>(&this->val_));
rhs.val_ = nullptr;
}
}
return *this;
}
template <class T>
......
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