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

Unified Diff: src/objects.h

Issue 768633002: Add infrastructure to keep track of references to prototypes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use WeakCellForMap() when appropriate Created 6 years 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/lookup.cc ('k') | 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 92d134f518e82233440d799ced586131ab1f4bf4..dacbd837fce1cfca04e6065b1518f6d34e5804fd 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -88,6 +88,7 @@
// - ScopeInfo
// - TransitionArray
// - ScriptContextTable
+// - WeakFixedArray
// - FixedDoubleArray
// - ExternalArray
// - ExternalUint8ClampedArray
@@ -943,6 +944,7 @@ template <class C> inline bool Is(Object* obj);
V(DependentCode) \
V(FixedArray) \
V(FixedDoubleArray) \
+ V(WeakFixedArray) \
V(ConstantPoolArray) \
V(Context) \
V(ScriptContextTable) \
@@ -1821,6 +1823,10 @@ class JSObject: public JSReceiver {
static void OptimizeAsPrototype(Handle<JSObject> object,
PrototypeOptimizationMode mode);
static void ReoptimizeIfPrototype(Handle<JSObject> object);
+ static void RegisterPrototypeUser(Handle<JSObject> prototype,
+ Handle<HeapObject> user);
+ static void UnregisterPrototypeUser(Handle<JSObject> prototype,
+ Handle<HeapObject> user);
// Retrieve interceptors.
InterceptorInfo* GetNamedInterceptor();
@@ -2608,6 +2614,45 @@ class FixedDoubleArray: public FixedArrayBase {
};
+class WeakFixedArray : public FixedArray {
+ public:
+ enum SearchForDuplicates { kAlwaysAdd, kAddIfNotFound };
+
+ // If |maybe_array| is not a WeakFixedArray, a fresh one will be allocated.
+ static Handle<WeakFixedArray> Add(
+ Handle<Object> maybe_array, Handle<HeapObject> value,
+ SearchForDuplicates search_for_duplicates = kAlwaysAdd);
+
+ void Remove(Handle<HeapObject> value);
+
+ inline Object* Get(int index) const;
+ inline int Length() const;
+
+ DECLARE_CAST(WeakFixedArray)
+
+ private:
+ static const int kLastUsedIndexIndex = 0;
+ static const int kFirstIndex = 1;
+
+ static Handle<WeakFixedArray> Allocate(
+ Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from);
+
+ static void Set(Handle<WeakFixedArray> array, int index,
+ Handle<HeapObject> value);
+ inline void clear(int index);
+ inline bool IsEmptySlot(int index) const;
+
+ inline int last_used_index() const;
+ inline void set_last_used_index(int index);
+
+ // Disallow inherited setters.
+ void set(int index, Smi* value);
+ void set(int index, Object* value);
+ void set(int index, Object* value, WriteBarrierMode mode);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray);
+};
+
+
// ConstantPoolArray describes a fixed-sized array containing constant pool
// entries.
//
@@ -5926,6 +5971,11 @@ class Map: public HeapObject {
// [prototype]: implicit prototype object.
DECL_ACCESSORS(prototype, Object)
+ // TODO(jkummerow): make set_prototype private.
+ void SetPrototype(Handle<Object> prototype,
+ PrototypeOptimizationMode proto_mode = FAST_PROTOTYPE);
+ bool ShouldRegisterAsPrototypeUser(Handle<JSObject> prototype);
+ bool CanUseOptimizationsBasedOnPrototypeRegistry();
// [constructor]: points back to the function responsible for this map.
DECL_ACCESSORS(constructor, Object)
@@ -6257,10 +6307,11 @@ class Map: public HeapObject {
// the original map. That way we can transition to the same map if the same
// prototype is set, rather than creating a new map every time. The
// transitions are in the form of a map where the keys are prototype objects
- // and the values are the maps the are transitioned to.
+ // and the values are the maps they transition to.
static const int kMaxCachedPrototypeTransitions = 256;
static Handle<Map> TransitionToPrototype(Handle<Map> map,
- Handle<Object> prototype);
+ Handle<Object> prototype,
+ PrototypeOptimizationMode mode);
static const int kMaxPreAllocatedPropertyFields = 255;
« no previous file with comments | « src/lookup.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698