[V8] Generalize external object resources
authorAaron Kennedy <aaron.kennedy@nokia.com>
Tue, 4 Oct 2011 06:06:09 +0000 (16:06 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 26 Apr 2012 06:56:14 +0000 (08:56 +0200)
commitbe6cf8d816419603ee993109f7903ebb002653af
tree7907fc1b75d17836349a16c01e0f9e393dbc5a4a
parent281fbf4fe599f7e864e4ac0c1fda1b82292849cd
[V8] Generalize external object resources

V8 was already able to manage and finalize an external string
resource.  This change generalizes that mechanism to handle a
single generic external resource - a v8::Object::ExternalResource
derived instance - on normal JSObject's.

This is useful for mapping C++ objects to JS objects where the
C++ object's memory is effectively owned by the JS Object, and
thus needs to destroyed when the JS Object is garbage collected.
The V8 mailing list suggests using a weak persistent handle for
this purpose, but that seems to incur a fairly massive performance
penalty for short lived objects as weak persistent handle callbacks
are not called until the object has been promoted into the old
object space.

Change-Id: I83677c9d906742a2bf0596961491eecb7ee60003
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
src/3rdparty/v8/include/v8.h
src/3rdparty/v8/src/api.cc
src/3rdparty/v8/src/factory.cc
src/3rdparty/v8/src/heap-inl.h
src/3rdparty/v8/src/heap.cc
src/3rdparty/v8/src/heap.h
src/3rdparty/v8/src/mark-compact.cc
src/3rdparty/v8/src/objects-inl.h
src/3rdparty/v8/src/objects.h