| OLD | NEW |
| 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 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 | 1900 |
| 1901 void ExternalAsciiString::set_resource( | 1901 void ExternalAsciiString::set_resource( |
| 1902 ExternalAsciiString::Resource* resource) { | 1902 ExternalAsciiString::Resource* resource) { |
| 1903 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; | 1903 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; |
| 1904 } | 1904 } |
| 1905 | 1905 |
| 1906 | 1906 |
| 1907 Map* ExternalAsciiString::StringMap(int length) { | 1907 Map* ExternalAsciiString::StringMap(int length) { |
| 1908 Map* map; | 1908 Map* map; |
| 1909 // Number of characters: determines the map. | 1909 // Number of characters: determines the map. |
| 1910 if (length <= String::kMaxShortStringSize) { | 1910 if (length <= String::kMaxShortSize) { |
| 1911 map = Heap::short_external_ascii_string_map(); | 1911 map = Heap::short_external_ascii_string_map(); |
| 1912 } else if (length <= String::kMaxMediumStringSize) { | 1912 } else if (length <= String::kMaxMediumSize) { |
| 1913 map = Heap::medium_external_ascii_string_map(); | 1913 map = Heap::medium_external_ascii_string_map(); |
| 1914 } else { | 1914 } else { |
| 1915 map = Heap::long_external_ascii_string_map(); | 1915 map = Heap::long_external_ascii_string_map(); |
| 1916 } | 1916 } |
| 1917 return map; | 1917 return map; |
| 1918 } | 1918 } |
| 1919 | 1919 |
| 1920 | 1920 |
| 1921 Map* ExternalAsciiString::SymbolMap(int length) { | 1921 Map* ExternalAsciiString::SymbolMap(int length) { |
| 1922 Map* map; | 1922 Map* map; |
| 1923 // Number of characters: determines the map. | 1923 // Number of characters: determines the map. |
| 1924 if (length <= String::kMaxShortStringSize) { | 1924 if (length <= String::kMaxShortSize) { |
| 1925 map = Heap::short_external_ascii_symbol_map(); | 1925 map = Heap::short_external_ascii_symbol_map(); |
| 1926 } else if (length <= String::kMaxMediumStringSize) { | 1926 } else if (length <= String::kMaxMediumSize) { |
| 1927 map = Heap::medium_external_ascii_symbol_map(); | 1927 map = Heap::medium_external_ascii_symbol_map(); |
| 1928 } else { | 1928 } else { |
| 1929 map = Heap::long_external_ascii_symbol_map(); | 1929 map = Heap::long_external_ascii_symbol_map(); |
| 1930 } | 1930 } |
| 1931 return map; | 1931 return map; |
| 1932 } | 1932 } |
| 1933 | 1933 |
| 1934 | 1934 |
| 1935 ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { | 1935 ExternalTwoByteString::Resource* ExternalTwoByteString::resource() { |
| 1936 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); | 1936 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
| 1937 } | 1937 } |
| 1938 | 1938 |
| 1939 | 1939 |
| 1940 void ExternalTwoByteString::set_resource( | 1940 void ExternalTwoByteString::set_resource( |
| 1941 ExternalTwoByteString::Resource* resource) { | 1941 ExternalTwoByteString::Resource* resource) { |
| 1942 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; | 1942 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; |
| 1943 } | 1943 } |
| 1944 | 1944 |
| 1945 | 1945 |
| 1946 Map* ExternalTwoByteString::StringMap(int length) { | 1946 Map* ExternalTwoByteString::StringMap(int length) { |
| 1947 Map* map; | 1947 Map* map; |
| 1948 // Number of characters: determines the map. | 1948 // Number of characters: determines the map. |
| 1949 if (length <= String::kMaxShortStringSize) { | 1949 if (length <= String::kMaxShortSize) { |
| 1950 map = Heap::short_external_string_map(); | 1950 map = Heap::short_external_string_map(); |
| 1951 } else if (length <= String::kMaxMediumStringSize) { | 1951 } else if (length <= String::kMaxMediumSize) { |
| 1952 map = Heap::medium_external_string_map(); | 1952 map = Heap::medium_external_string_map(); |
| 1953 } else { | 1953 } else { |
| 1954 map = Heap::long_external_string_map(); | 1954 map = Heap::long_external_string_map(); |
| 1955 } | 1955 } |
| 1956 return map; | 1956 return map; |
| 1957 } | 1957 } |
| 1958 | 1958 |
| 1959 | 1959 |
| 1960 Map* ExternalTwoByteString::SymbolMap(int length) { | 1960 Map* ExternalTwoByteString::SymbolMap(int length) { |
| 1961 Map* map; | 1961 Map* map; |
| 1962 // Number of characters: determines the map. | 1962 // Number of characters: determines the map. |
| 1963 if (length <= String::kMaxShortStringSize) { | 1963 if (length <= String::kMaxShortSize) { |
| 1964 map = Heap::short_external_symbol_map(); | 1964 map = Heap::short_external_symbol_map(); |
| 1965 } else if (length <= String::kMaxMediumStringSize) { | 1965 } else if (length <= String::kMaxMediumSize) { |
| 1966 map = Heap::medium_external_symbol_map(); | 1966 map = Heap::medium_external_symbol_map(); |
| 1967 } else { | 1967 } else { |
| 1968 map = Heap::long_external_symbol_map(); | 1968 map = Heap::long_external_symbol_map(); |
| 1969 } | 1969 } |
| 1970 return map; | 1970 return map; |
| 1971 } | 1971 } |
| 1972 | 1972 |
| 1973 | 1973 |
| 1974 byte ByteArray::get(int index) { | 1974 byte ByteArray::get(int index) { |
| 1975 ASSERT(index >= 0 && index < this->length()); | 1975 ASSERT(index >= 0 && index < this->length()); |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 StringHasher::StringHasher(int length) | 2969 StringHasher::StringHasher(int length) |
| 2970 : length_(length), | 2970 : length_(length), |
| 2971 raw_running_hash_(0), | 2971 raw_running_hash_(0), |
| 2972 array_index_(0), | 2972 array_index_(0), |
| 2973 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), | 2973 is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), |
| 2974 is_first_char_(true), | 2974 is_first_char_(true), |
| 2975 is_valid_(true) { } | 2975 is_valid_(true) { } |
| 2976 | 2976 |
| 2977 | 2977 |
| 2978 bool StringHasher::has_trivial_hash() { | 2978 bool StringHasher::has_trivial_hash() { |
| 2979 return length_ > String::kMaxMediumStringSize; | 2979 return length_ > String::kMaxMediumSize; |
| 2980 } | 2980 } |
| 2981 | 2981 |
| 2982 | 2982 |
| 2983 void StringHasher::AddCharacter(uc32 c) { | 2983 void StringHasher::AddCharacter(uc32 c) { |
| 2984 // Use the Jenkins one-at-a-time hash function to update the hash | 2984 // Use the Jenkins one-at-a-time hash function to update the hash |
| 2985 // for the given character. | 2985 // for the given character. |
| 2986 raw_running_hash_ += c; | 2986 raw_running_hash_ += c; |
| 2987 raw_running_hash_ += (raw_running_hash_ << 10); | 2987 raw_running_hash_ += (raw_running_hash_ << 10); |
| 2988 raw_running_hash_ ^= (raw_running_hash_ >> 6); | 2988 raw_running_hash_ ^= (raw_running_hash_ >> 6); |
| 2989 // Incremental array index computation. | 2989 // Incremental array index computation. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3153 #undef WRITE_INT_FIELD | 3153 #undef WRITE_INT_FIELD |
| 3154 #undef READ_SHORT_FIELD | 3154 #undef READ_SHORT_FIELD |
| 3155 #undef WRITE_SHORT_FIELD | 3155 #undef WRITE_SHORT_FIELD |
| 3156 #undef READ_BYTE_FIELD | 3156 #undef READ_BYTE_FIELD |
| 3157 #undef WRITE_BYTE_FIELD | 3157 #undef WRITE_BYTE_FIELD |
| 3158 | 3158 |
| 3159 | 3159 |
| 3160 } } // namespace v8::internal | 3160 } } // namespace v8::internal |
| 3161 | 3161 |
| 3162 #endif // V8_OBJECTS_INL_H_ | 3162 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |