[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>
Wed, 13 Jun 2012 07:56:37 +0000 (09:56 +0200)
commitccad1b6e4ca295861ff50b8e84560dd9769930d1
treefd180f05ac14f4f806711ce4f2316d899a1536d5
parentc010afb5a3c2948730ab9b35baa3deba1acb6531
[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: I8f1a1f2a2be052339e8507b98058b289c7f16b0a
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