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 3675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3686 return GetChars()[index]; | 3686 return GetChars()[index]; |
3687 } | 3687 } |
3688 | 3688 |
3689 | 3689 |
3690 const uint16_t* ExternalTwoByteString::ExternalTwoByteStringGetData( | 3690 const uint16_t* ExternalTwoByteString::ExternalTwoByteStringGetData( |
3691 unsigned start) { | 3691 unsigned start) { |
3692 return GetChars() + start; | 3692 return GetChars() + start; |
3693 } | 3693 } |
3694 | 3694 |
3695 | 3695 |
3696 int ConsStringIteratorOp::OffsetForDepth(int depth) { | 3696 int ConsStringIterator::OffsetForDepth(int depth) { return depth & kDepthMask; } |
3697 return depth & kDepthMask; | |
3698 } | |
3699 | 3697 |
3700 | 3698 |
3701 void ConsStringIteratorOp::PushLeft(ConsString* string) { | 3699 void ConsStringIterator::PushLeft(ConsString* string) { |
3702 frames_[depth_++ & kDepthMask] = string; | 3700 frames_[depth_++ & kDepthMask] = string; |
3703 } | 3701 } |
3704 | 3702 |
3705 | 3703 |
3706 void ConsStringIteratorOp::PushRight(ConsString* string) { | 3704 void ConsStringIterator::PushRight(ConsString* string) { |
3707 // Inplace update. | 3705 // Inplace update. |
3708 frames_[(depth_-1) & kDepthMask] = string; | 3706 frames_[(depth_-1) & kDepthMask] = string; |
3709 } | 3707 } |
3710 | 3708 |
3711 | 3709 |
3712 void ConsStringIteratorOp::AdjustMaximumDepth() { | 3710 void ConsStringIterator::AdjustMaximumDepth() { |
3713 if (depth_ > maximum_depth_) maximum_depth_ = depth_; | 3711 if (depth_ > maximum_depth_) maximum_depth_ = depth_; |
3714 } | 3712 } |
3715 | 3713 |
3716 | 3714 |
3717 void ConsStringIteratorOp::Pop() { | 3715 void ConsStringIterator::Pop() { |
3718 DCHECK(depth_ > 0); | 3716 DCHECK(depth_ > 0); |
3719 DCHECK(depth_ <= maximum_depth_); | 3717 DCHECK(depth_ <= maximum_depth_); |
3720 depth_--; | 3718 depth_--; |
3721 } | 3719 } |
3722 | 3720 |
3723 | 3721 |
3724 uint16_t StringCharacterStream::GetNext() { | 3722 uint16_t StringCharacterStream::GetNext() { |
3725 DCHECK(buffer8_ != NULL && end_ != NULL); | 3723 DCHECK(buffer8_ != NULL && end_ != NULL); |
3726 // Advance cursor if needed. | 3724 // Advance cursor if needed. |
3727 if (buffer8_ == end_) HasMore(); | 3725 if (buffer8_ == end_) HasMore(); |
3728 DCHECK(buffer8_ < end_); | 3726 DCHECK(buffer8_ < end_); |
3729 return is_one_byte_ ? *buffer8_++ : *buffer16_++; | 3727 return is_one_byte_ ? *buffer8_++ : *buffer16_++; |
3730 } | 3728 } |
3731 | 3729 |
3732 | 3730 |
3733 StringCharacterStream::StringCharacterStream(String* string, | 3731 StringCharacterStream::StringCharacterStream(String* string, int offset) |
3734 ConsStringIteratorOp* op, | 3732 : is_one_byte_(false) { |
3735 int offset) | |
3736 : is_one_byte_(false), | |
3737 op_(op) { | |
3738 Reset(string, offset); | 3733 Reset(string, offset); |
3739 } | 3734 } |
3740 | 3735 |
3741 | 3736 |
3742 void StringCharacterStream::Reset(String* string, int offset) { | 3737 void StringCharacterStream::Reset(String* string, int offset) { |
3743 buffer8_ = NULL; | 3738 buffer8_ = NULL; |
3744 end_ = NULL; | 3739 end_ = NULL; |
3745 ConsString* cons_string = String::VisitFlat(this, string, offset); | 3740 ConsString* cons_string = String::VisitFlat(this, string, offset); |
3746 op_->Reset(cons_string, offset); | 3741 iter_.Reset(cons_string, offset); |
3747 if (cons_string != NULL) { | 3742 if (cons_string != NULL) { |
3748 string = op_->Next(&offset); | 3743 string = iter_.Next(&offset); |
3749 if (string != NULL) String::VisitFlat(this, string, offset); | 3744 if (string != NULL) String::VisitFlat(this, string, offset); |
3750 } | 3745 } |
3751 } | 3746 } |
3752 | 3747 |
3753 | 3748 |
3754 bool StringCharacterStream::HasMore() { | 3749 bool StringCharacterStream::HasMore() { |
3755 if (buffer8_ != end_) return true; | 3750 if (buffer8_ != end_) return true; |
3756 int offset; | 3751 int offset; |
3757 String* string = op_->Next(&offset); | 3752 String* string = iter_.Next(&offset); |
3758 DCHECK_EQ(offset, 0); | 3753 DCHECK_EQ(offset, 0); |
3759 if (string == NULL) return false; | 3754 if (string == NULL) return false; |
3760 String::VisitFlat(this, string); | 3755 String::VisitFlat(this, string); |
3761 DCHECK(buffer8_ != end_); | 3756 DCHECK(buffer8_ != end_); |
3762 return true; | 3757 return true; |
3763 } | 3758 } |
3764 | 3759 |
3765 | 3760 |
3766 void StringCharacterStream::VisitOneByteString( | 3761 void StringCharacterStream::VisitOneByteString( |
3767 const uint8_t* chars, int length) { | 3762 const uint8_t* chars, int length) { |
(...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6623 | 6618 |
6624 | 6619 |
6625 uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) { | 6620 uint32_t IteratingStringHasher::Hash(String* string, uint32_t seed) { |
6626 IteratingStringHasher hasher(string->length(), seed); | 6621 IteratingStringHasher hasher(string->length(), seed); |
6627 // Nothing to do. | 6622 // Nothing to do. |
6628 if (hasher.has_trivial_hash()) return hasher.GetHashField(); | 6623 if (hasher.has_trivial_hash()) return hasher.GetHashField(); |
6629 ConsString* cons_string = String::VisitFlat(&hasher, string); | 6624 ConsString* cons_string = String::VisitFlat(&hasher, string); |
6630 // The string was flat. | 6625 // The string was flat. |
6631 if (cons_string == NULL) return hasher.GetHashField(); | 6626 if (cons_string == NULL) return hasher.GetHashField(); |
6632 // This is a ConsString, iterate across it. | 6627 // This is a ConsString, iterate across it. |
6633 ConsStringIteratorOp op(cons_string); | 6628 ConsStringIterator iter(cons_string); |
6634 int offset; | 6629 int offset; |
6635 while (NULL != (string = op.Next(&offset))) { | 6630 while (NULL != (string = iter.Next(&offset))) { |
6636 String::VisitFlat(&hasher, string, offset); | 6631 String::VisitFlat(&hasher, string, offset); |
6637 } | 6632 } |
6638 return hasher.GetHashField(); | 6633 return hasher.GetHashField(); |
6639 } | 6634 } |
6640 | 6635 |
6641 | 6636 |
6642 void IteratingStringHasher::VisitOneByteString(const uint8_t* chars, | 6637 void IteratingStringHasher::VisitOneByteString(const uint8_t* chars, |
6643 int length) { | 6638 int length) { |
6644 AddCharacters(chars, length); | 6639 AddCharacters(chars, length); |
6645 } | 6640 } |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7283 #undef READ_SHORT_FIELD | 7278 #undef READ_SHORT_FIELD |
7284 #undef WRITE_SHORT_FIELD | 7279 #undef WRITE_SHORT_FIELD |
7285 #undef READ_BYTE_FIELD | 7280 #undef READ_BYTE_FIELD |
7286 #undef WRITE_BYTE_FIELD | 7281 #undef WRITE_BYTE_FIELD |
7287 #undef NOBARRIER_READ_BYTE_FIELD | 7282 #undef NOBARRIER_READ_BYTE_FIELD |
7288 #undef NOBARRIER_WRITE_BYTE_FIELD | 7283 #undef NOBARRIER_WRITE_BYTE_FIELD |
7289 | 7284 |
7290 } } // namespace v8::internal | 7285 } } // namespace v8::internal |
7291 | 7286 |
7292 #endif // V8_OBJECTS_INL_H_ | 7287 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |