Commit 8465f397 authored by machenbach's avatar machenbach Committed by Commit bot

Revert of rename UniquePersistent to Global (patchset #2 id:20001 of...

Revert of rename UniquePersistent to Global (patchset #2 id:20001 of https://codereview.chromium.org/980173003/)

Reason for revert:
breaks arm compile

Original issue's description:
> rename UniquePersistent to Global
>
> BUG=
>
> Committed: https://crrev.com/3f5ae16c62b031ad572f750d81ffc71c5d6d1f9b
> Cr-Commit-Position: refs/heads/master@{#27011}

TBR=svenpanne@chromium.org,dcarney@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review URL: https://codereview.chromium.org/983653002

Cr-Commit-Position: refs/heads/master@{#27012}
parent 3f5ae16c
...@@ -115,8 +115,7 @@ template<class T> class NonCopyablePersistentTraits; ...@@ -115,8 +115,7 @@ template<class T> class NonCopyablePersistentTraits;
template<class T> class PersistentBase; template<class T> class PersistentBase;
template<class T, template<class T,
class M = NonCopyablePersistentTraits<T> > class Persistent; class M = NonCopyablePersistentTraits<T> > class Persistent;
template <class T> template<class T> class UniquePersistent;
class Global;
template<class K, class V, class T> class PersistentValueMap; template<class K, class V, class T> class PersistentValueMap;
template <class K, class V, class T> template <class K, class V, class T>
class PersistentValueMapBase; class PersistentValueMapBase;
...@@ -657,8 +656,7 @@ template <class T> class PersistentBase { ...@@ -657,8 +656,7 @@ template <class T> class PersistentBase {
template<class F> friend class Handle; template<class F> friend class Handle;
template<class F> friend class Local; template<class F> friend class Local;
template<class F1, class F2> friend class Persistent; template<class F1, class F2> friend class Persistent;
template <class F> template<class F> friend class UniquePersistent;
friend class Global;
template<class F> friend class PersistentBase; template<class F> friend class PersistentBase;
template<class F> friend class ReturnValue; template<class F> friend class ReturnValue;
template <class F1, class F2, class F3> template <class F1, class F2, class F3>
...@@ -814,45 +812,46 @@ template <class T, class M> class Persistent : public PersistentBase<T> { ...@@ -814,45 +812,46 @@ template <class T, class M> class Persistent : public PersistentBase<T> {
* *
* Note: Persistent class hierarchy is subject to future changes. * Note: Persistent class hierarchy is subject to future changes.
*/ */
template <class T> template<class T>
class Global : public PersistentBase<T> { class UniquePersistent : public PersistentBase<T> {
public: public:
/** /**
* A Global with no storage cell. * A UniquePersistent with no storage cell.
*/ */
V8_INLINE Global() : PersistentBase<T>(nullptr) {} V8_INLINE UniquePersistent() : PersistentBase<T>(nullptr) {}
/** /**
* Construct a Global from a Handle. * Construct a UniquePersistent from a Handle.
* When the Handle is non-empty, a new storage cell is created * When the Handle is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set. * pointing to the same object, and no flags are set.
*/ */
template <class S> template <class S>
V8_INLINE Global(Isolate* isolate, Handle<S> that) V8_INLINE UniquePersistent(Isolate* isolate, Handle<S> that)
: PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
/** /**
* Construct a Global from a PersistentBase. * Construct a UniquePersistent from a PersistentBase.
* When the Persistent is non-empty, a new storage cell is created * When the Persistent is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set. * pointing to the same object, and no flags are set.
*/ */
template <class S> template <class S>
V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that) V8_INLINE UniquePersistent(Isolate* isolate, const PersistentBase<S>& that)
: PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) { : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
/** /**
* Move constructor. * Move constructor.
*/ */
V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) { V8_INLINE UniquePersistent(UniquePersistent&& other)
: PersistentBase<T>(other.val_) {
other.val_ = nullptr; other.val_ = nullptr;
} }
V8_INLINE ~Global() { this->Reset(); } V8_INLINE ~UniquePersistent() { this->Reset(); }
/** /**
* Move via assignment. * Move via assignment.
*/ */
template <class S> template <class S>
V8_INLINE Global& operator=(Global<S>&& rhs) { V8_INLINE UniquePersistent& operator=(UniquePersistent<S>&& rhs) {
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
if (this != &rhs) { if (this != &rhs) {
this->Reset(); this->Reset();
...@@ -864,19 +863,14 @@ class Global : public PersistentBase<T> { ...@@ -864,19 +863,14 @@ class Global : public PersistentBase<T> {
/** /**
* Pass allows returning uniques from functions, etc. * Pass allows returning uniques from functions, etc.
*/ */
Global Pass() { return static_cast<Global&&>(*this); } UniquePersistent Pass() { return static_cast<UniquePersistent&&>(*this); }
private: private:
Global(Global&) = delete; UniquePersistent(UniquePersistent&) = delete;
void operator=(Global&) = delete; void operator=(UniquePersistent&) = delete;
}; };
// UniquePersistent is an alias for Global for historical reason.
template <class T>
using UniquePersistent = Global<T>;
/** /**
* A stack-allocated class that governs a number of local handles. * A stack-allocated class that governs a number of local handles.
* After a handle scope has been created, all local handles will be * After a handle scope has been created, all local handles will be
......
...@@ -2127,7 +2127,7 @@ THREADED_TEST(InternalFieldsAlignedPointers) { ...@@ -2127,7 +2127,7 @@ THREADED_TEST(InternalFieldsAlignedPointers) {
void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1)); void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1));
CheckAlignedPointerInInternalField(obj, huge); CheckAlignedPointerInInternalField(obj, huge);
v8::Global<v8::Object> persistent(isolate, obj); v8::UniquePersistent<v8::Object> persistent(isolate, obj);
CHECK_EQ(1, Object::InternalFieldCount(persistent)); CHECK_EQ(1, Object::InternalFieldCount(persistent));
CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0)); CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0));
} }
...@@ -3038,20 +3038,20 @@ THREADED_TEST(ResettingGlobalHandleToEmpty) { ...@@ -3038,20 +3038,20 @@ THREADED_TEST(ResettingGlobalHandleToEmpty) {
template <class T> template <class T>
static v8::Global<T> PassUnique(v8::Global<T> unique) { static v8::UniquePersistent<T> PassUnique(v8::UniquePersistent<T> unique) {
return unique.Pass(); return unique.Pass();
} }
template <class T> template <class T>
static v8::Global<T> ReturnUnique(v8::Isolate* isolate, static v8::UniquePersistent<T> ReturnUnique(v8::Isolate* isolate,
const v8::Persistent<T>& global) { const v8::Persistent<T>& global) {
v8::Global<String> unique(isolate, global); v8::UniquePersistent<String> unique(isolate, global);
return unique.Pass(); return unique.Pass();
} }
THREADED_TEST(Global) { THREADED_TEST(UniquePersistent) {
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();
v8::Persistent<String> global; v8::Persistent<String> global;
{ {
...@@ -3062,11 +3062,11 @@ THREADED_TEST(Global) { ...@@ -3062,11 +3062,11 @@ THREADED_TEST(Global) {
reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
int initial_handle_count = global_handles->global_handles_count(); int initial_handle_count = global_handles->global_handles_count();
{ {
v8::Global<String> unique(isolate, global); v8::UniquePersistent<String> unique(isolate, global);
CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count());
// Test assignment via Pass // Test assignment via Pass
{ {
v8::Global<String> copy = unique.Pass(); v8::UniquePersistent<String> copy = unique.Pass();
CHECK(unique.IsEmpty()); CHECK(unique.IsEmpty());
CHECK(copy == global); CHECK(copy == global);
CHECK_EQ(initial_handle_count + 1, CHECK_EQ(initial_handle_count + 1,
...@@ -3075,7 +3075,7 @@ THREADED_TEST(Global) { ...@@ -3075,7 +3075,7 @@ THREADED_TEST(Global) {
} }
// Test ctor via Pass // Test ctor via Pass
{ {
v8::Global<String> copy(unique.Pass()); v8::UniquePersistent<String> copy(unique.Pass());
CHECK(unique.IsEmpty()); CHECK(unique.IsEmpty());
CHECK(copy == global); CHECK(copy == global);
CHECK_EQ(initial_handle_count + 1, CHECK_EQ(initial_handle_count + 1,
...@@ -3084,7 +3084,7 @@ THREADED_TEST(Global) { ...@@ -3084,7 +3084,7 @@ THREADED_TEST(Global) {
} }
// Test pass through function call // Test pass through function call
{ {
v8::Global<String> copy = PassUnique(unique.Pass()); v8::UniquePersistent<String> copy = PassUnique(unique.Pass());
CHECK(unique.IsEmpty()); CHECK(unique.IsEmpty());
CHECK(copy == global); CHECK(copy == global);
CHECK_EQ(initial_handle_count + 1, CHECK_EQ(initial_handle_count + 1,
...@@ -3095,7 +3095,7 @@ THREADED_TEST(Global) { ...@@ -3095,7 +3095,7 @@ THREADED_TEST(Global) {
} }
// Test pass from function call // Test pass from function call
{ {
v8::Global<String> unique = ReturnUnique(isolate, global); v8::UniquePersistent<String> unique = ReturnUnique(isolate, global);
CHECK(unique == global); CHECK(unique == global);
CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count());
} }
...@@ -3129,7 +3129,8 @@ class WeakStdMapTraits : public v8::StdMapTraits<K, V> { ...@@ -3129,7 +3129,8 @@ class WeakStdMapTraits : public v8::StdMapTraits<K, V> {
return data.GetParameter()->key; return data.GetParameter()->key;
} }
static void DisposeCallbackData(WeakCallbackDataType* data) { delete data; } static void DisposeCallbackData(WeakCallbackDataType* data) { delete data; }
static void Dispose(v8::Isolate* isolate, v8::Global<V> value, K key) {} static void Dispose(v8::Isolate* isolate, v8::UniquePersistent<V> value,
K key) {}
}; };
...@@ -3155,7 +3156,7 @@ static void TestPersistentValueMap() { ...@@ -3155,7 +3156,7 @@ static void TestPersistentValueMap() {
typename Map::PersistentValueReference ref = map.GetReference(7); typename Map::PersistentValueReference ref = map.GetReference(7);
CHECK(expected->Equals(ref.NewLocal(isolate))); CHECK(expected->Equals(ref.NewLocal(isolate)));
} }
v8::Global<v8::Object> removed = map.Remove(7); v8::UniquePersistent<v8::Object> removed = map.Remove(7);
CHECK_EQ(0, static_cast<int>(map.Size())); CHECK_EQ(0, static_cast<int>(map.Size()));
CHECK(expected == removed); CHECK(expected == removed);
removed = map.Remove(7); removed = map.Remove(7);
...@@ -3167,7 +3168,8 @@ static void TestPersistentValueMap() { ...@@ -3167,7 +3168,8 @@ static void TestPersistentValueMap() {
{ {
typename Map::PersistentValueReference ref; typename Map::PersistentValueReference ref;
Local<v8::Object> expected2 = v8::Object::New(isolate); Local<v8::Object> expected2 = v8::Object::New(isolate);
removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref); removed = map.Set(8, v8::UniquePersistent<v8::Object>(isolate, expected2),
&ref);
CHECK_EQ(1, static_cast<int>(map.Size())); CHECK_EQ(1, static_cast<int>(map.Size()));
CHECK(expected == removed); CHECK(expected == removed);
CHECK(expected2->Equals(ref.NewLocal(isolate))); CHECK(expected2->Equals(ref.NewLocal(isolate)));
...@@ -3210,7 +3212,7 @@ TEST(PersistentValueVector) { ...@@ -3210,7 +3212,7 @@ TEST(PersistentValueVector) {
Local<v8::Object> obj1 = v8::Object::New(isolate); Local<v8::Object> obj1 = v8::Object::New(isolate);
Local<v8::Object> obj2 = v8::Object::New(isolate); Local<v8::Object> obj2 = v8::Object::New(isolate);
v8::Global<v8::Object> obj3(isolate, v8::Object::New(isolate)); v8::UniquePersistent<v8::Object> obj3(isolate, v8::Object::New(isolate));
CHECK(vector.IsEmpty()); CHECK(vector.IsEmpty());
CHECK_EQ(0, static_cast<int>(vector.Size())); CHECK_EQ(0, static_cast<int>(vector.Size()));
......
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