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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 290 |
291 bool StringShape::IsSymbol() { | 291 bool StringShape::IsSymbol() { |
292 ASSERT(valid()); | 292 ASSERT(valid()); |
293 STATIC_ASSERT(kSymbolTag != 0); | 293 STATIC_ASSERT(kSymbolTag != 0); |
294 return (type_ & kIsSymbolMask) != 0; | 294 return (type_ & kIsSymbolMask) != 0; |
295 } | 295 } |
296 | 296 |
297 | 297 |
298 bool String::IsAsciiRepresentation() { | 298 bool String::IsAsciiRepresentation() { |
299 uint32_t type = map()->instance_type(); | 299 uint32_t type = map()->instance_type(); |
300 return (type & kStringEncodingMask) == kAsciiStringTag; | 300 return (type & kStringEncodingMask) == kOneByteStringTag; |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 bool String::IsTwoByteRepresentation() { | 304 bool String::IsTwoByteRepresentation() { |
305 uint32_t type = map()->instance_type(); | 305 uint32_t type = map()->instance_type(); |
306 return (type & kStringEncodingMask) == kTwoByteStringTag; | 306 return (type & kStringEncodingMask) == kTwoByteStringTag; |
307 } | 307 } |
308 | 308 |
309 | 309 |
310 bool String::IsAsciiRepresentationUnderneath() { | 310 bool String::IsAsciiRepresentationUnderneath() { |
311 uint32_t type = map()->instance_type(); | 311 uint32_t type = map()->instance_type(); |
312 STATIC_ASSERT(kIsIndirectStringTag != 0); | 312 STATIC_ASSERT(kIsIndirectStringTag != 0); |
313 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); | 313 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); |
314 ASSERT(IsFlat()); | 314 ASSERT(IsFlat()); |
315 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { | 315 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { |
316 case kAsciiStringTag: | 316 case kOneByteStringTag: |
317 return true; | 317 return true; |
318 case kTwoByteStringTag: | 318 case kTwoByteStringTag: |
319 return false; | 319 return false; |
320 default: // Cons or sliced string. Need to go deeper. | 320 default: // Cons or sliced string. Need to go deeper. |
321 return GetUnderlying()->IsAsciiRepresentation(); | 321 return GetUnderlying()->IsAsciiRepresentation(); |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 | 325 |
326 bool String::IsTwoByteRepresentationUnderneath() { | 326 bool String::IsTwoByteRepresentationUnderneath() { |
327 uint32_t type = map()->instance_type(); | 327 uint32_t type = map()->instance_type(); |
328 STATIC_ASSERT(kIsIndirectStringTag != 0); | 328 STATIC_ASSERT(kIsIndirectStringTag != 0); |
329 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); | 329 STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0); |
330 ASSERT(IsFlat()); | 330 ASSERT(IsFlat()); |
331 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { | 331 switch (type & (kIsIndirectStringMask | kStringEncodingMask)) { |
332 case kAsciiStringTag: | 332 case kOneByteStringTag: |
333 return false; | 333 return false; |
334 case kTwoByteStringTag: | 334 case kTwoByteStringTag: |
335 return true; | 335 return true; |
336 default: // Cons or sliced string. Need to go deeper. | 336 default: // Cons or sliced string. Need to go deeper. |
337 return GetUnderlying()->IsTwoByteRepresentation(); | 337 return GetUnderlying()->IsTwoByteRepresentation(); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 | 341 |
342 bool String::HasOnlyAsciiChars() { | 342 bool String::HasOnlyAsciiChars() { |
343 uint32_t type = map()->instance_type(); | 343 uint32_t type = map()->instance_type(); |
344 return (type & kStringEncodingMask) == kAsciiStringTag || | 344 return (type & kStringEncodingMask) == kOneByteStringTag || |
345 (type & kAsciiDataHintMask) == kAsciiDataHintTag; | 345 (type & kAsciiDataHintMask) == kAsciiDataHintTag; |
346 } | 346 } |
347 | 347 |
348 | 348 |
349 bool StringShape::IsCons() { | 349 bool StringShape::IsCons() { |
350 return (type_ & kStringRepresentationMask) == kConsStringTag; | 350 return (type_ & kStringRepresentationMask) == kConsStringTag; |
351 } | 351 } |
352 | 352 |
353 | 353 |
354 bool StringShape::IsSliced() { | 354 bool StringShape::IsSliced() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 | 389 |
390 STATIC_CHECK((kStringRepresentationMask | kStringEncodingMask) == | 390 STATIC_CHECK((kStringRepresentationMask | kStringEncodingMask) == |
391 Internals::kFullStringRepresentationMask); | 391 Internals::kFullStringRepresentationMask); |
392 | 392 |
393 STATIC_CHECK(static_cast<uint32_t>(kStringEncodingMask) == | 393 STATIC_CHECK(static_cast<uint32_t>(kStringEncodingMask) == |
394 Internals::kStringEncodingMask); | 394 Internals::kStringEncodingMask); |
395 | 395 |
396 | 396 |
397 bool StringShape::IsSequentialAscii() { | 397 bool StringShape::IsSequentialAscii() { |
398 return full_representation_tag() == (kSeqStringTag | kAsciiStringTag); | 398 return full_representation_tag() == (kSeqStringTag | kOneByteStringTag); |
399 } | 399 } |
400 | 400 |
401 | 401 |
402 bool StringShape::IsSequentialTwoByte() { | 402 bool StringShape::IsSequentialTwoByte() { |
403 return full_representation_tag() == (kSeqStringTag | kTwoByteStringTag); | 403 return full_representation_tag() == (kSeqStringTag | kTwoByteStringTag); |
404 } | 404 } |
405 | 405 |
406 | 406 |
407 bool StringShape::IsExternalAscii() { | 407 bool StringShape::IsExternalAscii() { |
408 return full_representation_tag() == (kExternalStringTag | kAsciiStringTag); | 408 return full_representation_tag() == (kExternalStringTag | kOneByteStringTag); |
409 } | 409 } |
410 | 410 |
411 | 411 |
412 STATIC_CHECK((kExternalStringTag | kAsciiStringTag) == | 412 STATIC_CHECK((kExternalStringTag | kOneByteStringTag) == |
413 Internals::kExternalAsciiRepresentationTag); | 413 Internals::kExternalAsciiRepresentationTag); |
414 | 414 |
415 STATIC_CHECK(v8::String::ASCII_ENCODING == kAsciiStringTag); | 415 STATIC_CHECK(v8::String::ASCII_ENCODING == kOneByteStringTag); |
416 | 416 |
417 | 417 |
418 bool StringShape::IsExternalTwoByte() { | 418 bool StringShape::IsExternalTwoByte() { |
419 return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag); | 419 return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag); |
420 } | 420 } |
421 | 421 |
422 | 422 |
423 STATIC_CHECK((kExternalStringTag | kTwoByteStringTag) == | 423 STATIC_CHECK((kExternalStringTag | kTwoByteStringTag) == |
424 Internals::kExternalTwoByteRepresentationTag); | 424 Internals::kExternalTwoByteRepresentationTag); |
425 | 425 |
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 MaybeObject* flat = TryFlatten(pretenure); | 2451 MaybeObject* flat = TryFlatten(pretenure); |
2452 Object* successfully_flattened; | 2452 Object* successfully_flattened; |
2453 if (!flat->ToObject(&successfully_flattened)) return this; | 2453 if (!flat->ToObject(&successfully_flattened)) return this; |
2454 return String::cast(successfully_flattened); | 2454 return String::cast(successfully_flattened); |
2455 } | 2455 } |
2456 | 2456 |
2457 | 2457 |
2458 uint16_t String::Get(int index) { | 2458 uint16_t String::Get(int index) { |
2459 ASSERT(index >= 0 && index < length()); | 2459 ASSERT(index >= 0 && index < length()); |
2460 switch (StringShape(this).full_representation_tag()) { | 2460 switch (StringShape(this).full_representation_tag()) { |
2461 case kSeqStringTag | kAsciiStringTag: | 2461 case kSeqStringTag | kOneByteStringTag: |
2462 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); | 2462 return SeqAsciiString::cast(this)->SeqAsciiStringGet(index); |
2463 case kSeqStringTag | kTwoByteStringTag: | 2463 case kSeqStringTag | kTwoByteStringTag: |
2464 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); | 2464 return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index); |
2465 case kConsStringTag | kAsciiStringTag: | 2465 case kConsStringTag | kOneByteStringTag: |
2466 case kConsStringTag | kTwoByteStringTag: | 2466 case kConsStringTag | kTwoByteStringTag: |
2467 return ConsString::cast(this)->ConsStringGet(index); | 2467 return ConsString::cast(this)->ConsStringGet(index); |
2468 case kExternalStringTag | kAsciiStringTag: | 2468 case kExternalStringTag | kOneByteStringTag: |
2469 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); | 2469 return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index); |
2470 case kExternalStringTag | kTwoByteStringTag: | 2470 case kExternalStringTag | kTwoByteStringTag: |
2471 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); | 2471 return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index); |
2472 case kSlicedStringTag | kAsciiStringTag: | 2472 case kSlicedStringTag | kOneByteStringTag: |
2473 case kSlicedStringTag | kTwoByteStringTag: | 2473 case kSlicedStringTag | kTwoByteStringTag: |
2474 return SlicedString::cast(this)->SlicedStringGet(index); | 2474 return SlicedString::cast(this)->SlicedStringGet(index); |
2475 default: | 2475 default: |
2476 break; | 2476 break; |
2477 } | 2477 } |
2478 | 2478 |
2479 UNREACHABLE(); | 2479 UNREACHABLE(); |
2480 return 0; | 2480 return 0; |
2481 } | 2481 } |
2482 | 2482 |
(...skipping 3082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5565 #undef WRITE_UINT32_FIELD | 5565 #undef WRITE_UINT32_FIELD |
5566 #undef READ_SHORT_FIELD | 5566 #undef READ_SHORT_FIELD |
5567 #undef WRITE_SHORT_FIELD | 5567 #undef WRITE_SHORT_FIELD |
5568 #undef READ_BYTE_FIELD | 5568 #undef READ_BYTE_FIELD |
5569 #undef WRITE_BYTE_FIELD | 5569 #undef WRITE_BYTE_FIELD |
5570 | 5570 |
5571 | 5571 |
5572 } } // namespace v8::internal | 5572 } } // namespace v8::internal |
5573 | 5573 |
5574 #endif // V8_OBJECTS_INL_H_ | 5574 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |