Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: src/objects.h

Issue 300023011: Convert String array index/length hash to BitField (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "allocation.h" 8 #include "allocation.h"
9 #include "assert-scope.h" 9 #include "assert-scope.h"
10 #include "builtins.h" 10 #include "builtins.h"
(...skipping 8768 matching lines...) Expand 10 before | Expand all | Expand 10 after
8779 8779
8780 // For strings which are array indexes the hash value has the string length 8780 // For strings which are array indexes the hash value has the string length
8781 // mixed into the hash, mainly to avoid a hash value of zero which would be 8781 // mixed into the hash, mainly to avoid a hash value of zero which would be
8782 // the case for the string '0'. 24 bits are used for the array index value. 8782 // the case for the string '0'. 24 bits are used for the array index value.
8783 static const int kArrayIndexValueBits = 24; 8783 static const int kArrayIndexValueBits = 24;
8784 static const int kArrayIndexLengthBits = 8784 static const int kArrayIndexLengthBits =
8785 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields; 8785 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields;
8786 8786
8787 STATIC_CHECK((kArrayIndexLengthBits > 0)); 8787 STATIC_CHECK((kArrayIndexLengthBits > 0));
8788 8788
8789 static const int kArrayIndexHashLengthShift = 8789 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields,
8790 kArrayIndexValueBits + kNofHashBitFields; 8790 kArrayIndexValueBits> {};
8791 8791 class ArrayIndexLengthBits : public BitField<unsigned int,
8792 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1; 8792 kNofHashBitFields + kArrayIndexValueBits,
8793 8793 kArrayIndexLengthBits> {};
8794 static const int kArrayIndexValueMask =
8795 ((1 << kArrayIndexValueBits) - 1) << kHashShift;
8796 8794
8797 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we 8795 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we
8798 // could use a mask to test if the length of string is less than or equal to 8796 // could use a mask to test if the length of string is less than or equal to
8799 // kMaxCachedArrayIndexLength. 8797 // kMaxCachedArrayIndexLength.
8800 STATIC_CHECK(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1)); 8798 STATIC_CHECK(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1));
8801 8799
8802 static const unsigned int kContainsCachedArrayIndexMask = 8800 static const unsigned int kContainsCachedArrayIndexMask =
8803 (~kMaxCachedArrayIndexLength << kArrayIndexHashLengthShift) | 8801 (~kMaxCachedArrayIndexLength << ArrayIndexLengthBits::kShift) |
8804 kIsNotArrayIndexMask; 8802 kIsNotArrayIndexMask;
8805 8803
8806 // Value of empty hash field indicating that the hash is not computed. 8804 // Value of empty hash field indicating that the hash is not computed.
8807 static const int kEmptyHashField = 8805 static const int kEmptyHashField =
8808 kIsNotArrayIndexMask | kHashNotComputedMask; 8806 kIsNotArrayIndexMask | kHashNotComputedMask;
8809 8807
8810 protected: 8808 protected:
8811 static inline bool IsHashFieldComputed(uint32_t field); 8809 static inline bool IsHashFieldComputed(uint32_t field);
8812 8810
8813 private: 8811 private:
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
11063 } else { 11061 } else {
11064 value &= ~(1 << bit_position); 11062 value &= ~(1 << bit_position);
11065 } 11063 }
11066 return value; 11064 return value;
11067 } 11065 }
11068 }; 11066 };
11069 11067
11070 } } // namespace v8::internal 11068 } } // namespace v8::internal
11071 11069
11072 #endif // V8_OBJECTS_H_ 11070 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698