| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 bool Object::IsSpecFunction() { | 214 bool Object::IsSpecFunction() { |
| 215 if (!Object::IsHeapObject()) return false; | 215 if (!Object::IsHeapObject()) return false; |
| 216 InstanceType type = HeapObject::cast(this)->map()->instance_type(); | 216 InstanceType type = HeapObject::cast(this)->map()->instance_type(); |
| 217 return type == JS_FUNCTION_TYPE || type == JS_FUNCTION_PROXY_TYPE; | 217 return type == JS_FUNCTION_TYPE || type == JS_FUNCTION_PROXY_TYPE; |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 bool Object::IsInternalizedString() { | 221 bool Object::IsInternalizedString() { |
| 222 if (!this->IsHeapObject()) return false; | 222 if (!this->IsHeapObject()) return false; |
| 223 uint32_t type = HeapObject::cast(this)->map()->instance_type(); | 223 uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
| 224 // Because the internalized tag is non-zero and no non-string types have the | |
| 225 // internalized bit set we can test for internalized strings with a very | |
| 226 // simple test operation. | |
| 227 STATIC_ASSERT(kInternalizedTag != 0); | 224 STATIC_ASSERT(kInternalizedTag != 0); |
| 228 ASSERT(kNotStringTag + kIsInternalizedMask > LAST_TYPE); | 225 return (type & (kIsNotStringMask | kIsInternalizedMask)) == |
| 229 return (type & kIsInternalizedMask) != 0; | 226 (kInternalizedTag | kStringTag); |
| 230 } | 227 } |
| 231 | 228 |
| 232 | 229 |
| 233 bool Object::IsConsString() { | 230 bool Object::IsConsString() { |
| 234 if (!IsString()) return false; | 231 if (!IsString()) return false; |
| 235 return StringShape(String::cast(this)).IsCons(); | 232 return StringShape(String::cast(this)).IsCons(); |
| 236 } | 233 } |
| 237 | 234 |
| 238 | 235 |
| 239 bool Object::IsSlicedString() { | 236 bool Object::IsSlicedString() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 StringShape::StringShape(InstanceType t) | 313 StringShape::StringShape(InstanceType t) |
| 317 : type_(static_cast<uint32_t>(t)) { | 314 : type_(static_cast<uint32_t>(t)) { |
| 318 set_valid(); | 315 set_valid(); |
| 319 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 316 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
| 320 } | 317 } |
| 321 | 318 |
| 322 | 319 |
| 323 bool StringShape::IsInternalized() { | 320 bool StringShape::IsInternalized() { |
| 324 ASSERT(valid()); | 321 ASSERT(valid()); |
| 325 STATIC_ASSERT(kInternalizedTag != 0); | 322 STATIC_ASSERT(kInternalizedTag != 0); |
| 326 return (type_ & kIsInternalizedMask) != 0; | 323 return (type_ & (kIsNotStringMask | kIsInternalizedMask)) == |
| 324 (kInternalizedTag | kStringTag); |
| 327 } | 325 } |
| 328 | 326 |
| 329 | 327 |
| 330 bool String::IsOneByteRepresentation() { | 328 bool String::IsOneByteRepresentation() { |
| 331 uint32_t type = map()->instance_type(); | 329 uint32_t type = map()->instance_type(); |
| 332 return (type & kStringEncodingMask) == kOneByteStringTag; | 330 return (type & kStringEncodingMask) == kOneByteStringTag; |
| 333 } | 331 } |
| 334 | 332 |
| 335 | 333 |
| 336 bool String::IsTwoByteRepresentation() { | 334 bool String::IsTwoByteRepresentation() { |
| (...skipping 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3381 | 3379 |
| 3382 | 3380 |
| 3383 int Map::pre_allocated_property_fields() { | 3381 int Map::pre_allocated_property_fields() { |
| 3384 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | 3382 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); |
| 3385 } | 3383 } |
| 3386 | 3384 |
| 3387 | 3385 |
| 3388 int HeapObject::SizeFromMap(Map* map) { | 3386 int HeapObject::SizeFromMap(Map* map) { |
| 3389 int instance_size = map->instance_size(); | 3387 int instance_size = map->instance_size(); |
| 3390 if (instance_size != kVariableSizeSentinel) return instance_size; | 3388 if (instance_size != kVariableSizeSentinel) return instance_size; |
| 3391 // We can ignore the "internalized" bit because it is only set for strings | |
| 3392 // and thus implies a string type. | |
| 3393 int instance_type = | |
| 3394 static_cast<int>(map->instance_type()) & ~kIsInternalizedMask; | |
| 3395 // Only inline the most frequent cases. | 3389 // Only inline the most frequent cases. |
| 3390 int instance_type = static_cast<int>(map->instance_type()); |
| 3396 if (instance_type == FIXED_ARRAY_TYPE) { | 3391 if (instance_type == FIXED_ARRAY_TYPE) { |
| 3397 return FixedArray::BodyDescriptor::SizeOf(map, this); | 3392 return FixedArray::BodyDescriptor::SizeOf(map, this); |
| 3398 } | 3393 } |
| 3399 if (instance_type == ASCII_STRING_TYPE) { | 3394 if (instance_type == ASCII_STRING_TYPE || |
| 3395 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { |
| 3400 return SeqOneByteString::SizeFor( | 3396 return SeqOneByteString::SizeFor( |
| 3401 reinterpret_cast<SeqOneByteString*>(this)->length()); | 3397 reinterpret_cast<SeqOneByteString*>(this)->length()); |
| 3402 } | 3398 } |
| 3403 if (instance_type == BYTE_ARRAY_TYPE) { | 3399 if (instance_type == BYTE_ARRAY_TYPE) { |
| 3404 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); | 3400 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); |
| 3405 } | 3401 } |
| 3406 if (instance_type == FREE_SPACE_TYPE) { | 3402 if (instance_type == FREE_SPACE_TYPE) { |
| 3407 return reinterpret_cast<FreeSpace*>(this)->size(); | 3403 return reinterpret_cast<FreeSpace*>(this)->size(); |
| 3408 } | 3404 } |
| 3409 if (instance_type == STRING_TYPE) { | 3405 if (instance_type == STRING_TYPE || |
| 3406 instance_type == INTERNALIZED_STRING_TYPE) { |
| 3410 return SeqTwoByteString::SizeFor( | 3407 return SeqTwoByteString::SizeFor( |
| 3411 reinterpret_cast<SeqTwoByteString*>(this)->length()); | 3408 reinterpret_cast<SeqTwoByteString*>(this)->length()); |
| 3412 } | 3409 } |
| 3413 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | 3410 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { |
| 3414 return FixedDoubleArray::SizeFor( | 3411 return FixedDoubleArray::SizeFor( |
| 3415 reinterpret_cast<FixedDoubleArray*>(this)->length()); | 3412 reinterpret_cast<FixedDoubleArray*>(this)->length()); |
| 3416 } | 3413 } |
| 3417 ASSERT(instance_type == CODE_TYPE); | 3414 ASSERT(instance_type == CODE_TYPE); |
| 3418 return reinterpret_cast<Code*>(this)->CodeSize(); | 3415 return reinterpret_cast<Code*>(this)->CodeSize(); |
| 3419 } | 3416 } |
| (...skipping 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6190 #undef WRITE_UINT32_FIELD | 6187 #undef WRITE_UINT32_FIELD |
| 6191 #undef READ_SHORT_FIELD | 6188 #undef READ_SHORT_FIELD |
| 6192 #undef WRITE_SHORT_FIELD | 6189 #undef WRITE_SHORT_FIELD |
| 6193 #undef READ_BYTE_FIELD | 6190 #undef READ_BYTE_FIELD |
| 6194 #undef WRITE_BYTE_FIELD | 6191 #undef WRITE_BYTE_FIELD |
| 6195 | 6192 |
| 6196 | 6193 |
| 6197 } } // namespace v8::internal | 6194 } } // namespace v8::internal |
| 6198 | 6195 |
| 6199 #endif // V8_OBJECTS_INL_H_ | 6196 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |