| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 | 172 |
| 173 bool Object::IsConsString() { | 173 bool Object::IsConsString() { |
| 174 if (!this->IsHeapObject()) return false; | 174 if (!this->IsHeapObject()) return false; |
| 175 uint32_t type = HeapObject::cast(this)->map()->instance_type(); | 175 uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
| 176 return (type & (kIsNotStringMask | kStringRepresentationMask)) == | 176 return (type & (kIsNotStringMask | kStringRepresentationMask)) == |
| 177 (kStringTag | kConsStringTag); | 177 (kStringTag | kConsStringTag); |
| 178 } | 178 } |
| 179 | 179 |
| 180 | 180 |
| 181 bool Object::IsFlatString() { |
| 182 if (!this->IsHeapObject()) return false; |
| 183 uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
| 184 return (type & (kIsNotStringMask | kStringRepresentationMask)) == kStringTag; |
| 185 } |
| 186 |
| 187 |
| 181 bool Object::IsSeqString() { | 188 bool Object::IsSeqString() { |
| 182 if (!IsString()) return false; | 189 if (!IsString()) return false; |
| 183 return StringShape(String::cast(this)).IsSequential(); | 190 return StringShape(String::cast(this)).IsSequential(); |
| 184 } | 191 } |
| 185 | 192 |
| 186 | 193 |
| 187 bool Object::IsSeqAsciiString() { | 194 bool Object::IsSeqAsciiString() { |
| 188 if (!IsString()) return false; | 195 if (!IsString()) return false; |
| 189 return StringShape(String::cast(this)).IsSequential() && | 196 return StringShape(String::cast(this)).IsSequential() && |
| 190 String::cast(this)->IsAsciiRepresentation(); | 197 String::cast(this)->IsAsciiRepresentation(); |
| (...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 CAST_ACCESSOR(DescriptorArray) | 1875 CAST_ACCESSOR(DescriptorArray) |
| 1869 CAST_ACCESSOR(DeoptimizationInputData) | 1876 CAST_ACCESSOR(DeoptimizationInputData) |
| 1870 CAST_ACCESSOR(DeoptimizationOutputData) | 1877 CAST_ACCESSOR(DeoptimizationOutputData) |
| 1871 CAST_ACCESSOR(SymbolTable) | 1878 CAST_ACCESSOR(SymbolTable) |
| 1872 CAST_ACCESSOR(JSFunctionResultCache) | 1879 CAST_ACCESSOR(JSFunctionResultCache) |
| 1873 CAST_ACCESSOR(NormalizedMapCache) | 1880 CAST_ACCESSOR(NormalizedMapCache) |
| 1874 CAST_ACCESSOR(CompilationCacheTable) | 1881 CAST_ACCESSOR(CompilationCacheTable) |
| 1875 CAST_ACCESSOR(CodeCacheHashTable) | 1882 CAST_ACCESSOR(CodeCacheHashTable) |
| 1876 CAST_ACCESSOR(MapCache) | 1883 CAST_ACCESSOR(MapCache) |
| 1877 CAST_ACCESSOR(String) | 1884 CAST_ACCESSOR(String) |
| 1885 CAST_ACCESSOR(FlatString) |
| 1878 CAST_ACCESSOR(SeqString) | 1886 CAST_ACCESSOR(SeqString) |
| 1879 CAST_ACCESSOR(SeqAsciiString) | 1887 CAST_ACCESSOR(SeqAsciiString) |
| 1880 CAST_ACCESSOR(SeqTwoByteString) | 1888 CAST_ACCESSOR(SeqTwoByteString) |
| 1881 CAST_ACCESSOR(ConsString) | 1889 CAST_ACCESSOR(ConsString) |
| 1882 CAST_ACCESSOR(ExternalString) | 1890 CAST_ACCESSOR(ExternalString) |
| 1883 CAST_ACCESSOR(ExternalAsciiString) | 1891 CAST_ACCESSOR(ExternalAsciiString) |
| 1884 CAST_ACCESSOR(ExternalTwoByteString) | 1892 CAST_ACCESSOR(ExternalTwoByteString) |
| 1885 CAST_ACCESSOR(JSObject) | 1893 CAST_ACCESSOR(JSObject) |
| 1886 CAST_ACCESSOR(Smi) | 1894 CAST_ACCESSOR(Smi) |
| 1887 CAST_ACCESSOR(HeapObject) | 1895 CAST_ACCESSOR(HeapObject) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 String* String::TryFlattenGetString(PretenureFlag pretenure) { | 1975 String* String::TryFlattenGetString(PretenureFlag pretenure) { |
| 1968 MaybeObject* flat = TryFlatten(pretenure); | 1976 MaybeObject* flat = TryFlatten(pretenure); |
| 1969 Object* successfully_flattened; | 1977 Object* successfully_flattened; |
| 1970 if (flat->ToObject(&successfully_flattened)) { | 1978 if (flat->ToObject(&successfully_flattened)) { |
| 1971 return String::cast(successfully_flattened); | 1979 return String::cast(successfully_flattened); |
| 1972 } | 1980 } |
| 1973 return this; | 1981 return this; |
| 1974 } | 1982 } |
| 1975 | 1983 |
| 1976 | 1984 |
| 1985 uint16_t FlatString::FlatStringGet(int index) { |
| 1986 ASSERT(index >= 0 && index < length()); |
| 1987 switch (StringShape(this).full_representation_tag()) { |
| 1988 case kSeqStringTag | kAsciiStringTag: |
| 1989 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); |
| 1990 case kSeqStringTag | kTwoByteStringTag: |
| 1991 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
| 1992 case kExternalStringTag | kAsciiStringTag: |
| 1993 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); |
| 1994 case kExternalStringTag | kTwoByteStringTag: |
| 1995 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); |
| 1996 default: |
| 1997 break; |
| 1998 } |
| 1999 |
| 2000 UNREACHABLE(); |
| 2001 return 0; |
| 2002 } |
| 2003 |
| 2004 |
| 1977 uint16_t String::Get(int index) { | 2005 uint16_t String::Get(int index) { |
| 1978 ASSERT(index >= 0 && index < length()); | 2006 ASSERT(index >= 0 && index < length()); |
| 1979 switch (StringShape(this).full_representation_tag()) { | 2007 switch (StringShape(this).full_representation_tag()) { |
| 1980 case kSeqStringTag | kAsciiStringTag: | 2008 case kSeqStringTag | kAsciiStringTag: |
| 1981 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); | 2009 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); |
| 1982 case kSeqStringTag | kTwoByteStringTag: | 2010 case kSeqStringTag | kTwoByteStringTag: |
| 1983 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); | 2011 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
| 1984 case kConsStringTag | kAsciiStringTag: | 2012 case kConsStringTag | kAsciiStringTag: |
| 1985 case kConsStringTag | kTwoByteStringTag: | 2013 case kConsStringTag | kTwoByteStringTag: |
| 1986 return ConsString::cast(this)->ConsStringGet(index); | 2014 return ConsString::cast(this)->ConsStringGet(index); |
| 1987 case kExternalStringTag | kAsciiStringTag: | 2015 case kExternalStringTag | kAsciiStringTag: |
| 1988 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); | 2016 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); |
| 1989 case kExternalStringTag | kTwoByteStringTag: | 2017 case kExternalStringTag | kTwoByteStringTag: |
| 1990 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); | 2018 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); |
| 1991 default: | 2019 default: |
| 1992 break; | 2020 break; |
| 1993 } | 2021 } |
| 1994 | |
| 1995 UNREACHABLE(); | 2022 UNREACHABLE(); |
| 1996 return 0; | 2023 return 0; |
| 1997 } | 2024 } |
| 1998 | 2025 |
| 1999 | 2026 |
| 2027 MaybeObject* String::GetMayFlatten(int index) { |
| 2028 if (this->IsConsString()) { |
| 2029 return ConsString::cast(this)->ConsStringGetMayFlatten(index); |
| 2030 } |
| 2031 return Smi::FromInt(FlatString::cast(this)->FlatStringGet(index)); |
| 2032 } |
| 2033 |
| 2034 |
| 2000 void String::Set(int index, uint16_t value) { | 2035 void String::Set(int index, uint16_t value) { |
| 2001 ASSERT(index >= 0 && index < length()); | 2036 ASSERT(index >= 0 && index < length()); |
| 2002 ASSERT(StringShape(this).IsSequential()); | 2037 ASSERT(StringShape(this).IsSequential()); |
| 2003 | 2038 |
| 2004 return this->IsAsciiRepresentation() | 2039 return this->IsAsciiRepresentation() |
| 2005 ? SeqAsciiString::cast(this)->SeqAsciiStringSet(index, value) | 2040 ? SeqAsciiString::cast(this)->SeqAsciiStringSet(index, value) |
| 2006 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value); | 2041 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value); |
| 2007 } | 2042 } |
| 2008 | 2043 |
| 2009 | 2044 |
| (...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4205 #undef WRITE_INT_FIELD | 4240 #undef WRITE_INT_FIELD |
| 4206 #undef READ_SHORT_FIELD | 4241 #undef READ_SHORT_FIELD |
| 4207 #undef WRITE_SHORT_FIELD | 4242 #undef WRITE_SHORT_FIELD |
| 4208 #undef READ_BYTE_FIELD | 4243 #undef READ_BYTE_FIELD |
| 4209 #undef WRITE_BYTE_FIELD | 4244 #undef WRITE_BYTE_FIELD |
| 4210 | 4245 |
| 4211 | 4246 |
| 4212 } } // namespace v8::internal | 4247 } } // namespace v8::internal |
| 4213 | 4248 |
| 4214 #endif // V8_OBJECTS_INL_H_ | 4249 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |