Version 3.19.6

Fixed IfBuilder::Deopt to clear the current block (Chromium issue 243868).

Performance and stability improvements on all platforms.

git-svn-id: http://v8.googlecode.com/svn/trunk@14858 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/include/v8.h b/include/v8.h
index b5c780a..51040fe 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -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
@@ -576,6 +577,22 @@
     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));
 
   /**
@@ -2779,8 +2796,8 @@
  public:
   V8_INLINE(explicit ReturnValue(internal::Object** slot));
   // Handle setters
-  V8_INLINE(void Set(const Persistent<T>& handle));
-  V8_INLINE(void Set(const Handle<T> handle));
+  template <typename S> V8_INLINE(void Set(const Persistent<S>& handle));
+  template <typename S> V8_INLINE(void Set(const Handle<S> handle));
   // Fast primitive setters
   V8_INLINE(void Set(bool value));
   V8_INLINE(void Set(double i));
@@ -4929,6 +4946,7 @@
     explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context) {
       context_->Enter();
     }
+    // TODO(dcarney): deprecate
     V8_INLINE(Scope(Isolate* isolate, Persistent<Context>& context)) // NOLINT
 #ifndef V8_USE_UNSAFE_HANDLES
     : context_(Handle<Context>::New(isolate, context)) {
@@ -5684,12 +5702,16 @@
 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
 
 template<typename T>
-void ReturnValue<T>::Set(const Persistent<T>& handle) {
+template<typename S>
+void ReturnValue<T>::Set(const Persistent<S>& handle) {
+  TYPE_CHECK(T, S);
   *value_ = *reinterpret_cast<internal::Object**>(*handle);
 }
 
 template<typename T>
-void ReturnValue<T>::Set(const Handle<T> handle) {
+template<typename S>
+void ReturnValue<T>::Set(const Handle<S> handle) {
+  TYPE_CHECK(T, S);
   *value_ = *reinterpret_cast<internal::Object**>(*handle);
 }