Revision: 14849
Author:   [email protected]
Date:     Tue May 28 04:54:52 2013
Log:      remove most V8_ALLOW_ACCESS_TO_* defines from test classes

[email protected]
BUG=

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

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

=======================================
--- /branches/bleeding_edge/include/v8.h        Tue May 28 03:36:21 2013
+++ /branches/bleeding_edge/include/v8.h        Tue May 28 04:54:52 2013
@@ -563,6 +563,7 @@

 #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
@@ -575,6 +576,22 @@
   template <class S> V8_INLINE(Persistent<S> As()) {
     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));

=======================================
--- /branches/bleeding_edge/test/cctest/cctest.cc       Mon May 13 07:18:43 2013
+++ /branches/bleeding_edge/test/cctest/cctest.cc       Tue May 28 04:54:52 2013
@@ -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 @@
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);
   }
-  context_->Enter();
+  {
+    v8::HandleScope scope(isolate);
+    v8::Local<v8::Context> context =
+        v8::Local<v8::Context>::New(isolate, context_);
+    context->Enter();
+  }
 }


=======================================
--- /branches/bleeding_edge/test/cctest/test-assembler-arm.cc Fri May 17 08:38:14 2013 +++ /branches/bleeding_edge/test/cctest/test-assembler-arm.cc Tue May 28 04:54:52 2013
@@ -25,10 +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.

-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"

 #include "disassembler.h"
=======================================
--- /branches/bleeding_edge/test/cctest/test-assembler-ia32.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-assembler-ia32.cc Tue May 28 04:54:52 2013
@@ -27,10 +27,6 @@

 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-assembler-x64.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-assembler-x64.cc Tue May 28 04:54:52 2013
@@ -27,10 +27,6 @@

 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-compiler.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-compiler.cc Tue May 28 04:54:52 2013
@@ -28,10 +28,6 @@
 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Tue May 28 01:00:16 2013 +++ /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Tue May 28 04:54:52 2013
@@ -27,10 +27,6 @@
 //
 // 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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Mon May 13 07:18:05 2013 +++ /branches/bleeding_edge/test/cctest/test-debug.cc Tue May 28 04:54:52 2013
@@ -29,10 +29,6 @@

 #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 @@
     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 @@
   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
=======================================
--- /branches/bleeding_edge/test/cctest/test-declarative-accessors.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-declarative-accessors.cc Tue May 28 04:54:52 2013
@@ -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 @@
       ->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);
 }
=======================================
--- /branches/bleeding_edge/test/cctest/test-decls.cc Wed May 8 00:45:16 2013 +++ /branches/bleeding_edge/test/cctest/test-decls.cc Tue May 28 04:54:52 2013
@@ -27,11 +27,6 @@

 #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 @@

   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 @@
                                                &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);
 }


=======================================
--- /branches/bleeding_edge/test/cctest/test-disasm-arm.cc Fri May 17 08:38:14 2013 +++ /branches/bleeding_edge/test/cctest/test-disasm-arm.cc Tue May 28 04:54:52 2013
@@ -28,10 +28,6 @@

 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-disasm-ia32.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-disasm-ia32.cc Tue May 28 04:54:52 2013
@@ -27,10 +27,6 @@

 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-func-name-inference.cc Tue May 28 04:54:52 2013
@@ -26,11 +26,6 @@
 // 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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-hashing.cc Wed May 8 00:45:16 2013 +++ /branches/bleeding_edge/test/cctest/test-hashing.cc Tue May 28 04:54:52 2013
@@ -27,9 +27,6 @@

 #include <stdlib.h>

-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"

 #include "factory.h"
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Tue May 28 01:00:16 2013 +++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Tue May 28 04:54:52 2013
@@ -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 @@
       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 @@
     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 @@
  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 @@

   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);
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Thu May 23 01:17:03 2013 +++ /branches/bleeding_edge/test/cctest/test-heap.cc Tue May 28 04:54:52 2013
@@ -27,10 +27,6 @@

 #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 @@
   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 @@
     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 @@
   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 @@
     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 @@
   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 @@
     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 @@
   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 @@
     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());
 }
=======================================
--- /branches/bleeding_edge/test/cctest/test-lockers.cc Tue May 28 03:36:21 2013 +++ /branches/bleeding_edge/test/cctest/test-lockers.cc Tue May 28 04:54:52 2013
@@ -27,9 +27,6 @@

 #include <limits.h>

-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-
 #include "v8.h"

 #include "api.h"
=======================================
--- /branches/bleeding_edge/test/cctest/test-log-stack-tracer.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-log-stack-tracer.cc Tue May 28 04:54:52 2013
@@ -29,10 +29,6 @@

 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-log.cc     Wed May  8 00:45:16 2013
+++ /branches/bleeding_edge/test/cctest/test-log.cc     Tue May 28 04:54:52 2013
@@ -34,11 +34,6 @@
 #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 @@
   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 @@
                   ObjMethod1);

   CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length()));
-
-  obj.Dispose(v8::Isolate::GetCurrent());
 }


@@ -458,9 +451,9 @@
   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 @@
                   Prop2Getter);
   CHECK_NE(NULL,
StrNStr(log.start(), prop2_getter_record.start(), log.length()));
-
-  obj.Dispose(v8::Isolate::GetCurrent());
 }


=======================================
--- /branches/bleeding_edge/test/cctest/test-mark-compact.cc Wed May 15 01:59:28 2013 +++ /branches/bleeding_edge/test/cctest/test-mark-compact.cc Tue May 28 04:54:52 2013
@@ -36,10 +36,6 @@
 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-parsing.cc Wed May 15 01:59:28 2013 +++ /branches/bleeding_edge/test/cctest/test-parsing.cc Tue May 28 04:54:52 2013
@@ -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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-profile-generator.cc Tue May 28 01:36:17 2013 +++ /branches/bleeding_edge/test/cctest/test-profile-generator.cc Tue May 28 04:54:52 2013
@@ -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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-random.cc Wed May 8 00:45:16 2013 +++ /branches/bleeding_edge/test/cctest/test-random.cc Tue May 28 04:54:52 2013
@@ -25,10 +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.

-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"

 #include "cctest.h"
=======================================
--- /branches/bleeding_edge/test/cctest/test-regexp.cc Wed May 8 00:45:16 2013 +++ /branches/bleeding_edge/test/cctest/test-regexp.cc Tue May 28 04:54:52 2013
@@ -28,10 +28,6 @@

 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-serialize.cc Wed May 8 00:45:16 2013 +++ /branches/bleeding_edge/test/cctest/test-serialize.cc Tue May 28 04:54:52 2013
@@ -29,10 +29,6 @@

 #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 @@
     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 @@

     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 @@
     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 @@
     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 @@
     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);
=======================================
--- /branches/bleeding_edge/test/cctest/test-strings.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-strings.cc Tue May 28 04:54:52 2013
@@ -32,10 +32,6 @@

 #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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-symbols.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-symbols.cc Tue May 28 04:54:52 2013
@@ -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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-thread-termination.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-thread-termination.cc Tue May 28 04:54:52 2013
@@ -25,10 +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.

-// 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"
=======================================
--- /branches/bleeding_edge/test/cctest/test-threads.cc Thu May 2 13:18:42 2013 +++ /branches/bleeding_edge/test/cctest/test-threads.cc Tue May 28 04:54:52 2013
@@ -25,10 +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.

-// TODO(dcarney): remove
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
-#define V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
-
 #include "v8.h"

 #include "platform.h"

--
--
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