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

Side by Side Diff: src/objects.cc

Issue 7911: Various API changes (Closed)
Patch Set: "Various API changes Created 12 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 3701 matching lines...) Expand 10 before | Expand all | Expand 10 after
3712 return false; 3712 return false;
3713 } 3713 }
3714 return true; 3714 return true;
3715 } 3715 }
3716 3716
3717 3717
3718 // Compares the contents of two strings by reading and comparing 3718 // Compares the contents of two strings by reading and comparing
3719 // int-sized blocks of characters. 3719 // int-sized blocks of characters.
3720 template <typename Char> 3720 template <typename Char>
3721 static inline bool CompareRawStringContents(Vector<Char> a, Vector<Char> b) { 3721 static inline bool CompareRawStringContents(Vector<Char> a, Vector<Char> b) {
3722 // Lint complains about taking sizeof a type rather than a variable.
3723 // That's just stupid in this case so I'm turning it off.
3724 const int kStepSize = sizeof(int) / sizeof(Char); // NOLINT
3725 int length = a.length(); 3722 int length = a.length();
3726 ASSERT_EQ(length, b.length()); 3723 ASSERT_EQ(length, b.length());
3727 int endpoint = length - kStepSize;
3728 const Char* pa = a.start(); 3724 const Char* pa = a.start();
3729 const Char* pb = b.start(); 3725 const Char* pb = b.start();
3726 int i = 0;
3730 #ifndef CAN_READ_UNALIGNED 3727 #ifndef CAN_READ_UNALIGNED
3731 // If this architecture isn't comfortable reading unaligned ints 3728 // If this architecture isn't comfortable reading unaligned ints
3732 // then we have to check that the strings are alingned and fall back 3729 // then we have to check that the strings are aligned before
3733 // to the standard comparison if they are not. 3730 // comparing them blockwise.
3734 const int kAlignmentMask = sizeof(uint32_t) - 1; // NOLINT 3731 const int kAlignmentMask = sizeof(uint32_t) - 1; // NOLINT
3735 uint32_t pa_addr = reinterpret_cast<uint32_t>(pa); 3732 uint32_t pa_addr = reinterpret_cast<uint32_t>(pa);
3736 uint32_t pb_addr = reinterpret_cast<uint32_t>(pb); 3733 uint32_t pb_addr = reinterpret_cast<uint32_t>(pb);
3737 if ((pa_addr & kAlignmentMask) | (pb_addr & kAlignmentMask) != 0) { 3734 if ((pa_addr & kAlignmentMask) | (pb_addr & kAlignmentMask) == 0) {
3738 VectorIterator<Char> ia(a); 3735 #endif
3739 VectorIterator<Char> ib(b); 3736 const int kStepSize = sizeof(int) / sizeof(Char); // NOLINT
3740 return CompareStringContents(&ia, &ib); 3737 int endpoint = length - kStepSize;
3738 // Compare blocks until we reach near the end of the string.
3739 for (; i <= endpoint; i += kStepSize) {
3740 uint32_t wa = *reinterpret_cast<const uint32_t*>(pa + i);
3741 uint32_t wb = *reinterpret_cast<const uint32_t*>(pb + i);
3742 if (wa != wb) {
3743 return false;
3744 }
3745 }
3746 #ifndef CAN_READ_UNALIGNED
3741 } 3747 }
3742 #endif 3748 #endif
3743 int i;
3744 // Compare blocks until we reach near the end of the string.
3745 for (i = 0; i <= endpoint; i += kStepSize) {
3746 uint32_t wa = *reinterpret_cast<const uint32_t*>(pa + i);
3747 uint32_t wb = *reinterpret_cast<const uint32_t*>(pb + i);
3748 if (wa != wb) {
3749 return false;
3750 }
3751 }
3752 // Compare the remaining characters that didn't fit into a block. 3749 // Compare the remaining characters that didn't fit into a block.
3753 for (; i < length; i++) { 3750 for (; i < length; i++) {
3754 if (a[i] != b[i]) { 3751 if (a[i] != b[i]) {
3755 return false; 3752 return false;
3756 } 3753 }
3757 } 3754 }
3758 return true; 3755 return true;
3759 } 3756 }
3760 3757
3761 3758
(...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after
6642 // No break point. 6639 // No break point.
6643 if (break_point_objects()->IsUndefined()) return 0; 6640 if (break_point_objects()->IsUndefined()) return 0;
6644 // Single beak point. 6641 // Single beak point.
6645 if (!break_point_objects()->IsFixedArray()) return 1; 6642 if (!break_point_objects()->IsFixedArray()) return 1;
6646 // Multiple break points. 6643 // Multiple break points.
6647 return FixedArray::cast(break_point_objects())->length(); 6644 return FixedArray::cast(break_point_objects())->length();
6648 } 6645 }
6649 6646
6650 6647
6651 } } // namespace v8::internal 6648 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698