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

Side by Side Diff: src/objects.cc

Issue 293027: Use WriteToFlat instead of to C strings methods as WriteToFlat performs notab... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 return this; 747 return this;
748 } 748 }
749 } 749 }
750 750
751 751
752 bool String::MakeExternal(v8::String::ExternalStringResource* resource) { 752 bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
753 #ifdef DEBUG 753 #ifdef DEBUG
754 if (FLAG_enable_slow_asserts) { 754 if (FLAG_enable_slow_asserts) {
755 // Assert that the resource and the string are equivalent. 755 // Assert that the resource and the string are equivalent.
756 ASSERT(static_cast<size_t>(this->length()) == resource->length()); 756 ASSERT(static_cast<size_t>(this->length()) == resource->length());
757 SmartPointer<uc16> smart_chars = this->ToWideCString(); 757 SmartPointer<uc16> smart_chars(NewArray<uc16>(this->length()));
758 String::WriteToFlat(this, *smart_chars, 0, this->length());
758 ASSERT(memcmp(*smart_chars, 759 ASSERT(memcmp(*smart_chars,
759 resource->data(), 760 resource->data(),
760 resource->length() * sizeof(**smart_chars)) == 0); 761 resource->length() * sizeof(**smart_chars)) == 0);
761 } 762 }
762 #endif // DEBUG 763 #endif // DEBUG
763 764
764 int size = this->Size(); // Byte size of the original string. 765 int size = this->Size(); // Byte size of the original string.
765 if (size < ExternalString::kSize) { 766 if (size < ExternalString::kSize) {
766 // The string is too small to fit an external String in its place. This can 767 // The string is too small to fit an external String in its place. This can
767 // only happen for zero length strings. 768 // only happen for zero length strings.
(...skipping 22 matching lines...) Expand all
790 Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size); 791 Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
791 return true; 792 return true;
792 } 793 }
793 794
794 795
795 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { 796 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
796 #ifdef DEBUG 797 #ifdef DEBUG
797 if (FLAG_enable_slow_asserts) { 798 if (FLAG_enable_slow_asserts) {
798 // Assert that the resource and the string are equivalent. 799 // Assert that the resource and the string are equivalent.
799 ASSERT(static_cast<size_t>(this->length()) == resource->length()); 800 ASSERT(static_cast<size_t>(this->length()) == resource->length());
800 SmartPointer<char> smart_chars = this->ToCString(); 801 SmartPointer<char> smart_chars(NewArray<char>(this->length()));
802 String::WriteToFlat(this, *smart_chars, 0, this->length());
801 ASSERT(memcmp(*smart_chars, 803 ASSERT(memcmp(*smart_chars,
802 resource->data(), 804 resource->data(),
803 resource->length()*sizeof(**smart_chars)) == 0); 805 resource->length()*sizeof(**smart_chars)) == 0);
804 } 806 }
805 #endif // DEBUG 807 #endif // DEBUG
806 808
807 int size = this->Size(); // Byte size of the original string. 809 int size = this->Size(); // Byte size of the original string.
808 if (size < ExternalString::kSize) { 810 if (size < ExternalString::kSize) {
809 // The string is too small to fit an external String in its place. This can 811 // The string is too small to fit an external String in its place. This can
810 // only happen for zero length strings. 812 // only happen for zero length strings.
(...skipping 7170 matching lines...) Expand 10 before | Expand all | Expand 10 after
7981 if (break_point_objects()->IsUndefined()) return 0; 7983 if (break_point_objects()->IsUndefined()) return 0;
7982 // Single beak point. 7984 // Single beak point.
7983 if (!break_point_objects()->IsFixedArray()) return 1; 7985 if (!break_point_objects()->IsFixedArray()) return 1;
7984 // Multiple break points. 7986 // Multiple break points.
7985 return FixedArray::cast(break_point_objects())->length(); 7987 return FixedArray::cast(break_point_objects())->length();
7986 } 7988 }
7987 #endif 7989 #endif
7988 7990
7989 7991
7990 } } // namespace v8::internal 7992 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698