remove most V8_ALLOW_ACCESS_TO_* defines from test classes
authordcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 28 May 2013 11:54:52 +0000 (11:54 +0000)
committerdcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 28 May 2013 11:54:52 +0000 (11:54 +0000)
R=svenpanne@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14849 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

29 files changed:
include/v8.h
test/cctest/cctest.cc
test/cctest/test-assembler-arm.cc
test/cctest/test-assembler-ia32.cc
test/cctest/test-assembler-x64.cc
test/cctest/test-compiler.cc
test/cctest/test-cpu-profiler.cc
test/cctest/test-debug.cc
test/cctest/test-declarative-accessors.cc
test/cctest/test-decls.cc
test/cctest/test-disasm-arm.cc
test/cctest/test-disasm-ia32.cc
test/cctest/test-func-name-inference.cc
test/cctest/test-hashing.cc
test/cctest/test-heap-profiler.cc
test/cctest/test-heap.cc
test/cctest/test-lockers.cc
test/cctest/test-log-stack-tracer.cc
test/cctest/test-log.cc
test/cctest/test-mark-compact.cc
test/cctest/test-parsing.cc
test/cctest/test-profile-generator.cc
test/cctest/test-random.cc
test/cctest/test-regexp.cc
test/cctest/test-serialize.cc
test/cctest/test-strings.cc
test/cctest/test-symbols.cc
test/cctest/test-thread-termination.cc
test/cctest/test-threads.cc

index 9f6190a4c9dc02a40574f42d3abfb6cd778e9d12..51040fe1a70f57d992f08d6107e8f0316de42955 100644 (file)
@@ -563,6 +563,7 @@ template <class T> class Persistent // NOLINT
 
 #endif
 
+#ifdef V8_USE_UNSAFE_HANDLES
   template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that)) {
 #ifdef V8_ENABLE_CHECKS
     // If we're going to perform the type check then we have to check
@@ -576,6 +577,22 @@ template <class T> class Persistent // NOLINT
     return Persistent<S>::Cast(*this);
   }
 
+#else
+  template <class S>
+  V8_INLINE(static Persistent<T>& Cast(Persistent<S>& that)) { // NOLINT
+#ifdef V8_ENABLE_CHECKS
+    // If we're going to perform the type check then we have to check
+    // that the handle isn't empty before doing the checked cast.
+    if (!that.IsEmpty()) T::Cast(*that);
+#endif
+    return reinterpret_cast<Persistent<T>&>(that);
+  }
+
+  template <class S> V8_INLINE(Persistent<S>& As()) { // NOLINT
+    return Persistent<S>::Cast(*this);
+  }
+#endif
+
   V8_DEPRECATED(static Persistent<T> New(Handle<T> that));
 
   /**
index 5507ac6f31a89cee76cd815f6c98cd59015052fa..b241f32a01ac000cccc9a32ded1e5bf83eccc2b0 100644 (file)
@@ -25,9 +25,6 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include <v8.h>
 #include "cctest.h"
 #include "debug.h"
@@ -70,14 +67,19 @@ void CcTest::InitializeVM(CcTestExtensionFlags extensions) {
   if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id;
   EXTENSION_LIST(CHECK_EXTENSION_FLAG)
 #undef CHECK_EXTENSION_FLAG
+  v8::Isolate* isolate = default_isolate();
   if (context_.IsEmpty()) {
-    v8::Isolate* isolate = default_isolate();
     v8::HandleScope scope(isolate);
     v8::ExtensionConfiguration config(extension_count, extension_names);
     v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
-    context_ = v8::Persistent<v8::Context>::New(isolate, context);
+    context_.Reset(isolate, context);
+  }
+  {
+    v8::HandleScope scope(isolate);
+    v8::Local<v8::Context> context =
+        v8::Local<v8::Context>::New(isolate, context_);
+    context->Enter();
   }
-  context_->Enter();
 }
 
 
index 9acb90ab22d96c6ad1350c38f23d1f616e11be73..61eaa98e3c68de8d390bd930cb1cc3023dc4a6e7 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "disassembler.h"
index 7c8e70cdbb128ca137ddcf871148b06ab7de93f8..8d39ee73fb3b472beddd8fadfaaad17277b69936 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "disassembler.h"
index a989fbbd4416d26115a5142b699072ea08e013ed..669475ad8aba17dd4b4f4dd1f8ffe2c6bab7f933 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "macro-assembler.h"
index cff0f82414546290061d212b3cd1cd567f31a835..f200435489c48b97686e3daf53e3a6becbf534a1 100644 (file)
 #include <stdlib.h>
 #include <wchar.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "compiler.h"
index 3eebf96a6153d8db42cc38587d86e69e77a6c033..2234e1188a148bd94480bbc5091929aa9a89313e 100644 (file)
 //
 // Tests of profiles generator and utilities.
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #define V8_DISABLE_DEPRECATIONS 1
 #include "v8.h"
 #include "cpu-profiler-inl.h"
index c4df73ebbd201ab90ea6a4e363457afd3ac2c753..d802a85aa69b079d28f440e0607cfa147cc68dd0 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "api.h"
@@ -6626,7 +6622,15 @@ TEST(ScriptCollectedEventContext) {
     v8::HandleScope scope(isolate);
     context.Reset(isolate, v8::Context::New(isolate));
   }
-  context->Enter();
+
+  // Enter context.  We can't have a handle to the context in the outer
+  // scope, so we have to do it the hard way.
+  {
+    v8::HandleScope scope(isolate);
+    v8::Local<v8::Context> local_context =
+        v8::Local<v8::Context>::New(isolate, context);
+    local_context->Enter();
+  }
 
   // Request the loaded scripts to initialize the debugger script cache.
   debug->GetLoadedScripts();
@@ -6639,7 +6643,13 @@ TEST(ScriptCollectedEventContext) {
   v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
   v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
 
-  context->Exit();
+  // Leave context
+  {
+    v8::HandleScope scope(isolate);
+    v8::Local<v8::Context> local_context =
+        v8::Local<v8::Context>::New(isolate, context);
+    local_context->Exit();
+  }
   context.Dispose(isolate);
 
   // Do garbage collection to collect the script above which is no longer
index b09a29d1e8a3c946f181b0fe52a111c6f2190c55..a14c7fae201f84538b182b8cf69197700d827cf7 100644 (file)
@@ -27,9 +27,6 @@
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "cctest.h"
@@ -298,7 +295,6 @@ TEST(HandleDereferenceRead) {
       ->NewHandleDereference(helper.isolate_);
   HandleArray* array = *helper.handle_array_;
   v8::Handle<v8::String> expected = v8_str("whatever");
-  array->handles_[index] = v8::Persistent<v8::Value>::New(helper.isolate_,
-                                                          expected);
+  array->handles_[index].Reset(helper.isolate_, expected);
   VerifyRead(descriptor, internal_field, array, expected);
 }
index 6be5303cde4643fd85b75b362d40f7905652f063..de45cbcdb884a0061e01bffe51ed93ee8a36fa71 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "heap.h"
@@ -57,8 +52,11 @@ class DeclarationContext {
 
   virtual ~DeclarationContext() {
     if (is_initialized_) {
-      context_->Exit();
-      context_.Dispose(context_->GetIsolate());
+      Isolate* isolate = Isolate::GetCurrent();
+      HandleScope scope(isolate);
+      Local<Context> context = Local<Context>::New(isolate, context_);
+      context->Exit();
+      context_.Dispose(isolate);
     }
   }
 
@@ -127,14 +125,14 @@ void DeclarationContext::InitializeIfNeeded() {
                                                &HandleQuery,
                                                0, 0,
                                                data);
-  context_.Reset(isolate,
-                 Context::New(isolate,
-                              0,
-                              function->InstanceTemplate(),
-                              Local<Value>()));
-  context_->Enter();
+  Local<Context> context = Context::New(isolate,
+                                        0,
+                                        function->InstanceTemplate(),
+                                        Local<Value>());
+  context_.Reset(isolate, context);
+  context->Enter();
   is_initialized_ = true;
-  PostInitializeContext(Local<Context>::New(isolate, context_));
+  PostInitializeContext(context);
 }
 
 
index 84f0d8630f15df48cd3244d42fc626a53fd6044e..85b472d30a31445bb148de8282510b62127b28d3 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "debug.h"
index f81b173e132b87ad1547857eb5249940d4f748f8..ca81a5a4f5afd51dd45e2f3286126232171bb35a 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "debug.h"
index 5ebc679c1285a944235e7cde1af51214b39a5466..a86dfd28a1aab6ae39c307cab87df1d403f04fa5 100644 (file)
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "api.h"
index 154761313935d7fce15d4decdcb64e3dbdef01a7..4906296ba2267a7503eba9079fe4a8522ae7aee3 100644 (file)
@@ -27,9 +27,6 @@
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "factory.h"
index 9b53879b2dc7037000bcea0be49c33b6294fc3e1..254cd1e490bbe28e5eac66bf0358edb23eb7d4c3 100644 (file)
@@ -29,9 +29,6 @@
 
 #include <ctype.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "cctest.h"
@@ -1137,14 +1134,11 @@ TEST(HeapSnapshotRetainedObjectInfo) {
       1, TestRetainedObjectInfo::WrapperInfoCallback);
   heap_profiler->SetWrapperClassInfoProvider(
       2, TestRetainedObjectInfo::WrapperInfoCallback);
-  v8::Persistent<v8::String> p_AAA =
-      v8::Persistent<v8::String>::New(isolate, v8_str("AAA"));
+  v8::Persistent<v8::String> p_AAA(isolate, v8_str("AAA"));
   p_AAA.SetWrapperClassId(isolate, 1);
-  v8::Persistent<v8::String> p_BBB =
-      v8::Persistent<v8::String>::New(isolate, v8_str("BBB"));
+  v8::Persistent<v8::String> p_BBB(isolate, v8_str("BBB"));
   p_BBB.SetWrapperClassId(isolate, 1);
-  v8::Persistent<v8::String> p_CCC =
-      v8::Persistent<v8::String>::New(isolate, v8_str("CCC"));
+  v8::Persistent<v8::String> p_CCC(isolate, v8_str("CCC"));
   p_CCC.SetWrapperClassId(isolate, 2);
   CHECK_EQ(0, TestRetainedObjectInfo::instances.length());
   const v8::HeapSnapshot* snapshot =
@@ -1196,8 +1190,7 @@ class GraphWithImplicitRefs {
     instance_ = this;
     isolate_ = (*env)->GetIsolate();
     for (int i = 0; i < kObjectsCount; i++) {
-      objects_[i] =
-          v8::Persistent<v8::Object>::New(isolate_, v8::Object::New());
+      objects_[i].Reset(isolate_, v8::Object::New());
     }
     (*env)->Global()->Set(v8_str("root_object"),
                           v8::Local<v8::Value>::New(isolate_, objects_[0]));
@@ -1213,15 +1206,15 @@ class GraphWithImplicitRefs {
  private:
   void AddImplicitReferences() {
     // 0 -> 1
-    isolate_->SetObjectGroupId(v8::Persistent<v8::Object>::Cast(objects_[0]),
+    isolate_->SetObjectGroupId(objects_[0],
                                v8::UniqueId(1));
     isolate_->SetReferenceFromGroup(
-        v8::UniqueId(1), v8::Persistent<v8::Object>::Cast(objects_[1]));
+        v8::UniqueId(1), objects_[1]);
     // Adding two more references: 1 -> 2, 1 -> 3
-    isolate_->SetReference(v8::Persistent<v8::Object>::Cast(objects_[1]),
-                           v8::Persistent<v8::Object>::Cast(objects_[2]));
-    isolate_->SetReference(v8::Persistent<v8::Object>::Cast(objects_[1]),
-                           v8::Persistent<v8::Object>::Cast(objects_[3]));
+    isolate_->SetReference(objects_[1].As<v8::Object>(),
+                           objects_[2]);
+    isolate_->SetReference(objects_[1].As<v8::Object>(),
+                           objects_[3]);
   }
 
   v8::Persistent<v8::Value> objects_[kObjectsCount];
@@ -1611,8 +1604,7 @@ TEST(WeakGlobalHandle) {
 
   CHECK(!HasWeakGlobalHandle());
 
-  v8::Persistent<v8::Object> handle =
-      v8::Persistent<v8::Object>::New(env->GetIsolate(), v8::Object::New());
+  v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New());
   handle.MakeWeak<v8::Value, void>(env->GetIsolate(),
                                    NULL,
                                    PersistentHandleCallback);
index 8967ff594c9ada9e8c739416efecfed54009583c..1122fa98cb2dd47a0d84b86912befc20aa63dfaf 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "compilation-cache.h"
@@ -1663,21 +1659,23 @@ TEST(LeakNativeContextViaMap) {
   i::FLAG_allow_natives_syntax = true;
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
   v8::HandleScope outer_scope(isolate);
-  v8::Persistent<v8::Context> ctx1;
-  v8::Persistent<v8::Context> ctx2;
+  v8::Persistent<v8::Context> ctx1p;
+  v8::Persistent<v8::Context> ctx2p;
   {
     v8::HandleScope scope(isolate);
-    ctx1.Reset(isolate, v8::Context::New(isolate));
-    ctx2.Reset(isolate, v8::Context::New(isolate));
+    ctx1p.Reset(isolate, v8::Context::New(isolate));
+    ctx2p.Reset(isolate, v8::Context::New(isolate));
+    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
   }
-  ctx1->Enter();
 
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
+    v8::HandleScope inner_scope(isolate);
     CompileRun("var v = {x: 42}");
+    v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
+    v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
     ctx2->Global()->Set(v8_str("o"), v);
@@ -1689,13 +1687,13 @@ TEST(LeakNativeContextViaMap) {
     CHECK_EQ(42, res->Int32Value());
     ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
     ctx2->Exit();
-    ctx1->Exit();
-    ctx1.Dispose(ctx1->GetIsolate());
+    v8::Local<v8::Context>::New(isolate, ctx1)->Exit();
+    ctx1p.Dispose(isolate);
     v8::V8::ContextDisposedNotification();
   }
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(2, NumberOfGlobalObjects());
-  ctx2.Dispose(ctx2->GetIsolate());
+  ctx2p.Dispose(isolate);
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(0, NumberOfGlobalObjects());
 }
@@ -1707,21 +1705,23 @@ TEST(LeakNativeContextViaFunction) {
   i::FLAG_allow_natives_syntax = true;
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
   v8::HandleScope outer_scope(isolate);
-  v8::Persistent<v8::Context> ctx1;
-  v8::Persistent<v8::Context> ctx2;
+  v8::Persistent<v8::Context> ctx1p;
+  v8::Persistent<v8::Context> ctx2p;
   {
     v8::HandleScope scope(isolate);
-    ctx1.Reset(isolate, v8::Context::New(isolate));
-    ctx2.Reset(isolate, v8::Context::New(isolate));
+    ctx1p.Reset(isolate, v8::Context::New(isolate));
+    ctx2p.Reset(isolate, v8::Context::New(isolate));
+    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
   }
-  ctx1->Enter();
 
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
+    v8::HandleScope inner_scope(isolate);
     CompileRun("var v = function() { return 42; }");
+    v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
+    v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
     ctx2->Global()->Set(v8_str("o"), v);
@@ -1734,12 +1734,12 @@ TEST(LeakNativeContextViaFunction) {
     ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
     ctx2->Exit();
     ctx1->Exit();
-    ctx1.Dispose(ctx1->GetIsolate());
+    ctx1p.Dispose(ctx1->GetIsolate());
     v8::V8::ContextDisposedNotification();
   }
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(2, NumberOfGlobalObjects());
-  ctx2.Dispose(ctx2->GetIsolate());
+  ctx2p.Dispose(isolate);
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(0, NumberOfGlobalObjects());
 }
@@ -1749,21 +1749,23 @@ TEST(LeakNativeContextViaMapKeyed) {
   i::FLAG_allow_natives_syntax = true;
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
   v8::HandleScope outer_scope(isolate);
-  v8::Persistent<v8::Context> ctx1;
-  v8::Persistent<v8::Context> ctx2;
+  v8::Persistent<v8::Context> ctx1p;
+  v8::Persistent<v8::Context> ctx2p;
   {
     v8::HandleScope scope(isolate);
-    ctx1.Reset(isolate, v8::Context::New(isolate));
-    ctx2.Reset(isolate, v8::Context::New(isolate));
+    ctx1p.Reset(isolate, v8::Context::New(isolate));
+    ctx2p.Reset(isolate, v8::Context::New(isolate));
+    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
   }
-  ctx1->Enter();
 
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
+    v8::HandleScope inner_scope(isolate);
     CompileRun("var v = [42, 43]");
+    v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
+    v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
     ctx2->Global()->Set(v8_str("o"), v);
@@ -1776,12 +1778,12 @@ TEST(LeakNativeContextViaMapKeyed) {
     ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
     ctx2->Exit();
     ctx1->Exit();
-    ctx1.Dispose(ctx1->GetIsolate());
+    ctx1p.Dispose(ctx1->GetIsolate());
     v8::V8::ContextDisposedNotification();
   }
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(2, NumberOfGlobalObjects());
-  ctx2.Dispose(ctx2->GetIsolate());
+  ctx2p.Dispose(isolate);
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(0, NumberOfGlobalObjects());
 }
@@ -1791,21 +1793,23 @@ TEST(LeakNativeContextViaMapProto) {
   i::FLAG_allow_natives_syntax = true;
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
   v8::HandleScope outer_scope(isolate);
-  v8::Persistent<v8::Context> ctx1;
-  v8::Persistent<v8::Context> ctx2;
+  v8::Persistent<v8::Context> ctx1p;
+  v8::Persistent<v8::Context> ctx2p;
   {
     v8::HandleScope scope(isolate);
-    ctx1.Reset(isolate, v8::Context::New(isolate));
-    ctx2.Reset(isolate, v8::Context::New(isolate));
+    ctx1p.Reset(isolate, v8::Context::New(isolate));
+    ctx2p.Reset(isolate, v8::Context::New(isolate));
+    v8::Local<v8::Context>::New(isolate, ctx1p)->Enter();
   }
-  ctx1->Enter();
 
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
+    v8::HandleScope inner_scope(isolate);
     CompileRun("var v = { y: 42}");
+    v8::Local<v8::Context> ctx1 = v8::Local<v8::Context>::New(isolate, ctx1p);
+    v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
     ctx2->Global()->Set(v8_str("o"), v);
@@ -1822,12 +1826,12 @@ TEST(LeakNativeContextViaMapProto) {
     ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
     ctx2->Exit();
     ctx1->Exit();
-    ctx1.Dispose(ctx1->GetIsolate());
+    ctx1p.Dispose(isolate);
     v8::V8::ContextDisposedNotification();
   }
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(2, NumberOfGlobalObjects());
-  ctx2.Dispose(ctx2->GetIsolate());
+  ctx2p.Dispose(isolate);
   HEAP->CollectAllAvailableGarbage();
   CHECK_EQ(0, NumberOfGlobalObjects());
 }
index fbff717cdedb8660cdc824c3ccc2713fccf4945b..9d245359529c1b872e25abd9a49bd53ea54edc30 100644 (file)
@@ -27,9 +27,6 @@
 
 #include <limits.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "api.h"
index 3c34ede8bf406b3c0df498b8a2bbca2e388a54e5..ca6c7aea47bd11f76bc3e10e4f16f7c7174a8453 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "api.h"
index 3288fc8a61bb51f4bb7cb850c1450d7d35c2539f..d2ef02d6b6a5ac3323983f0bd76b01120673fae4 100644 (file)
 #include <cmath>
 #endif  // __linux__
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 #include "log.h"
 #include "cpu-profiler.h"
@@ -405,9 +400,9 @@ TEST(LogCallbacks) {
   ScopedLoggerInitializer initialize_logger(false);
   Logger* logger = initialize_logger.logger();
 
-  v8::Persistent<v8::FunctionTemplate> obj =
-      v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
-                                                v8::FunctionTemplate::New());
+  v8::Local<v8::FunctionTemplate> obj =
+      v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
+                                           v8::FunctionTemplate::New());
   obj->SetClassName(v8_str("Obj"));
   v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
   v8::Local<v8::Signature> signature =
@@ -434,8 +429,6 @@ TEST(LogCallbacks) {
                   ObjMethod1);
 
   CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length()));
-
-  obj.Dispose(v8::Isolate::GetCurrent());
 }
 
 
@@ -458,9 +451,9 @@ TEST(LogAccessorCallbacks) {
   ScopedLoggerInitializer initialize_logger(false);
   Logger* logger = initialize_logger.logger();
 
-  v8::Persistent<v8::FunctionTemplate> obj =
-      v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
-                                                v8::FunctionTemplate::New());
+  v8::Local<v8::FunctionTemplate> obj =
+      v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
+                                           v8::FunctionTemplate::New());
   obj->SetClassName(v8_str("Obj"));
   v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
   inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
@@ -493,8 +486,6 @@ TEST(LogAccessorCallbacks) {
                   Prop2Getter);
   CHECK_NE(NULL,
            StrNStr(log.start(), prop2_getter_record.start(), log.length()));
-
-  obj.Dispose(v8::Isolate::GetCurrent());
 }
 
 
index dc21ac2e3c613127354c6029d8e0e0ed3db91838..4b8ba812b5750547a8ed248f6a0aac8920b197f0 100644 (file)
 #endif
 
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "global-handles.h"
index 170ec76a14e01998fe74d7834e45977c0dc29091..e81bf3271eb3c78b0403a18a0ae9c0729f979190 100644 (file)
@@ -29,9 +29,6 @@
 #include <stdio.h>
 #include <string.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 
 #include "cctest.h"
index b7c123a6c66b6dc1d1a4fddf95cab10eed56b5dd..70091d90325ec7d71a9a59b1858ef23ec4c7bf31 100644 (file)
@@ -27,9 +27,6 @@
 //
 // Tests of profiles generator and utilities.
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"
 #include "profile-generator-inl.h"
 #include "cctest.h"
index 0837ab3e360307febecf069582a8914da89e6b04..430355ca5a7dbd3e484899932273a9c873f9a079 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "cctest.h"
index f311dcc578c0df66a65c409c96772c210203951b..6bcf5f576325396fd286a0eafbbcf97fa131cd18 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "ast.h"
index 0cf80440f6dafe823dcbbfcb4bf2dadacb1c39a9..f87eb96e9db01c01e7127c71f38ddf18fa2f110e 100644 (file)
 
 #include "sys/stat.h"
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "debug.h"
@@ -373,16 +369,19 @@ TEST(PartialSerialization) {
     Serializer::Enable();
     v8::V8::Initialize();
     Isolate* isolate = Isolate::Current();
+    v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
     Heap* heap = isolate->heap();
 
     v8::Persistent<v8::Context> env;
     {
       HandleScope scope(isolate);
-      env.Reset(v8::Isolate::GetCurrent(),
-                v8::Context::New(v8::Isolate::GetCurrent()));
+      env.Reset(v8_isolate, v8::Context::New(v8_isolate));
     }
     ASSERT(!env.IsEmpty());
-    env->Enter();
+    {
+      v8::HandleScope handle_scope(v8_isolate);
+      v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
+    }
     // Make sure all builtin scripts are cached.
     { HandleScope scope(isolate);
       for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
@@ -394,7 +393,7 @@ TEST(PartialSerialization) {
 
     Object* raw_foo;
     {
-      v8::HandleScope handle_scope(env->GetIsolate());
+      v8::HandleScope handle_scope(v8_isolate);
       v8::Local<v8::String> foo = v8::String::New("foo");
       ASSERT(!foo.IsEmpty());
       raw_foo = *(v8::Utils::OpenHandle(*foo));
@@ -404,8 +403,11 @@ TEST(PartialSerialization) {
     Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
     OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
 
-    env->Exit();
-    env.Dispose(env->GetIsolate());
+    {
+      v8::HandleScope handle_scope(v8_isolate);
+      v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
+    }
+    env.Dispose(v8_isolate);
 
     FileByteSink startup_sink(startup_name.start());
     StartupSerializer startup_serializer(&startup_sink);
@@ -512,16 +514,19 @@ TEST(ContextSerialization) {
     Serializer::Enable();
     v8::V8::Initialize();
     Isolate* isolate = Isolate::Current();
+    v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
     Heap* heap = isolate->heap();
 
     v8::Persistent<v8::Context> env;
     {
       HandleScope scope(isolate);
-      env.Reset(v8::Isolate::GetCurrent(),
-                v8::Context::New(v8::Isolate::GetCurrent()));
+      env.Reset(v8_isolate, v8::Context::New(v8_isolate));
     }
     ASSERT(!env.IsEmpty());
-    env->Enter();
+    {
+      v8::HandleScope handle_scope(v8_isolate);
+      v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
+    }
     // Make sure all builtin scripts are cached.
     { HandleScope scope(isolate);
       for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
@@ -536,11 +541,14 @@ TEST(ContextSerialization) {
     Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
     OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
 
-    env->Exit();
+    {
+      v8::HandleScope handle_scope(v8_isolate);
+      v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
+    }
 
     Object* raw_context = *(v8::Utils::OpenHandle(*env));
 
-    env.Dispose(env->GetIsolate());
+    env.Dispose(v8_isolate);
 
     FileByteSink startup_sink(startup_name.start());
     StartupSerializer startup_serializer(&startup_sink);
index 77e8e1b9671403fcdde5dc815a41cab40424dd5d..2889172f5a625e9ccfea54cf72a113e4d2dc6633 100644 (file)
 
 #include <stdlib.h>
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "api.h"
index e1b3ea77ef83d5bb9adf6577a532c688192c79a4..6a8323bea4ace612ebd453d0569f942677b065cd 100644 (file)
@@ -5,10 +5,6 @@
 // of ConsStrings.  These operations may not be very fast, but they
 // should be possible without getting errors due to too deep recursion.
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "cctest.h"
index 4008663c3e0c095d824461518bf05f29e24a6522..524a56402945671373ec4bcf4252bfb38bb4d60b 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 #include "platform.h"
 #include "cctest.h"
index edec8bfbe4d38bb889bbe7f567d9a32f50762367..3b9c1ad80b11bb4c9267f8e5031160f282db04fe 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"
 
 #include "platform.h"