OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 bool StringShape::IsExternalTwoByte() { | 466 bool StringShape::IsExternalTwoByte() { |
467 return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag); | 467 return full_representation_tag() == (kExternalStringTag | kTwoByteStringTag); |
468 } | 468 } |
469 | 469 |
470 | 470 |
471 STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) == | 471 STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) == |
472 Internals::kExternalTwoByteRepresentationTag); | 472 Internals::kExternalTwoByteRepresentationTag); |
473 | 473 |
474 STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag); | 474 STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag); |
475 | 475 |
| 476 |
476 uc32 FlatStringReader::Get(int index) { | 477 uc32 FlatStringReader::Get(int index) { |
477 DCHECK(0 <= index && index <= length_); | |
478 if (is_one_byte_) { | 478 if (is_one_byte_) { |
479 return static_cast<const byte*>(start_)[index]; | 479 return Get<uint8_t>(index); |
480 } else { | 480 } else { |
481 return static_cast<const uc16*>(start_)[index]; | 481 return Get<uc16>(index); |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
| 485 |
| 486 template <typename Char> |
| 487 Char FlatStringReader::Get(int index) { |
| 488 DCHECK_EQ(is_one_byte_, sizeof(Char) == 1); |
| 489 DCHECK(0 <= index && index <= length_); |
| 490 if (sizeof(Char) == 1) { |
| 491 return static_cast<Char>(static_cast<const uint8_t*>(start_)[index]); |
| 492 } else { |
| 493 return static_cast<Char>(static_cast<const uc16*>(start_)[index]); |
| 494 } |
| 495 } |
| 496 |
485 | 497 |
486 Handle<Object> StringTableShape::AsHandle(Isolate* isolate, HashTableKey* key) { | 498 Handle<Object> StringTableShape::AsHandle(Isolate* isolate, HashTableKey* key) { |
487 return key->AsHandle(isolate); | 499 return key->AsHandle(isolate); |
488 } | 500 } |
489 | 501 |
490 | 502 |
491 Handle<Object> CompilationCacheShape::AsHandle(Isolate* isolate, | 503 Handle<Object> CompilationCacheShape::AsHandle(Isolate* isolate, |
492 HashTableKey* key) { | 504 HashTableKey* key) { |
493 return key->AsHandle(isolate); | 505 return key->AsHandle(isolate); |
494 } | 506 } |
(...skipping 6924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7419 #undef READ_SHORT_FIELD | 7431 #undef READ_SHORT_FIELD |
7420 #undef WRITE_SHORT_FIELD | 7432 #undef WRITE_SHORT_FIELD |
7421 #undef READ_BYTE_FIELD | 7433 #undef READ_BYTE_FIELD |
7422 #undef WRITE_BYTE_FIELD | 7434 #undef WRITE_BYTE_FIELD |
7423 #undef NOBARRIER_READ_BYTE_FIELD | 7435 #undef NOBARRIER_READ_BYTE_FIELD |
7424 #undef NOBARRIER_WRITE_BYTE_FIELD | 7436 #undef NOBARRIER_WRITE_BYTE_FIELD |
7425 | 7437 |
7426 } } // namespace v8::internal | 7438 } } // namespace v8::internal |
7427 | 7439 |
7428 #endif // V8_OBJECTS_INL_H_ | 7440 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |