| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 bool Object::IsString() { | 144 bool Object::IsString() { |
| 145 return Object::IsHeapObject() | 145 return Object::IsHeapObject() |
| 146 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; | 146 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; |
| 147 } | 147 } |
| 148 | 148 |
| 149 | 149 |
| 150 bool Object::IsSymbol() { | 150 bool Object::IsSymbol() { |
| 151 if (!this->IsHeapObject()) return false; | 151 if (!this->IsHeapObject()) return false; |
| 152 uint32_t type = HeapObject::cast(this)->map()->instance_type(); | 152 uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
| 153 return (type & (kIsNotStringMask | kIsSymbolMask)) == | 153 // Because the symbol tag is non-zero and no non-string types have the |
| 154 (kStringTag | kSymbolTag); | 154 // symbol bit set we can test for symbols with a very simple test |
| 155 // operation. |
| 156 ASSERT(kSymbolTag != 0); |
| 157 ASSERT(kNotStringTag + kIsSymbolMask > LAST_TYPE); |
| 158 return (type & kIsSymbolMask != 0); |
| 155 } | 159 } |
| 156 | 160 |
| 157 | 161 |
| 158 bool Object::IsConsString() { | 162 bool Object::IsConsString() { |
| 159 if (!this->IsHeapObject()) return false; | 163 if (!this->IsHeapObject()) return false; |
| 160 uint32_t type = HeapObject::cast(this)->map()->instance_type(); | 164 uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
| 161 return (type & (kIsNotStringMask | kStringRepresentationMask)) == | 165 return (type & (kIsNotStringMask | kStringRepresentationMask)) == |
| 162 (kStringTag | kConsStringTag); | 166 (kStringTag | kConsStringTag); |
| 163 } | 167 } |
| 164 | 168 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 223 |
| 220 StringShape::StringShape(InstanceType t) | 224 StringShape::StringShape(InstanceType t) |
| 221 : type_(static_cast<uint32_t>(t)) { | 225 : type_(static_cast<uint32_t>(t)) { |
| 222 set_valid(); | 226 set_valid(); |
| 223 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 227 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
| 224 } | 228 } |
| 225 | 229 |
| 226 | 230 |
| 227 bool StringShape::IsSymbol() { | 231 bool StringShape::IsSymbol() { |
| 228 ASSERT(valid()); | 232 ASSERT(valid()); |
| 229 return (type_ & kIsSymbolMask) == kSymbolTag; | 233 ASSERT(kSymbolTag != 0); |
| 234 return (type_ & kIsSymbolMask) != 0; |
| 230 } | 235 } |
| 231 | 236 |
| 232 | 237 |
| 233 bool String::IsAsciiRepresentation() { | 238 bool String::IsAsciiRepresentation() { |
| 234 uint32_t type = map()->instance_type(); | 239 uint32_t type = map()->instance_type(); |
| 235 if ((type & kStringRepresentationMask) == kConsStringTag && | 240 if ((type & kStringRepresentationMask) == kConsStringTag && |
| 236 ConsString::cast(this)->second()->length() == 0) { | 241 ConsString::cast(this)->second()->length() == 0) { |
| 237 return ConsString::cast(this)->first()->IsAsciiRepresentation(); | 242 return ConsString::cast(this)->first()->IsAsciiRepresentation(); |
| 238 } | 243 } |
| 239 return (type & kStringEncodingMask) == kAsciiStringTag; | 244 return (type & kStringEncodingMask) == kAsciiStringTag; |
| (...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 #undef WRITE_INT_FIELD | 3035 #undef WRITE_INT_FIELD |
| 3031 #undef READ_SHORT_FIELD | 3036 #undef READ_SHORT_FIELD |
| 3032 #undef WRITE_SHORT_FIELD | 3037 #undef WRITE_SHORT_FIELD |
| 3033 #undef READ_BYTE_FIELD | 3038 #undef READ_BYTE_FIELD |
| 3034 #undef WRITE_BYTE_FIELD | 3039 #undef WRITE_BYTE_FIELD |
| 3035 | 3040 |
| 3036 | 3041 |
| 3037 } } // namespace v8::internal | 3042 } } // namespace v8::internal |
| 3038 | 3043 |
| 3039 #endif // V8_OBJECTS_INL_H_ | 3044 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |