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 STATIC_ASSERT(kInternalizedTag != 0); | 224 STATIC_ASSERT(kNotInternalizedTag != 0); |
225 return (type & (kIsNotStringMask | kIsInternalizedMask)) == | 225 return type < kNotInternalizedTag; |
Yang
2013/07/19 09:52:18
I kinda prefer the bit-masking way, since it doesn
mvstanton
2013/07/19 11:07:42
I wondered about that too, it's better to be symme
| |
226 (kInternalizedTag | kStringTag); | |
227 } | 226 } |
228 | 227 |
229 | 228 |
230 bool Object::IsConsString() { | 229 bool Object::IsConsString() { |
231 if (!IsString()) return false; | 230 if (!IsString()) return false; |
232 return StringShape(String::cast(this)).IsCons(); | 231 return StringShape(String::cast(this)).IsCons(); |
233 } | 232 } |
234 | 233 |
235 | 234 |
236 bool Object::IsSlicedString() { | 235 bool Object::IsSlicedString() { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 | 311 |
313 StringShape::StringShape(InstanceType t) | 312 StringShape::StringShape(InstanceType t) |
314 : type_(static_cast<uint32_t>(t)) { | 313 : type_(static_cast<uint32_t>(t)) { |
315 set_valid(); | 314 set_valid(); |
316 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 315 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
317 } | 316 } |
318 | 317 |
319 | 318 |
320 bool StringShape::IsInternalized() { | 319 bool StringShape::IsInternalized() { |
321 ASSERT(valid()); | 320 ASSERT(valid()); |
322 STATIC_ASSERT(kInternalizedTag != 0); | 321 STATIC_ASSERT(kNotInternalizedTag != 0); |
323 return (type_ & (kIsNotStringMask | kIsInternalizedMask)) == | 322 return type_ < kNotInternalizedTag; |
mvstanton
2013/07/19 11:07:42
I restored this one too.
| |
324 (kInternalizedTag | kStringTag); | |
325 } | 323 } |
326 | 324 |
327 | 325 |
328 bool String::IsOneByteRepresentation() { | 326 bool String::IsOneByteRepresentation() { |
329 uint32_t type = map()->instance_type(); | 327 uint32_t type = map()->instance_type(); |
330 return (type & kStringEncodingMask) == kOneByteStringTag; | 328 return (type & kStringEncodingMask) == kOneByteStringTag; |
331 } | 329 } |
332 | 330 |
333 | 331 |
334 bool String::IsTwoByteRepresentation() { | 332 bool String::IsTwoByteRepresentation() { |
(...skipping 5850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6185 #undef WRITE_UINT32_FIELD | 6183 #undef WRITE_UINT32_FIELD |
6186 #undef READ_SHORT_FIELD | 6184 #undef READ_SHORT_FIELD |
6187 #undef WRITE_SHORT_FIELD | 6185 #undef WRITE_SHORT_FIELD |
6188 #undef READ_BYTE_FIELD | 6186 #undef READ_BYTE_FIELD |
6189 #undef WRITE_BYTE_FIELD | 6187 #undef WRITE_BYTE_FIELD |
6190 | 6188 |
6191 | 6189 |
6192 } } // namespace v8::internal | 6190 } } // namespace v8::internal |
6193 | 6191 |
6194 #endif // V8_OBJECTS_INL_H_ | 6192 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |