OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 | 2502 |
2503 // HashTable is a subclass of FixedArray that implements a hash table | 2503 // HashTable is a subclass of FixedArray that implements a hash table |
2504 // that uses open addressing and quadratic probing. | 2504 // that uses open addressing and quadratic probing. |
2505 // | 2505 // |
2506 // In order for the quadratic probing to work, elements that have not | 2506 // In order for the quadratic probing to work, elements that have not |
2507 // yet been used and elements that have been deleted are | 2507 // yet been used and elements that have been deleted are |
2508 // distinguished. Probing continues when deleted elements are | 2508 // distinguished. Probing continues when deleted elements are |
2509 // encountered and stops when unused elements are encountered. | 2509 // encountered and stops when unused elements are encountered. |
2510 // | 2510 // |
2511 // - Elements with key == undefined have not been used yet. | 2511 // - Elements with key == undefined have not been used yet. |
2512 // - Elements with key == null have been deleted. | 2512 // - Elements with key == the_hole have been deleted. |
2513 // | 2513 // |
2514 // The hash table class is parameterized with a Shape and a Key. | 2514 // The hash table class is parameterized with a Shape and a Key. |
2515 // Shape must be a class with the following interface: | 2515 // Shape must be a class with the following interface: |
2516 // class ExampleShape { | 2516 // class ExampleShape { |
2517 // public: | 2517 // public: |
2518 // // Tells whether key matches other. | 2518 // // Tells whether key matches other. |
2519 // static bool IsMatch(Key key, Object* other); | 2519 // static bool IsMatch(Key key, Object* other); |
2520 // // Returns the hash value for key. | 2520 // // Returns the hash value for key. |
2521 // static uint32_t Hash(Key key); | 2521 // static uint32_t Hash(Key key); |
2522 // // Returns the hash value for object. | 2522 // // Returns the hash value for object. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 int at_least_space_for, | 2571 int at_least_space_for, |
2572 PretenureFlag pretenure = NOT_TENURED); | 2572 PretenureFlag pretenure = NOT_TENURED); |
2573 | 2573 |
2574 // Computes the required capacity for a table holding the given | 2574 // Computes the required capacity for a table holding the given |
2575 // number of elements. May be more than HashTable::kMaxCapacity. | 2575 // number of elements. May be more than HashTable::kMaxCapacity. |
2576 static int ComputeCapacity(int at_least_space_for); | 2576 static int ComputeCapacity(int at_least_space_for); |
2577 | 2577 |
2578 // Returns the key at entry. | 2578 // Returns the key at entry. |
2579 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } | 2579 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } |
2580 | 2580 |
2581 // Tells whether k is a real key. Null and undefined are not allowed | 2581 // Tells whether k is a real key. The hole and undefined are not allowed |
2582 // as keys and can be used to indicate missing or deleted elements. | 2582 // as keys and can be used to indicate missing or deleted elements. |
2583 bool IsKey(Object* k) { | 2583 bool IsKey(Object* k) { |
2584 return !k->IsNull() && !k->IsUndefined(); | 2584 return !k->IsTheHole() && !k->IsUndefined(); |
2585 } | 2585 } |
2586 | 2586 |
2587 // Garbage collection support. | 2587 // Garbage collection support. |
2588 void IteratePrefix(ObjectVisitor* visitor); | 2588 void IteratePrefix(ObjectVisitor* visitor); |
2589 void IterateElements(ObjectVisitor* visitor); | 2589 void IterateElements(ObjectVisitor* visitor); |
2590 | 2590 |
2591 // Casting. | 2591 // Casting. |
2592 static inline HashTable* cast(Object* obj); | 2592 static inline HashTable* cast(Object* obj); |
2593 | 2593 |
2594 // Compute the probe offset (quadratic probing). | 2594 // Compute the probe offset (quadratic probing). |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3043 Object* Lookup(Object* key); | 3043 Object* Lookup(Object* key); |
3044 | 3044 |
3045 // Adds (or overwrites) the value associated with the given key. Mapping a | 3045 // Adds (or overwrites) the value associated with the given key. Mapping a |
3046 // key to the undefined value causes removal of the whole entry. | 3046 // key to the undefined value causes removal of the whole entry. |
3047 MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value); | 3047 MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value); |
3048 | 3048 |
3049 private: | 3049 private: |
3050 friend class MarkCompactCollector; | 3050 friend class MarkCompactCollector; |
3051 | 3051 |
3052 void AddEntry(int entry, Object* key, Object* value); | 3052 void AddEntry(int entry, Object* key, Object* value); |
3053 void RemoveEntry(int entry, Heap* heap); | 3053 void RemoveEntry(int entry); |
3054 inline void RemoveEntry(int entry); | |
3055 | 3054 |
3056 // Returns the index to the value of an entry. | 3055 // Returns the index to the value of an entry. |
3057 static inline int EntryToValueIndex(int entry) { | 3056 static inline int EntryToValueIndex(int entry) { |
3058 return EntryToIndex(entry) + 1; | 3057 return EntryToIndex(entry) + 1; |
3059 } | 3058 } |
3060 }; | 3059 }; |
3061 | 3060 |
3062 | 3061 |
3063 // JSFunctionResultCache caches results of some JSFunction invocation. | 3062 // JSFunctionResultCache caches results of some JSFunction invocation. |
3064 // It is a fixed array with fixed structure: | 3063 // It is a fixed array with fixed structure: |
(...skipping 4008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7073 | 7072 |
7074 typedef FixedBodyDescriptor<kHandlerOffset, | 7073 typedef FixedBodyDescriptor<kHandlerOffset, |
7075 kConstructTrapOffset + kPointerSize, | 7074 kConstructTrapOffset + kPointerSize, |
7076 kSize> BodyDescriptor; | 7075 kSize> BodyDescriptor; |
7077 | 7076 |
7078 private: | 7077 private: |
7079 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); | 7078 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunctionProxy); |
7080 }; | 7079 }; |
7081 | 7080 |
7082 | 7081 |
7083 // The JSSet describes EcmaScript Harmony maps | 7082 // The JSSet describes EcmaScript Harmony sets |
7084 class JSSet: public JSObject { | 7083 class JSSet: public JSObject { |
7085 public: | 7084 public: |
7086 // [set]: the backing hash set containing keys. | 7085 // [set]: the backing hash set containing keys. |
7087 DECL_ACCESSORS(table, Object) | 7086 DECL_ACCESSORS(table, Object) |
7088 | 7087 |
7089 // Casting. | 7088 // Casting. |
7090 static inline JSSet* cast(Object* obj); | 7089 static inline JSSet* cast(Object* obj); |
7091 | 7090 |
7092 #ifdef OBJECT_PRINT | 7091 #ifdef OBJECT_PRINT |
7093 inline void JSSetPrint() { | 7092 inline void JSSetPrint() { |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7806 } else { | 7805 } else { |
7807 value &= ~(1 << bit_position); | 7806 value &= ~(1 << bit_position); |
7808 } | 7807 } |
7809 return value; | 7808 return value; |
7810 } | 7809 } |
7811 }; | 7810 }; |
7812 | 7811 |
7813 } } // namespace v8::internal | 7812 } } // namespace v8::internal |
7814 | 7813 |
7815 #endif // V8_OBJECTS_H_ | 7814 #endif // V8_OBJECTS_H_ |
OLD | NEW |