OLD | NEW |
---|---|
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 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1505 MUST_USE_RESULT MaybeObject* GetElementWithReceiver(Isolate* isolate, | 1505 MUST_USE_RESULT MaybeObject* GetElementWithReceiver(Isolate* isolate, |
1506 Object* receiver, | 1506 Object* receiver, |
1507 uint32_t index); | 1507 uint32_t index); |
1508 | 1508 |
1509 // Return the object's prototype (might be Heap::null_value()). | 1509 // Return the object's prototype (might be Heap::null_value()). |
1510 Object* GetPrototype(Isolate* isolate); | 1510 Object* GetPrototype(Isolate* isolate); |
1511 | 1511 |
1512 // Returns the permanent hash code associated with this object depending on | 1512 // Returns the permanent hash code associated with this object depending on |
1513 // the actual object type. Might return a failure in case no hash was | 1513 // the actual object type. Might return a failure in case no hash was |
1514 // created yet or GC was caused by creation. | 1514 // created yet or GC was caused by creation. |
1515 static Handle<Object> GetHash(Handle<Object> object, Isolate* isolate, | |
Michael Starzinger
2013/11/04 10:29:11
nit: The current implementation as a wrapper requi
rafaelw
2013/11/04 15:12:01
Done (although this todo is now on GetOrCreateHash
| |
1516 CreationFlag flag); | |
1517 | |
1515 MUST_USE_RESULT MaybeObject* GetHash(CreationFlag flag); | 1518 MUST_USE_RESULT MaybeObject* GetHash(CreationFlag flag); |
1516 | 1519 |
1517 // Checks whether this object has the same value as the given one. This | 1520 // Checks whether this object has the same value as the given one. This |
1518 // function is implemented according to ES5, section 9.12 and can be used | 1521 // function is implemented according to ES5, section 9.12 and can be used |
1519 // to implement the Harmony "egal" function. | 1522 // to implement the Harmony "egal" function. |
1520 bool SameValue(Object* other); | 1523 bool SameValue(Object* other); |
1521 | 1524 |
1522 // Tries to convert an object to an array index. Returns true and sets | 1525 // Tries to convert an object to an array index. Returns true and sets |
1523 // the output parameter if it succeeds. | 1526 // the output parameter if it succeeds. |
1524 inline bool ToArrayIndex(uint32_t* index); | 1527 inline bool ToArrayIndex(uint32_t* index); |
(...skipping 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4053 // ObjectHashSet holds keys that are arbitrary objects by using the identity | 4056 // ObjectHashSet holds keys that are arbitrary objects by using the identity |
4054 // hash of the key for hashing purposes. | 4057 // hash of the key for hashing purposes. |
4055 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> { | 4058 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> { |
4056 public: | 4059 public: |
4057 static inline ObjectHashSet* cast(Object* obj) { | 4060 static inline ObjectHashSet* cast(Object* obj) { |
4058 ASSERT(obj->IsHashTable()); | 4061 ASSERT(obj->IsHashTable()); |
4059 return reinterpret_cast<ObjectHashSet*>(obj); | 4062 return reinterpret_cast<ObjectHashSet*>(obj); |
4060 } | 4063 } |
4061 | 4064 |
4062 // Looks up whether the given key is part of this hash set. | 4065 // Looks up whether the given key is part of this hash set. |
4063 bool Contains(Object* key); | 4066 static bool Contains(Handle<ObjectHashSet> table, Handle<Object> key); |
Michael Starzinger
2013/11/04 10:29:11
The ObjectHashSet::Contains method should never ca
rafaelw
2013/11/04 15:12:01
Done.
| |
4067 | |
4068 static Handle<ObjectHashSet> EnsureSetCapacity( | |
rafaelw
2013/10/29 19:14:51
Note that I've named this "EnsureSetCapacity" beca
Michael Starzinger
2013/11/04 10:29:11
One way to address that I can think of would be to
rafaelw
2013/11/04 15:12:01
Done. Applied to ObjectHash(Set/Table)::(EnsureCap
| |
4069 Handle<ObjectHashSet> table, | |
4070 int n, | |
4071 Handle<Object> key, | |
4072 PretenureFlag pretenure = NOT_TENURED); | |
4073 | |
4074 // Attempt to shrink hash table after removal of key. | |
4075 static Handle<ObjectHashSet> ShrinkSet(Handle<ObjectHashSet> table, | |
4076 Handle<Object> key); | |
4064 | 4077 |
4065 // Adds the given key to this hash set. | 4078 // Adds the given key to this hash set. |
4066 MUST_USE_RESULT MaybeObject* Add(Object* key); | 4079 static Handle<ObjectHashSet> Add(Handle<ObjectHashSet> table, |
4080 Handle<Object> key); | |
4067 | 4081 |
4068 // Removes the given key from this hash set. | 4082 // Removes the given key from this hash set. |
4069 MUST_USE_RESULT MaybeObject* Remove(Object* key); | 4083 static Handle<ObjectHashSet> Remove(Handle<ObjectHashSet> table, |
4084 Handle<Object> key); | |
4070 }; | 4085 }; |
4071 | 4086 |
4072 | 4087 |
4073 // ObjectHashTable maps keys that are arbitrary objects to object values by | 4088 // ObjectHashTable maps keys that are arbitrary objects to object values by |
4074 // using the identity hash of the key for hashing purposes. | 4089 // using the identity hash of the key for hashing purposes. |
4075 class ObjectHashTable: public HashTable<ObjectHashTableShape<2>, Object*> { | 4090 class ObjectHashTable: public HashTable<ObjectHashTableShape<2>, Object*> { |
4076 public: | 4091 public: |
4077 static inline ObjectHashTable* cast(Object* obj) { | 4092 static inline ObjectHashTable* cast(Object* obj) { |
4078 ASSERT(obj->IsHashTable()); | 4093 ASSERT(obj->IsHashTable()); |
4079 return reinterpret_cast<ObjectHashTable*>(obj); | 4094 return reinterpret_cast<ObjectHashTable*>(obj); |
(...skipping 6360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10440 } else { | 10455 } else { |
10441 value &= ~(1 << bit_position); | 10456 value &= ~(1 << bit_position); |
10442 } | 10457 } |
10443 return value; | 10458 return value; |
10444 } | 10459 } |
10445 }; | 10460 }; |
10446 | 10461 |
10447 } } // namespace v8::internal | 10462 } } // namespace v8::internal |
10448 | 10463 |
10449 #endif // V8_OBJECTS_H_ | 10464 #endif // V8_OBJECTS_H_ |
OLD | NEW |