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

Side by Side Diff: src/objects.h

Issue 153923005: A64: Synchronize with r17525. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/object-observe.js ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 251
252 // NormalizedMapSharingMode is used to specify whether a map may be shared 252 // NormalizedMapSharingMode is used to specify whether a map may be shared
253 // by different objects with normalized properties. 253 // by different objects with normalized properties.
254 enum NormalizedMapSharingMode { 254 enum NormalizedMapSharingMode {
255 UNIQUE_NORMALIZED_MAP, 255 UNIQUE_NORMALIZED_MAP,
256 SHARED_NORMALIZED_MAP 256 SHARED_NORMALIZED_MAP
257 }; 257 };
258 258
259 259
260 // Indicates whether a get method should implicitly create the object looked up.
261 enum CreationFlag {
262 ALLOW_CREATION,
263 OMIT_CREATION
264 };
265
266
267 // Indicates whether transitions can be added to a source map or not. 260 // Indicates whether transitions can be added to a source map or not.
268 enum TransitionFlag { 261 enum TransitionFlag {
269 INSERT_TRANSITION, 262 INSERT_TRANSITION,
270 OMIT_TRANSITION 263 OMIT_TRANSITION
271 }; 264 };
272 265
273 266
274 enum DebugExtraICState { 267 enum DebugExtraICState {
275 DEBUG_BREAK, 268 DEBUG_BREAK,
276 DEBUG_PREPARE_STEP_IN 269 DEBUG_PREPARE_STEP_IN
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 uint32_t index); 1535 uint32_t index);
1543 // For use when we know that no exception can be thrown. 1536 // For use when we know that no exception can be thrown.
1544 inline Object* GetElementNoExceptionThrown(Isolate* isolate, uint32_t index); 1537 inline Object* GetElementNoExceptionThrown(Isolate* isolate, uint32_t index);
1545 MUST_USE_RESULT MaybeObject* GetElementWithReceiver(Isolate* isolate, 1538 MUST_USE_RESULT MaybeObject* GetElementWithReceiver(Isolate* isolate,
1546 Object* receiver, 1539 Object* receiver,
1547 uint32_t index); 1540 uint32_t index);
1548 1541
1549 // Return the object's prototype (might be Heap::null_value()). 1542 // Return the object's prototype (might be Heap::null_value()).
1550 Object* GetPrototype(Isolate* isolate); 1543 Object* GetPrototype(Isolate* isolate);
1551 1544
1545 // Returns the permanent hash code associated with this object. May return
1546 // undefined if not yet created.
1547 Object* GetHash();
1548
1552 // Returns the permanent hash code associated with this object depending on 1549 // Returns the permanent hash code associated with this object depending on
1553 // the actual object type. Might return a failure in case no hash was 1550 // the actual object type. May create and store a hash code if needed and none
1554 // created yet or GC was caused by creation. 1551 // exists.
1555 MUST_USE_RESULT MaybeObject* GetHash(CreationFlag flag); 1552 // TODO(rafaelw): Remove isolate parameter when objects.cc is fully
1553 // handlified.
1554 static Handle<Object> GetOrCreateHash(Handle<Object> object,
1555 Isolate* isolate);
1556 1556
1557 // Checks whether this object has the same value as the given one. This 1557 // Checks whether this object has the same value as the given one. This
1558 // function is implemented according to ES5, section 9.12 and can be used 1558 // function is implemented according to ES5, section 9.12 and can be used
1559 // to implement the Harmony "egal" function. 1559 // to implement the Harmony "egal" function.
1560 bool SameValue(Object* other); 1560 bool SameValue(Object* other);
1561 1561
1562 // Tries to convert an object to an array index. Returns true and sets 1562 // Tries to convert an object to an array index. Returns true and sets
1563 // the output parameter if it succeeds. 1563 // the output parameter if it succeeds.
1564 inline bool ToArrayIndex(uint32_t* index); 1564 inline bool ToArrayIndex(uint32_t* index);
1565 1565
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 inline PropertyAttributes GetElementAttribute(uint32_t index); 2036 inline PropertyAttributes GetElementAttribute(uint32_t index);
2037 inline PropertyAttributes GetLocalElementAttribute(uint32_t index); 2037 inline PropertyAttributes GetLocalElementAttribute(uint32_t index);
2038 2038
2039 // Return the object's prototype (might be Heap::null_value()). 2039 // Return the object's prototype (might be Heap::null_value()).
2040 inline Object* GetPrototype(); 2040 inline Object* GetPrototype();
2041 2041
2042 // Return the constructor function (may be Heap::null_value()). 2042 // Return the constructor function (may be Heap::null_value()).
2043 inline Object* GetConstructor(); 2043 inline Object* GetConstructor();
2044 2044
2045 // Retrieves a permanent object identity hash code. The undefined value might 2045 // Retrieves a permanent object identity hash code. The undefined value might
2046 // be returned in case no hash was created yet and OMIT_CREATION was used. 2046 // be returned in case no hash was created yet.
2047 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); 2047 inline Object* GetIdentityHash();
2048
2049 // Retrieves a permanent object identity hash code. May create and store a
2050 // hash code if needed and none exists.
2051 inline static Handle<Object> GetOrCreateIdentityHash(
2052 Handle<JSReceiver> object);
2048 2053
2049 // Lookup a property. If found, the result is valid and has 2054 // Lookup a property. If found, the result is valid and has
2050 // detailed information. 2055 // detailed information.
2051 void LocalLookup(Name* name, LookupResult* result, 2056 void LocalLookup(Name* name, LookupResult* result,
2052 bool search_hidden_prototypes = false); 2057 bool search_hidden_prototypes = false);
2053 void Lookup(Name* name, LookupResult* result); 2058 void Lookup(Name* name, LookupResult* result);
2054 2059
2055 protected: 2060 protected:
2056 Smi* GenerateIdentityHash(); 2061 Smi* GenerateIdentityHash();
2057 2062
(...skipping 11 matching lines...) Expand all
2069 LookupResult* result, 2074 LookupResult* result,
2070 Handle<Name> key, 2075 Handle<Name> key,
2071 Handle<Object> value, 2076 Handle<Object> value,
2072 PropertyAttributes attributes, 2077 PropertyAttributes attributes,
2073 StrictModeFlag strict_mode, 2078 StrictModeFlag strict_mode,
2074 StoreFromKeyed store_from_keyed); 2079 StoreFromKeyed store_from_keyed);
2075 2080
2076 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); 2081 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver);
2077 }; 2082 };
2078 2083
2084 // Forward declaration for JSObject::GetOrCreateHiddenPropertiesHashTable.
2085 class ObjectHashTable;
2086
2079 // The JSObject describes real heap allocated JavaScript objects with 2087 // The JSObject describes real heap allocated JavaScript objects with
2080 // properties. 2088 // properties.
2081 // Note that the map of JSObject changes during execution to enable inline 2089 // Note that the map of JSObject changes during execution to enable inline
2082 // caching. 2090 // caching.
2083 class JSObject: public JSReceiver { 2091 class JSObject: public JSReceiver {
2084 public: 2092 public:
2085 // [properties]: Backing storage for properties. 2093 // [properties]: Backing storage for properties.
2086 // properties is a FixedArray in the fast case and a Dictionary in the 2094 // properties is a FixedArray in the fast case and a Dictionary in the
2087 // slow case. 2095 // slow case.
2088 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. 2096 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); 2226 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map);
2219 2227
2220 // Migrates the given object to a map whose field representations are the 2228 // Migrates the given object to a map whose field representations are the
2221 // lowest upper bound of all known representations for that field. 2229 // lowest upper bound of all known representations for that field.
2222 static void MigrateInstance(Handle<JSObject> instance); 2230 static void MigrateInstance(Handle<JSObject> instance);
2223 2231
2224 // Migrates the given object only if the target map is already available, 2232 // Migrates the given object only if the target map is already available,
2225 // or returns an empty handle if such a map is not yet available. 2233 // or returns an empty handle if such a map is not yet available.
2226 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); 2234 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance);
2227 2235
2228 // Can cause GC.
2229 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributesTrampoline(
2230 Name* key,
2231 Object* value,
2232 PropertyAttributes attributes,
2233 ValueType value_type = OPTIMAL_REPRESENTATION,
2234 StoreMode mode = ALLOW_AS_CONSTANT,
2235 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK);
2236
2237 // Retrieve a value in a normalized object given a lookup result. 2236 // Retrieve a value in a normalized object given a lookup result.
2238 // Handles the special representation of JS global objects. 2237 // Handles the special representation of JS global objects.
2239 Object* GetNormalizedProperty(LookupResult* result); 2238 Object* GetNormalizedProperty(LookupResult* result);
2240 2239
2241 // Sets the property value in a normalized object given a lookup result. 2240 // Sets the property value in a normalized object given a lookup result.
2242 // Handles the special representation of JS global objects. 2241 // Handles the special representation of JS global objects.
2243 static void SetNormalizedProperty(Handle<JSObject> object, 2242 static void SetNormalizedProperty(Handle<JSObject> object,
2244 LookupResult* result, 2243 LookupResult* result,
2245 Handle<Object> value); 2244 Handle<Object> value);
2246 2245
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 // 2319 //
2321 // Hidden properties are not local properties of the object itself. 2320 // Hidden properties are not local properties of the object itself.
2322 // Instead they are stored in an auxiliary structure kept as a local 2321 // Instead they are stored in an auxiliary structure kept as a local
2323 // property with a special name Heap::hidden_string(). But if the 2322 // property with a special name Heap::hidden_string(). But if the
2324 // receiver is a JSGlobalProxy then the auxiliary object is a property 2323 // receiver is a JSGlobalProxy then the auxiliary object is a property
2325 // of its prototype, and if it's a detached proxy, then you can't have 2324 // of its prototype, and if it's a detached proxy, then you can't have
2326 // hidden properties. 2325 // hidden properties.
2327 2326
2328 // Sets a hidden property on this object. Returns this object if successful, 2327 // Sets a hidden property on this object. Returns this object if successful,
2329 // undefined if called on a detached proxy. 2328 // undefined if called on a detached proxy.
2330 static Handle<Object> SetHiddenProperty(Handle<JSObject> obj, 2329 static Handle<Object> SetHiddenProperty(Handle<JSObject> object,
2331 Handle<Name> key, 2330 Handle<Name> key,
2332 Handle<Object> value); 2331 Handle<Object> value);
2333 // Returns a failure if a GC is required.
2334 MUST_USE_RESULT MaybeObject* SetHiddenProperty(Name* key, Object* value);
2335 // Gets the value of a hidden property with the given key. Returns the hole 2332 // Gets the value of a hidden property with the given key. Returns the hole
2336 // if the property doesn't exist (or if called on a detached proxy), 2333 // if the property doesn't exist (or if called on a detached proxy),
2337 // otherwise returns the value set for the key. 2334 // otherwise returns the value set for the key.
2338 Object* GetHiddenProperty(Name* key); 2335 Object* GetHiddenProperty(Name* key);
2339 // Deletes a hidden property. Deleting a non-existing property is 2336 // Deletes a hidden property. Deleting a non-existing property is
2340 // considered successful. 2337 // considered successful.
2341 static void DeleteHiddenProperty(Handle<JSObject> object, 2338 static void DeleteHiddenProperty(Handle<JSObject> object,
2342 Handle<Name> key); 2339 Handle<Name> key);
2343 // Returns true if the object has a property with the hidden string as name. 2340 // Returns true if the object has a property with the hidden string as name.
2344 bool HasHiddenProperties(); 2341 bool HasHiddenProperties();
2345 2342
2346 static int GetIdentityHash(Handle<JSObject> object); 2343 static void SetIdentityHash(Handle<JSObject> object, Handle<Smi> hash);
2347 static void SetIdentityHash(Handle<JSObject> object, Smi* hash);
2348 2344
2349 inline void ValidateElements(); 2345 inline void ValidateElements();
2350 2346
2351 // Makes sure that this object can contain HeapObject as elements. 2347 // Makes sure that this object can contain HeapObject as elements.
2352 static inline void EnsureCanContainHeapObjectElements(Handle<JSObject> obj); 2348 static inline void EnsureCanContainHeapObjectElements(Handle<JSObject> obj);
2353 2349
2354 // Makes sure that this object can contain the specified elements. 2350 // Makes sure that this object can contain the specified elements.
2355 MUST_USE_RESULT inline MaybeObject* EnsureCanContainElements( 2351 MUST_USE_RESULT inline MaybeObject* EnsureCanContainElements(
2356 Object** elements, 2352 Object** elements,
2357 uint32_t count, 2353 uint32_t count,
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 v8::AccessControl access_control); 2887 v8::AccessControl access_control);
2892 2888
2893 // Try to define a single accessor paying attention to map transitions. 2889 // Try to define a single accessor paying attention to map transitions.
2894 // Returns false if this was not possible and we have to use the slow case. 2890 // Returns false if this was not possible and we have to use the slow case.
2895 static bool DefineFastAccessor(Handle<JSObject> object, 2891 static bool DefineFastAccessor(Handle<JSObject> object,
2896 Handle<Name> name, 2892 Handle<Name> name,
2897 AccessorComponent component, 2893 AccessorComponent component,
2898 Handle<Object> accessor, 2894 Handle<Object> accessor,
2899 PropertyAttributes attributes); 2895 PropertyAttributes attributes);
2900 2896
2901 enum InitializeHiddenProperties {
2902 CREATE_NEW_IF_ABSENT,
2903 ONLY_RETURN_INLINE_VALUE
2904 };
2905 2897
2906 // If create_if_absent is true, return the hash table backing store 2898 // Return the hash table backing store or the inline stored identity hash,
2907 // for hidden properties. If there is no backing store, allocate one. 2899 // whatever is found.
2908 // If create_if_absent is false, return the hash table backing store 2900 MUST_USE_RESULT Object* GetHiddenPropertiesHashTable();
2909 // or the inline stored identity hash, whatever is found. 2901
2910 MUST_USE_RESULT MaybeObject* GetHiddenPropertiesHashTable( 2902 // Return the hash table backing store for hidden properties. If there is no
2911 InitializeHiddenProperties init_option); 2903 // backing store, allocate one.
2904 static Handle<ObjectHashTable> GetOrCreateHiddenPropertiesHashtable(
2905 Handle<JSObject> object);
2906
2912 // Set the hidden property backing store to either a hash table or 2907 // Set the hidden property backing store to either a hash table or
2913 // the inline-stored identity hash. 2908 // the inline-stored identity hash.
2914 MUST_USE_RESULT MaybeObject* SetHiddenPropertiesHashTable( 2909 static Handle<Object> SetHiddenPropertiesHashTable(
2915 Object* value); 2910 Handle<JSObject> object,
2911 Handle<Object> value);
2916 2912
2917 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); 2913 MUST_USE_RESULT Object* GetIdentityHash();
2914
2915 static Handle<Object> GetOrCreateIdentityHash(Handle<JSObject> object);
2918 2916
2919 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); 2917 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
2920 }; 2918 };
2921 2919
2922 2920
2923 // Common superclass for FixedArrays that allow implementations to share 2921 // Common superclass for FixedArrays that allow implementations to share
2924 // common accessors and some code paths. 2922 // common accessors and some code paths.
2925 class FixedArrayBase: public HeapObject { 2923 class FixedArrayBase: public HeapObject {
2926 public: 2924 public:
2927 // [length]: length of the array. 2925 // [length]: length of the array.
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
3517 static uint32_t HashForObject(Key key, Object* object) { return 0; } 3515 static uint32_t HashForObject(Key key, Object* object) { return 0; }
3518 static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) { 3516 static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) {
3519 ASSERT(UsesSeed); 3517 ASSERT(UsesSeed);
3520 return HashForObject(key, object); 3518 return HashForObject(key, object);
3521 } 3519 }
3522 }; 3520 };
3523 3521
3524 template<typename Shape, typename Key> 3522 template<typename Shape, typename Key>
3525 class HashTable: public FixedArray { 3523 class HashTable: public FixedArray {
3526 public: 3524 public:
3527 enum MinimumCapacity {
3528 USE_DEFAULT_MINIMUM_CAPACITY,
3529 USE_CUSTOM_MINIMUM_CAPACITY
3530 };
3531
3532 // Wrapper methods 3525 // Wrapper methods
3533 inline uint32_t Hash(Key key) { 3526 inline uint32_t Hash(Key key) {
3534 if (Shape::UsesSeed) { 3527 if (Shape::UsesSeed) {
3535 return Shape::SeededHash(key, 3528 return Shape::SeededHash(key,
3536 GetHeap()->HashSeed()); 3529 GetHeap()->HashSeed());
3537 } else { 3530 } else {
3538 return Shape::Hash(key); 3531 return Shape::Hash(key);
3539 } 3532 }
3540 } 3533 }
3541 3534
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3632 (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize; 3625 (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize;
3633 3626
3634 // Find entry for key otherwise return kNotFound. 3627 // Find entry for key otherwise return kNotFound.
3635 inline int FindEntry(Key key); 3628 inline int FindEntry(Key key);
3636 int FindEntry(Isolate* isolate, Key key); 3629 int FindEntry(Isolate* isolate, Key key);
3637 3630
3638 // Rehashes the table in-place. 3631 // Rehashes the table in-place.
3639 void Rehash(Key key); 3632 void Rehash(Key key);
3640 3633
3641 protected: 3634 protected:
3635 friend class ObjectHashSet;
3636 friend class ObjectHashTable;
3637
3642 // Find the entry at which to insert element with the given key that 3638 // Find the entry at which to insert element with the given key that
3643 // has the given hash value. 3639 // has the given hash value.
3644 uint32_t FindInsertionEntry(uint32_t hash); 3640 uint32_t FindInsertionEntry(uint32_t hash);
3645 3641
3646 // Returns the index for an entry (of the key) 3642 // Returns the index for an entry (of the key)
3647 static inline int EntryToIndex(int entry) { 3643 static inline int EntryToIndex(int entry) {
3648 return (entry * kEntrySize) + kElementsStartIndex; 3644 return (entry * kEntrySize) + kElementsStartIndex;
3649 } 3645 }
3650 3646
3651 // Update the number of elements in the hash table. 3647 // Update the number of elements in the hash table.
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
4095 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> { 4091 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> {
4096 public: 4092 public:
4097 static inline ObjectHashSet* cast(Object* obj) { 4093 static inline ObjectHashSet* cast(Object* obj) {
4098 ASSERT(obj->IsHashTable()); 4094 ASSERT(obj->IsHashTable());
4099 return reinterpret_cast<ObjectHashSet*>(obj); 4095 return reinterpret_cast<ObjectHashSet*>(obj);
4100 } 4096 }
4101 4097
4102 // Looks up whether the given key is part of this hash set. 4098 // Looks up whether the given key is part of this hash set.
4103 bool Contains(Object* key); 4099 bool Contains(Object* key);
4104 4100
4101 static Handle<ObjectHashSet> EnsureCapacity(
4102 Handle<ObjectHashSet> table,
4103 int n,
4104 Handle<Object> key,
4105 PretenureFlag pretenure = NOT_TENURED);
4106
4107 // Attempt to shrink hash table after removal of key.
4108 static Handle<ObjectHashSet> Shrink(Handle<ObjectHashSet> table,
4109 Handle<Object> key);
4110
4105 // Adds the given key to this hash set. 4111 // Adds the given key to this hash set.
4106 MUST_USE_RESULT MaybeObject* Add(Object* key); 4112 static Handle<ObjectHashSet> Add(Handle<ObjectHashSet> table,
4113 Handle<Object> key);
4107 4114
4108 // Removes the given key from this hash set. 4115 // Removes the given key from this hash set.
4109 MUST_USE_RESULT MaybeObject* Remove(Object* key); 4116 static Handle<ObjectHashSet> Remove(Handle<ObjectHashSet> table,
4117 Handle<Object> key);
4110 }; 4118 };
4111 4119
4112 4120
4113 // ObjectHashTable maps keys that are arbitrary objects to object values by 4121 // ObjectHashTable maps keys that are arbitrary objects to object values by
4114 // using the identity hash of the key for hashing purposes. 4122 // using the identity hash of the key for hashing purposes.
4115 class ObjectHashTable: public HashTable<ObjectHashTableShape<2>, Object*> { 4123 class ObjectHashTable: public HashTable<ObjectHashTableShape<2>, Object*> {
4116 public: 4124 public:
4117 static inline ObjectHashTable* cast(Object* obj) { 4125 static inline ObjectHashTable* cast(Object* obj) {
4118 ASSERT(obj->IsHashTable()); 4126 ASSERT(obj->IsHashTable());
4119 return reinterpret_cast<ObjectHashTable*>(obj); 4127 return reinterpret_cast<ObjectHashTable*>(obj);
4120 } 4128 }
4121 4129
4130 static Handle<ObjectHashTable> EnsureCapacity(
4131 Handle<ObjectHashTable> table,
4132 int n,
4133 Handle<Object> key,
4134 PretenureFlag pretenure = NOT_TENURED);
4135
4136 // Attempt to shrink hash table after removal of key.
4137 static Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table,
4138 Handle<Object> key);
4139
4122 // Looks up the value associated with the given key. The hole value is 4140 // Looks up the value associated with the given key. The hole value is
4123 // returned in case the key is not present. 4141 // returned in case the key is not present.
4124 Object* Lookup(Object* key); 4142 Object* Lookup(Object* key);
4125 4143
4126 // Adds (or overwrites) the value associated with the given key. Mapping a 4144 // Adds (or overwrites) the value associated with the given key. Mapping a
4127 // key to the hole value causes removal of the whole entry. 4145 // key to the hole value causes removal of the whole entry.
4128 MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value); 4146 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
4147 Handle<Object> key,
4148 Handle<Object> value);
4129 4149
4130 private: 4150 private:
4131 friend class MarkCompactCollector; 4151 friend class MarkCompactCollector;
4132 4152
4133 void AddEntry(int entry, Object* key, Object* value); 4153 void AddEntry(int entry, Object* key, Object* value);
4134 void RemoveEntry(int entry); 4154 void RemoveEntry(int entry);
4135 4155
4136 // Returns the index to the value of an entry. 4156 // Returns the index to the value of an entry.
4137 static inline int EntryToValueIndex(int entry) { 4157 static inline int EntryToValueIndex(int entry) {
4138 return EntryToIndex(entry) + 1; 4158 return EntryToIndex(entry) + 1;
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
5048 // [relocation_info]: Code relocation information 5068 // [relocation_info]: Code relocation information
5049 DECL_ACCESSORS(relocation_info, ByteArray) 5069 DECL_ACCESSORS(relocation_info, ByteArray)
5050 void InvalidateRelocation(); 5070 void InvalidateRelocation();
5051 5071
5052 // [handler_table]: Fixed array containing offsets of exception handlers. 5072 // [handler_table]: Fixed array containing offsets of exception handlers.
5053 DECL_ACCESSORS(handler_table, FixedArray) 5073 DECL_ACCESSORS(handler_table, FixedArray)
5054 5074
5055 // [deoptimization_data]: Array containing data for deopt. 5075 // [deoptimization_data]: Array containing data for deopt.
5056 DECL_ACCESSORS(deoptimization_data, FixedArray) 5076 DECL_ACCESSORS(deoptimization_data, FixedArray)
5057 5077
5058 // [type_feedback_info]: This field stores various things, depending on the 5078 // [raw_type_feedback_info]: This field stores various things, depending on
5059 // kind of the code object. 5079 // the kind of the code object.
5060 // FUNCTION => type feedback information. 5080 // FUNCTION => type feedback information.
5061 // STUB => various things, e.g. a SMI 5081 // STUB => various things, e.g. a SMI
5062 // OPTIMIZED_FUNCTION => the next_code_link for optimized code list. 5082 // OPTIMIZED_FUNCTION => the next_code_link for optimized code list.
5063 DECL_ACCESSORS(type_feedback_info, Object) 5083 DECL_ACCESSORS(raw_type_feedback_info, Object)
5064 inline void InitializeTypeFeedbackInfoNoWriteBarrier(Object* value); 5084 inline Object* type_feedback_info();
5085 inline void set_type_feedback_info(
5086 Object* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
5065 inline int stub_info(); 5087 inline int stub_info();
5066 inline void set_stub_info(int info); 5088 inline void set_stub_info(int info);
5067 5089
5068 // [next_code_link]: Link for lists of optimized or deoptimized code. 5090 // [next_code_link]: Link for lists of optimized or deoptimized code.
5069 // Note that storage for this field is overlapped with typefeedback_info. 5091 // Note that storage for this field is overlapped with typefeedback_info.
5070 DECL_ACCESSORS(next_code_link, Object) 5092 DECL_ACCESSORS(next_code_link, Object)
5071 5093
5072 // [gc_metadata]: Field used to hold GC related metadata. The contents of this 5094 // [gc_metadata]: Field used to hold GC related metadata. The contents of this
5073 // field does not have to be traced during garbage collection since 5095 // field does not have to be traced during garbage collection since
5074 // it is only used by the garbage collector itself. 5096 // it is only used by the garbage collector itself.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
5229 5251
5230 // Find |length| handlers and put them into |code_list|. Returns false if not 5252 // Find |length| handlers and put them into |code_list|. Returns false if not
5231 // enough handlers can be found. 5253 // enough handlers can be found.
5232 bool FindHandlers(CodeHandleList* code_list, int length = -1); 5254 bool FindHandlers(CodeHandleList* code_list, int length = -1);
5233 5255
5234 // Find the first name in an IC stub. 5256 // Find the first name in an IC stub.
5235 Name* FindFirstName(); 5257 Name* FindFirstName();
5236 5258
5237 void ReplaceNthCell(int n, Cell* replace_with); 5259 void ReplaceNthCell(int n, Cell* replace_with);
5238 5260
5261 // The entire code object including its header is copied verbatim to the
5262 // snapshot so that it can be written in one, fast, memcpy during
5263 // deserialization. The deserializer will overwrite some pointers, rather
5264 // like a runtime linker, but the random allocation addresses used in the
5265 // mksnapshot process would still be present in the unlinked snapshot data,
5266 // which would make snapshot production non-reproducible. This method wipes
5267 // out the to-be-overwritten header data for reproducible snapshots.
5268 inline void WipeOutHeader();
5269
5239 class ExtraICStateStrictMode: public BitField<StrictModeFlag, 0, 1> {}; 5270 class ExtraICStateStrictMode: public BitField<StrictModeFlag, 0, 1> {};
5240 class ExtraICStateKeyedAccessStoreMode: 5271 class ExtraICStateKeyedAccessStoreMode:
5241 public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT 5272 public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT
5242 5273
5243 static inline StrictModeFlag GetStrictMode(ExtraICState extra_ic_state) { 5274 static inline StrictModeFlag GetStrictMode(ExtraICState extra_ic_state) {
5244 return ExtraICStateStrictMode::decode(extra_ic_state); 5275 return ExtraICStateStrictMode::decode(extra_ic_state);
5245 } 5276 }
5246 5277
5247 static inline KeyedAccessStoreMode GetKeyedAccessStoreMode( 5278 static inline KeyedAccessStoreMode GetKeyedAccessStoreMode(
5248 ExtraICState extra_ic_state) { 5279 ExtraICState extra_ic_state) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
5339 int CodeSize() { return SizeFor(body_size()); } 5370 int CodeSize() { return SizeFor(body_size()); }
5340 inline void CodeIterateBody(ObjectVisitor* v); 5371 inline void CodeIterateBody(ObjectVisitor* v);
5341 5372
5342 template<typename StaticVisitor> 5373 template<typename StaticVisitor>
5343 inline void CodeIterateBody(Heap* heap); 5374 inline void CodeIterateBody(Heap* heap);
5344 5375
5345 DECLARE_PRINTER(Code) 5376 DECLARE_PRINTER(Code)
5346 DECLARE_VERIFIER(Code) 5377 DECLARE_VERIFIER(Code)
5347 5378
5348 void ClearInlineCaches(); 5379 void ClearInlineCaches();
5380 void ClearInlineCaches(Kind kind);
5381
5349 void ClearTypeFeedbackCells(Heap* heap); 5382 void ClearTypeFeedbackCells(Heap* heap);
5350 5383
5351 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset); 5384 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset);
5352 5385
5353 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge, 5386 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge,
5354 enum Age { 5387 enum Age {
5355 kNotExecutedCodeAge = -2, 5388 kNotExecutedCodeAge = -2,
5356 kExecutedOnceCodeAge = -1, 5389 kExecutedOnceCodeAge = -1,
5357 kNoAgeCodeAge = 0, 5390 kNoAgeCodeAge = 0,
5358 CODE_AGE_LIST(DECLARE_CODE_AGE_ENUM) 5391 CODE_AGE_LIST(DECLARE_CODE_AGE_ENUM)
5359 kAfterLastCodeAge, 5392 kAfterLastCodeAge,
5393 kFirstCodeAge = kNotExecutedCodeAge,
5360 kLastCodeAge = kAfterLastCodeAge - 1, 5394 kLastCodeAge = kAfterLastCodeAge - 1,
5361 kCodeAgeCount = kAfterLastCodeAge - 1, 5395 kCodeAgeCount = kAfterLastCodeAge - kNotExecutedCodeAge - 1,
5362 kIsOldCodeAge = kSexagenarianCodeAge, 5396 kIsOldCodeAge = kSexagenarianCodeAge,
5363 kPreAgedCodeAge = kIsOldCodeAge - 1 5397 kPreAgedCodeAge = kIsOldCodeAge - 1
5364 }; 5398 };
5365 #undef DECLARE_CODE_AGE_ENUM 5399 #undef DECLARE_CODE_AGE_ENUM
5366 5400
5367 // Code aging. Indicates how many full GCs this code has survived without 5401 // Code aging. Indicates how many full GCs this code has survived without
5368 // being entered through the prologue. Used to determine when it is 5402 // being entered through the prologue. Used to determine when it is
5369 // relatively safe to flush this code object and replace it with the lazy 5403 // relatively safe to flush this code object and replace it with the lazy
5370 // compilation stub. 5404 // compilation stub.
5371 static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate); 5405 static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate);
5372 static void MarkCodeAsExecuted(byte* sequence, Isolate* isolate); 5406 static void MarkCodeAsExecuted(byte* sequence, Isolate* isolate);
5373 void MakeOlder(MarkingParity); 5407 void MakeOlder(MarkingParity);
5374 static bool IsYoungSequence(byte* sequence); 5408 static bool IsYoungSequence(byte* sequence);
5375 bool IsOld(); 5409 bool IsOld();
5376 Age GetAge(); 5410 Age GetAge();
5411 // Gets the raw code age, including psuedo code-age values such as
5412 // kNotExecutedCodeAge and kExecutedOnceCodeAge.
5413 Age GetRawAge();
5377 static inline Code* GetPreAgedCodeAgeStub(Isolate* isolate) { 5414 static inline Code* GetPreAgedCodeAgeStub(Isolate* isolate) {
5378 return GetCodeAgeStub(isolate, kNotExecutedCodeAge, NO_MARKING_PARITY); 5415 return GetCodeAgeStub(isolate, kNotExecutedCodeAge, NO_MARKING_PARITY);
5379 } 5416 }
5380 5417
5381 void PrintDeoptLocation(int bailout_id); 5418 void PrintDeoptLocation(int bailout_id);
5382 bool CanDeoptAt(Address pc); 5419 bool CanDeoptAt(Address pc);
5383 5420
5384 #ifdef VERIFY_HEAP 5421 #ifdef VERIFY_HEAP
5385 void VerifyEmbeddedObjectsDependency(); 5422 void VerifyEmbeddedObjectsDependency();
5386 #endif 5423 #endif
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5507 ExtendedExtraICStateField::kShift + 5544 ExtendedExtraICStateField::kShift +
5508 ExtendedExtraICStateField::kSize); 5545 ExtendedExtraICStateField::kSize);
5509 5546
5510 // This constant should be encodable in an ARM instruction. 5547 // This constant should be encodable in an ARM instruction.
5511 static const int kFlagsNotUsedInLookup = 5548 static const int kFlagsNotUsedInLookup =
5512 TypeField::kMask | CacheHolderField::kMask; 5549 TypeField::kMask | CacheHolderField::kMask;
5513 5550
5514 private: 5551 private:
5515 friend class RelocIterator; 5552 friend class RelocIterator;
5516 5553
5554 void ClearInlineCaches(Kind* kind);
5555
5517 // Code aging 5556 // Code aging
5518 byte* FindCodeAgeSequence(); 5557 byte* FindCodeAgeSequence();
5519 static void GetCodeAgeAndParity(Code* code, Age* age, 5558 static void GetCodeAgeAndParity(Code* code, Age* age,
5520 MarkingParity* parity); 5559 MarkingParity* parity);
5521 static void GetCodeAgeAndParity(byte* sequence, Age* age, 5560 static void GetCodeAgeAndParity(byte* sequence, Age* age,
5522 MarkingParity* parity); 5561 MarkingParity* parity);
5523 static Code* GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity); 5562 static Code* GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity);
5524 5563
5525 // Code aging -- platform-specific 5564 // Code aging -- platform-specific
5526 static void PatchPlatformCodeAge(Isolate* isolate, 5565 static void PatchPlatformCodeAge(Isolate* isolate,
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
5798 } 5837 }
5799 5838
5800 inline bool has_slow_elements_kind() { 5839 inline bool has_slow_elements_kind() {
5801 return elements_kind() == DICTIONARY_ELEMENTS 5840 return elements_kind() == DICTIONARY_ELEMENTS
5802 || elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS; 5841 || elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS;
5803 } 5842 }
5804 5843
5805 static bool IsValidElementsTransition(ElementsKind from_kind, 5844 static bool IsValidElementsTransition(ElementsKind from_kind,
5806 ElementsKind to_kind); 5845 ElementsKind to_kind);
5807 5846
5847 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a
5848 // map with DICTIONARY_ELEMENTS was found in the prototype chain.
5849 bool DictionaryElementsInPrototypeChainOnly();
5850
5808 inline bool HasTransitionArray(); 5851 inline bool HasTransitionArray();
5809 inline bool HasElementsTransition(); 5852 inline bool HasElementsTransition();
5810 inline Map* elements_transition_map(); 5853 inline Map* elements_transition_map();
5811 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( 5854 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map(
5812 Map* transitioned_map); 5855 Map* transitioned_map);
5813 inline void SetTransition(int transition_index, Map* target); 5856 inline void SetTransition(int transition_index, Map* target);
5814 inline Map* GetTransition(int transition_index); 5857 inline Map* GetTransition(int transition_index);
5815 5858
5816 static Handle<TransitionArray> AddTransition(Handle<Map> map, 5859 static Handle<TransitionArray> AddTransition(Handle<Map> map,
5817 Handle<Name> key, 5860 Handle<Name> key,
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
7272 inline FixedArray* literals(); 7315 inline FixedArray* literals();
7273 inline void set_literals(FixedArray* literals); 7316 inline void set_literals(FixedArray* literals);
7274 7317
7275 inline FixedArray* function_bindings(); 7318 inline FixedArray* function_bindings();
7276 inline void set_function_bindings(FixedArray* bindings); 7319 inline void set_function_bindings(FixedArray* bindings);
7277 7320
7278 // The initial map for an object created by this constructor. 7321 // The initial map for an object created by this constructor.
7279 inline Map* initial_map(); 7322 inline Map* initial_map();
7280 inline void set_initial_map(Map* value); 7323 inline void set_initial_map(Map* value);
7281 inline bool has_initial_map(); 7324 inline bool has_initial_map();
7325 static void EnsureHasInitialMap(Handle<JSFunction> function);
7282 7326
7283 // Get and set the prototype property on a JSFunction. If the 7327 // Get and set the prototype property on a JSFunction. If the
7284 // function has an initial map the prototype is set on the initial 7328 // function has an initial map the prototype is set on the initial
7285 // map. Otherwise, the prototype is put in the initial map field 7329 // map. Otherwise, the prototype is put in the initial map field
7286 // until an initial map is needed. 7330 // until an initial map is needed.
7287 inline bool has_prototype(); 7331 inline bool has_prototype();
7288 inline bool has_instance_prototype(); 7332 inline bool has_instance_prototype();
7289 inline Object* prototype(); 7333 inline Object* prototype();
7290 inline Object* instance_prototype(); 7334 inline Object* instance_prototype();
7291 static void SetPrototype(Handle<JSFunction> function, 7335 static void SetPrototype(Handle<JSFunction> function,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
7422 7466
7423 // This is like GetProperty, but is used when you know the lookup won't fail 7467 // This is like GetProperty, but is used when you know the lookup won't fail
7424 // by throwing an exception. This is for the debug and builtins global 7468 // by throwing an exception. This is for the debug and builtins global
7425 // objects, where it is known which properties can be expected to be present 7469 // objects, where it is known which properties can be expected to be present
7426 // on the object. 7470 // on the object.
7427 Object* GetPropertyNoExceptionThrown(Name* key) { 7471 Object* GetPropertyNoExceptionThrown(Name* key) {
7428 Object* answer = GetProperty(key)->ToObjectUnchecked(); 7472 Object* answer = GetProperty(key)->ToObjectUnchecked();
7429 return answer; 7473 return answer;
7430 } 7474 }
7431 7475
7432 // Ensure that the global object has a cell for the given property name.
7433 static Handle<PropertyCell> EnsurePropertyCell(Handle<GlobalObject> global,
7434 Handle<Name> name);
7435
7436 // Casting. 7476 // Casting.
7437 static inline GlobalObject* cast(Object* obj); 7477 static inline GlobalObject* cast(Object* obj);
7438 7478
7439 // Layout description. 7479 // Layout description.
7440 static const int kBuiltinsOffset = JSObject::kHeaderSize; 7480 static const int kBuiltinsOffset = JSObject::kHeaderSize;
7441 static const int kNativeContextOffset = kBuiltinsOffset + kPointerSize; 7481 static const int kNativeContextOffset = kBuiltinsOffset + kPointerSize;
7442 static const int kGlobalContextOffset = kNativeContextOffset + kPointerSize; 7482 static const int kGlobalContextOffset = kNativeContextOffset + kPointerSize;
7443 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; 7483 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize;
7444 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; 7484 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize;
7445 7485
7446 private: 7486 private:
7447 DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject); 7487 DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject);
7448 }; 7488 };
7449 7489
7450 7490
7451 // JavaScript global object. 7491 // JavaScript global object.
7452 class JSGlobalObject: public GlobalObject { 7492 class JSGlobalObject: public GlobalObject {
7453 public: 7493 public:
7454 // Casting. 7494 // Casting.
7455 static inline JSGlobalObject* cast(Object* obj); 7495 static inline JSGlobalObject* cast(Object* obj);
7456 7496
7497 // Ensure that the global object has a cell for the given property name.
7498 static Handle<PropertyCell> EnsurePropertyCell(Handle<JSGlobalObject> global,
7499 Handle<Name> name);
7500
7457 // Dispatched behavior. 7501 // Dispatched behavior.
7458 DECLARE_PRINTER(JSGlobalObject) 7502 DECLARE_PRINTER(JSGlobalObject)
7459 DECLARE_VERIFIER(JSGlobalObject) 7503 DECLARE_VERIFIER(JSGlobalObject)
7460 7504
7461 // Layout description. 7505 // Layout description.
7462 static const int kSize = GlobalObject::kHeaderSize; 7506 static const int kSize = GlobalObject::kHeaderSize;
7463 7507
7464 private: 7508 private:
7465 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalObject); 7509 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalObject);
7466 }; 7510 };
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after
9390 static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name); 9434 static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name);
9391 static bool HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index); 9435 static bool HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index);
9392 9436
9393 static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy, 9437 static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy,
9394 Handle<Name> name, 9438 Handle<Name> name,
9395 DeleteMode mode); 9439 DeleteMode mode);
9396 static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy, 9440 static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy,
9397 uint32_t index, 9441 uint32_t index,
9398 DeleteMode mode); 9442 DeleteMode mode);
9399 9443
9400 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); 9444 MUST_USE_RESULT Object* GetIdentityHash();
9401 static Handle<Object> GetIdentityHash(Handle<JSProxy> proxy, 9445
9402 CreationFlag flag); 9446 static Handle<Object> GetOrCreateIdentityHash(Handle<JSProxy> proxy);
9403 9447
9404 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); 9448 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
9405 }; 9449 };
9406 9450
9407 9451
9408 class JSFunctionProxy: public JSProxy { 9452 class JSFunctionProxy: public JSProxy {
9409 public: 9453 public:
9410 // [call_trap]: The call trap. 9454 // [call_trap]: The call trap.
9411 DECL_ACCESSORS(call_trap, Object) 9455 DECL_ACCESSORS(call_trap, Object)
9412 9456
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
10480 } else { 10524 } else {
10481 value &= ~(1 << bit_position); 10525 value &= ~(1 << bit_position);
10482 } 10526 }
10483 return value; 10527 return value;
10484 } 10528 }
10485 }; 10529 };
10486 10530
10487 } } // namespace v8::internal 10531 } } // namespace v8::internal
10488 10532
10489 #endif // V8_OBJECTS_H_ 10533 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/object-observe.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698