| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, | 1213 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, |
| 1214 uint32_t index, Handle<Object> value, LanguageMode language_mode); | 1214 uint32_t index, Handle<Object> value, LanguageMode language_mode); |
| 1215 | 1215 |
| 1216 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( | 1216 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( |
| 1217 Isolate* isolate, Handle<Object> receiver); | 1217 Isolate* isolate, Handle<Object> receiver); |
| 1218 | 1218 |
| 1219 // Returns the permanent hash code associated with this object. May return | 1219 // Returns the permanent hash code associated with this object. May return |
| 1220 // undefined if not yet created. | 1220 // undefined if not yet created. |
| 1221 Object* GetHash(); | 1221 Object* GetHash(); |
| 1222 | 1222 |
| 1223 // Returns undefined for JSObjects, but returns the hash code for simple |
| 1224 // objects. This avoids a double lookup in the cases where we know we will |
| 1225 // add the hash to the JSObject if it does not already exist. |
| 1226 Object* GetSimpleHash(); |
| 1227 |
| 1223 // Returns the permanent hash code associated with this object depending on | 1228 // Returns the permanent hash code associated with this object depending on |
| 1224 // the actual object type. May create and store a hash code if needed and none | 1229 // the actual object type. May create and store a hash code if needed and none |
| 1225 // exists. | 1230 // exists. |
| 1226 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object); | 1231 static Handle<Smi> GetOrCreateHash(Isolate* isolate, Handle<Object> object); |
| 1227 | 1232 |
| 1228 // Checks whether this object has the same value as the given one. This | 1233 // Checks whether this object has the same value as the given one. This |
| 1229 // function is implemented according to ES5, section 9.12 and can be used | 1234 // function is implemented according to ES5, section 9.12 and can be used |
| 1230 // to implement the Harmony "egal" function. | 1235 // to implement the Harmony "egal" function. |
| 1231 bool SameValue(Object* other); | 1236 bool SameValue(Object* other); |
| 1232 | 1237 |
| (...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3429 PretenureFlag pretenure = NOT_TENURED); | 3434 PretenureFlag pretenure = NOT_TENURED); |
| 3430 | 3435 |
| 3431 DECLARE_CAST(HashTable) | 3436 DECLARE_CAST(HashTable) |
| 3432 | 3437 |
| 3433 // Garbage collection support. | 3438 // Garbage collection support. |
| 3434 void IteratePrefix(ObjectVisitor* visitor); | 3439 void IteratePrefix(ObjectVisitor* visitor); |
| 3435 void IterateElements(ObjectVisitor* visitor); | 3440 void IterateElements(ObjectVisitor* visitor); |
| 3436 | 3441 |
| 3437 // Find entry for key otherwise return kNotFound. | 3442 // Find entry for key otherwise return kNotFound. |
| 3438 inline int FindEntry(Key key); | 3443 inline int FindEntry(Key key); |
| 3444 inline int FindEntry(Isolate* isolate, Key key, int32_t hash); |
| 3439 int FindEntry(Isolate* isolate, Key key); | 3445 int FindEntry(Isolate* isolate, Key key); |
| 3440 | 3446 |
| 3441 // Rehashes the table in-place. | 3447 // Rehashes the table in-place. |
| 3442 void Rehash(Key key); | 3448 void Rehash(Key key); |
| 3443 | 3449 |
| 3444 // Returns the key at entry. | 3450 // Returns the key at entry. |
| 3445 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } | 3451 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } |
| 3446 | 3452 |
| 3447 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; | 3453 static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; |
| 3448 static const int kEntrySize = Shape::kEntrySize; | 3454 static const int kEntrySize = Shape::kEntrySize; |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3935 DECLARE_CAST(ObjectHashTable) | 3941 DECLARE_CAST(ObjectHashTable) |
| 3936 | 3942 |
| 3937 // Attempt to shrink hash table after removal of key. | 3943 // Attempt to shrink hash table after removal of key. |
| 3938 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( | 3944 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( |
| 3939 Handle<ObjectHashTable> table, | 3945 Handle<ObjectHashTable> table, |
| 3940 Handle<Object> key); | 3946 Handle<Object> key); |
| 3941 | 3947 |
| 3942 // Looks up the value associated with the given key. The hole value is | 3948 // Looks up the value associated with the given key. The hole value is |
| 3943 // returned in case the key is not present. | 3949 // returned in case the key is not present. |
| 3944 Object* Lookup(Handle<Object> key); | 3950 Object* Lookup(Handle<Object> key); |
| 3951 Object* Lookup(Handle<Object> key, int32_t hash); |
| 3945 | 3952 |
| 3946 // Adds (or overwrites) the value associated with the given key. | 3953 // Adds (or overwrites) the value associated with the given key. |
| 3947 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, | 3954 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
| 3948 Handle<Object> key, | 3955 Handle<Object> key, |
| 3949 Handle<Object> value); | 3956 Handle<Object> value); |
| 3957 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
| 3958 Handle<Object> key, Handle<Object> value, |
| 3959 int32_t hash); |
| 3950 | 3960 |
| 3951 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. | 3961 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. |
| 3952 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, | 3962 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, |
| 3953 Handle<Object> key, | 3963 Handle<Object> key, |
| 3954 bool* was_present); | 3964 bool* was_present); |
| 3965 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, |
| 3966 Handle<Object> key, bool* was_present, |
| 3967 int32_t hash); |
| 3955 | 3968 |
| 3956 private: | 3969 private: |
| 3957 friend class MarkCompactCollector; | 3970 friend class MarkCompactCollector; |
| 3958 | 3971 |
| 3959 void AddEntry(int entry, Object* key, Object* value); | 3972 void AddEntry(int entry, Object* key, Object* value); |
| 3960 void RemoveEntry(int entry); | 3973 void RemoveEntry(int entry); |
| 3961 | 3974 |
| 3962 // Returns the index to the value of an entry. | 3975 // Returns the index to the value of an entry. |
| 3963 static inline int EntryToValueIndex(int entry) { | 3976 static inline int EntryToValueIndex(int entry) { |
| 3964 return EntryToIndex(entry) + 1; | 3977 return EntryToIndex(entry) + 1; |
| (...skipping 7166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11131 } else { | 11144 } else { |
| 11132 value &= ~(1 << bit_position); | 11145 value &= ~(1 << bit_position); |
| 11133 } | 11146 } |
| 11134 return value; | 11147 return value; |
| 11135 } | 11148 } |
| 11136 }; | 11149 }; |
| 11137 | 11150 |
| 11138 } } // namespace v8::internal | 11151 } } // namespace v8::internal |
| 11139 | 11152 |
| 11140 #endif // V8_OBJECTS_H_ | 11153 #endif // V8_OBJECTS_H_ |
| OLD | NEW |