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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 | 157 |
158 bool Object::IsConsString() { | 158 bool Object::IsConsString() { |
159 if (!this->IsHeapObject()) return false; | 159 if (!this->IsHeapObject()) return false; |
160 uint32_t type = HeapObject::cast(this)->map()->instance_type(); | 160 uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
161 return (type & (kIsNotStringMask | kStringRepresentationMask)) == | 161 return (type & (kIsNotStringMask | kStringRepresentationMask)) == |
162 (kStringTag | kConsStringTag); | 162 (kStringTag | kConsStringTag); |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 #ifdef DEBUG | |
167 // These are for cast checks. If you need one of these in release | |
168 // mode you should consider using a StringShape before moving it out | |
169 // of the ifdef | |
170 | |
171 bool Object::IsSeqString() { | 166 bool Object::IsSeqString() { |
172 if (!IsString()) return false; | 167 if (!IsString()) return false; |
173 return StringShape(String::cast(this)).IsSequential(); | 168 return StringShape(String::cast(this)).IsSequential(); |
174 } | 169 } |
175 | 170 |
176 | 171 |
177 bool Object::IsSeqAsciiString() { | 172 bool Object::IsSeqAsciiString() { |
178 if (!IsString()) return false; | 173 if (!IsString()) return false; |
179 return StringShape(String::cast(this)).IsSequential() && | 174 return StringShape(String::cast(this)).IsSequential() && |
180 String::cast(this)->IsAsciiRepresentation(); | 175 String::cast(this)->IsAsciiRepresentation(); |
(...skipping 26 matching lines...) Expand all Loading... |
207 String::cast(this)->IsTwoByteRepresentation(); | 202 String::cast(this)->IsTwoByteRepresentation(); |
208 } | 203 } |
209 | 204 |
210 | 205 |
211 bool Object::IsSlicedString() { | 206 bool Object::IsSlicedString() { |
212 if (!IsString()) return false; | 207 if (!IsString()) return false; |
213 return StringShape(String::cast(this)).IsSliced(); | 208 return StringShape(String::cast(this)).IsSliced(); |
214 } | 209 } |
215 | 210 |
216 | 211 |
217 #endif // DEBUG | |
218 | |
219 | |
220 StringShape::StringShape(String* str) | 212 StringShape::StringShape(String* str) |
221 : type_(str->map()->instance_type()) { | 213 : type_(str->map()->instance_type()) { |
222 set_valid(); | 214 set_valid(); |
223 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 215 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
224 } | 216 } |
225 | 217 |
226 | 218 |
227 StringShape::StringShape(Map* map) | 219 StringShape::StringShape(Map* map) |
228 : type_(map->instance_type()) { | 220 : type_(map->instance_type()) { |
229 set_valid(); | 221 set_valid(); |
(...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 #undef WRITE_INT_FIELD | 3148 #undef WRITE_INT_FIELD |
3157 #undef READ_SHORT_FIELD | 3149 #undef READ_SHORT_FIELD |
3158 #undef WRITE_SHORT_FIELD | 3150 #undef WRITE_SHORT_FIELD |
3159 #undef READ_BYTE_FIELD | 3151 #undef READ_BYTE_FIELD |
3160 #undef WRITE_BYTE_FIELD | 3152 #undef WRITE_BYTE_FIELD |
3161 | 3153 |
3162 | 3154 |
3163 } } // namespace v8::internal | 3155 } } // namespace v8::internal |
3164 | 3156 |
3165 #endif // V8_OBJECTS_INL_H_ | 3157 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |