| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 String::cast(this)->IsAsciiRepresentation(); | 249 String::cast(this)->IsAsciiRepresentation(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 | 252 |
| 253 bool Object::IsExternalTwoByteString() { | 253 bool Object::IsExternalTwoByteString() { |
| 254 if (!IsString()) return false; | 254 if (!IsString()) return false; |
| 255 return StringShape(String::cast(this)).IsExternal() && | 255 return StringShape(String::cast(this)).IsExternal() && |
| 256 String::cast(this)->IsTwoByteRepresentation(); | 256 String::cast(this)->IsTwoByteRepresentation(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 |
| 259 bool Object::HasValidElements() { | 260 bool Object::HasValidElements() { |
| 260 // Dictionary is covered under FixedArray. | 261 // Dictionary is covered under FixedArray. |
| 261 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); | 262 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); |
| 262 } | 263 } |
| 263 | 264 |
| 265 |
| 264 StringShape::StringShape(String* str) | 266 StringShape::StringShape(String* str) |
| 265 : type_(str->map()->instance_type()) { | 267 : type_(str->map()->instance_type()) { |
| 266 set_valid(); | 268 set_valid(); |
| 267 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 269 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
| 268 } | 270 } |
| 269 | 271 |
| 270 | 272 |
| 271 StringShape::StringShape(Map* map) | 273 StringShape::StringShape(Map* map) |
| 272 : type_(map->instance_type()) { | 274 : type_(map->instance_type()) { |
| 273 set_valid(); | 275 set_valid(); |
| (...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 | 2138 |
| 2137 | 2139 |
| 2138 String* String::TryFlattenGetString(PretenureFlag pretenure) { | 2140 String* String::TryFlattenGetString(PretenureFlag pretenure) { |
| 2139 MaybeObject* flat = TryFlatten(pretenure); | 2141 MaybeObject* flat = TryFlatten(pretenure); |
| 2140 Object* successfully_flattened; | 2142 Object* successfully_flattened; |
| 2141 if (!flat->ToObject(&successfully_flattened)) return this; | 2143 if (!flat->ToObject(&successfully_flattened)) return this; |
| 2142 return String::cast(successfully_flattened); | 2144 return String::cast(successfully_flattened); |
| 2143 } | 2145 } |
| 2144 | 2146 |
| 2145 | 2147 |
| 2146 uint16_t String::Get(int index) { | 2148 uint16_t String::Get(int index, ExternalStringBufferFlag flag) { |
| 2147 ASSERT(index >= 0 && index < length()); | 2149 ASSERT(index >= 0 && index < length()); |
| 2148 switch (StringShape(this).full_representation_tag()) { | 2150 switch (StringShape(this).full_representation_tag()) { |
| 2149 case kSeqStringTag | kAsciiStringTag: | 2151 case kSeqStringTag | kAsciiStringTag: |
| 2150 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); | 2152 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); |
| 2151 case kSeqStringTag | kTwoByteStringTag: | 2153 case kSeqStringTag | kTwoByteStringTag: |
| 2152 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); | 2154 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
| 2153 case kConsStringTag | kAsciiStringTag: | 2155 case kConsStringTag | kAsciiStringTag: |
| 2154 case kConsStringTag | kTwoByteStringTag: | 2156 case kConsStringTag | kTwoByteStringTag: |
| 2155 return ConsString::cast(this)->ConsStringGet(index); | 2157 return ConsString::cast(this)->ConsStringGet(index, flag); |
| 2156 case kExternalStringTag | kAsciiStringTag: | 2158 case kExternalStringTag | kAsciiStringTag: |
| 2157 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); | 2159 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index, |
| 2160 flag); |
| 2158 case kExternalStringTag | kTwoByteStringTag: | 2161 case kExternalStringTag | kTwoByteStringTag: |
| 2159 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); | 2162 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index, |
| 2163 flag); |
| 2160 case kSlicedStringTag | kAsciiStringTag: | 2164 case kSlicedStringTag | kAsciiStringTag: |
| 2161 case kSlicedStringTag | kTwoByteStringTag: | 2165 case kSlicedStringTag | kTwoByteStringTag: |
| 2162 return SlicedString::cast(this)->SlicedStringGet(index); | 2166 return SlicedString::cast(this)->SlicedStringGet(index, flag); |
| 2163 default: | 2167 default: |
| 2164 break; | 2168 break; |
| 2165 } | 2169 } |
| 2166 | 2170 |
| 2167 UNREACHABLE(); | 2171 UNREACHABLE(); |
| 2168 return 0; | 2172 return 0; |
| 2169 } | 2173 } |
| 2170 | 2174 |
| 2171 | 2175 |
| 2172 void String::Set(int index, uint16_t value) { | 2176 void String::Set(int index, uint16_t value) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 return READ_FIELD(this, kSecondOffset); | 2294 return READ_FIELD(this, kSecondOffset); |
| 2291 } | 2295 } |
| 2292 | 2296 |
| 2293 | 2297 |
| 2294 void ConsString::set_second(String* value, WriteBarrierMode mode) { | 2298 void ConsString::set_second(String* value, WriteBarrierMode mode) { |
| 2295 WRITE_FIELD(this, kSecondOffset, value); | 2299 WRITE_FIELD(this, kSecondOffset, value); |
| 2296 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode); | 2300 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, value, mode); |
| 2297 } | 2301 } |
| 2298 | 2302 |
| 2299 | 2303 |
| 2304 bool ExternalString::IsBuffered() { |
| 2305 uint32_t type = map()->instance_type(); |
| 2306 ASSERT(StringShape(this).IsExternal()); |
| 2307 return (type & kBufferedStringMask) == kBufferedStringTag; |
| 2308 } |
| 2309 |
| 2310 |
| 2311 int ExternalString::buffer_index() { |
| 2312 ASSERT(IsBuffered()); |
| 2313 Object* value = READ_FIELD(this, kBufferIndexOffset); |
| 2314 return Smi::cast(value)->value(); |
| 2315 } |
| 2316 |
| 2317 |
| 2318 void ExternalString::set_buffer_index(int value) { |
| 2319 ASSERT(IsBuffered()); |
| 2320 WRITE_FIELD(this, kBufferIndexOffset, Smi::FromInt(value)); |
| 2321 } |
| 2322 |
| 2323 |
| 2324 Address ExternalString::buffer() { |
| 2325 return reinterpret_cast<Address>( |
| 2326 HeapObject::RawField(this, kBufferContentOffset)); |
| 2327 } |
| 2328 |
| 2329 |
| 2300 const ExternalAsciiString::Resource* ExternalAsciiString::resource() { | 2330 const ExternalAsciiString::Resource* ExternalAsciiString::resource() { |
| 2301 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); | 2331 return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)); |
| 2302 } | 2332 } |
| 2303 | 2333 |
| 2304 | 2334 |
| 2305 void ExternalAsciiString::set_resource( | 2335 void ExternalAsciiString::set_resource( |
| 2306 const ExternalAsciiString::Resource* resource) { | 2336 const ExternalAsciiString::Resource* resource) { |
| 2307 *reinterpret_cast<const Resource**>( | 2337 *reinterpret_cast<const Resource**>( |
| 2308 FIELD_ADDR(this, kResourceOffset)) = resource; | 2338 FIELD_ADDR(this, kResourceOffset)) = resource; |
| 2309 } | 2339 } |
| (...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4628 #undef WRITE_INT_FIELD | 4658 #undef WRITE_INT_FIELD |
| 4629 #undef READ_SHORT_FIELD | 4659 #undef READ_SHORT_FIELD |
| 4630 #undef WRITE_SHORT_FIELD | 4660 #undef WRITE_SHORT_FIELD |
| 4631 #undef READ_BYTE_FIELD | 4661 #undef READ_BYTE_FIELD |
| 4632 #undef WRITE_BYTE_FIELD | 4662 #undef WRITE_BYTE_FIELD |
| 4633 | 4663 |
| 4634 | 4664 |
| 4635 } } // namespace v8::internal | 4665 } } // namespace v8::internal |
| 4636 | 4666 |
| 4637 #endif // V8_OBJECTS_INL_H_ | 4667 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |