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

Side by Side Diff: src/objects.cc

Issue 568753002: Remove V8_HOST_CAN_READ_UNALIGNED and its uses. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 3 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/regexp-macro-assembler.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 8489 matching lines...) Expand 10 before | Expand all | Expand 10 after
8500 return array; 8500 return array;
8501 } 8501 }
8502 8502
8503 8503
8504 // Compares the contents of two strings by reading and comparing 8504 // Compares the contents of two strings by reading and comparing
8505 // int-sized blocks of characters. 8505 // int-sized blocks of characters.
8506 template <typename Char> 8506 template <typename Char>
8507 static inline bool CompareRawStringContents(const Char* const a, 8507 static inline bool CompareRawStringContents(const Char* const a,
8508 const Char* const b, 8508 const Char* const b,
8509 int length) { 8509 int length) {
8510 int i = 0; 8510 return CompareChars(a, b, length) == 0;
8511 #ifndef V8_HOST_CAN_READ_UNALIGNED
8512 // If this architecture isn't comfortable reading unaligned ints
8513 // then we have to check that the strings are aligned before
8514 // comparing them blockwise.
8515 const int kAlignmentMask = sizeof(uint32_t) - 1; // NOLINT
8516 uintptr_t pa_addr = reinterpret_cast<uintptr_t>(a);
8517 uintptr_t pb_addr = reinterpret_cast<uintptr_t>(b);
8518 if (((pa_addr & kAlignmentMask) | (pb_addr & kAlignmentMask)) == 0) {
8519 #endif
8520 const int kStepSize = sizeof(int) / sizeof(Char); // NOLINT
8521 int endpoint = length - kStepSize;
8522 // Compare blocks until we reach near the end of the string.
8523 for (; i <= endpoint; i += kStepSize) {
8524 uint32_t wa = *reinterpret_cast<const uint32_t*>(a + i);
8525 uint32_t wb = *reinterpret_cast<const uint32_t*>(b + i);
8526 if (wa != wb) {
8527 return false;
8528 }
8529 }
8530 #ifndef V8_HOST_CAN_READ_UNALIGNED
8531 }
8532 #endif
8533 // Compare the remaining characters that didn't fit into a block.
8534 for (; i < length; i++) {
8535 if (a[i] != b[i]) {
8536 return false;
8537 }
8538 }
8539 return true;
8540 } 8511 }
8541 8512
8542 8513
8543 template<typename Chars1, typename Chars2> 8514 template<typename Chars1, typename Chars2>
8544 class RawStringComparator : public AllStatic { 8515 class RawStringComparator : public AllStatic {
8545 public: 8516 public:
8546 static inline bool compare(const Chars1* a, const Chars2* b, int len) { 8517 static inline bool compare(const Chars1* a, const Chars2* b, int len) {
8547 DCHECK(sizeof(Chars1) != sizeof(Chars2)); 8518 DCHECK(sizeof(Chars1) != sizeof(Chars2));
8548 for (int i = 0; i < len; i++) { 8519 for (int i = 0; i < len; i++) {
8549 if (a[i] != b[i]) { 8520 if (a[i] != b[i]) {
(...skipping 7851 matching lines...) Expand 10 before | Expand all | Expand 10 after
16401 #define ERROR_MESSAGES_TEXTS(C, T) T, 16372 #define ERROR_MESSAGES_TEXTS(C, T) T,
16402 static const char* error_messages_[] = { 16373 static const char* error_messages_[] = {
16403 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16374 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16404 }; 16375 };
16405 #undef ERROR_MESSAGES_TEXTS 16376 #undef ERROR_MESSAGES_TEXTS
16406 return error_messages_[reason]; 16377 return error_messages_[reason];
16407 } 16378 }
16408 16379
16409 16380
16410 } } // namespace v8::internal 16381 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/regexp-macro-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698