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 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 2766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 template <SearchMode search_mode, typename T> | 2777 template <SearchMode search_mode, typename T> |
2778 int BinarySearch(T* array, Name* name, int low, int high, int valid_entries, | 2778 int BinarySearch(T* array, Name* name, int low, int high, int valid_entries, |
2779 int* out_insertion_index) { | 2779 int* out_insertion_index) { |
2780 DCHECK(search_mode == ALL_ENTRIES || out_insertion_index == NULL); | 2780 DCHECK(search_mode == ALL_ENTRIES || out_insertion_index == NULL); |
2781 uint32_t hash = name->Hash(); | 2781 uint32_t hash = name->Hash(); |
2782 int limit = high; | 2782 int limit = high; |
2783 | 2783 |
2784 DCHECK(low <= high); | 2784 DCHECK(low <= high); |
2785 | 2785 |
2786 while (low != high) { | 2786 while (low != high) { |
2787 int mid = (low + high) / 2; | 2787 int mid = low + (high - low) / 2; |
2788 Name* mid_name = array->GetSortedKey(mid); | 2788 Name* mid_name = array->GetSortedKey(mid); |
2789 uint32_t mid_hash = mid_name->Hash(); | 2789 uint32_t mid_hash = mid_name->Hash(); |
2790 | 2790 |
2791 if (mid_hash >= hash) { | 2791 if (mid_hash >= hash) { |
2792 high = mid; | 2792 high = mid; |
2793 } else { | 2793 } else { |
2794 low = mid + 1; | 2794 low = mid + 1; |
2795 } | 2795 } |
2796 } | 2796 } |
2797 | 2797 |
(...skipping 5088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7886 #undef READ_INT64_FIELD | 7886 #undef READ_INT64_FIELD |
7887 #undef WRITE_INT64_FIELD | 7887 #undef WRITE_INT64_FIELD |
7888 #undef READ_BYTE_FIELD | 7888 #undef READ_BYTE_FIELD |
7889 #undef WRITE_BYTE_FIELD | 7889 #undef WRITE_BYTE_FIELD |
7890 #undef NOBARRIER_READ_BYTE_FIELD | 7890 #undef NOBARRIER_READ_BYTE_FIELD |
7891 #undef NOBARRIER_WRITE_BYTE_FIELD | 7891 #undef NOBARRIER_WRITE_BYTE_FIELD |
7892 | 7892 |
7893 } } // namespace v8::internal | 7893 } } // namespace v8::internal |
7894 | 7894 |
7895 #endif // V8_OBJECTS_INL_H_ | 7895 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |