Revision: 14868
Author:   [email protected]
Date:     Wed May 29 01:32:45 2013
Log:      de-isolate remaining persistent calls

[email protected]
BUG=

Review URL: https://codereview.chromium.org/16153003
http://code.google.com/p/v8/source/detail?r=14868

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/global-handles.cc
 /branches/bleeding_edge/src/global-handles.h

=======================================
--- /branches/bleeding_edge/include/v8.h        Tue May 28 04:54:52 2013
+++ /branches/bleeding_edge/include/v8.h        Wed May 29 01:32:45 2013
@@ -632,27 +632,43 @@
    * This handle's reference, and any other references to the storage
    * cell remain and IsEmpty will still return false.
    */
-  // TODO(dcarney): remove before cutover
-  V8_INLINE(void Dispose(Isolate* isolate));
+  // TODO(dcarney): deprecate
+  V8_INLINE(void Dispose(Isolate* isolate)) { Dispose(); }

+  /**
+   * Make the reference to this object weak.  When only weak handles
+   * refer to the object, the garbage collector will perform a
+   * callback to the given V8::NearDeathCallback function, passing
+   * it the object reference and the given parameters.
+   */
   template<typename S, typename P>
   V8_INLINE(void MakeWeak(
-      Isolate* isolate,
       P* parameters,
       typename WeakReferenceCallbacks<S, P>::Revivable callback));

   template<typename P>
   V8_INLINE(void MakeWeak(
-      Isolate* isolate,
       P* parameters,
       typename WeakReferenceCallbacks<T, P>::Revivable callback));

-  /**
-   * Make the reference to this object weak.  When only weak handles
-   * refer to the object, the garbage collector will perform a
-   * callback to the given V8::NearDeathCallback function, passing
-   * it the object reference and the given parameters.
-   */
+  // TODO(dcarney): deprecate
+  template<typename S, typename P>
+  V8_INLINE(void MakeWeak(
+      Isolate* isolate,
+      P* parameters,
+      typename WeakReferenceCallbacks<S, P>::Revivable callback)) {
+    MakeWeak<S, P>(parameters, callback);
+  }
+
+  // TODO(dcarney): deprecate
+  template<typename P>
+  V8_INLINE(void MakeWeak(
+      Isolate* isolate,
+      P* parameters,
+      typename WeakReferenceCallbacks<T, P>::Revivable callback)) {
+    MakeWeak<P>(parameters, callback);
+  }
+
   // TODO(dcarney): remove before cutover
   V8_INLINE(void MakeWeak(Isolate* isolate,
                           void* parameters,
@@ -660,10 +676,8 @@

   V8_INLINE(void ClearWeak());

-  // TODO(dcarney): remove before cutover
-  V8_INLINE(void ClearWeak(Isolate* isolate));
-
-  V8_INLINE(void MarkIndependent());
+  // TODO(dcarney): deprecate
+  V8_INLINE(void ClearWeak(Isolate* isolate)) { ClearWeak(); }

   /**
* Marks the reference to this object independent. Garbage collector is free
@@ -671,10 +685,10 @@
* independent handle should not assume that it will be preceded by a global
    * GC prologue callback or followed by a global GC epilogue callback.
    */
-  // TODO(dcarney): remove before cutover
-  V8_INLINE(void MarkIndependent(Isolate* isolate));
+  V8_INLINE(void MarkIndependent());

-  V8_INLINE(void MarkPartiallyDependent());
+  // TODO(dcarney): deprecate
+  V8_INLINE(void MarkIndependent(Isolate* isolate)) { MarkIndependent(); }

   /**
* Marks the reference to this object partially dependent. Partially dependent
@@ -684,43 +698,53 @@
    * external dependencies. This mark is automatically cleared after each
    * garbage collection.
    */
-  // TODO(dcarney): remove before cutover
-  V8_INLINE(void MarkPartiallyDependent(Isolate* isolate));
+  V8_INLINE(void MarkPartiallyDependent());
+
+  // TODO(dcarney): deprecate
+  V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)) {
+    MarkPartiallyDependent();
+  }

   V8_INLINE(bool IsIndependent() const);

-  // TODO(dcarney): remove before cutover
-  V8_INLINE(bool IsIndependent(Isolate* isolate) const);
-
-  V8_INLINE(bool IsNearDeath() const);
+  // TODO(dcarney): deprecate
+  V8_INLINE(bool IsIndependent(Isolate* isolate) const) {
+    return IsIndependent();
+  }

   /** Checks if the handle holds the only reference to an object. */
-  // TODO(dcarney): remove before cutover
-  V8_INLINE(bool IsNearDeath(Isolate* isolate) const);
+  V8_INLINE(bool IsNearDeath() const);

-  V8_INLINE(bool IsWeak() const);
+  // TODO(dcarney): deprecate
+ V8_INLINE(bool IsNearDeath(Isolate* isolate) const) { return IsNearDeath(); }

   /** Returns true if the handle's reference is weak.  */
-  // TODO(dcarney): remove before cutover
-  V8_INLINE(bool IsWeak(Isolate* isolate) const);
+  V8_INLINE(bool IsWeak() const);

-  V8_INLINE(void SetWrapperClassId(uint16_t class_id));
+  // TODO(dcarney): deprecate
+  V8_INLINE(bool IsWeak(Isolate* isolate) const) { return IsWeak(); }

   /**
* Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
    * description in v8-profiler.h for details.
    */
-  // TODO(dcarney): remove before cutover
-  V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id));
+  V8_INLINE(void SetWrapperClassId(uint16_t class_id));

-  V8_INLINE(uint16_t WrapperClassId() const);
+  // TODO(dcarney): deprecate
+  V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id)) {
+    SetWrapperClassId(class_id);
+  }

   /**
* Returns the class ID previously assigned to this handle or 0 if no class ID
    * was previously assigned.
    */
-  // TODO(dcarney): remove before cutover
-  V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const);
+  V8_INLINE(uint16_t WrapperClassId() const);
+
+  // TODO(dcarney): deprecate
+  V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const) {
+    return WrapperClassId();
+  }

   /**
    * Disposes the current contents of the handle and replaces it.
@@ -4600,13 +4624,11 @@
                                                internal::Object** handle);
   static void DisposeGlobal(internal::Object** global_handle);
   typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback;
-  static void MakeWeak(internal::Isolate* isolate,
-                       internal::Object** global_handle,
+  static void MakeWeak(internal::Object** global_handle,
                        void* data,
                        RevivableCallback weak_reference_callback,
                        NearDeathCallback near_death_callback);
-  static void ClearWeak(internal::Isolate* isolate,
-                        internal::Object** global_handle);
+  static void ClearWeak(internal::Object** global_handle);

   template <class T> friend class Handle;
   template <class T> friend class Local;
@@ -5495,15 +5517,8 @@

 template <class T>
 bool Persistent<T>::IsIndependent() const {
-  return IsIndependent(Isolate::GetCurrent());
-}
-
-
-template <class T>
-bool Persistent<T>::IsIndependent(Isolate* isolate) const {
   typedef internal::Internals I;
   if (this->IsEmpty()) return false;
-  if (!I::IsInitialized(isolate)) return false;
   return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
                         I::kNodeIsIndependentShift);
 }
@@ -5511,15 +5526,8 @@

 template <class T>
 bool Persistent<T>::IsNearDeath() const {
-  return IsNearDeath(Isolate::GetCurrent());
-}
-
-
-template <class T>
-bool Persistent<T>::IsNearDeath(Isolate* isolate) const {
   typedef internal::Internals I;
   if (this->IsEmpty()) return false;
-  if (!I::IsInitialized(isolate)) return false;
return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
       I::kNodeStateIsNearDeathValue;
 }
@@ -5527,15 +5535,8 @@

 template <class T>
 bool Persistent<T>::IsWeak() const {
-  return IsWeak(Isolate::GetCurrent());
-}
-
-
-template <class T>
-bool Persistent<T>::IsWeak(Isolate* isolate) const {
   typedef internal::Internals I;
   if (this->IsEmpty()) return false;
-  if (!I::IsInitialized(isolate)) return false;
return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
       I::kNodeStateIsWeakValue;
 }
@@ -5549,24 +5550,16 @@
   val_ = 0;
 #endif
 }
-
-
-template <class T>
-void Persistent<T>::Dispose(Isolate* isolate) {
-  Dispose();
-}


 template <class T>
 template <typename S, typename P>
 void Persistent<T>::MakeWeak(
-    Isolate* isolate,
     P* parameters,
     typename WeakReferenceCallbacks<S, P>::Revivable callback) {
   TYPE_CHECK(S, T);
typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable;
-  V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
-               reinterpret_cast<internal::Object**>(this->val_),
+  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
                parameters,
                reinterpret_cast<Revivable>(callback),
                NULL);
@@ -5576,10 +5569,9 @@
 template <class T>
 template <typename P>
 void Persistent<T>::MakeWeak(
-    Isolate* isolate,
     P* parameters,
     typename WeakReferenceCallbacks<T, P>::Revivable callback) {
-  MakeWeak<T, P>(isolate, parameters, callback);
+  MakeWeak<T, P>(parameters, callback);
 }


@@ -5587,58 +5579,37 @@
 void Persistent<T>::MakeWeak(Isolate* isolate,
                              void* parameters,
                              NearDeathCallback callback) {
-  V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
-               reinterpret_cast<internal::Object**>(this->val_),
+  V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
                parameters,
                NULL,
                callback);
 }
+

 template <class T>
 void Persistent<T>::ClearWeak() {
-  ClearWeak(Isolate::GetCurrent());
+  V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_));
 }

-template <class T>
-void Persistent<T>::ClearWeak(Isolate* isolate) {
-  V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate),
-                reinterpret_cast<internal::Object**>(this->val_));
-}

 template <class T>
 void Persistent<T>::MarkIndependent() {
-  MarkIndependent(Isolate::GetCurrent());
-}
-
-template <class T>
-void Persistent<T>::MarkIndependent(Isolate* isolate) {
   typedef internal::Internals I;
   if (this->IsEmpty()) return;
-  if (!I::IsInitialized(isolate)) return;
   I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
                     true,
                     I::kNodeIsIndependentShift);
 }

-template <class T>
-void Persistent<T>::MarkPartiallyDependent() {
-  MarkPartiallyDependent(Isolate::GetCurrent());
-}

 template <class T>
-void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
+void Persistent<T>::MarkPartiallyDependent() {
   typedef internal::Internals I;
   if (this->IsEmpty()) return;
-  if (!I::IsInitialized(isolate)) return;
   I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
                     true,
                     I::kNodeIsPartiallyDependentShift);
 }
-
-template <class T>
-void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
-  SetWrapperClassId(Isolate::GetCurrent(), class_id);
-}


 template <class T>
@@ -5673,25 +5644,19 @@


 template <class T>
-void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) {
+void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
   typedef internal::Internals I;
   if (this->IsEmpty()) return;
-  if (!I::IsInitialized(isolate)) return;
internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
   uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
   *reinterpret_cast<uint16_t*>(addr) = class_id;
 }
+

 template <class T>
 uint16_t Persistent<T>::WrapperClassId() const {
-  return WrapperClassId(Isolate::GetCurrent());
-}
-
-template <class T>
-uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const {
   typedef internal::Internals I;
   if (this->IsEmpty()) return 0;
-  if (!I::IsInitialized(isolate)) return 0;
internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
   uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
   return *reinterpret_cast<uint16_t*>(addr);
=======================================
--- /branches/bleeding_edge/src/api.cc  Tue May 28 01:00:16 2013
+++ /branches/bleeding_edge/src/api.cc  Wed May 29 01:32:45 2013
@@ -625,23 +625,19 @@
 }


-void V8::MakeWeak(i::Isolate* isolate,
-                  i::Object** object,
+void V8::MakeWeak(i::Object** object,
                   void* parameters,
                   RevivableCallback weak_reference_callback,
                   NearDeathCallback near_death_callback) {
-  ASSERT(isolate == i::Isolate::Current());
-  LOG_API(isolate, "MakeWeak");
-  isolate->global_handles()->MakeWeak(object,
-                                      parameters,
-                                      weak_reference_callback,
-                                      near_death_callback);
+  i::GlobalHandles::MakeWeak(object,
+                             parameters,
+                             weak_reference_callback,
+                             near_death_callback);
 }


-void V8::ClearWeak(i::Isolate* isolate, i::Object** obj) {
-  LOG_API(isolate, "ClearWeak");
-  isolate->global_handles()->ClearWeakness(obj);
+void V8::ClearWeak(i::Object** obj) {
+  i::GlobalHandles::ClearWeakness(obj);
 }


=======================================
--- /branches/bleeding_edge/src/global-handles.cc       Thu May 23 01:19:27 2013
+++ /branches/bleeding_edge/src/global-handles.cc       Wed May 29 01:32:45 2013
@@ -199,9 +199,9 @@
     set_independent(true);
   }

-  void MarkPartiallyDependent(GlobalHandles* global_handles) {
+  void MarkPartiallyDependent() {
     ASSERT(state() != FREE);
-    if (global_handles->isolate()->heap()->InNewSpace(object_)) {
+    if (GetGlobalHandles()->isolate()->heap()->InNewSpace(object_)) {
       set_partially_dependent(true);
     }
   }
@@ -231,8 +231,7 @@
     parameter_or_next_free_.next_free = value;
   }

-  void MakeWeak(GlobalHandles* global_handles,
-                void* parameter,
+  void MakeWeak(void* parameter,
                 RevivableCallback weak_reference_callback,
                 NearDeathCallback near_death_callback) {
     ASSERT(state() != FREE);
@@ -248,7 +247,7 @@
     }
   }

-  void ClearWeakness(GlobalHandles* global_handles) {
+  void ClearWeakness() {
     ASSERT(state() != FREE);
     set_state(NORMAL);
     set_parameter(NULL);
@@ -296,6 +295,7 @@

  private:
   inline NodeBlock* FindBlock();
+  inline GlobalHandles* GetGlobalHandles();
   inline void IncreaseBlockUses();
   inline void DecreaseBlockUses();

@@ -400,6 +400,11 @@
 };


+GlobalHandles* GlobalHandles::Node::GetGlobalHandles() {
+  return FindBlock()->global_handles();
+}
+
+
 GlobalHandles::NodeBlock* GlobalHandles::Node::FindBlock() {
   intptr_t ptr = reinterpret_cast<intptr_t>(this);
   ptr = ptr - index_ * sizeof(Node);
@@ -507,15 +512,14 @@
                              RevivableCallback weak_reference_callback,
                              NearDeathCallback near_death_callback) {
ASSERT((weak_reference_callback == NULL) != (near_death_callback == NULL));
-  Node::FromLocation(location)->MakeWeak(this,
-                                         parameter,
+  Node::FromLocation(location)->MakeWeak(parameter,
                                          weak_reference_callback,
                                          near_death_callback);
 }


 void GlobalHandles::ClearWeakness(Object** location) {
-  Node::FromLocation(location)->ClearWeakness(this);
+  Node::FromLocation(location)->ClearWeakness();
 }


@@ -525,7 +529,7 @@


 void GlobalHandles::MarkPartiallyDependent(Object** location) {
-  Node::FromLocation(location)->MarkPartiallyDependent(this);
+  Node::FromLocation(location)->MarkPartiallyDependent();
 }


=======================================
--- /branches/bleeding_edge/src/global-handles.h        Thu May 23 01:19:27 2013
+++ /branches/bleeding_edge/src/global-handles.h        Wed May 29 01:32:45 2013
@@ -138,10 +138,10 @@
// function is invoked (for each handle) with the handle and corresponding // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The // reason is that Smi::FromInt(0) does not change during garage collection.
-  void MakeWeak(Object** location,
-                void* parameter,
-                RevivableCallback weak_reference_callback,
-                NearDeathCallback near_death_callback);
+  static void MakeWeak(Object** location,
+                       void* parameter,
+                       RevivableCallback weak_reference_callback,
+                       NearDeathCallback near_death_callback);

   void RecordStats(HeapStats* stats);

@@ -158,13 +158,13 @@
   }

   // Clear the weakness of a global handle.
-  void ClearWeakness(Object** location);
+  static void ClearWeakness(Object** location);

   // Clear the weakness of a global handle.
-  void MarkIndependent(Object** location);
+  static void MarkIndependent(Object** location);

   // Mark the reference to this object externaly unreachable.
-  void MarkPartiallyDependent(Object** location);
+  static void MarkPartiallyDependent(Object** location);

   static bool IsIndependent(Object** location);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to