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

Unified Diff: src/objects.h

Issue 10824042: Use linear backing store for hidden properties to save memory. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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 | « no previous file | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 7ed297340373326cc33c02e3d43173371bf1d04c..25759568a4e15fcf1bf1871e00db454f6f0b9bdf 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -74,6 +74,7 @@
// - FixedArrayBase
// - ByteArray
// - FixedArray
+// - HiddenPropertiesArray
// - DescriptorArray
// - HashTable
// - Dictionary
@@ -799,6 +800,7 @@ class MaybeObject BASE_EMBEDDED {
V(JSContextExtensionObject) \
V(JSModule) \
V(Map) \
+ V(HiddenPropertiesArray) \
V(DescriptorArray) \
V(TransitionArray) \
V(DeoptimizationInputData) \
@@ -2235,16 +2237,15 @@ class JSObject: public JSReceiver {
Object* setter,
PropertyAttributes attributes);
- // Returns the hidden properties backing store object, currently
- // a StringDictionary, stored on this object.
+ // Returns the hidden properties backing store object stored on this object.
// If no hidden properties object has been put on this object,
// return undefined, unless create_if_absent is true, in which case
- // a new dictionary is created, added to this object, and returned.
- MUST_USE_RESULT MaybeObject* GetHiddenPropertiesDictionary(
+ // a new backing store is allocated, added to this object, and returned.
+ MUST_USE_RESULT MaybeObject* GetHiddenPropertiesArray(
bool create_if_absent);
- // Updates the existing hidden properties dictionary.
- MUST_USE_RESULT MaybeObject* SetHiddenPropertiesDictionary(
- StringDictionary* dictionary);
+ // Updates the existing hidden properties backing store.
+ MUST_USE_RESULT MaybeObject* SetHiddenPropertiesArray(
+ HiddenPropertiesArray* hidden_properties);
DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
};
@@ -2455,6 +2456,29 @@ class FixedDoubleArray: public FixedArrayBase {
DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray);
};
+// HiddenPropertiesArray are fixed arrays used to store hidden properties.
+// Since we expect very few hidden properties, we use store the entries
+// linearly and use linear search for retrieval.
+class HiddenPropertiesArray: public FixedArray {
+ public:
+ // We allocate the backing store as FixedArray filled with holes.
+ MUST_USE_RESULT static inline MaybeObject* Allocate();
+
+ // Set a hidden property. Return the current backing store afterwards
+ // (the backing store may be re-allocated when extended).
+ MUST_USE_RESULT inline MaybeObject* Set(String* key, Object* value);
+
+ // If the entry corresponding to the key is found, set the key of the entry
+ // to the hole and the value to undefined. This way we can distinguish
+ // deleted entries from end of the list when we do linear search.
+ inline void Delete(String* key);
+ inline Object* Get(String* key);
+ static inline HiddenPropertiesArray* cast(Object* obj);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(HiddenPropertiesArray);
+};
+
// DescriptorArrays are fixed arrays used to hold instance descriptors.
// The format of the these objects is:
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698