| 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 6675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6686 return SmartArrayPointer<uc16>(result); | 6686 return SmartArrayPointer<uc16>(result); |
| 6687 } | 6687 } |
| 6688 | 6688 |
| 6689 | 6689 |
| 6690 const uc16* SeqTwoByteString::SeqTwoByteStringGetData(unsigned start) { | 6690 const uc16* SeqTwoByteString::SeqTwoByteStringGetData(unsigned start) { |
| 6691 return reinterpret_cast<uc16*>( | 6691 return reinterpret_cast<uc16*>( |
| 6692 reinterpret_cast<char*>(this) - kHeapObjectTag + kHeaderSize) + start; | 6692 reinterpret_cast<char*>(this) - kHeapObjectTag + kHeaderSize) + start; |
| 6693 } | 6693 } |
| 6694 | 6694 |
| 6695 | 6695 |
| 6696 void SeqTwoByteString::SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* rbb, | |
| 6697 unsigned* offset_ptr, | |
| 6698 unsigned max_chars) { | |
| 6699 unsigned chars_read = 0; | |
| 6700 unsigned offset = *offset_ptr; | |
| 6701 while (chars_read < max_chars) { | |
| 6702 uint16_t c = *reinterpret_cast<uint16_t*>( | |
| 6703 reinterpret_cast<char*>(this) - | |
| 6704 kHeapObjectTag + kHeaderSize + offset * kShortSize); | |
| 6705 if (c <= kMaxAsciiCharCode) { | |
| 6706 // Fast case for ASCII characters. Cursor is an input output argument. | |
| 6707 if (!unibrow::CharacterStream::EncodeAsciiCharacter(c, | |
| 6708 rbb->util_buffer, | |
| 6709 rbb->capacity, | |
| 6710 rbb->cursor)) { | |
| 6711 break; | |
| 6712 } | |
| 6713 } else { | |
| 6714 if (!unibrow::CharacterStream::EncodeNonAsciiCharacter(c, | |
| 6715 rbb->util_buffer, | |
| 6716 rbb->capacity, | |
| 6717 rbb->cursor)) { | |
| 6718 break; | |
| 6719 } | |
| 6720 } | |
| 6721 offset++; | |
| 6722 chars_read++; | |
| 6723 } | |
| 6724 *offset_ptr = offset; | |
| 6725 rbb->remaining += chars_read; | |
| 6726 } | |
| 6727 | |
| 6728 | |
| 6729 const unibrow::byte* SeqOneByteString::SeqOneByteStringReadBlock( | |
| 6730 unsigned* remaining, | |
| 6731 unsigned* offset_ptr, | |
| 6732 unsigned max_chars) { | |
| 6733 const unibrow::byte* b = reinterpret_cast<unibrow::byte*>(this) - | |
| 6734 kHeapObjectTag + kHeaderSize + *offset_ptr * kCharSize; | |
| 6735 *remaining = max_chars; | |
| 6736 *offset_ptr += max_chars; | |
| 6737 return b; | |
| 6738 } | |
| 6739 | |
| 6740 | |
| 6741 // This will iterate unless the block of string data spans two 'halves' of | |
| 6742 // a ConsString, in which case it will recurse. Since the block of string | |
| 6743 // data to be read has a maximum size this limits the maximum recursion | |
| 6744 // depth to something sane. Since C++ does not have tail call recursion | |
| 6745 // elimination, the iteration must be explicit. Since this is not an | |
| 6746 // -IntoBuffer method it can delegate to one of the efficient | |
| 6747 // *AsciiStringReadBlock routines. | |
| 6748 const unibrow::byte* ConsString::ConsStringReadBlock(ReadBlockBuffer* rbb, | |
| 6749 unsigned* offset_ptr, | |
| 6750 unsigned max_chars) { | |
| 6751 ConsString* current = this; | |
| 6752 unsigned offset = *offset_ptr; | |
| 6753 int offset_correction = 0; | |
| 6754 | |
| 6755 while (true) { | |
| 6756 String* left = current->first(); | |
| 6757 unsigned left_length = (unsigned)left->length(); | |
| 6758 if (left_length > offset && | |
| 6759 (max_chars <= left_length - offset || | |
| 6760 (rbb->capacity <= left_length - offset && | |
| 6761 (max_chars = left_length - offset, true)))) { // comma operator! | |
| 6762 // Left hand side only - iterate unless we have reached the bottom of | |
| 6763 // the cons tree. The assignment on the left of the comma operator is | |
| 6764 // in order to make use of the fact that the -IntoBuffer routines can | |
| 6765 // produce at most 'capacity' characters. This enables us to postpone | |
| 6766 // the point where we switch to the -IntoBuffer routines (below) in order | |
| 6767 // to maximize the chances of delegating a big chunk of work to the | |
| 6768 // efficient *AsciiStringReadBlock routines. | |
| 6769 if (StringShape(left).IsCons()) { | |
| 6770 current = ConsString::cast(left); | |
| 6771 continue; | |
| 6772 } else { | |
| 6773 const unibrow::byte* answer = | |
| 6774 String::ReadBlock(left, rbb, &offset, max_chars); | |
| 6775 *offset_ptr = offset + offset_correction; | |
| 6776 return answer; | |
| 6777 } | |
| 6778 } else if (left_length <= offset) { | |
| 6779 // Right hand side only - iterate unless we have reached the bottom of | |
| 6780 // the cons tree. | |
| 6781 String* right = current->second(); | |
| 6782 offset -= left_length; | |
| 6783 offset_correction += left_length; | |
| 6784 if (StringShape(right).IsCons()) { | |
| 6785 current = ConsString::cast(right); | |
| 6786 continue; | |
| 6787 } else { | |
| 6788 const unibrow::byte* answer = | |
| 6789 String::ReadBlock(right, rbb, &offset, max_chars); | |
| 6790 *offset_ptr = offset + offset_correction; | |
| 6791 return answer; | |
| 6792 } | |
| 6793 } else { | |
| 6794 // The block to be read spans two sides of the ConsString, so we call the | |
| 6795 // -IntoBuffer version, which will recurse. The -IntoBuffer methods | |
| 6796 // are able to assemble data from several part strings because they use | |
| 6797 // the util_buffer to store their data and never return direct pointers | |
| 6798 // to their storage. We don't try to read more than the buffer capacity | |
| 6799 // here or we can get too much recursion. | |
| 6800 ASSERT(rbb->remaining == 0); | |
| 6801 ASSERT(rbb->cursor == 0); | |
| 6802 current->ConsStringReadBlockIntoBuffer( | |
| 6803 rbb, | |
| 6804 &offset, | |
| 6805 max_chars > rbb->capacity ? rbb->capacity : max_chars); | |
| 6806 *offset_ptr = offset + offset_correction; | |
| 6807 return rbb->util_buffer; | |
| 6808 } | |
| 6809 } | |
| 6810 } | |
| 6811 | |
| 6812 | |
| 6813 const unibrow::byte* ExternalAsciiString::ExternalAsciiStringReadBlock( | |
| 6814 unsigned* remaining, | |
| 6815 unsigned* offset_ptr, | |
| 6816 unsigned max_chars) { | |
| 6817 // Cast const char* to unibrow::byte* (signedness difference). | |
| 6818 const unibrow::byte* b = | |
| 6819 reinterpret_cast<const unibrow::byte*>(GetChars()) + *offset_ptr; | |
| 6820 *remaining = max_chars; | |
| 6821 *offset_ptr += max_chars; | |
| 6822 return b; | |
| 6823 } | |
| 6824 | |
| 6825 | |
| 6826 void ExternalTwoByteString::ExternalTwoByteStringReadBlockIntoBuffer( | |
| 6827 ReadBlockBuffer* rbb, | |
| 6828 unsigned* offset_ptr, | |
| 6829 unsigned max_chars) { | |
| 6830 unsigned chars_read = 0; | |
| 6831 unsigned offset = *offset_ptr; | |
| 6832 const uint16_t* data = GetChars(); | |
| 6833 while (chars_read < max_chars) { | |
| 6834 uint16_t c = data[offset]; | |
| 6835 if (c <= kMaxAsciiCharCode) { | |
| 6836 // Fast case for ASCII characters. Cursor is an input output argument. | |
| 6837 if (!unibrow::CharacterStream::EncodeAsciiCharacter(c, | |
| 6838 rbb->util_buffer, | |
| 6839 rbb->capacity, | |
| 6840 rbb->cursor)) | |
| 6841 break; | |
| 6842 } else { | |
| 6843 if (!unibrow::CharacterStream::EncodeNonAsciiCharacter(c, | |
| 6844 rbb->util_buffer, | |
| 6845 rbb->capacity, | |
| 6846 rbb->cursor)) | |
| 6847 break; | |
| 6848 } | |
| 6849 offset++; | |
| 6850 chars_read++; | |
| 6851 } | |
| 6852 *offset_ptr = offset; | |
| 6853 rbb->remaining += chars_read; | |
| 6854 } | |
| 6855 | |
| 6856 | |
| 6857 void SeqOneByteString::SeqOneByteStringReadBlockIntoBuffer(ReadBlockBuffer* rbb, | |
| 6858 unsigned* offset_ptr, | |
| 6859 unsigned max_chars) { | |
| 6860 unsigned capacity = rbb->capacity - rbb->cursor; | |
| 6861 if (max_chars > capacity) max_chars = capacity; | |
| 6862 memcpy(rbb->util_buffer + rbb->cursor, | |
| 6863 reinterpret_cast<char*>(this) - kHeapObjectTag + kHeaderSize + | |
| 6864 *offset_ptr * kCharSize, | |
| 6865 max_chars); | |
| 6866 rbb->remaining += max_chars; | |
| 6867 *offset_ptr += max_chars; | |
| 6868 rbb->cursor += max_chars; | |
| 6869 } | |
| 6870 | |
| 6871 | |
| 6872 void ExternalAsciiString::ExternalAsciiStringReadBlockIntoBuffer( | |
| 6873 ReadBlockBuffer* rbb, | |
| 6874 unsigned* offset_ptr, | |
| 6875 unsigned max_chars) { | |
| 6876 unsigned capacity = rbb->capacity - rbb->cursor; | |
| 6877 if (max_chars > capacity) max_chars = capacity; | |
| 6878 memcpy(rbb->util_buffer + rbb->cursor, GetChars() + *offset_ptr, max_chars); | |
| 6879 rbb->remaining += max_chars; | |
| 6880 *offset_ptr += max_chars; | |
| 6881 rbb->cursor += max_chars; | |
| 6882 } | |
| 6883 | |
| 6884 | |
| 6885 // This method determines the type of string involved and then copies | |
| 6886 // a whole chunk of characters into a buffer, or returns a pointer to a buffer | |
| 6887 // where they can be found. The pointer is not necessarily valid across a GC | |
| 6888 // (see AsciiStringReadBlock). | |
| 6889 const unibrow::byte* String::ReadBlock(String* input, | |
| 6890 ReadBlockBuffer* rbb, | |
| 6891 unsigned* offset_ptr, | |
| 6892 unsigned max_chars) { | |
| 6893 ASSERT(*offset_ptr <= static_cast<unsigned>(input->length())); | |
| 6894 if (max_chars == 0) { | |
| 6895 rbb->remaining = 0; | |
| 6896 return NULL; | |
| 6897 } | |
| 6898 switch (StringShape(input).representation_tag()) { | |
| 6899 case kSeqStringTag: | |
| 6900 if (input->IsOneByteRepresentation()) { | |
| 6901 SeqOneByteString* str = SeqOneByteString::cast(input); | |
| 6902 return str->SeqOneByteStringReadBlock(&rbb->remaining, | |
| 6903 offset_ptr, | |
| 6904 max_chars); | |
| 6905 } else { | |
| 6906 SeqTwoByteString* str = SeqTwoByteString::cast(input); | |
| 6907 str->SeqTwoByteStringReadBlockIntoBuffer(rbb, | |
| 6908 offset_ptr, | |
| 6909 max_chars); | |
| 6910 return rbb->util_buffer; | |
| 6911 } | |
| 6912 case kConsStringTag: | |
| 6913 return ConsString::cast(input)->ConsStringReadBlock(rbb, | |
| 6914 offset_ptr, | |
| 6915 max_chars); | |
| 6916 case kExternalStringTag: | |
| 6917 if (input->IsOneByteRepresentation()) { | |
| 6918 return ExternalAsciiString::cast(input)->ExternalAsciiStringReadBlock( | |
| 6919 &rbb->remaining, | |
| 6920 offset_ptr, | |
| 6921 max_chars); | |
| 6922 } else { | |
| 6923 ExternalTwoByteString::cast(input)-> | |
| 6924 ExternalTwoByteStringReadBlockIntoBuffer(rbb, | |
| 6925 offset_ptr, | |
| 6926 max_chars); | |
| 6927 return rbb->util_buffer; | |
| 6928 } | |
| 6929 case kSlicedStringTag: | |
| 6930 return SlicedString::cast(input)->SlicedStringReadBlock(rbb, | |
| 6931 offset_ptr, | |
| 6932 max_chars); | |
| 6933 default: | |
| 6934 break; | |
| 6935 } | |
| 6936 | |
| 6937 UNREACHABLE(); | |
| 6938 return 0; | |
| 6939 } | |
| 6940 | |
| 6941 | |
| 6942 void Relocatable::PostGarbageCollectionProcessing() { | 6696 void Relocatable::PostGarbageCollectionProcessing() { |
| 6943 Isolate* isolate = Isolate::Current(); | 6697 Isolate* isolate = Isolate::Current(); |
| 6944 Relocatable* current = isolate->relocatable_top(); | 6698 Relocatable* current = isolate->relocatable_top(); |
| 6945 while (current != NULL) { | 6699 while (current != NULL) { |
| 6946 current->PostGarbageCollection(); | 6700 current->PostGarbageCollection(); |
| 6947 current = current->prev_; | 6701 current = current->prev_; |
| 6948 } | 6702 } |
| 6949 } | 6703 } |
| 6950 | 6704 |
| 6951 | 6705 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7016 ASSERT(content.IsFlat()); | 6770 ASSERT(content.IsFlat()); |
| 7017 is_ascii_ = content.IsAscii(); | 6771 is_ascii_ = content.IsAscii(); |
| 7018 if (is_ascii_) { | 6772 if (is_ascii_) { |
| 7019 start_ = content.ToAsciiVector().start(); | 6773 start_ = content.ToAsciiVector().start(); |
| 7020 } else { | 6774 } else { |
| 7021 start_ = content.ToUC16Vector().start(); | 6775 start_ = content.ToUC16Vector().start(); |
| 7022 } | 6776 } |
| 7023 } | 6777 } |
| 7024 | 6778 |
| 7025 | 6779 |
| 7026 void StringInputBuffer::Seek(unsigned pos) { | |
| 7027 Reset(pos, input_); | |
| 7028 } | |
| 7029 | |
| 7030 | |
| 7031 String* ConsStringIteratorOp::Operate(String* string, | 6780 String* ConsStringIteratorOp::Operate(String* string, |
| 7032 unsigned* offset_out, | 6781 unsigned* offset_out, |
| 7033 int32_t* type_out, | 6782 int32_t* type_out, |
| 7034 unsigned* length_out) { | 6783 unsigned* length_out) { |
| 7035 ASSERT(string->IsConsString()); | 6784 ASSERT(string->IsConsString()); |
| 7036 ConsString* cons_string = ConsString::cast(string); | 6785 ConsString* cons_string = ConsString::cast(string); |
| 7037 // Set up search data. | 6786 // Set up search data. |
| 7038 root_ = cons_string; | 6787 root_ = cons_string; |
| 7039 consumed_ = *offset_out; | 6788 consumed_ = *offset_out; |
| 7040 // Now search. | 6789 // Now search. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7156 } | 6905 } |
| 7157 cons_string = ConsString::cast(string); | 6906 cons_string = ConsString::cast(string); |
| 7158 PushLeft(cons_string); | 6907 PushLeft(cons_string); |
| 7159 } | 6908 } |
| 7160 } | 6909 } |
| 7161 UNREACHABLE(); | 6910 UNREACHABLE(); |
| 7162 return NULL; | 6911 return NULL; |
| 7163 } | 6912 } |
| 7164 | 6913 |
| 7165 | 6914 |
| 7166 // This method determines the type of string involved and then copies | |
| 7167 // a whole chunk of characters into a buffer. It can be used with strings | |
| 7168 // that have been glued together to form a ConsString and which must cooperate | |
| 7169 // to fill up a buffer. | |
| 7170 void String::ReadBlockIntoBuffer(String* input, | |
| 7171 ReadBlockBuffer* rbb, | |
| 7172 unsigned* offset_ptr, | |
| 7173 unsigned max_chars) { | |
| 7174 ASSERT(*offset_ptr <= (unsigned)input->length()); | |
| 7175 if (max_chars == 0) return; | |
| 7176 | |
| 7177 switch (StringShape(input).representation_tag()) { | |
| 7178 case kSeqStringTag: | |
| 7179 if (input->IsOneByteRepresentation()) { | |
| 7180 SeqOneByteString::cast(input)->SeqOneByteStringReadBlockIntoBuffer(rbb, | |
| 7181 offset_ptr, | |
| 7182 max_chars); | |
| 7183 return; | |
| 7184 } else { | |
| 7185 SeqTwoByteString::cast(input)->SeqTwoByteStringReadBlockIntoBuffer(rbb, | |
| 7186 offset_ptr, | |
| 7187 max_chars); | |
| 7188 return; | |
| 7189 } | |
| 7190 case kConsStringTag: | |
| 7191 ConsString::cast(input)->ConsStringReadBlockIntoBuffer(rbb, | |
| 7192 offset_ptr, | |
| 7193 max_chars); | |
| 7194 return; | |
| 7195 case kExternalStringTag: | |
| 7196 if (input->IsOneByteRepresentation()) { | |
| 7197 ExternalAsciiString::cast(input)-> | |
| 7198 ExternalAsciiStringReadBlockIntoBuffer(rbb, offset_ptr, max_chars); | |
| 7199 } else { | |
| 7200 ExternalTwoByteString::cast(input)-> | |
| 7201 ExternalTwoByteStringReadBlockIntoBuffer(rbb, | |
| 7202 offset_ptr, | |
| 7203 max_chars); | |
| 7204 } | |
| 7205 return; | |
| 7206 case kSlicedStringTag: | |
| 7207 SlicedString::cast(input)->SlicedStringReadBlockIntoBuffer(rbb, | |
| 7208 offset_ptr, | |
| 7209 max_chars); | |
| 7210 return; | |
| 7211 default: | |
| 7212 break; | |
| 7213 } | |
| 7214 | |
| 7215 UNREACHABLE(); | |
| 7216 return; | |
| 7217 } | |
| 7218 | |
| 7219 | |
| 7220 const unibrow::byte* String::ReadBlock(String* input, | |
| 7221 unibrow::byte* util_buffer, | |
| 7222 unsigned capacity, | |
| 7223 unsigned* remaining, | |
| 7224 unsigned* offset_ptr) { | |
| 7225 ASSERT(*offset_ptr <= (unsigned)input->length()); | |
| 7226 unsigned chars = input->length() - *offset_ptr; | |
| 7227 ReadBlockBuffer rbb(util_buffer, 0, capacity, 0); | |
| 7228 const unibrow::byte* answer = ReadBlock(input, &rbb, offset_ptr, chars); | |
| 7229 ASSERT(rbb.remaining <= static_cast<unsigned>(input->length())); | |
| 7230 *remaining = rbb.remaining; | |
| 7231 return answer; | |
| 7232 } | |
| 7233 | |
| 7234 | |
| 7235 const unibrow::byte* String::ReadBlock(String** raw_input, | |
| 7236 unibrow::byte* util_buffer, | |
| 7237 unsigned capacity, | |
| 7238 unsigned* remaining, | |
| 7239 unsigned* offset_ptr) { | |
| 7240 Handle<String> input(raw_input); | |
| 7241 ASSERT(*offset_ptr <= (unsigned)input->length()); | |
| 7242 unsigned chars = input->length() - *offset_ptr; | |
| 7243 if (chars > capacity) chars = capacity; | |
| 7244 ReadBlockBuffer rbb(util_buffer, 0, capacity, 0); | |
| 7245 ReadBlockIntoBuffer(*input, &rbb, offset_ptr, chars); | |
| 7246 ASSERT(rbb.remaining <= static_cast<unsigned>(input->length())); | |
| 7247 *remaining = rbb.remaining; | |
| 7248 return rbb.util_buffer; | |
| 7249 } | |
| 7250 | |
| 7251 | |
| 7252 // This will iterate unless the block of string data spans two 'halves' of | |
| 7253 // a ConsString, in which case it will recurse. Since the block of string | |
| 7254 // data to be read has a maximum size this limits the maximum recursion | |
| 7255 // depth to something sane. Since C++ does not have tail call recursion | |
| 7256 // elimination, the iteration must be explicit. | |
| 7257 void ConsString::ConsStringReadBlockIntoBuffer(ReadBlockBuffer* rbb, | |
| 7258 unsigned* offset_ptr, | |
| 7259 unsigned max_chars) { | |
| 7260 ConsString* current = this; | |
| 7261 unsigned offset = *offset_ptr; | |
| 7262 int offset_correction = 0; | |
| 7263 | |
| 7264 while (true) { | |
| 7265 String* left = current->first(); | |
| 7266 unsigned left_length = (unsigned)left->length(); | |
| 7267 if (left_length > offset && | |
| 7268 max_chars <= left_length - offset) { | |
| 7269 // Left hand side only - iterate unless we have reached the bottom of | |
| 7270 // the cons tree. | |
| 7271 if (StringShape(left).IsCons()) { | |
| 7272 current = ConsString::cast(left); | |
| 7273 continue; | |
| 7274 } else { | |
| 7275 String::ReadBlockIntoBuffer(left, rbb, &offset, max_chars); | |
| 7276 *offset_ptr = offset + offset_correction; | |
| 7277 return; | |
| 7278 } | |
| 7279 } else if (left_length <= offset) { | |
| 7280 // Right hand side only - iterate unless we have reached the bottom of | |
| 7281 // the cons tree. | |
| 7282 offset -= left_length; | |
| 7283 offset_correction += left_length; | |
| 7284 String* right = current->second(); | |
| 7285 if (StringShape(right).IsCons()) { | |
| 7286 current = ConsString::cast(right); | |
| 7287 continue; | |
| 7288 } else { | |
| 7289 String::ReadBlockIntoBuffer(right, rbb, &offset, max_chars); | |
| 7290 *offset_ptr = offset + offset_correction; | |
| 7291 return; | |
| 7292 } | |
| 7293 } else { | |
| 7294 // The block to be read spans two sides of the ConsString, so we recurse. | |
| 7295 // First recurse on the left. | |
| 7296 max_chars -= left_length - offset; | |
| 7297 String::ReadBlockIntoBuffer(left, rbb, &offset, left_length - offset); | |
| 7298 // We may have reached the max or there may not have been enough space | |
| 7299 // in the buffer for the characters in the left hand side. | |
| 7300 if (offset == left_length) { | |
| 7301 // Recurse on the right. | |
| 7302 String* right = String::cast(current->second()); | |
| 7303 offset -= left_length; | |
| 7304 offset_correction += left_length; | |
| 7305 String::ReadBlockIntoBuffer(right, rbb, &offset, max_chars); | |
| 7306 } | |
| 7307 *offset_ptr = offset + offset_correction; | |
| 7308 return; | |
| 7309 } | |
| 7310 } | |
| 7311 } | |
| 7312 | |
| 7313 | |
| 7314 uint16_t ConsString::ConsStringGet(int index) { | 6915 uint16_t ConsString::ConsStringGet(int index) { |
| 7315 ASSERT(index >= 0 && index < this->length()); | 6916 ASSERT(index >= 0 && index < this->length()); |
| 7316 | 6917 |
| 7317 // Check for a flattened cons string | 6918 // Check for a flattened cons string |
| 7318 if (second()->length() == 0) { | 6919 if (second()->length() == 0) { |
| 7319 String* left = first(); | 6920 String* left = first(); |
| 7320 return left->Get(index); | 6921 return left->Get(index); |
| 7321 } | 6922 } |
| 7322 | 6923 |
| 7323 String* string = String::cast(this); | 6924 String* string = String::cast(this); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7340 UNREACHABLE(); | 6941 UNREACHABLE(); |
| 7341 return 0; | 6942 return 0; |
| 7342 } | 6943 } |
| 7343 | 6944 |
| 7344 | 6945 |
| 7345 uint16_t SlicedString::SlicedStringGet(int index) { | 6946 uint16_t SlicedString::SlicedStringGet(int index) { |
| 7346 return parent()->Get(offset() + index); | 6947 return parent()->Get(offset() + index); |
| 7347 } | 6948 } |
| 7348 | 6949 |
| 7349 | 6950 |
| 7350 const unibrow::byte* SlicedString::SlicedStringReadBlock( | |
| 7351 ReadBlockBuffer* buffer, unsigned* offset_ptr, unsigned chars) { | |
| 7352 unsigned offset = this->offset(); | |
| 7353 *offset_ptr += offset; | |
| 7354 const unibrow::byte* answer = String::ReadBlock(String::cast(parent()), | |
| 7355 buffer, offset_ptr, chars); | |
| 7356 *offset_ptr -= offset; | |
| 7357 return answer; | |
| 7358 } | |
| 7359 | |
| 7360 | |
| 7361 void SlicedString::SlicedStringReadBlockIntoBuffer( | |
| 7362 ReadBlockBuffer* buffer, unsigned* offset_ptr, unsigned chars) { | |
| 7363 unsigned offset = this->offset(); | |
| 7364 *offset_ptr += offset; | |
| 7365 String::ReadBlockIntoBuffer(String::cast(parent()), | |
| 7366 buffer, offset_ptr, chars); | |
| 7367 *offset_ptr -= offset; | |
| 7368 } | |
| 7369 | |
| 7370 template <typename sinkchar> | 6951 template <typename sinkchar> |
| 7371 void String::WriteToFlat(String* src, | 6952 void String::WriteToFlat(String* src, |
| 7372 sinkchar* sink, | 6953 sinkchar* sink, |
| 7373 int f, | 6954 int f, |
| 7374 int t) { | 6955 int t) { |
| 7375 String* source = src; | 6956 String* source = src; |
| 7376 int from = f; | 6957 int from = f; |
| 7377 int to = t; | 6958 int to = t; |
| 7378 while (true) { | 6959 while (true) { |
| 7379 ASSERT(0 <= from && from <= to && to <= source->length()); | 6960 ASSERT(0 <= from && from <= to && to <= source->length()); |
| (...skipping 6762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14142 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13723 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 14143 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13724 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 14144 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13725 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 14145 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13726 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 14146 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13727 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 14147 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13728 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 14148 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13729 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 14149 } | 13730 } |
| 14150 | 13731 |
| 14151 } } // namespace v8::internal | 13732 } } // namespace v8::internal |
| OLD | NEW |