Version 3.19.7
Added support for //# sourceURL similar to deprecated //@ sourceURL one. (issue 2702)
Made sure IfBuilder::Return clears the current block. (Chromium issue 243868)
Fixed two CPU profiler tests on ARM and MIPS simulators (issue 2628)
Fixed idle incremental GC for large objects. (Chromium issue 241815)
Disabled --optimize-constructed-arrays due to crashes (Chromium issue 244461)
Performance and stability improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@14900 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/include/v8.h b/include/v8.h
index 51040fe..3fef9cd 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -228,6 +228,7 @@
#define V8_USE_UNSAFE_HANDLES
+#define V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
/**
* An object reference managed by the v8 garbage collector.
@@ -370,11 +371,11 @@
#endif
private:
- template<class F>
- friend class Persistent;
- template<class F>
- friend class Local;
+ template<class F> friend class Persistent;
+ template<class F> friend class Local;
friend class Arguments;
+ template<class F> friend class FunctionCallbackInfo;
+ template<class F> friend class PropertyCallbackInfo;
friend class String;
friend class Object;
friend class AccessorInfo;
@@ -385,6 +386,7 @@
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
+ friend class HandleScope;
#ifndef V8_USE_UNSAFE_HANDLES
V8_INLINE(static Handle<T> New(Isolate* isolate, T* that));
@@ -458,17 +460,18 @@
#endif
private:
- template<class F>
- friend class Persistent;
- template<class F>
- friend class Handle;
+ template<class F> friend class Persistent;
+ template<class F> friend class Handle;
friend class Arguments;
+ template<class F> friend class FunctionCallbackInfo;
+ template<class F> friend class PropertyCallbackInfo;
friend class String;
friend class Object;
friend class AccessorInfo;
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
+ friend class HandleScope;
V8_INLINE(static Local<T> New(Isolate* isolate, T* that));
};
@@ -516,6 +519,10 @@
template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that))
: val_(*New(isolate, that)) { }
+ template <class S> V8_INLINE(Persistent(Isolate* isolate,
+ Persistent<S>& that)) // NOLINT
+ : val_(*New(isolate, that)) { }
+
#else
/**
* Creates an empty persistent handle that doesn't point to any
@@ -632,20 +639,8 @@
* 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));
-
- 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));
+ // TODO(dcarney): deprecate
+ V8_INLINE(void Dispose(Isolate* isolate)) { Dispose(); }
/**
* Make the reference to this object weak. When only weak handles
@@ -653,6 +648,34 @@
* 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(
+ P* parameters,
+ typename WeakReferenceCallbacks<S, P>::Revivable callback));
+
+ template<typename P>
+ V8_INLINE(void MakeWeak(
+ P* parameters,
+ typename WeakReferenceCallbacks<T, P>::Revivable callback));
+
+ // 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 +683,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 +692,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,49 +705,63 @@
* 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.
*/
V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other));
+#ifndef V8_USE_UNSAFE_HANDLES
+ V8_INLINE(void Reset(Isolate* isolate, const Persistent<T>& other));
+#endif
+
/**
* Returns the underlying raw pointer and clears the handle. The caller is
* responsible of eventually destroying the underlying object (by creating a
@@ -776,10 +811,8 @@
#endif
private:
- template<class F>
- friend class Handle;
- template<class F>
- friend class Local;
+ template<class F> friend class Handle;
+ template<class F> friend class Local;
friend class ImplementationUtilities;
friend class ObjectTemplate;
friend class Context;
@@ -1219,7 +1252,8 @@
/**
* Returns the name of the resource that contains the script for the
* function for this StackFrame or sourceURL value if the script name
- * is undefined and its source ends with //@ sourceURL=... string.
+ * is undefined and its source ends with //# sourceURL=... string or
+ * deprecated //@ sourceURL=... string.
*/
Local<String> GetScriptNameOrSourceURL() const;
@@ -4107,8 +4141,13 @@
class V8EXPORT PersistentHandleVisitor { // NOLINT
public:
virtual ~PersistentHandleVisitor() {}
+#ifdef V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS
virtual void VisitPersistentHandle(Persistent<Value> value,
uint16_t class_id) {}
+#else
+ virtual void VisitPersistentHandle(Persistent<Value>* value,
+ uint16_t class_id) {}
+#endif
};
@@ -4334,41 +4373,6 @@
static void RemoveCallCompletedCallback(CallCompletedCallback callback);
/**
- * Allows the host application to group objects together. If one
- * object in the group is alive, all objects in the group are alive.
- * After each garbage collection, object groups are removed. It is
- * intended to be used in the before-garbage-collection callback
- * function, for instance to simulate DOM tree connections among JS
- * wrapper objects. Object groups for all dependent handles need to
- * be provided for kGCTypeMarkSweepCompact collections, for all other
- * garbage collection types it is sufficient to provide object groups
- * for partially dependent handles only.
- * See v8-profiler.h for RetainedObjectInfo interface description.
- */
- // TODO(marja): deprecate AddObjectGroup. Use Isolate::SetObjectGroupId and
- // HeapProfiler::SetRetainedObjectInfo instead.
- static void AddObjectGroup(Persistent<Value>* objects,
- size_t length,
- RetainedObjectInfo* info = NULL);
- static void AddObjectGroup(Isolate* isolate,
- Persistent<Value>* objects,
- size_t length,
- RetainedObjectInfo* info = NULL);
-
- /**
- * Allows the host application to declare implicit references between
- * the objects: if |parent| is alive, all |children| are alive too.
- * After each garbage collection, all implicit references
- * are removed. It is intended to be used in the before-garbage-collection
- * callback function.
- */
- // TODO(marja): Deprecate AddImplicitReferences. Use
- // Isolate::SetReferenceFromGroup instead.
- static void AddImplicitReferences(Persistent<Object> parent,
- Persistent<Value>* children,
- size_t length);
-
- /**
* Initializes from snapshot if possible. Otherwise, attempts to
* initialize from scratch. This function is called implicitly if
* you use the API without calling it first.
@@ -4600,13 +4604,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 +5497,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 +5506,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 +5515,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;
}
@@ -5552,21 +5533,13 @@
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 +5549,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,59 +5559,38 @@
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());
-}
template <class T>
-void Persistent<T>::ClearWeak(Isolate* isolate) {
- V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate),
- reinterpret_cast<internal::Object**>(this->val_));
+void Persistent<T>::ClearWeak() {
+ V8::ClearWeak(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>
void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) {
@@ -5658,6 +5609,21 @@
}
+#ifndef V8_USE_UNSAFE_HANDLES
+template <class T>
+void Persistent<T>::Reset(Isolate* isolate, const Persistent<T>& other) {
+ Dispose(isolate);
+ if (other.IsEmpty()) {
+ this->val_ = NULL;
+ return;
+ }
+ internal::Object** p = reinterpret_cast<internal::Object**>(other.val_);
+ this->val_ = reinterpret_cast<T*>(
+ V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), p));
+}
+#endif
+
+
template <class T>
T* Persistent<T>::ClearAndLeak() {
T* old;
@@ -5673,25 +5639,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 {
+uint16_t Persistent<T>::WrapperClassId() 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);
@@ -5705,14 +5665,22 @@
template<typename S>
void ReturnValue<T>::Set(const Persistent<S>& handle) {
TYPE_CHECK(T, S);
- *value_ = *reinterpret_cast<internal::Object**>(*handle);
+ if (V8_UNLIKELY(handle.IsEmpty())) {
+ SetUndefined();
+ } else {
+ *value_ = *reinterpret_cast<internal::Object**>(*handle);
+ }
}
template<typename T>
template<typename S>
void ReturnValue<T>::Set(const Handle<S> handle) {
TYPE_CHECK(T, S);
- *value_ = *reinterpret_cast<internal::Object**>(*handle);
+ if (V8_UNLIKELY(handle.IsEmpty())) {
+ SetUndefined();
+ } else {
+ *value_ = *reinterpret_cast<internal::Object**>(*handle);
+ }
}
template<typename T>