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

Side by Side Diff: src/objects.cc

Issue 7860035: Merge bleeding edge up to 9192 into the GC branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 3 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
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 ObjectVisitor* v) { 1213 ObjectVisitor* v) {
1214 // Avoiding <Type>::cast(this) because it accesses the map pointer field. 1214 // Avoiding <Type>::cast(this) because it accesses the map pointer field.
1215 // During GC, the map pointer field is encoded. 1215 // During GC, the map pointer field is encoded.
1216 if (type < FIRST_NONSTRING_TYPE) { 1216 if (type < FIRST_NONSTRING_TYPE) {
1217 switch (type & kStringRepresentationMask) { 1217 switch (type & kStringRepresentationMask) {
1218 case kSeqStringTag: 1218 case kSeqStringTag:
1219 break; 1219 break;
1220 case kConsStringTag: 1220 case kConsStringTag:
1221 ConsString::BodyDescriptor::IterateBody(this, v); 1221 ConsString::BodyDescriptor::IterateBody(this, v);
1222 break; 1222 break;
1223 case kSlicedStringTag:
1224 SlicedString::BodyDescriptor::IterateBody(this, v);
1225 break;
1223 case kExternalStringTag: 1226 case kExternalStringTag:
1224 if ((type & kStringEncodingMask) == kAsciiStringTag) { 1227 if ((type & kStringEncodingMask) == kAsciiStringTag) {
1225 reinterpret_cast<ExternalAsciiString*>(this)-> 1228 reinterpret_cast<ExternalAsciiString*>(this)->
1226 ExternalAsciiStringIterateBody(v); 1229 ExternalAsciiStringIterateBody(v);
1227 } else { 1230 } else {
1228 reinterpret_cast<ExternalTwoByteString*>(this)-> 1231 reinterpret_cast<ExternalTwoByteString*>(this)->
1229 ExternalTwoByteStringIterateBody(v); 1232 ExternalTwoByteStringIterateBody(v);
1230 } 1233 }
1231 break; 1234 break;
1232 } 1235 }
(...skipping 3821 matching lines...) Expand 10 before | Expand all | Expand 10 after
5054 while (buffer->has_more()) 5057 while (buffer->has_more())
5055 result += unibrow::Utf8::Length(buffer->GetNext()); 5058 result += unibrow::Utf8::Length(buffer->GetNext());
5056 return result; 5059 return result;
5057 } 5060 }
5058 5061
5059 5062
5060 String::FlatContent String::GetFlatContent() { 5063 String::FlatContent String::GetFlatContent() {
5061 int length = this->length(); 5064 int length = this->length();
5062 StringShape shape(this); 5065 StringShape shape(this);
5063 String* string = this; 5066 String* string = this;
5067 int offset = 0;
5064 if (shape.representation_tag() == kConsStringTag) { 5068 if (shape.representation_tag() == kConsStringTag) {
5065 ConsString* cons = ConsString::cast(string); 5069 ConsString* cons = ConsString::cast(string);
5066 if (cons->second()->length() != 0) { 5070 if (cons->second()->length() != 0) {
5067 return FlatContent(); 5071 return FlatContent();
5068 } 5072 }
5069 string = cons->first(); 5073 string = cons->first();
5070 shape = StringShape(string); 5074 shape = StringShape(string);
5071 } 5075 }
5076 if (shape.representation_tag() == kSlicedStringTag) {
5077 SlicedString* slice = SlicedString::cast(string);
5078 offset = slice->offset();
5079 string = slice->parent();
5080 shape = StringShape(string);
5081 ASSERT(shape.representation_tag() != kConsStringTag &&
5082 shape.representation_tag() != kSlicedStringTag);
5083 }
5072 if (shape.encoding_tag() == kAsciiStringTag) { 5084 if (shape.encoding_tag() == kAsciiStringTag) {
5073 const char* start; 5085 const char* start;
5074 if (shape.representation_tag() == kSeqStringTag) { 5086 if (shape.representation_tag() == kSeqStringTag) {
5075 start = SeqAsciiString::cast(string)->GetChars(); 5087 start = SeqAsciiString::cast(string)->GetChars();
5076 } else { 5088 } else {
5077 start = ExternalAsciiString::cast(string)->resource()->data(); 5089 start = ExternalAsciiString::cast(string)->resource()->data();
5078 } 5090 }
5079 return FlatContent(Vector<const char>(start, length)); 5091 return FlatContent(Vector<const char>(start + offset, length));
5080 } else { 5092 } else {
5081 ASSERT(shape.encoding_tag() == kTwoByteStringTag); 5093 ASSERT(shape.encoding_tag() == kTwoByteStringTag);
5082 const uc16* start; 5094 const uc16* start;
5083 if (shape.representation_tag() == kSeqStringTag) { 5095 if (shape.representation_tag() == kSeqStringTag) {
5084 start = SeqTwoByteString::cast(string)->GetChars(); 5096 start = SeqTwoByteString::cast(string)->GetChars();
5085 } else { 5097 } else {
5086 start = ExternalTwoByteString::cast(string)->resource()->data(); 5098 start = ExternalTwoByteString::cast(string)->resource()->data();
5087 } 5099 }
5088 return FlatContent(Vector<const uc16>(start, length)); 5100 return FlatContent(Vector<const uc16>(start + offset, length));
5089 } 5101 }
5090 } 5102 }
5091 5103
5092 5104
5093 SmartPointer<char> String::ToCString(AllowNullsFlag allow_nulls, 5105 SmartPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
5094 RobustnessFlag robust_flag, 5106 RobustnessFlag robust_flag,
5095 int offset, 5107 int offset,
5096 int length, 5108 int length,
5097 int* length_return) { 5109 int* length_return) {
5098 if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) { 5110 if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
5150 return ToCString(allow_nulls, robust_flag, 0, -1, length_return); 5162 return ToCString(allow_nulls, robust_flag, 0, -1, length_return);
5151 } 5163 }
5152 5164
5153 5165
5154 const uc16* String::GetTwoByteData() { 5166 const uc16* String::GetTwoByteData() {
5155 return GetTwoByteData(0); 5167 return GetTwoByteData(0);
5156 } 5168 }
5157 5169
5158 5170
5159 const uc16* String::GetTwoByteData(unsigned start) { 5171 const uc16* String::GetTwoByteData(unsigned start) {
5160 ASSERT(!IsAsciiRepresentation()); 5172 ASSERT(!IsAsciiRepresentationUnderneath());
5161 switch (StringShape(this).representation_tag()) { 5173 switch (StringShape(this).representation_tag()) {
5162 case kSeqStringTag: 5174 case kSeqStringTag:
5163 return SeqTwoByteString::cast(this)->SeqTwoByteStringGetData(start); 5175 return SeqTwoByteString::cast(this)->SeqTwoByteStringGetData(start);
5164 case kExternalStringTag: 5176 case kExternalStringTag:
5165 return ExternalTwoByteString::cast(this)-> 5177 return ExternalTwoByteString::cast(this)->
5166 ExternalTwoByteStringGetData(start); 5178 ExternalTwoByteStringGetData(start);
5179 case kSlicedStringTag: {
5180 SlicedString* slice = SlicedString::cast(this);
5181 return slice->parent()->GetTwoByteData(start + slice->offset());
5182 }
5167 case kConsStringTag: 5183 case kConsStringTag:
5168 UNREACHABLE(); 5184 UNREACHABLE();
5169 return NULL; 5185 return NULL;
5170 } 5186 }
5171 UNREACHABLE(); 5187 UNREACHABLE();
5172 return NULL; 5188 return NULL;
5173 } 5189 }
5174 5190
5175 5191
5176 SmartPointer<uc16> String::ToWideCString(RobustnessFlag robust_flag) { 5192 SmartPointer<uc16> String::ToWideCString(RobustnessFlag robust_flag) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
5447 &rbb->remaining, 5463 &rbb->remaining,
5448 offset_ptr, 5464 offset_ptr,
5449 max_chars); 5465 max_chars);
5450 } else { 5466 } else {
5451 ExternalTwoByteString::cast(input)-> 5467 ExternalTwoByteString::cast(input)->
5452 ExternalTwoByteStringReadBlockIntoBuffer(rbb, 5468 ExternalTwoByteStringReadBlockIntoBuffer(rbb,
5453 offset_ptr, 5469 offset_ptr,
5454 max_chars); 5470 max_chars);
5455 return rbb->util_buffer; 5471 return rbb->util_buffer;
5456 } 5472 }
5473 case kSlicedStringTag:
5474 return SlicedString::cast(input)->SlicedStringReadBlock(rbb,
5475 offset_ptr,
5476 max_chars);
5457 default: 5477 default:
5458 break; 5478 break;
5459 } 5479 }
5460 5480
5461 UNREACHABLE(); 5481 UNREACHABLE();
5462 return 0; 5482 return 0;
5463 } 5483 }
5464 5484
5465 5485
5466 void Relocatable::PostGarbageCollectionProcessing() { 5486 void Relocatable::PostGarbageCollectionProcessing() {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
5590 if (input->IsAsciiRepresentation()) { 5610 if (input->IsAsciiRepresentation()) {
5591 ExternalAsciiString::cast(input)-> 5611 ExternalAsciiString::cast(input)->
5592 ExternalAsciiStringReadBlockIntoBuffer(rbb, offset_ptr, max_chars); 5612 ExternalAsciiStringReadBlockIntoBuffer(rbb, offset_ptr, max_chars);
5593 } else { 5613 } else {
5594 ExternalTwoByteString::cast(input)-> 5614 ExternalTwoByteString::cast(input)->
5595 ExternalTwoByteStringReadBlockIntoBuffer(rbb, 5615 ExternalTwoByteStringReadBlockIntoBuffer(rbb,
5596 offset_ptr, 5616 offset_ptr,
5597 max_chars); 5617 max_chars);
5598 } 5618 }
5599 return; 5619 return;
5620 case kSlicedStringTag:
5621 SlicedString::cast(input)->SlicedStringReadBlockIntoBuffer(rbb,
5622 offset_ptr,
5623 max_chars);
5624 return;
5600 default: 5625 default:
5601 break; 5626 break;
5602 } 5627 }
5603 5628
5604 UNREACHABLE(); 5629 UNREACHABLE();
5605 return; 5630 return;
5606 } 5631 }
5607 5632
5608 5633
5609 const unibrow::byte* String::ReadBlock(String* input, 5634 const unibrow::byte* String::ReadBlock(String* input,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
5724 } else { 5749 } else {
5725 return string->Get(index); 5750 return string->Get(index);
5726 } 5751 }
5727 } 5752 }
5728 5753
5729 UNREACHABLE(); 5754 UNREACHABLE();
5730 return 0; 5755 return 0;
5731 } 5756 }
5732 5757
5733 5758
5759 uint16_t SlicedString::SlicedStringGet(int index) {
5760 return parent()->Get(offset() + index);
5761 }
5762
5763
5764 const unibrow::byte* SlicedString::SlicedStringReadBlock(
5765 ReadBlockBuffer* buffer, unsigned* offset_ptr, unsigned chars) {
5766 unsigned offset = this->offset();
5767 *offset_ptr += offset;
5768 const unibrow::byte* answer = String::ReadBlock(String::cast(parent()),
5769 buffer, offset_ptr, chars);
5770 *offset_ptr -= offset;
5771 return answer;
5772 }
5773
5774
5775 void SlicedString::SlicedStringReadBlockIntoBuffer(
5776 ReadBlockBuffer* buffer, unsigned* offset_ptr, unsigned chars) {
5777 unsigned offset = this->offset();
5778 *offset_ptr += offset;
5779 String::ReadBlockIntoBuffer(String::cast(parent()),
5780 buffer, offset_ptr, chars);
5781 *offset_ptr -= offset;
5782 }
5783
5734 template <typename sinkchar> 5784 template <typename sinkchar>
5735 void String::WriteToFlat(String* src, 5785 void String::WriteToFlat(String* src,
5736 sinkchar* sink, 5786 sinkchar* sink,
5737 int f, 5787 int f,
5738 int t) { 5788 int t) {
5739 String* source = src; 5789 String* source = src;
5740 int from = f; 5790 int from = f;
5741 int to = t; 5791 int to = t;
5742 while (true) { 5792 while (true) {
5743 ASSERT(0 <= from && from <= to && to <= source->length()); 5793 ASSERT(0 <= from && from <= to && to <= source->length());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5791 WriteToFlat(second, 5841 WriteToFlat(second,
5792 sink + boundary - from, 5842 sink + boundary - from,
5793 0, 5843 0,
5794 to - boundary); 5844 to - boundary);
5795 to = boundary; 5845 to = boundary;
5796 } 5846 }
5797 source = first; 5847 source = first;
5798 } 5848 }
5799 break; 5849 break;
5800 } 5850 }
5851 case kAsciiStringTag | kSlicedStringTag:
5852 case kTwoByteStringTag | kSlicedStringTag: {
5853 SlicedString* slice = SlicedString::cast(source);
5854 unsigned offset = slice->offset();
5855 WriteToFlat(slice->parent(), sink, from + offset, to + offset);
5856 return;
5857 }
5801 } 5858 }
5802 } 5859 }
5803 } 5860 }
5804 5861
5805 5862
5806 template <typename IteratorA, typename IteratorB> 5863 template <typename IteratorA, typename IteratorB>
5807 static inline bool CompareStringContents(IteratorA* ia, IteratorB* ib) { 5864 static inline bool CompareStringContents(IteratorA* ia, IteratorB* ib) {
5808 // General slow case check. We know that the ia and ib iterators 5865 // General slow case check. We know that the ia and ib iterators
5809 // have the same length. 5866 // have the same length.
5810 while (ia->has_more()) { 5867 while (ia->has_more()) {
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
6966 case Translation::BEGIN: 7023 case Translation::BEGIN:
6967 UNREACHABLE(); 7024 UNREACHABLE();
6968 break; 7025 break;
6969 7026
6970 case Translation::FRAME: { 7027 case Translation::FRAME: {
6971 int ast_id = iterator.Next(); 7028 int ast_id = iterator.Next();
6972 int function_id = iterator.Next(); 7029 int function_id = iterator.Next();
6973 JSFunction* function = 7030 JSFunction* function =
6974 JSFunction::cast(LiteralArray()->get(function_id)); 7031 JSFunction::cast(LiteralArray()->get(function_id));
6975 unsigned height = iterator.Next(); 7032 unsigned height = iterator.Next();
6976 PrintF(out, "{ast_id=%d, \nfunction=", ast_id); 7033 PrintF(out, "{ast_id=%d, function=", ast_id);
6977 function->PrintName(out); 7034 function->PrintName(out);
6978 PrintF(out, ", height=%u}", height); 7035 PrintF(out, ", height=%u}", height);
6979 break; 7036 break;
6980 } 7037 }
6981 7038
6982 case Translation::DUPLICATE: 7039 case Translation::DUPLICATE:
6983 break; 7040 break;
6984 7041
6985 case Translation::REGISTER: { 7042 case Translation::REGISTER: {
6986 int reg_code = iterator.Next(); 7043 int reg_code = iterator.Next();
(...skipping 4576 matching lines...) Expand 10 before | Expand all | Expand 10 after
11563 if (break_point_objects()->IsUndefined()) return 0; 11620 if (break_point_objects()->IsUndefined()) return 0;
11564 // Single break point. 11621 // Single break point.
11565 if (!break_point_objects()->IsFixedArray()) return 1; 11622 if (!break_point_objects()->IsFixedArray()) return 1;
11566 // Multiple break points. 11623 // Multiple break points.
11567 return FixedArray::cast(break_point_objects())->length(); 11624 return FixedArray::cast(break_point_objects())->length();
11568 } 11625 }
11569 #endif 11626 #endif
11570 11627
11571 11628
11572 } } // namespace v8::internal 11629 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698