Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion r12852 committed - Implement IsIndependent(Isolate*)...

Received: by 10.66.81.200 with SMTP id c8mr3578673pay.1.1352118979712;
        Mon, 05 Nov 2012 04:36:19 -0800 (PST)
X-BeenThere: v8-dev@googlegroups.com
Received: by 10.68.216.6 with SMTP id om6ls7584839pbc.7.gmail; Mon, 05 Nov
 2012 04:36:18 -0800 (PST)
Received: by 10.66.78.40 with SMTP id y8mr3571214paw.9.1352118978939;
        Mon, 05 Nov 2012 04:36:18 -0800 (PST)
Received: by 10.66.78.40 with SMTP id y8mr3571213paw.9.1352118978928;
        Mon, 05 Nov 2012 04:36:18 -0800 (PST)
Return-Path: <3wrKXUBAKBhEt5uv9zAv-458v62Fx55x2v.t53CP-uvCx55x2vx85B69....@codesite.bounces.google.com>
Received: from mail-pa0-f76.google.com (mail-pa0-f76.google.com [209.85.220.76])
        by gmr-mx.google.com with ESMTPS id uz6si3975673pbc.0.2012.11.05.04.36.18
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 05 Nov 2012 04:36:18 -0800 (PST)
Received-SPF: pass (google.com: domain of 3wrKXUBAKBhEt5uv9zAv-458v62Fx55x2v.t53CP-uvCx55x2vx85B69....@codesite.bounces.google.com designates 209.85.220.76 as permitted sender) client-ip=209.85.220.76;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of 3wrKXUBAKBhEt5uv9zAv-458v62Fx55x2v.t53CP-uvCx55x2vx85B69....@codesite.bounces.google.com designates 209.85.220.76 as permitted sender) smtp.mail=3wrKXUBAKBhEt5uv9zAv-458v62Fx55x2v.t53CP-uvCx55x2vx85B69....@codesite.bounces.google.com; dkim=pass header...@google.com
Received: by mail-pa0-f76.google.com with SMTP id fb10so587595pad.3
        for <v8-dev@googlegroups.com>; Mon, 05 Nov 2012 04:36:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=mime-version:x-generated-by:message-id:date:subject:from:to
         :content-type;
        bh=kWfoWursk/DoVFg4+sbGFNNCpJz/7e1ypPUhwmNMz2U=;
        b=hLuJyG5s5lfOLxl0M7bYcLKx4i+mpq7SEIEyIVEp5UEzgpa+ubUgf9iC50wWQU0LTJ
         zYZ5MEM/71ma8DXabBoF62msG8m3XQmKYD0yMIgHEtHEeH/DQKGcxb825tITLyundbUV
         eYKuU8HbxCTrlfkxU8K7g+OUCaTbf9PvYgCgzJL3Y+N790mt2fhiOI1702ENJv3GhM/V
         TqNK9bS+w1+nviAgjhWqBF6eBRprvUBg84WAHfQVA5pSeHA9BPquSZ1/ZcFKQ78vxXjM
         1xf8LeBHjKTv05sENMdnSKE4/cauXDWbXVMw72NjrCc5n60ssl3D5dsxiCK6mbAVLT0F
         xgQQ==
MIME-Version: 1.0
Received: by 10.66.86.102 with SMTP id o6mr3531065paz.41.1352118978855; Mon,
 05 Nov 2012 04:36:18 -0800 (PST)
X-Generated-By: Google Code
Message-ID: <f46d042ef6ad6dc4eb04cdbeb...@google.com>
Date: Mon, 05 Nov 2012 12:36:18 +0000
Subject: [v8] r12852 committed - Implement IsIndependent(Isolate*)...
From: codesite-nore...@google.com
To: v8-dev@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

Revision: 12852
Author:   mstarzin...@chromium.org
Date:     Mon Nov  5 04:35:51 2012
Log:      Implement IsIndependent(Isolate*)

BUG=
TEST=cctest/test-api/IndependentWeakHandle

Review URL: https://codereview.chromium.org/11368053
Patch from Kentaro Hara <hara...@chromium.org>.
http://code.google.com/p/v8/source/detail?r=12852

Modified:
  /branches/bleeding_edge/include/v8.h
  /branches/bleeding_edge/src/api.cc
  /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h	Mon Nov  5 02:25:32 2012
+++ /branches/bleeding_edge/include/v8.h	Mon Nov  5 04:35:51 2012
@@ -392,6 +392,7 @@
     * cell remain and IsEmpty will still return false.
     */
    inline void Dispose();
+  inline void Dispose(Isolate* isolate);

    /**
     * Make the reference to this object weak.  When only weak handles
@@ -3511,6 +3512,8 @@

    static internal::Object** GlobalizeReference(internal::Object** handle);
    static void DisposeGlobal(internal::Object** global_handle);
+  static void DisposeGlobal(internal::Isolate* isolate,
+                            internal::Object** global_handle);
    static void MakeWeak(internal::Object** global_handle,
                         void* data,
                         WeakReferenceCallback);
@@ -4277,6 +4280,14 @@
    if (this->IsEmpty()) return;
    V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this));
  }
+
+
+template <class T>
+void Persistent<T>::Dispose(Isolate* isolate) {
+  if (this->IsEmpty()) return;
+  V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate),
+                    reinterpret_cast<internal::Object**>(**this));
+}


  template <class T>
=======================================
--- /branches/bleeding_edge/src/api.cc	Mon Nov  5 02:25:32 2012
+++ /branches/bleeding_edge/src/api.cc	Mon Nov  5 04:35:51 2012
@@ -681,6 +681,14 @@
    if (!isolate->IsInitialized()) return;
    isolate->global_handles()->Destroy(obj);
  }
+
+
+void V8::DisposeGlobal(i::Isolate* isolate, i::Object** obj) {
+  ASSERT(isolate == i::Isolate::Current());
+  LOG_API(isolate, "DisposeGlobal");
+  if (!isolate->IsInitialized()) return;
+  isolate->global_handles()->Destroy(obj);
+}

  // --- H a n d l e s ---

=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc	Mon Nov  5 02:25:32 2012
+++ /branches/bleeding_edge/test/cctest/test-api.cc	Mon Nov  5 04:35:51 2012
@@ -2345,6 +2345,14 @@
    }
    CHECK_EQ(global->Length(), 3);
    global.Dispose();
+
+  {
+    v8::HandleScope scope;
+    Local<String> str = v8_str("str");
+    global = v8::Persistent<String>::New(str);
+  }
+  CHECK_EQ(global->Length(), 3);
+  global.Dispose(v8::Isolate::GetCurrent());
  }