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

Side by Side Diff: src/objects.cc

Issue 1737023: Turn some usages of NewArray with DeleteArray in the same scope into ScopedVector or SmartPointer. (Closed)
Patch Set: Disabling implicit constructors Created 10 years, 7 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
« no previous file with comments | « src/log.cc ('k') | src/platform-freebsd.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 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 return this; 675 return this;
676 } 676 }
677 } 677 }
678 678
679 679
680 bool String::MakeExternal(v8::String::ExternalStringResource* resource) { 680 bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
681 #ifdef DEBUG 681 #ifdef DEBUG
682 if (FLAG_enable_slow_asserts) { 682 if (FLAG_enable_slow_asserts) {
683 // Assert that the resource and the string are equivalent. 683 // Assert that the resource and the string are equivalent.
684 ASSERT(static_cast<size_t>(this->length()) == resource->length()); 684 ASSERT(static_cast<size_t>(this->length()) == resource->length());
685 SmartPointer<uc16> smart_chars(NewArray<uc16>(this->length())); 685 ScopedVector<uc16> smart_chars(this->length());
686 String::WriteToFlat(this, *smart_chars, 0, this->length()); 686 String::WriteToFlat(this, smart_chars.start(), 0, this->length());
687 ASSERT(memcmp(*smart_chars, 687 ASSERT(memcmp(smart_chars.start(),
688 resource->data(), 688 resource->data(),
689 resource->length() * sizeof(**smart_chars)) == 0); 689 resource->length() * sizeof(smart_chars[0])) == 0);
690 } 690 }
691 #endif // DEBUG 691 #endif // DEBUG
692 692
693 int size = this->Size(); // Byte size of the original string. 693 int size = this->Size(); // Byte size of the original string.
694 if (size < ExternalString::kSize) { 694 if (size < ExternalString::kSize) {
695 // The string is too small to fit an external String in its place. This can 695 // The string is too small to fit an external String in its place. This can
696 // only happen for zero length strings. 696 // only happen for zero length strings.
697 return false; 697 return false;
698 } 698 }
699 ASSERT(size >= ExternalString::kSize); 699 ASSERT(size >= ExternalString::kSize);
(...skipping 21 matching lines...) Expand all
721 Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size); 721 Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
722 return true; 722 return true;
723 } 723 }
724 724
725 725
726 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { 726 bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
727 #ifdef DEBUG 727 #ifdef DEBUG
728 if (FLAG_enable_slow_asserts) { 728 if (FLAG_enable_slow_asserts) {
729 // Assert that the resource and the string are equivalent. 729 // Assert that the resource and the string are equivalent.
730 ASSERT(static_cast<size_t>(this->length()) == resource->length()); 730 ASSERT(static_cast<size_t>(this->length()) == resource->length());
731 SmartPointer<char> smart_chars(NewArray<char>(this->length())); 731 ScopedVector<char> smart_chars(this->length());
732 String::WriteToFlat(this, *smart_chars, 0, this->length()); 732 String::WriteToFlat(this, smart_chars.start(), 0, this->length());
733 ASSERT(memcmp(*smart_chars, 733 ASSERT(memcmp(smart_chars.start(),
734 resource->data(), 734 resource->data(),
735 resource->length()*sizeof(**smart_chars)) == 0); 735 resource->length() * sizeof(smart_chars[0])) == 0);
736 } 736 }
737 #endif // DEBUG 737 #endif // DEBUG
738 738
739 int size = this->Size(); // Byte size of the original string. 739 int size = this->Size(); // Byte size of the original string.
740 if (size < ExternalString::kSize) { 740 if (size < ExternalString::kSize) {
741 // The string is too small to fit an external String in its place. This can 741 // The string is too small to fit an external String in its place. This can
742 // only happen for zero length strings. 742 // only happen for zero length strings.
743 return false; 743 return false;
744 } 744 }
745 ASSERT(size >= ExternalString::kSize); 745 ASSERT(size >= ExternalString::kSize);
(...skipping 7799 matching lines...) Expand 10 before | Expand all | Expand 10 after
8545 if (break_point_objects()->IsUndefined()) return 0; 8545 if (break_point_objects()->IsUndefined()) return 0;
8546 // Single beak point. 8546 // Single beak point.
8547 if (!break_point_objects()->IsFixedArray()) return 1; 8547 if (!break_point_objects()->IsFixedArray()) return 1;
8548 // Multiple break points. 8548 // Multiple break points.
8549 return FixedArray::cast(break_point_objects())->length(); 8549 return FixedArray::cast(break_point_objects())->length();
8550 } 8550 }
8551 #endif 8551 #endif
8552 8552
8553 8553
8554 } } // namespace v8::internal 8554 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698