summaryrefslogtreecommitdiff
path: root/src/3rdparty/v8/src/heap.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-10-04 16:06:09 +1000
committerSimon Hausmann <simon.hausmann@nokia.com>2012-01-05 12:18:10 +0100
commite5ba7458fc5418e688de9cf294f5eb96cd6c4510 (patch)
treee6d46bb9991bfef3202e3c704547758707674a6b /src/3rdparty/v8/src/heap.h
parentcf1cca8e3f7b921c0e8de0a8363038ca7f60c572 (diff)
downloadqtjsbackend-e5ba7458fc5418e688de9cf294f5eb96cd6c4510.tar.gz
[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: Ia21a181927a2e68d33a623bbe47e0f1a4404ec8e
Diffstat (limited to 'src/3rdparty/v8/src/heap.h')
-rw-r--r--src/3rdparty/v8/src/heap.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/3rdparty/v8/src/heap.h b/src/3rdparty/v8/src/heap.h
index 7c0b0ea..5e90964 100644
--- a/src/3rdparty/v8/src/heap.h
+++ b/src/3rdparty/v8/src/heap.h
@@ -245,8 +245,8 @@ class Isolate;
class WeakObjectRetainer;
-typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap,
- Object** pointer);
+typedef HeapObject* (*ExternalStringTableUpdaterCallback)(Heap* heap,
+ Object** pointer);
class StoreBufferRebuilder {
public:
@@ -331,10 +331,14 @@ typedef void (*ScavengingCallback)(Map* map,
// External strings table is a place where all external strings are
// registered. We need to keep track of such strings to properly
// finalize them.
+// The ExternalStringTable can contain both strings and objects with
+// external resources. It was not renamed to make the patch simpler.
class ExternalStringTable {
public:
// Registers an external string.
inline void AddString(String* string);
+ // Registers an external object.
+ inline void AddObject(HeapObject* string);
inline void Iterate(ObjectVisitor* v);
@@ -352,10 +356,10 @@ class ExternalStringTable {
inline void Verify();
- inline void AddOldString(String* string);
+ inline void AddOldObject(HeapObject* string);
// Notifies the table that only a prefix of the new list is valid.
- inline void ShrinkNewStrings(int position);
+ inline void ShrinkNewObjects(int position);
// To speed up scavenge collections new space string are kept
// separate from old space strings.
@@ -851,7 +855,7 @@ class Heap {
// Finalizes an external string by deleting the associated external
// data and clearing the resource pointer.
- inline void FinalizeExternalString(String* string);
+ inline void FinalizeExternalString(HeapObject* string);
// Allocates an uninitialized object. The memory is non-executable if the
// hardware and OS allow.
@@ -1656,7 +1660,7 @@ class Heap {
// Performs a minor collection in new generation.
void Scavenge();
- static String* UpdateNewSpaceReferenceInExternalStringTableEntry(
+ static HeapObject* UpdateNewSpaceReferenceInExternalStringTableEntry(
Heap* heap,
Object** pointer);