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

Side by Side Diff: src/objects.cc

Issue 16530003: add function to test whether string contents are definitely one byte (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 6 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 } 1198 }
1199 return true; 1199 return true;
1200 } 1200 }
1201 1201
1202 1202
1203 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { 1203 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
1204 #ifdef DEBUG 1204 #ifdef DEBUG
1205 if (FLAG_enable_slow_asserts) { 1205 if (FLAG_enable_slow_asserts) {
1206 // Assert that the resource and the string are equivalent. 1206 // Assert that the resource and the string are equivalent.
1207 ASSERT(static_cast<size_t>(this->length()) == resource->length()); 1207 ASSERT(static_cast<size_t>(this->length()) == resource->length());
1208 if (this->IsTwoByteRepresentation()) {
1209 ScopedVector<uint16_t> smart_chars(this->length());
1210 String::WriteToFlat(this, smart_chars.start(), 0, this->length());
1211 ASSERT(String::IsOneByte(smart_chars.start(), this->length()));
1212 }
Yang 2013/06/06 12:57:36 Is this really necessary? We compare the new resou
dcarney 2013/06/06 13:11:03 the comparison below only compares lower bytes of
1208 ScopedVector<char> smart_chars(this->length()); 1213 ScopedVector<char> smart_chars(this->length());
1209 String::WriteToFlat(this, smart_chars.start(), 0, this->length()); 1214 String::WriteToFlat(this, smart_chars.start(), 0, this->length());
1210 ASSERT(memcmp(smart_chars.start(), 1215 ASSERT(memcmp(smart_chars.start(),
1211 resource->data(), 1216 resource->data(),
1212 resource->length() * sizeof(smart_chars[0])) == 0); 1217 resource->length() * sizeof(smart_chars[0])) == 0);
1213 } 1218 }
1214 #endif // DEBUG 1219 #endif // DEBUG
1215 Heap* heap = GetHeap(); 1220 Heap* heap = GetHeap();
1216 int size = this->Size(); // Byte size of the original string. 1221 int size = this->Size(); // Byte size of the original string.
1217 if (size < ExternalString::kShortSize) { 1222 if (size < ExternalString::kShortSize) {
(...skipping 14440 matching lines...) Expand 10 before | Expand all | Expand 10 after
15658 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15663 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15659 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15664 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15660 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15665 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15661 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15666 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15662 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15667 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15663 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15668 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15664 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15669 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15665 } 15670 }
15666 15671
15667 } } // namespace v8::internal 15672 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698