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

Side by Side Diff: src/objects.cc

Issue 7710018: Fix typo in assert. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Readded missing test Created 9 years, 4 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/runtime.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 5020 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 Access<StringInputBuffer> buffer( 5031 Access<StringInputBuffer> buffer(
5032 heap->isolate()->objects_string_input_buffer()); 5032 heap->isolate()->objects_string_input_buffer());
5033 buffer->Reset(0, this); 5033 buffer->Reset(0, this);
5034 int result = 0; 5034 int result = 0;
5035 while (buffer->has_more()) 5035 while (buffer->has_more())
5036 result += unibrow::Utf8::Length(buffer->GetNext()); 5036 result += unibrow::Utf8::Length(buffer->GetNext());
5037 return result; 5037 return result;
5038 } 5038 }
5039 5039
5040 5040
5041 String::FlatContent String::GetFlatContent(const AssertNoAllocation& promise) { 5041 String::FlatContent String::GetFlatContent() {
5042 // Argument isn't used, it's only there to ensure that the user is
5043 // aware that the extracted vectors may not survive a GC.
5044 int length = this->length(); 5042 int length = this->length();
5045 StringShape shape(this); 5043 StringShape shape(this);
5046 String* string = this; 5044 String* string = this;
5047 if (shape.representation_tag() == kConsStringTag) { 5045 if (shape.representation_tag() == kConsStringTag) {
5048 ConsString* cons = ConsString::cast(string); 5046 ConsString* cons = ConsString::cast(string);
5049 if (cons->second()->length() != 0) { 5047 if (cons->second()->length() != 0) {
5050 return FlatContent(); 5048 return FlatContent();
5051 } 5049 }
5052 string = cons->first(); 5050 string = cons->first();
5053 shape = StringShape(string); 5051 shape = StringShape(string);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
5512 str_(0), 5510 str_(0),
5513 is_ascii_(true), 5511 is_ascii_(true),
5514 length_(input.length()), 5512 length_(input.length()),
5515 start_(input.start()) { } 5513 start_(input.start()) { }
5516 5514
5517 5515
5518 void FlatStringReader::PostGarbageCollection() { 5516 void FlatStringReader::PostGarbageCollection() {
5519 if (str_ == NULL) return; 5517 if (str_ == NULL) return;
5520 Handle<String> str(str_); 5518 Handle<String> str(str_);
5521 ASSERT(str->IsFlat()); 5519 ASSERT(str->IsFlat());
5522 AssertNoAllocation no_alloc; 5520 String::FlatContent content = str->GetFlatContent();
5523 String::FlatContent content = str->GetFlatContent(no_alloc); 5521 ASSERT(content.IsFlat());
5524 ASSERT(content.is_flat());
5525 is_ascii_ = content.IsAscii(); 5522 is_ascii_ = content.IsAscii();
5526 if (is_ascii_) { 5523 if (is_ascii_) {
5527 start_ = content.ToAsciiVector().start(); 5524 start_ = content.ToAsciiVector().start();
5528 } else { 5525 } else {
5529 start_ = content.ToUC16Vector().start(); 5526 start_ = content.ToUC16Vector().start();
5530 } 5527 }
5531 } 5528 }
5532 5529
5533 5530
5534 void StringInputBuffer::Seek(unsigned pos) { 5531 void StringInputBuffer::Seek(unsigned pos) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
5839 } 5836 }
5840 } 5837 }
5841 return true; 5838 return true;
5842 } 5839 }
5843 5840
5844 5841
5845 template <typename IteratorA> 5842 template <typename IteratorA>
5846 static inline bool CompareStringContentsPartial(Isolate* isolate, 5843 static inline bool CompareStringContentsPartial(Isolate* isolate,
5847 IteratorA* ia, 5844 IteratorA* ia,
5848 String* b) { 5845 String* b) {
5849 AssertNoAllocation no_alloc; 5846 String::FlatContent content = b->GetFlatContent();
5850 String::FlatContent content = b->GetFlatContent(no_alloc);
5851 if (content.IsFlat()) { 5847 if (content.IsFlat()) {
5852 if (content.IsAscii()) { 5848 if (content.IsAscii()) {
5853 VectorIterator<char> ib(content.ToAsciiVector()); 5849 VectorIterator<char> ib(content.ToAsciiVector());
5854 return CompareStringContents(ia, &ib); 5850 return CompareStringContents(ia, &ib);
5855 } else { 5851 } else {
5856 VectorIterator<uc16> ib(content.ToUC16Vector()); 5852 VectorIterator<uc16> ib(content.ToUC16Vector());
5857 return CompareStringContents(ia, &ib); 5853 return CompareStringContents(ia, &ib);
5858 } 5854 }
5859 } else { 5855 } else {
5860 isolate->objects_string_compare_buffer_b()->Reset(0, b); 5856 isolate->objects_string_compare_buffer_b()->Reset(0, b);
(...skipping 15 matching lines...) Expand all
5876 if (Hash() != other->Hash()) return false; 5872 if (Hash() != other->Hash()) return false;
5877 } 5873 }
5878 5874
5879 // We know the strings are both non-empty. Compare the first chars 5875 // We know the strings are both non-empty. Compare the first chars
5880 // before we try to flatten the strings. 5876 // before we try to flatten the strings.
5881 if (this->Get(0) != other->Get(0)) return false; 5877 if (this->Get(0) != other->Get(0)) return false;
5882 5878
5883 String* lhs = this->TryFlattenGetString(); 5879 String* lhs = this->TryFlattenGetString();
5884 String* rhs = other->TryFlattenGetString(); 5880 String* rhs = other->TryFlattenGetString();
5885 5881
5886 AssertNoAllocation no_alloc;
5887
5888 if (StringShape(lhs).IsSequentialAscii() && 5882 if (StringShape(lhs).IsSequentialAscii() &&
5889 StringShape(rhs).IsSequentialAscii()) { 5883 StringShape(rhs).IsSequentialAscii()) {
5890 const char* str1 = SeqAsciiString::cast(lhs)->GetChars(); 5884 const char* str1 = SeqAsciiString::cast(lhs)->GetChars();
5891 const char* str2 = SeqAsciiString::cast(rhs)->GetChars(); 5885 const char* str2 = SeqAsciiString::cast(rhs)->GetChars();
5892 return CompareRawStringContents(Vector<const char>(str1, len), 5886 return CompareRawStringContents(Vector<const char>(str1, len),
5893 Vector<const char>(str2, len)); 5887 Vector<const char>(str2, len));
5894 } 5888 }
5895 5889
5896 Isolate* isolate = GetIsolate(); 5890 Isolate* isolate = GetIsolate();
5897 String::FlatContent lhs_content = lhs->GetFlatContent(no_alloc); 5891 String::FlatContent lhs_content = lhs->GetFlatContent();
5898 String::FlatContent rhs_content = rhs->GetFlatContent(no_alloc); 5892 String::FlatContent rhs_content = rhs->GetFlatContent();
5899 if (lhs_content.IsFlat()) { 5893 if (lhs_content.IsFlat()) {
5900 if (lhs_content.IsAscii()) { 5894 if (lhs_content.IsAscii()) {
5901 Vector<const char> vec1 = lhs_content.ToAsciiVector(); 5895 Vector<const char> vec1 = lhs_content.ToAsciiVector();
5902 if (rhs_content.IsFlat()) { 5896 if (rhs_content.IsFlat()) {
5903 if (rhs_content.IsAscii()) { 5897 if (rhs_content.IsAscii()) {
5904 Vector<const char> vec2 = rhs_content.ToAsciiVector(); 5898 Vector<const char> vec2 = rhs_content.ToAsciiVector();
5905 return CompareRawStringContents(vec1, vec2); 5899 return CompareRawStringContents(vec1, vec2);
5906 } else { 5900 } else {
5907 VectorIterator<char> buf1(vec1); 5901 VectorIterator<char> buf1(vec1);
5908 VectorIterator<uc16> ib(rhs_content.ToUC16Vector()); 5902 VectorIterator<uc16> ib(rhs_content.ToUC16Vector());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5966 int i; 5960 int i;
5967 for (i = 0; i < slen && decoder->has_more(); i++) { 5961 for (i = 0; i < slen && decoder->has_more(); i++) {
5968 uc32 r = decoder->GetNext(); 5962 uc32 r = decoder->GetNext();
5969 if (Get(i) != r) return false; 5963 if (Get(i) != r) return false;
5970 } 5964 }
5971 return i == slen && !decoder->has_more(); 5965 return i == slen && !decoder->has_more();
5972 } 5966 }
5973 5967
5974 5968
5975 bool String::IsAsciiEqualTo(Vector<const char> str) { 5969 bool String::IsAsciiEqualTo(Vector<const char> str) {
5976 AssertNoAllocation no_alloc;
5977 int slen = length(); 5970 int slen = length();
5978 if (str.length() != slen) return false; 5971 if (str.length() != slen) return false;
5979 FlatContent content = GetFlatContent(no_alloc); 5972 FlatContent content = GetFlatContent();
5980 if (content.IsAscii()) { 5973 if (content.IsAscii()) {
5981 return CompareChars(content.ToAsciiVector().start(), 5974 return CompareChars(content.ToAsciiVector().start(),
5982 str.start(), slen) == 0; 5975 str.start(), slen) == 0;
5983 } 5976 }
5984 for (int i = 0; i < slen; i++) { 5977 for (int i = 0; i < slen; i++) {
5985 if (Get(i) != static_cast<uint16_t>(str[i])) return false; 5978 if (Get(i) != static_cast<uint16_t>(str[i])) return false;
5986 } 5979 }
5987 return true; 5980 return true;
5988 } 5981 }
5989 5982
5990 5983
5991 bool String::IsTwoByteEqualTo(Vector<const uc16> str) { 5984 bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
5992 AssertNoAllocation no_alloc;
5993 int slen = length(); 5985 int slen = length();
5994 if (str.length() != slen) return false; 5986 if (str.length() != slen) return false;
5995 FlatContent content = GetFlatContent(no_alloc); 5987 FlatContent content = GetFlatContent();
5996 if (content.IsTwoByte()) { 5988 if (content.IsTwoByte()) {
5997 return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0; 5989 return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0;
5998 } 5990 }
5999 for (int i = 0; i < slen; i++) { 5991 for (int i = 0; i < slen; i++) {
6000 if (Get(i) != str[i]) return false; 5992 if (Get(i) != str[i]) return false;
6001 } 5993 }
6002 return true; 5994 return true;
6003 } 5995 }
6004 5996
6005 5997
(...skipping 5544 matching lines...) Expand 10 before | Expand all | Expand 10 after
11550 if (break_point_objects()->IsUndefined()) return 0; 11542 if (break_point_objects()->IsUndefined()) return 0;
11551 // Single break point. 11543 // Single break point.
11552 if (!break_point_objects()->IsFixedArray()) return 1; 11544 if (!break_point_objects()->IsFixedArray()) return 1;
11553 // Multiple break points. 11545 // Multiple break points.
11554 return FixedArray::cast(break_point_objects())->length(); 11546 return FixedArray::cast(break_point_objects())->length();
11555 } 11547 }
11556 #endif 11548 #endif
11557 11549
11558 11550
11559 } } // namespace v8::internal 11551 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698