Make unsafe Unique<T> constructor private.
authormstarzinger <mstarzinger@chromium.org>
Mon, 31 Aug 2015 10:44:05 +0000 (03:44 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 31 Aug 2015 10:44:21 +0000 (10:44 +0000)
The constructor taking an artificial raw address was only used as a
workaround in TurboFan. It should only be accessible by constructor
functions internal to Unique<T>.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30464}

src/unique.h

index 68fb869..68a4596 100644 (file)
@@ -32,7 +32,7 @@ class UniqueSet;
 // Careful! Comparison of two Uniques is only correct if both were created
 // in the same "era" of GC or if at least one is a non-movable object.
 template <typename T>
-class Unique {
+class Unique final {
  public:
   Unique<T>() : raw_address_(NULL) {}
 
@@ -54,10 +54,6 @@ class Unique {
     handle_ = handle;
   }
 
-  // TODO(titzer): this is a hack to migrate to Unique<T> incrementally.
-  Unique(Address raw_address, Handle<T> handle)
-    : raw_address_(raw_address), handle_(handle) { }
-
   // Constructor for handling automatic up casting.
   // Eg. Unique<JSFunction> can be passed when Unique<Object> is expected.
   template <class S> Unique(Unique<S> uniq) {
@@ -129,15 +125,16 @@ class Unique {
     return Unique<T>(reinterpret_cast<Address>(*handle), handle);
   }
 
-  friend class UniqueSet<T>;  // Uses internal details for speed.
-  template <class U>
-  friend class Unique;  // For comparing raw_address values.
+ private:
+  Unique(Address raw_address, Handle<T> handle)
+      : raw_address_(raw_address), handle_(handle) {}
 
- protected:
   Address raw_address_;
   Handle<T> handle_;
 
-  friend class SideEffectsTracker;
+  friend class UniqueSet<T>;  // Uses internal details for speed.
+  template <class U>
+  friend class Unique;  // For comparing raw_address values.
 };
 
 template <typename T>