Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(997)

Unified Diff: src/heap/heap.h

Issue 1312553003: [heap] Prevent direct access to ExternalStringTable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-heap-root-set-1
Patch Set: Addressed comments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/extensions/externalize-string-extension.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index aa63a00650ea3c4e8074e0786a80fce06a84819e..68de80b855e9ab5b02a1601fce0759e0a1213e58 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -422,16 +422,13 @@ namespace internal {
PRIVATE_SYMBOL_LIST(V)
// Forward declarations.
+class HeapObjectsFilter;
class HeapStats;
class Isolate;
class MemoryReducer;
class WeakObjectRetainer;
-typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap,
- Object** pointer);
-
-
// A queue of objects promoted during scavenge. Each object is accompanied
// by it's size to avoid dereferencing a map pointer for scanning.
// The last page in to-space is used for the promotion queue. On conflict
@@ -541,46 +538,6 @@ typedef void (*ScavengingCallback)(Map* map, HeapObject** slot,
HeapObject* object);
-// External strings table is a place where all external strings are
-// registered. We need to keep track of such strings to properly
-// finalize them.
-class ExternalStringTable {
- public:
- // Registers an external string.
- inline void AddString(String* string);
-
- inline void Iterate(ObjectVisitor* v);
-
- // Restores internal invariant and gets rid of collected strings.
- // Must be called after each Iterate() that modified the strings.
- void CleanUp();
-
- // Destroys all allocated memory.
- void TearDown();
-
- private:
- explicit ExternalStringTable(Heap* heap) : heap_(heap) {}
-
- friend class Heap;
-
- inline void Verify();
-
- inline void AddOldString(String* string);
-
- // Notifies the table that only a prefix of the new list is valid.
- inline void ShrinkNewStrings(int position);
-
- // To speed up scavenge collections new space string are kept
- // separate from old space strings.
- List<Object*> new_space_strings_;
- List<Object*> old_space_strings_;
-
- Heap* heap_;
-
- DISALLOW_COPY_AND_ASSIGN(ExternalStringTable);
-};
-
-
enum ArrayStorageAllocationMode {
DONT_INITIALIZE_ARRAY_ELEMENTS,
INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
@@ -870,10 +827,6 @@ class Heap {
// index.
void MoveElements(FixedArray* array, int dst_index, int src_index, int len);
- // Finalizes an external string by deleting the associated external
- // data and clearing the resource pointer.
- inline void FinalizeExternalString(String* string);
-
// Initialize a filler object to keep the ability to iterate over the heap
// when introducing gaps within pages.
void CreateFillerObjectAt(Address addr, int size);
@@ -1220,10 +1173,6 @@ class Heap {
return &mark_compact_collector_;
}
- ExternalStringTable* external_string_table() {
- return &external_string_table_;
- }
-
// ===========================================================================
// Root set access. ==========================================================
// ===========================================================================
@@ -1393,6 +1342,17 @@ class Heap {
IncrementalMarking* incremental_marking() { return &incremental_marking_; }
// ===========================================================================
+ // External string table API. ================================================
+ // ===========================================================================
+
+ // Registers an external string.
+ inline void RegisterExternalString(String* string);
+
+ // Finalizes an external string by deleting the associated external
+ // data and clearing the resource pointer.
+ inline void FinalizeExternalString(String* string);
+
+ // ===========================================================================
// Methods checking/returning the space of a given object/address. ===========
// ===========================================================================
@@ -1613,6 +1573,45 @@ class Heap {
private:
class UnmapFreeMemoryTask;
+ // External strings table is a place where all external strings are
+ // registered. We need to keep track of such strings to properly
+ // finalize them.
+ class ExternalStringTable {
+ public:
+ // Registers an external string.
+ inline void AddString(String* string);
+
+ inline void Iterate(ObjectVisitor* v);
+
+ // Restores internal invariant and gets rid of collected strings.
+ // Must be called after each Iterate() that modified the strings.
+ void CleanUp();
+
+ // Destroys all allocated memory.
+ void TearDown();
+
+ private:
+ explicit ExternalStringTable(Heap* heap) : heap_(heap) {}
+
+ inline void Verify();
+
+ inline void AddOldString(String* string);
+
+ // Notifies the table that only a prefix of the new list is valid.
+ inline void ShrinkNewStrings(int position);
+
+ // To speed up scavenge collections new space string are kept
+ // separate from old space strings.
+ List<Object*> new_space_strings_;
+ List<Object*> old_space_strings_;
+
+ Heap* heap_;
+
+ friend class Heap;
+
+ DISALLOW_COPY_AND_ASSIGN(ExternalStringTable);
+ };
+
struct StrongRootsList;
struct StringTypeTable {
@@ -1646,6 +1645,9 @@ class Heap {
bool pass_isolate;
};
+ typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap,
+ Object** pointer);
+
static const int kInitialStringTableSize = 2048;
static const int kInitialEvalCacheSize = 64;
static const int kInitialNumberStringCacheSize = 256;
@@ -2569,8 +2571,6 @@ class SpaceIterator : public Malloced {
// nodes filtering uses GC marks, it can't be used during MS/MC GC
// phases. Also, it is forbidden to interrupt iteration in this mode,
// as this will leave heap objects marked (and thus, unusable).
-class HeapObjectsFilter;
-
class HeapIterator BASE_EMBEDDED {
public:
enum HeapObjectsFiltering { kNoFiltering, kFilterUnreachable };
« no previous file with comments | « src/extensions/externalize-string-extension.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698