From 8465f397927bb10ea32c958cf4f82a8e15c02e24 Mon Sep 17 00:00:00 2001 From: machenbach Date: Thu, 5 Mar 2015 04:10:23 -0800 Subject: [PATCH] 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} --- include/v8.h | 42 ++++++++++++++++++----------------------- test/cctest/test-api.cc | 32 ++++++++++++++++--------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/include/v8.h b/include/v8.h index 44d756f15e..c90416c9bf 100644 --- a/include/v8.h +++ b/include/v8.h @@ -115,8 +115,7 @@ template class NonCopyablePersistentTraits; template class PersistentBase; template > class Persistent; -template -class Global; +template class UniquePersistent; template class PersistentValueMap; template class PersistentValueMapBase; @@ -657,8 +656,7 @@ template class PersistentBase { template friend class Handle; template friend class Local; template friend class Persistent; - template - friend class Global; + template friend class UniquePersistent; template friend class PersistentBase; template friend class ReturnValue; template @@ -814,45 +812,46 @@ template class Persistent : public PersistentBase { * * Note: Persistent class hierarchy is subject to future changes. */ -template -class Global : public PersistentBase { +template +class UniquePersistent : public PersistentBase { public: /** - * A Global with no storage cell. + * A UniquePersistent with no storage cell. */ - V8_INLINE Global() : PersistentBase(nullptr) {} + V8_INLINE UniquePersistent() : PersistentBase(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 * pointing to the same object, and no flags are set. */ template - V8_INLINE Global(Isolate* isolate, Handle that) + V8_INLINE UniquePersistent(Isolate* isolate, Handle that) : PersistentBase(PersistentBase::New(isolate, *that)) { 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 * pointing to the same object, and no flags are set. */ template - V8_INLINE Global(Isolate* isolate, const PersistentBase& that) - : PersistentBase(PersistentBase::New(isolate, that.val_)) { + V8_INLINE UniquePersistent(Isolate* isolate, const PersistentBase& that) + : PersistentBase(PersistentBase::New(isolate, that.val_)) { TYPE_CHECK(T, S); } /** * Move constructor. */ - V8_INLINE Global(Global&& other) : PersistentBase(other.val_) { + V8_INLINE UniquePersistent(UniquePersistent&& other) + : PersistentBase(other.val_) { other.val_ = nullptr; } - V8_INLINE ~Global() { this->Reset(); } + V8_INLINE ~UniquePersistent() { this->Reset(); } /** * Move via assignment. */ template - V8_INLINE Global& operator=(Global&& rhs) { + V8_INLINE UniquePersistent& operator=(UniquePersistent&& rhs) { TYPE_CHECK(T, S); if (this != &rhs) { this->Reset(); @@ -864,19 +863,14 @@ class Global : public PersistentBase { /** * Pass allows returning uniques from functions, etc. */ - Global Pass() { return static_cast(*this); } + UniquePersistent Pass() { return static_cast(*this); } private: - Global(Global&) = delete; - void operator=(Global&) = delete; + UniquePersistent(UniquePersistent&) = delete; + void operator=(UniquePersistent&) = delete; }; -// UniquePersistent is an alias for Global for historical reason. -template -using UniquePersistent = Global; - - /** * A stack-allocated class that governs a number of local handles. * After a handle scope has been created, all local handles will be diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 273d0090a6..44270382d4 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -2127,7 +2127,7 @@ THREADED_TEST(InternalFieldsAlignedPointers) { void* huge = reinterpret_cast(~static_cast(1)); CheckAlignedPointerInInternalField(obj, huge); - v8::Global persistent(isolate, obj); + v8::UniquePersistent persistent(isolate, obj); CHECK_EQ(1, Object::InternalFieldCount(persistent)); CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0)); } @@ -3038,20 +3038,20 @@ THREADED_TEST(ResettingGlobalHandleToEmpty) { template -static v8::Global PassUnique(v8::Global unique) { +static v8::UniquePersistent PassUnique(v8::UniquePersistent unique) { return unique.Pass(); } template -static v8::Global ReturnUnique(v8::Isolate* isolate, - const v8::Persistent& global) { - v8::Global unique(isolate, global); +static v8::UniquePersistent ReturnUnique(v8::Isolate* isolate, + const v8::Persistent& global) { + v8::UniquePersistent unique(isolate, global); return unique.Pass(); } -THREADED_TEST(Global) { +THREADED_TEST(UniquePersistent) { v8::Isolate* isolate = CcTest::isolate(); v8::Persistent global; { @@ -3062,11 +3062,11 @@ THREADED_TEST(Global) { reinterpret_cast(isolate)->global_handles(); int initial_handle_count = global_handles->global_handles_count(); { - v8::Global unique(isolate, global); + v8::UniquePersistent unique(isolate, global); CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); // Test assignment via Pass { - v8::Global copy = unique.Pass(); + v8::UniquePersistent copy = unique.Pass(); CHECK(unique.IsEmpty()); CHECK(copy == global); CHECK_EQ(initial_handle_count + 1, @@ -3075,7 +3075,7 @@ THREADED_TEST(Global) { } // Test ctor via Pass { - v8::Global copy(unique.Pass()); + v8::UniquePersistent copy(unique.Pass()); CHECK(unique.IsEmpty()); CHECK(copy == global); CHECK_EQ(initial_handle_count + 1, @@ -3084,7 +3084,7 @@ THREADED_TEST(Global) { } // Test pass through function call { - v8::Global copy = PassUnique(unique.Pass()); + v8::UniquePersistent copy = PassUnique(unique.Pass()); CHECK(unique.IsEmpty()); CHECK(copy == global); CHECK_EQ(initial_handle_count + 1, @@ -3095,7 +3095,7 @@ THREADED_TEST(Global) { } // Test pass from function call { - v8::Global unique = ReturnUnique(isolate, global); + v8::UniquePersistent unique = ReturnUnique(isolate, global); CHECK(unique == global); CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); } @@ -3129,7 +3129,8 @@ class WeakStdMapTraits : public v8::StdMapTraits { return data.GetParameter()->key; } static void DisposeCallbackData(WeakCallbackDataType* data) { delete data; } - static void Dispose(v8::Isolate* isolate, v8::Global value, K key) {} + static void Dispose(v8::Isolate* isolate, v8::UniquePersistent value, + K key) {} }; @@ -3155,7 +3156,7 @@ static void TestPersistentValueMap() { typename Map::PersistentValueReference ref = map.GetReference(7); CHECK(expected->Equals(ref.NewLocal(isolate))); } - v8::Global removed = map.Remove(7); + v8::UniquePersistent removed = map.Remove(7); CHECK_EQ(0, static_cast(map.Size())); CHECK(expected == removed); removed = map.Remove(7); @@ -3167,7 +3168,8 @@ static void TestPersistentValueMap() { { typename Map::PersistentValueReference ref; Local expected2 = v8::Object::New(isolate); - removed = map.Set(8, v8::Global(isolate, expected2), &ref); + removed = map.Set(8, v8::UniquePersistent(isolate, expected2), + &ref); CHECK_EQ(1, static_cast(map.Size())); CHECK(expected == removed); CHECK(expected2->Equals(ref.NewLocal(isolate))); @@ -3210,7 +3212,7 @@ TEST(PersistentValueVector) { Local obj1 = v8::Object::New(isolate); Local obj2 = v8::Object::New(isolate); - v8::Global obj3(isolate, v8::Object::New(isolate)); + v8::UniquePersistent obj3(isolate, v8::Object::New(isolate)); CHECK(vector.IsEmpty()); CHECK_EQ(0, static_cast(vector.Size()));