| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 bool Object::IsSeqString() { | 226 bool Object::IsSeqString() { |
| 227 if (!IsString()) return false; | 227 if (!IsString()) return false; |
| 228 return StringShape(String::cast(this)).IsSequential(); | 228 return StringShape(String::cast(this)).IsSequential(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 bool Object::IsSeqOneByteString() { | 232 bool Object::IsSeqOneByteString() { |
| 233 if (!IsString()) return false; | 233 if (!IsString()) return false; |
| 234 return StringShape(String::cast(this)).IsSequential() && | 234 return StringShape(String::cast(this)).IsSequential() && |
| 235 String::cast(this)->IsAsciiRepresentation(); | 235 String::cast(this)->IsOneByteRepresentation(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 bool Object::IsSeqTwoByteString() { | 239 bool Object::IsSeqTwoByteString() { |
| 240 if (!IsString()) return false; | 240 if (!IsString()) return false; |
| 241 return StringShape(String::cast(this)).IsSequential() && | 241 return StringShape(String::cast(this)).IsSequential() && |
| 242 String::cast(this)->IsTwoByteRepresentation(); | 242 String::cast(this)->IsTwoByteRepresentation(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 | 245 |
| 246 bool Object::IsExternalString() { | 246 bool Object::IsExternalString() { |
| 247 if (!IsString()) return false; | 247 if (!IsString()) return false; |
| 248 return StringShape(String::cast(this)).IsExternal(); | 248 return StringShape(String::cast(this)).IsExternal(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 | 251 |
| 252 bool Object::IsExternalAsciiString() { | 252 bool Object::IsExternalAsciiString() { |
| 253 if (!IsString()) return false; | 253 if (!IsString()) return false; |
| 254 return StringShape(String::cast(this)).IsExternal() && | 254 return StringShape(String::cast(this)).IsExternal() && |
| 255 String::cast(this)->IsAsciiRepresentation(); | 255 String::cast(this)->IsOneByteRepresentation(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 | 258 |
| 259 bool Object::IsExternalTwoByteString() { | 259 bool Object::IsExternalTwoByteString() { |
| 260 if (!IsString()) return false; | 260 if (!IsString()) return false; |
| 261 return StringShape(String::cast(this)).IsExternal() && | 261 return StringShape(String::cast(this)).IsExternal() && |
| 262 String::cast(this)->IsTwoByteRepresentation(); | 262 String::cast(this)->IsTwoByteRepresentation(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 bool Object::HasValidElements() { | 265 bool Object::HasValidElements() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 | 290 |
| 291 bool StringShape::IsSymbol() { | 291 bool StringShape::IsSymbol() { |
| 292 ASSERT(valid()); | 292 ASSERT(valid()); |
| 293 STATIC_ASSERT(kSymbolTag != 0); | 293 STATIC_ASSERT(kSymbolTag != 0); |
| 294 return (type_ & kIsSymbolMask) != 0; | 294 return (type_ & kIsSymbolMask) != 0; |
| 295 } | 295 } |
| 296 | 296 |
| 297 | 297 |
| 298 bool String::IsAsciiRepresentation() { | 298 bool String::IsOneByteRepresentation() { |
| 299 uint32_t type = map()->instance_type(); | 299 uint32_t type = map()->instance_type(); |
| 300 return (type & kStringEncodingMask) == kOneByteStringTag; | 300 return (type & kStringEncodingMask) == kOneByteStringTag; |
| 301 } | 301 } |
| 302 | 302 |
| 303 | 303 |
| 304 bool String::IsTwoByteRepresentation() { | 304 bool String::IsTwoByteRepresentation() { |
| 305 uint32_t type = map()->instance_type(); | 305 uint32_t type = map()->instance_type(); |
| 306 return (type & kStringEncodingMask) == kTwoByteStringTag; | 306 return (type & kStringEncodingMask) == kTwoByteStringTag; |
| 307 } | 307 } |
| 308 | 308 |
| 309 | 309 |
| 310 bool String::IsAsciiRepresentationUnderneath() { | 310 bool String::IsOneByteRepresentationUnderneath() { |
| 311 uint32_t type = map()->instance_type(); | 311 uint32_t type = map()->instance_type(); |
| 312 STATIC_ASSERT(kIsIndirectStringTag != 0); | 312 STATIC_ASSERT(kIsIndirectStringTag != 0); |
| 313 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); | 313 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); |
| 314 ASSERT(IsFlat()); | 314 ASSERT(IsFlat()); |
| 315 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { | 315 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { |
| 316 case kOneByteStringTag: | 316 case kOneByteStringTag: |
| 317 return true; | 317 return true; |
| 318 case kTwoByteStringTag: | 318 case kTwoByteStringTag: |
| 319 return false; | 319 return false; |
| 320 default: // Cons or sliced string. Need to go deeper. | 320 default: // Cons or sliced string. Need to go deeper. |
| 321 return GetUnderlying()->IsAsciiRepresentation(); | 321 return GetUnderlying()->IsOneByteRepresentation(); |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 | 325 |
| 326 bool String::IsTwoByteRepresentationUnderneath() { | 326 bool String::IsTwoByteRepresentationUnderneath() { |
| 327 uint32_t type = map()->instance_type(); | 327 uint32_t type = map()->instance_type(); |
| 328 STATIC_ASSERT(kIsIndirectStringTag != 0); | 328 STATIC_ASSERT(kIsIndirectStringTag != 0); |
| 329 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); | 329 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); |
| 330 ASSERT(IsFlat()); | 330 ASSERT(IsFlat()); |
| 331 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { | 331 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { |
| (...skipping 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2482 | 2482 |
| 2483 UNREACHABLE(); | 2483 UNREACHABLE(); |
| 2484 return 0; | 2484 return 0; |
| 2485 } | 2485 } |
| 2486 | 2486 |
| 2487 | 2487 |
| 2488 void String::Set(int index, uint16_t value) { | 2488 void String::Set(int index, uint16_t value) { |
| 2489 ASSERT(index >= 0 && index < length()); | 2489 ASSERT(index >= 0 && index < length()); |
| 2490 ASSERT(StringShape(this).IsSequential()); | 2490 ASSERT(StringShape(this).IsSequential()); |
| 2491 | 2491 |
| 2492 return this->IsAsciiRepresentation() | 2492 return this->IsOneByteRepresentation() |
| 2493 ? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value) | 2493 ? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value) |
| 2494 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value); | 2494 : SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value); |
| 2495 } | 2495 } |
| 2496 | 2496 |
| 2497 | 2497 |
| 2498 bool String::IsFlat() { | 2498 bool String::IsFlat() { |
| 2499 if (!StringShape(this).IsCons()) return true; | 2499 if (!StringShape(this).IsCons()) return true; |
| 2500 return ConsString::cast(this)->second()->length() == 0; | 2500 return ConsString::cast(this)->second()->length() == 0; |
| 2501 } | 2501 } |
| 2502 | 2502 |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4105 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) | 4105 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) |
| 4106 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) | 4106 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) |
| 4107 | 4107 |
| 4108 ACCESSORS(PolymorphicCodeCache, cache, Object, kCacheOffset) | 4108 ACCESSORS(PolymorphicCodeCache, cache, Object, kCacheOffset) |
| 4109 | 4109 |
| 4110 bool Script::HasValidSource() { | 4110 bool Script::HasValidSource() { |
| 4111 Object* src = this->source(); | 4111 Object* src = this->source(); |
| 4112 if (!src->IsString()) return true; | 4112 if (!src->IsString()) return true; |
| 4113 String* src_str = String::cast(src); | 4113 String* src_str = String::cast(src); |
| 4114 if (!StringShape(src_str).IsExternal()) return true; | 4114 if (!StringShape(src_str).IsExternal()) return true; |
| 4115 if (src_str->IsAsciiRepresentation()) { | 4115 if (src_str->IsOneByteRepresentation()) { |
| 4116 return ExternalAsciiString::cast(src)->resource() != NULL; | 4116 return ExternalAsciiString::cast(src)->resource() != NULL; |
| 4117 } else if (src_str->IsTwoByteRepresentation()) { | 4117 } else if (src_str->IsTwoByteRepresentation()) { |
| 4118 return ExternalTwoByteString::cast(src)->resource() != NULL; | 4118 return ExternalTwoByteString::cast(src)->resource() != NULL; |
| 4119 } | 4119 } |
| 4120 return true; | 4120 return true; |
| 4121 } | 4121 } |
| 4122 | 4122 |
| 4123 | 4123 |
| 4124 void SharedFunctionInfo::DontAdaptArguments() { | 4124 void SharedFunctionInfo::DontAdaptArguments() { |
| 4125 ASSERT(code()->kind() == Code::BUILTIN); | 4125 ASSERT(code()->kind() == Code::BUILTIN); |
| (...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5541 #undef WRITE_UINT32_FIELD | 5541 #undef WRITE_UINT32_FIELD |
| 5542 #undef READ_SHORT_FIELD | 5542 #undef READ_SHORT_FIELD |
| 5543 #undef WRITE_SHORT_FIELD | 5543 #undef WRITE_SHORT_FIELD |
| 5544 #undef READ_BYTE_FIELD | 5544 #undef READ_BYTE_FIELD |
| 5545 #undef WRITE_BYTE_FIELD | 5545 #undef WRITE_BYTE_FIELD |
| 5546 | 5546 |
| 5547 | 5547 |
| 5548 } } // namespace v8::internal | 5548 } } // namespace v8::internal |
| 5549 | 5549 |
| 5550 #endif // V8_OBJECTS_INL_H_ | 5550 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |