| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 OMIT_CREATION | 170 OMIT_CREATION |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 | 173 |
| 174 // Indicates whether transitions can be added to a source map or not. | 174 // Indicates whether transitions can be added to a source map or not. |
| 175 enum TransitionFlag { | 175 enum TransitionFlag { |
| 176 INSERT_TRANSITION, | 176 INSERT_TRANSITION, |
| 177 OMIT_TRANSITION | 177 OMIT_TRANSITION |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 | |
| 181 // Indicates whether the transition is simple: the target map of the transition | |
| 182 // either extends the current map with a new property, or it modifies the | |
| 183 // property that was added last to the current map. | |
| 184 enum SimpleTransitionFlag { | |
| 185 SIMPLE_TRANSITION, | |
| 186 FULL_TRANSITION | |
| 187 }; | |
| 188 | |
| 189 | |
| 190 // Indicates whether we are only interested in the descriptors of a particular | 180 // Indicates whether we are only interested in the descriptors of a particular |
| 191 // map, or in all descriptors in the descriptor array. | 181 // map, or in all descriptors in the descriptor array. |
| 192 enum DescriptorFlag { | 182 enum DescriptorFlag { |
| 193 ALL_DESCRIPTORS, | 183 ALL_DESCRIPTORS, |
| 194 OWN_DESCRIPTORS | 184 OWN_DESCRIPTORS |
| 195 }; | 185 }; |
| 196 | 186 |
| 197 | 187 |
| 198 // Instance size sentinel for objects of variable size. | 188 // Instance size sentinel for objects of variable size. |
| 199 const int kVariableSizeSentinel = 0; | 189 const int kVariableSizeSentinel = 0; |
| (...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 | 1680 |
| 1691 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 1681 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); |
| 1692 | 1682 |
| 1693 // Used from Object::GetProperty(). | 1683 // Used from Object::GetProperty(). |
| 1694 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 1684 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( |
| 1695 Object* receiver, | 1685 Object* receiver, |
| 1696 LookupResult* result, | 1686 LookupResult* result, |
| 1697 String* name, | 1687 String* name, |
| 1698 PropertyAttributes* attributes); | 1688 PropertyAttributes* attributes); |
| 1699 MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor( | 1689 MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor( |
| 1700 Object* receiver, | 1690 JSReceiver* receiver, |
| 1701 String* name, | 1691 String* name, |
| 1702 PropertyAttributes* attributes); | 1692 PropertyAttributes* attributes); |
| 1703 MUST_USE_RESULT MaybeObject* GetPropertyPostInterceptor( | 1693 MUST_USE_RESULT MaybeObject* GetPropertyPostInterceptor( |
| 1704 Object* receiver, | 1694 JSReceiver* receiver, |
| 1705 String* name, | 1695 String* name, |
| 1706 PropertyAttributes* attributes); | 1696 PropertyAttributes* attributes); |
| 1707 MUST_USE_RESULT MaybeObject* GetLocalPropertyPostInterceptor( | 1697 MUST_USE_RESULT MaybeObject* GetLocalPropertyPostInterceptor( |
| 1708 Object* receiver, | 1698 JSReceiver* receiver, |
| 1709 String* name, | 1699 String* name, |
| 1710 PropertyAttributes* attributes); | 1700 PropertyAttributes* attributes); |
| 1711 | 1701 |
| 1712 // Returns true if this is an instance of an api function and has | 1702 // Returns true if this is an instance of an api function and has |
| 1713 // been modified since it was created. May give false positives. | 1703 // been modified since it was created. May give false positives. |
| 1714 bool IsDirty(); | 1704 bool IsDirty(); |
| 1715 | 1705 |
| 1716 // If the receiver is a JSGlobalProxy this method will return its prototype, | 1706 // If the receiver is a JSGlobalProxy this method will return its prototype, |
| 1717 // otherwise the result is the receiver itself. | 1707 // otherwise the result is the receiver itself. |
| 1718 inline Object* BypassGlobalProxy(); | 1708 inline Object* BypassGlobalProxy(); |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2487 | 2477 |
| 2488 // Returns true for both shared empty_descriptor_array and for smis, which the | 2478 // Returns true for both shared empty_descriptor_array and for smis, which the |
| 2489 // map uses to encode additional bit fields when the descriptor array is not | 2479 // map uses to encode additional bit fields when the descriptor array is not |
| 2490 // yet used. | 2480 // yet used. |
| 2491 inline bool IsEmpty(); | 2481 inline bool IsEmpty(); |
| 2492 | 2482 |
| 2493 // Returns the number of descriptors in the array. | 2483 // Returns the number of descriptors in the array. |
| 2494 int number_of_descriptors() { | 2484 int number_of_descriptors() { |
| 2495 ASSERT(length() >= kFirstIndex || IsEmpty()); | 2485 ASSERT(length() >= kFirstIndex || IsEmpty()); |
| 2496 int len = length(); | 2486 int len = length(); |
| 2497 return len == 0 ? 0 : Smi::cast(get(kDescriptorLengthIndex))->value(); | 2487 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kDescriptorSize; |
| 2498 } | 2488 } |
| 2499 | 2489 |
| 2500 int number_of_descriptors_storage() { | |
| 2501 int len = length(); | |
| 2502 return len == 0 ? 0 : (len - kFirstIndex) / kDescriptorSize; | |
| 2503 } | |
| 2504 | |
| 2505 int NumberOfSlackDescriptors() { | |
| 2506 return number_of_descriptors_storage() - number_of_descriptors(); | |
| 2507 } | |
| 2508 | |
| 2509 inline void SetNumberOfDescriptors(int number_of_descriptors); | |
| 2510 inline int number_of_entries() { return number_of_descriptors(); } | 2490 inline int number_of_entries() { return number_of_descriptors(); } |
| 2511 | 2491 |
| 2512 bool HasEnumCache() { | 2492 bool HasEnumCache() { |
| 2513 return !IsEmpty() && !get(kEnumCacheIndex)->IsSmi(); | 2493 return !IsEmpty() && !get(kEnumCacheIndex)->IsSmi(); |
| 2514 } | 2494 } |
| 2515 | 2495 |
| 2516 void CopyEnumCacheFrom(DescriptorArray* array) { | 2496 void CopyEnumCacheFrom(DescriptorArray* array) { |
| 2517 set(kEnumCacheIndex, array->get(kEnumCacheIndex)); | 2497 set(kEnumCacheIndex, array->get(kEnumCacheIndex)); |
| 2518 } | 2498 } |
| 2519 | 2499 |
| 2520 FixedArray* GetEnumCache() { | 2500 Object* GetEnumCache() { |
| 2521 ASSERT(HasEnumCache()); | 2501 ASSERT(HasEnumCache()); |
| 2522 FixedArray* bridge = FixedArray::cast(get(kEnumCacheIndex)); | 2502 FixedArray* bridge = FixedArray::cast(get(kEnumCacheIndex)); |
| 2523 return FixedArray::cast(bridge->get(kEnumCacheBridgeCacheIndex)); | 2503 return bridge->get(kEnumCacheBridgeCacheIndex); |
| 2524 } | |
| 2525 | |
| 2526 bool HasEnumIndicesCache() { | |
| 2527 if (IsEmpty()) return false; | |
| 2528 Object* object = get(kEnumCacheIndex); | |
| 2529 if (object->IsSmi()) return false; | |
| 2530 FixedArray* bridge = FixedArray::cast(object); | |
| 2531 return !bridge->get(kEnumCacheBridgeIndicesCacheIndex)->IsSmi(); | |
| 2532 } | |
| 2533 | |
| 2534 FixedArray* GetEnumIndicesCache() { | |
| 2535 ASSERT(HasEnumIndicesCache()); | |
| 2536 FixedArray* bridge = FixedArray::cast(get(kEnumCacheIndex)); | |
| 2537 return FixedArray::cast(bridge->get(kEnumCacheBridgeIndicesCacheIndex)); | |
| 2538 } | 2504 } |
| 2539 | 2505 |
| 2540 Object** GetEnumCacheSlot() { | 2506 Object** GetEnumCacheSlot() { |
| 2541 ASSERT(HasEnumCache()); | 2507 ASSERT(HasEnumCache()); |
| 2542 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), | 2508 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), |
| 2543 kEnumCacheOffset); | 2509 kEnumCacheOffset); |
| 2544 } | 2510 } |
| 2545 | 2511 |
| 2546 void ClearEnumCache(); | 2512 void ClearEnumCache(); |
| 2547 | 2513 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2565 | 2531 |
| 2566 inline String* GetSortedKey(int descriptor_number); | 2532 inline String* GetSortedKey(int descriptor_number); |
| 2567 inline int GetSortedKeyIndex(int descriptor_number); | 2533 inline int GetSortedKeyIndex(int descriptor_number); |
| 2568 inline void SetSortedKey(int pointer, int descriptor_number); | 2534 inline void SetSortedKey(int pointer, int descriptor_number); |
| 2569 | 2535 |
| 2570 // Accessor for complete descriptor. | 2536 // Accessor for complete descriptor. |
| 2571 inline void Get(int descriptor_number, Descriptor* desc); | 2537 inline void Get(int descriptor_number, Descriptor* desc); |
| 2572 inline void Set(int descriptor_number, | 2538 inline void Set(int descriptor_number, |
| 2573 Descriptor* desc, | 2539 Descriptor* desc, |
| 2574 const WhitenessWitness&); | 2540 const WhitenessWitness&); |
| 2575 inline void Set(int descriptor_number, Descriptor* desc); | |
| 2576 inline void EraseDescriptor(Heap* heap, int descriptor_number); | |
| 2577 | 2541 |
| 2578 // Append automatically sets the enumeration index. This should only be used | 2542 // Append automatically sets the enumeration index. This should only be used |
| 2579 // to add descriptors in bulk at the end, followed by sorting the descriptor | 2543 // to add descriptors in bulk at the end, followed by sorting the descriptor |
| 2580 // array. | 2544 // array. |
| 2581 inline void Append(Descriptor* desc, const WhitenessWitness&); | 2545 inline void Append(Descriptor* desc, |
| 2582 inline void Append(Descriptor* desc); | 2546 const WhitenessWitness&, |
| 2547 int number_of_set_descriptors); |
| 2583 | 2548 |
| 2584 // Transfer a complete descriptor from the src descriptor array to this | 2549 // Transfer a complete descriptor from the src descriptor array to this |
| 2585 // descriptor array. | 2550 // descriptor array. |
| 2586 void CopyFrom(int dst_index, | 2551 void CopyFrom(int dst_index, |
| 2587 DescriptorArray* src, | 2552 DescriptorArray* src, |
| 2588 int src_index, | 2553 int src_index, |
| 2589 const WhitenessWitness&); | 2554 const WhitenessWitness&); |
| 2590 | 2555 |
| 2591 MUST_USE_RESULT MaybeObject* CopyUpTo(int enumeration_index); | 2556 MUST_USE_RESULT MaybeObject* CopyUpTo(int enumeration_index); |
| 2592 | 2557 |
| 2593 // Sort the instance descriptors by the hash codes of their keys. | 2558 // Sort the instance descriptors by the hash codes of their keys. |
| 2594 void Sort(); | 2559 void Sort(); |
| 2595 | 2560 |
| 2596 // Search the instance descriptors for given name. | 2561 // Search the instance descriptors for given name. |
| 2597 INLINE(int Search(String* name, int number_of_own_descriptors)); | 2562 INLINE(int Search(String* name, int number_of_own_descriptors)); |
| 2598 | 2563 |
| 2599 // As the above, but uses DescriptorLookupCache and updates it when | 2564 // As the above, but uses DescriptorLookupCache and updates it when |
| 2600 // necessary. | 2565 // necessary. |
| 2601 INLINE(int SearchWithCache(String* name, Map* map)); | 2566 INLINE(int SearchWithCache(String* name, Map* map)); |
| 2602 | 2567 |
| 2603 // Allocates a DescriptorArray, but returns the singleton | 2568 // Allocates a DescriptorArray, but returns the singleton |
| 2604 // empty descriptor array object if number_of_descriptors is 0. | 2569 // empty descriptor array object if number_of_descriptors is 0. |
| 2605 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, | 2570 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors); |
| 2606 int slack = 0); | |
| 2607 | 2571 |
| 2608 // Casting. | 2572 // Casting. |
| 2609 static inline DescriptorArray* cast(Object* obj); | 2573 static inline DescriptorArray* cast(Object* obj); |
| 2610 | 2574 |
| 2611 // Constant for denoting key was not found. | 2575 // Constant for denoting key was not found. |
| 2612 static const int kNotFound = -1; | 2576 static const int kNotFound = -1; |
| 2613 | 2577 |
| 2614 static const int kDescriptorLengthIndex = 0; | 2578 static const int kEnumCacheIndex = 0; |
| 2615 static const int kEnumCacheIndex = 1; | 2579 static const int kFirstIndex = 1; |
| 2616 static const int kFirstIndex = 2; | |
| 2617 | 2580 |
| 2618 // The length of the "bridge" to the enum cache. | 2581 // The length of the "bridge" to the enum cache. |
| 2619 static const int kEnumCacheBridgeLength = 2; | 2582 static const int kEnumCacheBridgeLength = 2; |
| 2620 static const int kEnumCacheBridgeCacheIndex = 0; | 2583 static const int kEnumCacheBridgeCacheIndex = 0; |
| 2621 static const int kEnumCacheBridgeIndicesCacheIndex = 1; | 2584 static const int kEnumCacheBridgeIndicesCacheIndex = 1; |
| 2622 | 2585 |
| 2623 // Layout description. | 2586 // Layout description. |
| 2624 static const int kDescriptorLengthOffset = FixedArray::kHeaderSize; | 2587 static const int kEnumCacheOffset = FixedArray::kHeaderSize; |
| 2625 static const int kEnumCacheOffset = kDescriptorLengthOffset + kPointerSize; | |
| 2626 static const int kFirstOffset = kEnumCacheOffset + kPointerSize; | 2588 static const int kFirstOffset = kEnumCacheOffset + kPointerSize; |
| 2627 | 2589 |
| 2628 // Layout description for the bridge array. | 2590 // Layout description for the bridge array. |
| 2629 static const int kEnumCacheBridgeCacheOffset = FixedArray::kHeaderSize; | 2591 static const int kEnumCacheBridgeCacheOffset = FixedArray::kHeaderSize; |
| 2630 | 2592 |
| 2631 // Layout of descriptor. | 2593 // Layout of descriptor. |
| 2632 static const int kDescriptorKey = 0; | 2594 static const int kDescriptorKey = 0; |
| 2633 static const int kDescriptorDetails = 1; | 2595 static const int kDescriptorDetails = 1; |
| 2634 static const int kDescriptorValue = 2; | 2596 static const int kDescriptorValue = 2; |
| 2635 static const int kDescriptorSize = 3; | 2597 static const int kDescriptorSize = 3; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2906 set(kCapacityIndex, Smi::FromInt(capacity)); | 2868 set(kCapacityIndex, Smi::FromInt(capacity)); |
| 2907 } | 2869 } |
| 2908 | 2870 |
| 2909 | 2871 |
| 2910 // Returns probe entry. | 2872 // Returns probe entry. |
| 2911 static uint32_t GetProbe(uint32_t hash, uint32_t number, uint32_t size) { | 2873 static uint32_t GetProbe(uint32_t hash, uint32_t number, uint32_t size) { |
| 2912 ASSERT(IsPowerOf2(size)); | 2874 ASSERT(IsPowerOf2(size)); |
| 2913 return (hash + GetProbeOffset(number)) & (size - 1); | 2875 return (hash + GetProbeOffset(number)) & (size - 1); |
| 2914 } | 2876 } |
| 2915 | 2877 |
| 2916 inline static uint32_t FirstProbe(uint32_t hash, uint32_t size) { | 2878 static uint32_t FirstProbe(uint32_t hash, uint32_t size) { |
| 2917 return hash & (size - 1); | 2879 return hash & (size - 1); |
| 2918 } | 2880 } |
| 2919 | 2881 |
| 2920 inline static uint32_t NextProbe( | 2882 static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size) { |
| 2921 uint32_t last, uint32_t number, uint32_t size) { | |
| 2922 return (last + number) & (size - 1); | 2883 return (last + number) & (size - 1); |
| 2923 } | 2884 } |
| 2924 | 2885 |
| 2925 // Rehashes this hash-table into the new table. | 2886 // Rehashes this hash-table into the new table. |
| 2926 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); | 2887 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); |
| 2927 | 2888 |
| 2928 // Attempt to shrink hash table after removal of key. | 2889 // Attempt to shrink hash table after removal of key. |
| 2929 MUST_USE_RESULT MaybeObject* Shrink(Key key); | 2890 MUST_USE_RESULT MaybeObject* Shrink(Key key); |
| 2930 | 2891 |
| 2931 // Ensure enough space for n additional elements. | 2892 // Ensure enough space for n additional elements. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2998 // parameter. | 2959 // parameter. |
| 2999 bool LookupSymbolIfExists(String* str, String** symbol); | 2960 bool LookupSymbolIfExists(String* str, String** symbol); |
| 3000 bool LookupTwoCharsSymbolIfExists(uint32_t c1, uint32_t c2, String** symbol); | 2961 bool LookupTwoCharsSymbolIfExists(uint32_t c1, uint32_t c2, String** symbol); |
| 3001 | 2962 |
| 3002 // Casting. | 2963 // Casting. |
| 3003 static inline SymbolTable* cast(Object* obj); | 2964 static inline SymbolTable* cast(Object* obj); |
| 3004 | 2965 |
| 3005 private: | 2966 private: |
| 3006 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s); | 2967 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s); |
| 3007 | 2968 |
| 3008 template <bool seq_ascii> friend class JsonParser; | |
| 3009 | |
| 3010 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable); | 2969 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable); |
| 3011 }; | 2970 }; |
| 3012 | 2971 |
| 3013 | 2972 |
| 3014 class MapCacheShape : public BaseShape<HashTableKey*> { | 2973 class MapCacheShape : public BaseShape<HashTableKey*> { |
| 3015 public: | 2974 public: |
| 3016 static inline bool IsMatch(HashTableKey* key, Object* value) { | 2975 static inline bool IsMatch(HashTableKey* key, Object* value) { |
| 3017 return key->IsMatch(value); | 2976 return key->IsMatch(value); |
| 3018 } | 2977 } |
| 3019 static inline uint32_t Hash(HashTableKey* key) { | 2978 static inline uint32_t Hash(HashTableKey* key) { |
| (...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4842 ElementsKind to_kind); | 4801 ElementsKind to_kind); |
| 4843 | 4802 |
| 4844 bool StoresOwnDescriptors() { return HasTransitionArray(); } | 4803 bool StoresOwnDescriptors() { return HasTransitionArray(); } |
| 4845 inline bool HasTransitionArray(); | 4804 inline bool HasTransitionArray(); |
| 4846 inline bool HasElementsTransition(); | 4805 inline bool HasElementsTransition(); |
| 4847 inline Map* elements_transition_map(); | 4806 inline Map* elements_transition_map(); |
| 4848 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( | 4807 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( |
| 4849 Map* transitioned_map); | 4808 Map* transitioned_map); |
| 4850 inline void SetTransition(int transition_index, Map* target); | 4809 inline void SetTransition(int transition_index, Map* target); |
| 4851 inline Map* GetTransition(int transition_index); | 4810 inline Map* GetTransition(int transition_index); |
| 4852 MUST_USE_RESULT inline MaybeObject* AddTransition(String* key, | 4811 MUST_USE_RESULT inline MaybeObject* AddTransition(String* key, Map* target); |
| 4853 Map* target, | |
| 4854 SimpleTransitionFlag flag); | |
| 4855 DECL_ACCESSORS(transitions, TransitionArray) | 4812 DECL_ACCESSORS(transitions, TransitionArray) |
| 4856 inline void ClearTransitions(Heap* heap, | 4813 inline void ClearTransitions(Heap* heap, |
| 4857 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 4814 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| 4858 | 4815 |
| 4859 // Tells whether the map is attached to SharedFunctionInfo | 4816 // Tells whether the map is attached to SharedFunctionInfo |
| 4860 // (for inobject slack tracking). | 4817 // (for inobject slack tracking). |
| 4861 inline void set_attached_to_shared_function_info(bool value); | 4818 inline void set_attached_to_shared_function_info(bool value); |
| 4862 | 4819 |
| 4863 inline bool attached_to_shared_function_info(); | 4820 inline bool attached_to_shared_function_info(); |
| 4864 | 4821 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4995 | 4952 |
| 4996 inline bool owns_descriptors(); | 4953 inline bool owns_descriptors(); |
| 4997 inline void set_owns_descriptors(bool is_shared); | 4954 inline void set_owns_descriptors(bool is_shared); |
| 4998 | 4955 |
| 4999 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); | 4956 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); |
| 5000 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); | 4957 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); |
| 5001 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); | 4958 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); |
| 5002 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( | 4959 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( |
| 5003 DescriptorArray* descriptors, | 4960 DescriptorArray* descriptors, |
| 5004 String* name, | 4961 String* name, |
| 5005 TransitionFlag flag, | 4962 TransitionFlag flag); |
| 5006 int descriptor_index); | |
| 5007 MUST_USE_RESULT MaybeObject* ShareDescriptor(Descriptor* descriptor); | 4963 MUST_USE_RESULT MaybeObject* ShareDescriptor(Descriptor* descriptor); |
| 5008 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, | 4964 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, |
| 5009 TransitionFlag flag); | 4965 TransitionFlag flag); |
| 5010 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, | 4966 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, |
| 5011 TransitionFlag flag); | 4967 TransitionFlag flag); |
| 5012 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(Descriptor* descriptor, | 4968 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(Descriptor* descriptor, |
| 5013 int index, | 4969 int index, |
| 5014 TransitionFlag flag); | 4970 TransitionFlag flag); |
| 5015 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, | 4971 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, |
| 5016 TransitionFlag flag); | 4972 TransitionFlag flag); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5048 inline void ClearCodeCache(Heap* heap); | 5004 inline void ClearCodeCache(Heap* heap); |
| 5049 | 5005 |
| 5050 // Update code cache. | 5006 // Update code cache. |
| 5051 static void UpdateCodeCache(Handle<Map> map, | 5007 static void UpdateCodeCache(Handle<Map> map, |
| 5052 Handle<String> name, | 5008 Handle<String> name, |
| 5053 Handle<Code> code); | 5009 Handle<Code> code); |
| 5054 MUST_USE_RESULT MaybeObject* UpdateCodeCache(String* name, Code* code); | 5010 MUST_USE_RESULT MaybeObject* UpdateCodeCache(String* name, Code* code); |
| 5055 | 5011 |
| 5056 // Extend the descriptor array of the map with the list of descriptors. | 5012 // Extend the descriptor array of the map with the list of descriptors. |
| 5057 // In case of duplicates, the latest descriptor is used. | 5013 // In case of duplicates, the latest descriptor is used. |
| 5058 static void AppendCallbackDescriptors(Handle<Map> map, | 5014 static void CopyAppendCallbackDescriptors(Handle<Map> map, |
| 5059 Handle<Object> descriptors); | 5015 Handle<Object> descriptors); |
| 5060 | |
| 5061 static void EnsureDescriptorSlack(Handle<Map> map, int slack); | |
| 5062 | 5016 |
| 5063 // Returns the found code or undefined if absent. | 5017 // Returns the found code or undefined if absent. |
| 5064 Object* FindInCodeCache(String* name, Code::Flags flags); | 5018 Object* FindInCodeCache(String* name, Code::Flags flags); |
| 5065 | 5019 |
| 5066 // Returns the non-negative index of the code object if it is in the | 5020 // Returns the non-negative index of the code object if it is in the |
| 5067 // cache and -1 otherwise. | 5021 // cache and -1 otherwise. |
| 5068 int IndexInCodeCache(Object* name, Code* code); | 5022 int IndexInCodeCache(Object* name, Code* code); |
| 5069 | 5023 |
| 5070 // Removes a code object from the code cache at the given index. | 5024 // Removes a code object from the code cache at the given index. |
| 5071 void RemoveFromCodeCache(String* name, Code* code, int index); | 5025 void RemoveFromCodeCache(String* name, Code* code, int index); |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7050 void AddSurrogatePairNoIndex(uc32 c); | 7004 void AddSurrogatePairNoIndex(uc32 c); |
| 7051 | 7005 |
| 7052 // Returns the value to store in the hash field of a string with | 7006 // Returns the value to store in the hash field of a string with |
| 7053 // the given length and contents. | 7007 // the given length and contents. |
| 7054 uint32_t GetHashField(); | 7008 uint32_t GetHashField(); |
| 7055 | 7009 |
| 7056 // Returns true if the characters seen so far make up a legal array | 7010 // Returns true if the characters seen so far make up a legal array |
| 7057 // index. | 7011 // index. |
| 7058 bool is_array_index() { return is_array_index_; } | 7012 bool is_array_index() { return is_array_index_; } |
| 7059 | 7013 |
| 7014 bool is_valid() { return is_valid_; } |
| 7015 |
| 7016 void invalidate() { is_valid_ = false; } |
| 7017 |
| 7060 // Calculated hash value for a string consisting of 1 to | 7018 // Calculated hash value for a string consisting of 1 to |
| 7061 // String::kMaxArrayIndexSize digits with no leading zeros (except "0"). | 7019 // String::kMaxArrayIndexSize digits with no leading zeros (except "0"). |
| 7062 // value is represented decimal value. | 7020 // value is represented decimal value. |
| 7063 static uint32_t MakeArrayIndexHash(uint32_t value, int length); | 7021 static uint32_t MakeArrayIndexHash(uint32_t value, int length); |
| 7064 | 7022 |
| 7065 // No string is allowed to have a hash of zero. That value is reserved | 7023 // No string is allowed to have a hash of zero. That value is reserved |
| 7066 // for internal properties. If the hash calculation yields zero then we | 7024 // for internal properties. If the hash calculation yields zero then we |
| 7067 // use 27 instead. | 7025 // use 27 instead. |
| 7068 static const int kZeroHash = 27; | 7026 static const int kZeroHash = 27; |
| 7069 | 7027 |
| 7070 private: | 7028 private: |
| 7071 uint32_t array_index() { | 7029 uint32_t array_index() { |
| 7072 ASSERT(is_array_index()); | 7030 ASSERT(is_array_index()); |
| 7073 return array_index_; | 7031 return array_index_; |
| 7074 } | 7032 } |
| 7075 | 7033 |
| 7076 inline uint32_t GetHash(); | 7034 inline uint32_t GetHash(); |
| 7077 | 7035 |
| 7078 // Reusable parts of the hashing algorithm. | |
| 7079 INLINE(static uint32_t AddCharacterCore(uint32_t running_hash, uint32_t c)); | |
| 7080 INLINE(static uint32_t GetHashCore(uint32_t running_hash)); | |
| 7081 | |
| 7082 int length_; | 7036 int length_; |
| 7083 uint32_t raw_running_hash_; | 7037 uint32_t raw_running_hash_; |
| 7084 uint32_t array_index_; | 7038 uint32_t array_index_; |
| 7085 bool is_array_index_; | 7039 bool is_array_index_; |
| 7086 bool is_first_char_; | 7040 bool is_first_char_; |
| 7041 bool is_valid_; |
| 7087 friend class TwoCharHashTableKey; | 7042 friend class TwoCharHashTableKey; |
| 7088 | |
| 7089 template <bool seq_ascii> friend class JsonParser; | |
| 7090 }; | 7043 }; |
| 7091 | 7044 |
| 7092 | 7045 |
| 7093 class IncrementalAsciiStringHasher { | |
| 7094 public: | |
| 7095 explicit inline IncrementalAsciiStringHasher(uint32_t seed, char first_char); | |
| 7096 inline void AddCharacter(uc32 c); | |
| 7097 inline uint32_t GetHash(); | |
| 7098 | |
| 7099 private: | |
| 7100 int length_; | |
| 7101 uint32_t raw_running_hash_; | |
| 7102 uint32_t array_index_; | |
| 7103 bool is_array_index_; | |
| 7104 char first_char_; | |
| 7105 }; | |
| 7106 | |
| 7107 | |
| 7108 // Calculates string hash. | 7046 // Calculates string hash. |
| 7109 template <typename schar> | 7047 template <typename schar> |
| 7110 inline uint32_t HashSequentialString(const schar* chars, | 7048 inline uint32_t HashSequentialString(const schar* chars, |
| 7111 int length, | 7049 int length, |
| 7112 uint32_t seed); | 7050 uint32_t seed); |
| 7113 | 7051 |
| 7114 | 7052 |
| 7115 // The characteristics of a string are stored in its map. Retrieving these | 7053 // The characteristics of a string are stored in its map. Retrieving these |
| 7116 // few bits of information is moderately expensive, involving two memory | 7054 // few bits of information is moderately expensive, involving two memory |
| 7117 // loads where the second is dependent on the first. To improve efficiency | 7055 // loads where the second is dependent on the first. To improve efficiency |
| (...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9038 } else { | 8976 } else { |
| 9039 value &= ~(1 << bit_position); | 8977 value &= ~(1 << bit_position); |
| 9040 } | 8978 } |
| 9041 return value; | 8979 return value; |
| 9042 } | 8980 } |
| 9043 }; | 8981 }; |
| 9044 | 8982 |
| 9045 } } // namespace v8::internal | 8983 } } // namespace v8::internal |
| 9046 | 8984 |
| 9047 #endif // V8_OBJECTS_H_ | 8985 #endif // V8_OBJECTS_H_ |
| OLD | NEW |