Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(995)

Side by Side Diff: src/objects-inl.h

Issue 7477045: Tentative implementation of string slices (hidden under the flag --string-slices). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 178
179 bool Object::IsConsString() { 179 bool Object::IsConsString() {
180 if (!this->IsHeapObject()) return false; 180 if (!this->IsHeapObject()) return false;
181 uint32_t type = HeapObject::cast(this)->map()->instance_type(); 181 uint32_t type = HeapObject::cast(this)->map()->instance_type();
182 return (type & (kIsNotStringMask | kStringRepresentationMask)) == 182 return (type & (kIsNotStringMask | kStringRepresentationMask)) ==
183 (kStringTag | kConsStringTag); 183 (kStringTag | kConsStringTag);
184 } 184 }
185 185
186 186
187 bool Object::IsSlicedString() {
188 if (!this->IsHeapObject()) return false;
189 uint32_t type = HeapObject::cast(this)->map()->instance_type();
190 return (type & (kIsNotStringMask | kStringRepresentationMask)) ==
antonm 2011/07/27 12:16:39 probably is worth refactoring.
191 (kStringTag | kSlicedStringTag);
192 }
193
194
187 bool Object::IsSeqString() { 195 bool Object::IsSeqString() {
188 if (!IsString()) return false; 196 if (!IsString()) return false;
189 return StringShape(String::cast(this)).IsSequential(); 197 return StringShape(String::cast(this)).IsSequential();
190 } 198 }
191 199
192 200
193 bool Object::IsSeqAsciiString() { 201 bool Object::IsSeqAsciiString() {
194 if (!IsString()) return false; 202 if (!IsString()) return false;
195 return StringShape(String::cast(this)).IsSequential() && 203 return StringShape(String::cast(this)).IsSequential() &&
196 String::cast(this)->IsAsciiRepresentation(); 204 String::cast(this)->IsAsciiRepresentation();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return (type & kStringEncodingMask) == kAsciiStringTag || 281 return (type & kStringEncodingMask) == kAsciiStringTag ||
274 (type & kAsciiDataHintMask) == kAsciiDataHintTag; 282 (type & kAsciiDataHintMask) == kAsciiDataHintTag;
275 } 283 }
276 284
277 285
278 bool StringShape::IsCons() { 286 bool StringShape::IsCons() {
279 return (type_ & kStringRepresentationMask) == kConsStringTag; 287 return (type_ & kStringRepresentationMask) == kConsStringTag;
280 } 288 }
281 289
282 290
291 bool StringShape::IsSliced() {
292 return (type_ & kStringRepresentationMask) == kSlicedStringTag;
293 }
294
295
283 bool StringShape::IsExternal() { 296 bool StringShape::IsExternal() {
284 return (type_ & kStringRepresentationMask) == kExternalStringTag; 297 return (type_ & kStringRepresentationMask) == kExternalStringTag;
285 } 298 }
286 299
287 300
288 bool StringShape::IsSequential() { 301 bool StringShape::IsSequential() {
289 return (type_ & kStringRepresentationMask) == kSeqStringTag; 302 return (type_ & kStringRepresentationMask) == kSeqStringTag;
290 } 303 }
291 304
292 305
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 CAST_ACCESSOR(JSFunctionResultCache) 2047 CAST_ACCESSOR(JSFunctionResultCache)
2035 CAST_ACCESSOR(NormalizedMapCache) 2048 CAST_ACCESSOR(NormalizedMapCache)
2036 CAST_ACCESSOR(CompilationCacheTable) 2049 CAST_ACCESSOR(CompilationCacheTable)
2037 CAST_ACCESSOR(CodeCacheHashTable) 2050 CAST_ACCESSOR(CodeCacheHashTable)
2038 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) 2051 CAST_ACCESSOR(PolymorphicCodeCacheHashTable)
2039 CAST_ACCESSOR(MapCache) 2052 CAST_ACCESSOR(MapCache)
2040 CAST_ACCESSOR(String) 2053 CAST_ACCESSOR(String)
2041 CAST_ACCESSOR(SeqString) 2054 CAST_ACCESSOR(SeqString)
2042 CAST_ACCESSOR(SeqAsciiString) 2055 CAST_ACCESSOR(SeqAsciiString)
2043 CAST_ACCESSOR(SeqTwoByteString) 2056 CAST_ACCESSOR(SeqTwoByteString)
2057 CAST_ACCESSOR(SlicedString)
2044 CAST_ACCESSOR(ConsString) 2058 CAST_ACCESSOR(ConsString)
2045 CAST_ACCESSOR(ExternalString) 2059 CAST_ACCESSOR(ExternalString)
2046 CAST_ACCESSOR(ExternalAsciiString) 2060 CAST_ACCESSOR(ExternalAsciiString)
2047 CAST_ACCESSOR(ExternalTwoByteString) 2061 CAST_ACCESSOR(ExternalTwoByteString)
2048 CAST_ACCESSOR(JSReceiver) 2062 CAST_ACCESSOR(JSReceiver)
2049 CAST_ACCESSOR(JSObject) 2063 CAST_ACCESSOR(JSObject)
2050 CAST_ACCESSOR(Smi) 2064 CAST_ACCESSOR(Smi)
2051 CAST_ACCESSOR(HeapObject) 2065 CAST_ACCESSOR(HeapObject)
2052 CAST_ACCESSOR(HeapNumber) 2066 CAST_ACCESSOR(HeapNumber)
2053 CAST_ACCESSOR(Oddball) 2067 CAST_ACCESSOR(Oddball)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); 2163 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index);
2150 case kSeqStringTag | kTwoByteStringTag: 2164 case kSeqStringTag | kTwoByteStringTag:
2151 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); 2165 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index);
2152 case kConsStringTag | kAsciiStringTag: 2166 case kConsStringTag | kAsciiStringTag:
2153 case kConsStringTag | kTwoByteStringTag: 2167 case kConsStringTag | kTwoByteStringTag:
2154 return ConsString::cast(this)->ConsStringGet(index); 2168 return ConsString::cast(this)->ConsStringGet(index);
2155 case kExternalStringTag | kAsciiStringTag: 2169 case kExternalStringTag | kAsciiStringTag:
2156 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); 2170 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index);
2157 case kExternalStringTag | kTwoByteStringTag: 2171 case kExternalStringTag | kTwoByteStringTag:
2158 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); 2172 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
2173 case kSlicedStringTag | kAsciiStringTag:
2174 case kSlicedStringTag | kTwoByteStringTag:
2175 return SlicedString::cast(this)->SlicedStringGet(index);
2159 default: 2176 default:
2160 break; 2177 break;
2161 } 2178 }
2162 2179
2163 UNREACHABLE(); 2180 UNREACHABLE();
2164 return 0; 2181 return 0;
2165 } 2182 }
2166 2183
2167 2184
2168 void String::Set(int index, uint16_t value) { 2185 void String::Set(int index, uint16_t value) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) { 2253 int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) {
2237 return SizeFor(length()); 2254 return SizeFor(length());
2238 } 2255 }
2239 2256
2240 2257
2241 int SeqAsciiString::SeqAsciiStringSize(InstanceType instance_type) { 2258 int SeqAsciiString::SeqAsciiStringSize(InstanceType instance_type) {
2242 return SizeFor(length()); 2259 return SizeFor(length());
2243 } 2260 }
2244 2261
2245 2262
2263 String* SlicedString::parent() {
2264 return String::cast(READ_FIELD(this, kParentOffset));
2265 }
2266
2267
2268 void SlicedString::set_parent(String* parent, WriteBarrierMode mode) {
2269 WRITE_FIELD(this, kParentOffset, parent);
antonm 2011/07/27 12:16:39 maybe add an assert that parent is never a sliced
2270 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, mode);
2271 }
2272
2273
2274 SMI_ACCESSORS(SlicedString, offset, kOffsetOffset)
2275
2276
2246 String* ConsString::first() { 2277 String* ConsString::first() {
2247 return String::cast(READ_FIELD(this, kFirstOffset)); 2278 return String::cast(READ_FIELD(this, kFirstOffset));
2248 } 2279 }
2249 2280
2250 2281
2251 Object* ConsString::unchecked_first() { 2282 Object* ConsString::unchecked_first() {
2252 return READ_FIELD(this, kFirstOffset); 2283 return READ_FIELD(this, kFirstOffset);
2253 } 2284 }
2254 2285
2255 2286
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
4511 #undef WRITE_INT_FIELD 4542 #undef WRITE_INT_FIELD
4512 #undef READ_SHORT_FIELD 4543 #undef READ_SHORT_FIELD
4513 #undef WRITE_SHORT_FIELD 4544 #undef WRITE_SHORT_FIELD
4514 #undef READ_BYTE_FIELD 4545 #undef READ_BYTE_FIELD
4515 #undef WRITE_BYTE_FIELD 4546 #undef WRITE_BYTE_FIELD
4516 4547
4517 4548
4518 } } // namespace v8::internal 4549 } } // namespace v8::internal
4519 4550
4520 #endif // V8_OBJECTS_INL_H_ 4551 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698