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

Side by Side Diff: src/objects.h

Issue 6489: Exclude the bit-field bits from string hash codes. String hash codes... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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/ic-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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2850 class String: public HeapObject { 2850 class String: public HeapObject {
2851 public: 2851 public:
2852 // Get and set the length of the string. 2852 // Get and set the length of the string.
2853 inline int length(); 2853 inline int length();
2854 inline void set_length(int value); 2854 inline void set_length(int value);
2855 2855
2856 // Get and set the uninterpreted length field of the string. Notice 2856 // Get and set the uninterpreted length field of the string. Notice
2857 // that the length field is also used to cache the hash value of 2857 // that the length field is also used to cache the hash value of
2858 // strings. In order to get or set the actual length of the string 2858 // strings. In order to get or set the actual length of the string
2859 // use the length() and set_length methods. 2859 // use the length() and set_length methods.
2860 inline int length_field(); 2860 inline uint32_t length_field();
2861 inline void set_length_field(int value); 2861 inline void set_length_field(uint32_t value);
2862 2862
2863 // Get and set individual two byte chars in the string. 2863 // Get and set individual two byte chars in the string.
2864 inline void Set(int index, uint16_t value); 2864 inline void Set(int index, uint16_t value);
2865 // Get individual two byte char in the string. Repeated calls 2865 // Get individual two byte char in the string. Repeated calls
2866 // to this method are not efficient unless the string is flat. 2866 // to this method are not efficient unless the string is flat.
2867 inline uint16_t Get(int index); 2867 inline uint16_t Get(int index);
2868 2868
2869 // Flatten the top level ConsString that is hiding behind this 2869 // Flatten the top level ConsString that is hiding behind this
2870 // string. This is a no-op unless the string is a ConsString or a 2870 // string. This is a no-op unless the string is a ConsString or a
2871 // SlicedString. Flatten mutates the ConsString and might return a 2871 // SlicedString. Flatten mutates the ConsString and might return a
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 // do any heap allocations. This is useful when printing stack traces. 2923 // do any heap allocations. This is useful when printing stack traces.
2924 SmartPointer<uc16> ToWideCString( 2924 SmartPointer<uc16> ToWideCString(
2925 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL); 2925 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL);
2926 2926
2927 // Tells whether the hash code has been computed. 2927 // Tells whether the hash code has been computed.
2928 inline bool HasHashCode(); 2928 inline bool HasHashCode();
2929 2929
2930 // Returns a hash value used for the property table 2930 // Returns a hash value used for the property table
2931 inline uint32_t Hash(); 2931 inline uint32_t Hash();
2932 2932
2933 static uint32_t ComputeHashCode(unibrow::CharacterStream* buffer, int length); 2933 static uint32_t ComputeLengthAndHashField(unibrow::CharacterStream* buffer,
2934 int length);
2935
2934 static bool ComputeArrayIndex(unibrow::CharacterStream* buffer, 2936 static bool ComputeArrayIndex(unibrow::CharacterStream* buffer,
2935 uint32_t* index, 2937 uint32_t* index,
2936 int length); 2938 int length);
2937 2939
2938 // Conversion. 2940 // Conversion.
2939 inline bool AsArrayIndex(uint32_t* index); 2941 inline bool AsArrayIndex(uint32_t* index);
2940 2942
2941 // Casting. 2943 // Casting.
2942 static inline String* cast(Object* obj); 2944 static inline String* cast(Object* obj);
2943 2945
(...skipping 30 matching lines...) Expand all
2974 static const int kLengthOffset = HeapObject::kHeaderSize; 2976 static const int kLengthOffset = HeapObject::kHeaderSize;
2975 static const int kSize = kLengthOffset + kIntSize; 2977 static const int kSize = kLengthOffset + kIntSize;
2976 2978
2977 // Limits on sizes of different types of strings. 2979 // Limits on sizes of different types of strings.
2978 static const int kMaxShortStringSize = 255; 2980 static const int kMaxShortStringSize = 255;
2979 static const int kMaxMediumStringSize = 65535; 2981 static const int kMaxMediumStringSize = 65535;
2980 2982
2981 // Max ascii char code. 2983 // Max ascii char code.
2982 static const int kMaxAsciiCharCode = 127; 2984 static const int kMaxAsciiCharCode = 127;
2983 2985
2984 // Shift constants for retriving length from length/hash field.
2985 static const int kShortLengthShift = 3 * kBitsPerByte;
2986 static const int kMediumLengthShift = 2 * kBitsPerByte;
2987 static const int kLongLengthShift = 2;
2988
2989 // Mask constant for checking if a string has a computed hash code 2986 // Mask constant for checking if a string has a computed hash code
2990 // and if it is an array index. The least significant bit indicates 2987 // and if it is an array index. The least significant bit indicates
2991 // whether a hash code has been computed. If the hash code has been 2988 // whether a hash code has been computed. If the hash code has been
2992 // computed the 2nd bit tells whether the string can be used as an 2989 // computed the 2nd bit tells whether the string can be used as an
2993 // array index. 2990 // array index.
2994 static const int kHashComputedMask = 1; 2991 static const int kHashComputedMask = 1;
2995 static const int kIsArrayIndexMask = 1 << 1; 2992 static const int kIsArrayIndexMask = 1 << 1;
2993 static const int kNofLengthBitFields = 2;
2994
2995 // Shift constants for retriving length and hash code from
2996 // length/hash field.
2997 static const int kHashShift = kNofLengthBitFields;
2998 static const int kShortLengthShift = 3 * kBitsPerByte;
2999 static const int kMediumLengthShift = 2 * kBitsPerByte;
3000 static const int kLongLengthShift = kHashShift;
3001
2996 3002
2997 // Limit for truncation in short printing. 3003 // Limit for truncation in short printing.
2998 static const int kMaxShortPrintLength = 1024; 3004 static const int kMaxShortPrintLength = 1024;
2999 3005
3000 // Support for regular expressions. 3006 // Support for regular expressions.
3001 const uc16* GetTwoByteData(); 3007 const uc16* GetTwoByteData();
3002 const uc16* GetTwoByteData(unsigned start); 3008 const uc16* GetTwoByteData(unsigned start);
3003 3009
3004 // Support for StringInputBuffer 3010 // Support for StringInputBuffer
3005 static const unibrow::byte* ReadBlock(String* input, 3011 static const unibrow::byte* ReadBlock(String* input,
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
3910 } else { 3916 } else {
3911 value &= ~(1 << bit_position); 3917 value &= ~(1 << bit_position);
3912 } 3918 }
3913 return value; 3919 return value;
3914 } 3920 }
3915 }; 3921 };
3916 3922
3917 } } // namespace v8::internal 3923 } } // namespace v8::internal
3918 3924
3919 #endif // V8_OBJECTS_H_ 3925 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ic-ia32.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698