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

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: Created 6 years, 1 month 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') | src/objects.cc » ('J')
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 ea84ebf335f99af66765fdd5a25b3a4738305bfd..b35c156451282c69b029b048b79e9948ea3ea1be 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -88,6 +88,7 @@
// - ScopeInfo
// - TransitionArray
// - ScriptContextTable
+// - WeakFixedArray
// - FixedDoubleArray
// - ExternalArray
// - ExternalUint8ClampedArray
@@ -942,6 +943,7 @@ template <class C> inline bool Is(Object* obj);
V(DependentCode) \
V(FixedArray) \
V(FixedDoubleArray) \
+ V(WeakFixedArray) \
V(ConstantPoolArray) \
V(Context) \
V(ScriptContextTable) \
@@ -1815,6 +1817,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();
@@ -2588,6 +2594,46 @@ class FixedDoubleArray: public FixedArrayBase {
};
+class WeakFixedArray : public FixedArray {
+ public:
+ inline Object* get(int index) const;
+
+ static bool StoreAnywhere(Handle<WeakFixedArray> array,
Toon Verwaest 2014/12/01 15:23:54 What about combining StoreAnywhere with GrowAndSto
Jakob Kummerow 2014/12/02 12:32:15 Done.
+ Handle<HeapObject> value,
+ bool may_be_duplicate = false);
+
+ static Handle<WeakFixedArray> GrowAndStore(Handle<WeakFixedArray> original,
+ Handle<HeapObject> value);
+ void Delete(Handle<HeapObject> value);
Toon Verwaest 2014/12/01 15:23:54 And then rename to Remove to match Add.
Jakob Kummerow 2014/12/02 12:32:15 Done.
+
+ DECLARE_CAST(WeakFixedArray)
+
+ private:
+ static const int kLastUsedIndexIndex = 0;
+ static const int kReservedFieldCount = 1;
+
+ static void Set(Handle<WeakFixedArray> array, int index,
+ Handle<HeapObject> value);
+ inline void clear(int index);
+ inline int length() const;
+ inline bool IsEmptySlot(int index) const;
+
+ inline int last_used_index() const;
+ inline void set_last_used_index(int index);
+
+ static void CopyFrom(Handle<WeakFixedArray> target,
+ Handle<WeakFixedArray> source);
+
+ friend class Factory; // For kReservedFieldCount.
Toon Verwaest 2014/12/01 15:23:54 Just move the method onto WeakFixedArray rather th
Jakob Kummerow 2014/12/02 12:32:15 Done. I've merged CopyFrom into it, to avoid redun
+
+ // 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.
//
@@ -5883,6 +5929,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)
@@ -6212,10 +6263,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') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698