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 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 // Gives access to raw memory which stores the array's data. | 2461 // Gives access to raw memory which stores the array's data. |
2462 inline Object** data_start(); | 2462 inline Object** data_start(); |
2463 | 2463 |
2464 inline void FillWithHoles(int from, int to); | 2464 inline void FillWithHoles(int from, int to); |
2465 | 2465 |
2466 // Shrink length and insert filler objects. | 2466 // Shrink length and insert filler objects. |
2467 void Shrink(int length); | 2467 void Shrink(int length); |
2468 | 2468 |
2469 enum KeyFilter { ALL_KEYS, NON_SYMBOL_KEYS }; | 2469 enum KeyFilter { ALL_KEYS, NON_SYMBOL_KEYS }; |
2470 | 2470 |
2471 // Add the elements of a JSArray to this FixedArray. | |
2472 MUST_USE_RESULT static MaybeHandle<FixedArray> AddKeysFromArrayLike( | |
2473 Handle<FixedArray> content, Handle<JSObject> array, | |
2474 KeyFilter filter = ALL_KEYS); | |
2475 | |
2476 // Computes the union of keys and return the result. | 2471 // Computes the union of keys and return the result. |
2477 // Used for implementing "for (n in object) { }" | 2472 // Used for implementing "for (n in object) { }" |
2478 MUST_USE_RESULT static MaybeHandle<FixedArray> UnionOfKeys( | 2473 MUST_USE_RESULT static MaybeHandle<FixedArray> UnionOfKeys( |
2479 Handle<FixedArray> first, | 2474 Handle<FixedArray> first, |
2480 Handle<FixedArray> second); | 2475 Handle<FixedArray> second); |
2481 | 2476 |
2482 // Copy a sub array from the receiver to dest. | 2477 // Copy a sub array from the receiver to dest. |
2483 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); | 2478 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); |
2484 | 2479 |
2485 // Garbage collection support. | 2480 // Garbage collection support. |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3565 // Attempt to shrink hash table after removal of key. | 3560 // Attempt to shrink hash table after removal of key. |
3566 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( | 3561 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( |
3567 Handle<ObjectHashTable> table, | 3562 Handle<ObjectHashTable> table, |
3568 Handle<Object> key); | 3563 Handle<Object> key); |
3569 | 3564 |
3570 // Looks up the value associated with the given key. The hole value is | 3565 // Looks up the value associated with the given key. The hole value is |
3571 // returned in case the key is not present. | 3566 // returned in case the key is not present. |
3572 Object* Lookup(Handle<Object> key); | 3567 Object* Lookup(Handle<Object> key); |
3573 Object* Lookup(Handle<Object> key, int32_t hash); | 3568 Object* Lookup(Handle<Object> key, int32_t hash); |
3574 Object* Lookup(Isolate* isolate, Handle<Object> key, int32_t hash); | 3569 Object* Lookup(Isolate* isolate, Handle<Object> key, int32_t hash); |
| 3570 bool HasKey(Isolate* isolate, Handle<Object> key); |
3575 | 3571 |
3576 // Adds (or overwrites) the value associated with the given key. | 3572 // Adds (or overwrites) the value associated with the given key. |
3577 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, | 3573 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
3578 Handle<Object> key, | 3574 Handle<Object> key, |
3579 Handle<Object> value); | 3575 Handle<Object> value); |
3580 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, | 3576 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
3581 Handle<Object> key, Handle<Object> value, | 3577 Handle<Object> key, Handle<Object> value, |
3582 int32_t hash); | 3578 int32_t hash); |
| 3579 static Handle<ObjectHashTable> Put(Isolate* isolate, |
| 3580 Handle<ObjectHashTable> table, |
| 3581 Handle<Object> key, Handle<Object> value); |
| 3582 static Handle<ObjectHashTable> Put(Isolate* isolate, |
| 3583 Handle<ObjectHashTable> table, |
| 3584 Handle<Object> key, Handle<Object> value, |
| 3585 int32_t hash); |
3583 | 3586 |
3584 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. | 3587 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. |
3585 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, | 3588 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, |
3586 Handle<Object> key, | 3589 Handle<Object> key, |
3587 bool* was_present); | 3590 bool* was_present); |
3588 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, | 3591 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, |
3589 Handle<Object> key, bool* was_present, | 3592 Handle<Object> key, bool* was_present, |
3590 int32_t hash); | 3593 int32_t hash); |
3591 | 3594 |
3592 protected: | 3595 protected: |
(...skipping 6870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10463 static inline int set(int value, int bit_position, bool v) { | 10466 static inline int set(int value, int bit_position, bool v) { |
10464 if (v) { | 10467 if (v) { |
10465 value |= (1 << bit_position); | 10468 value |= (1 << bit_position); |
10466 } else { | 10469 } else { |
10467 value &= ~(1 << bit_position); | 10470 value &= ~(1 << bit_position); |
10468 } | 10471 } |
10469 return value; | 10472 return value; |
10470 } | 10473 } |
10471 }; | 10474 }; |
10472 | 10475 |
| 10476 |
| 10477 class KeyAccumulator final BASE_EMBEDDED { |
| 10478 public: |
| 10479 explicit KeyAccumulator(Isolate* isolate) |
| 10480 : isolate_(isolate), keys_(), set_(), length_(0) {} |
| 10481 |
| 10482 void AddKeys(Handle<FixedArray> array, FixedArray::KeyFilter filter); |
| 10483 void AddKeys(Handle<JSObject> array, FixedArray::KeyFilter filter); |
| 10484 Handle<FixedArray> GetKeys(); |
| 10485 int GetLength(); |
| 10486 bool HasKey(Handle<Object> key, int limit); |
| 10487 void AddKey(Handle<Object> key); |
| 10488 void PrepareForComparisons(int count); |
| 10489 |
| 10490 private: |
| 10491 void EnsureCapacity(int capacity); |
| 10492 void Grow(); |
| 10493 |
| 10494 Isolate* isolate_; |
| 10495 Handle<FixedArray> keys_; |
| 10496 Handle<ObjectHashTable> set_; |
| 10497 int length_; |
| 10498 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
| 10499 }; |
10473 } } // namespace v8::internal | 10500 } } // namespace v8::internal |
10474 | 10501 |
10475 #endif // V8_OBJECTS_H_ | 10502 #endif // V8_OBJECTS_H_ |
OLD | NEW |