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

Side by Side Diff: src/utils.h

Issue 18613: Fix endianism issues in regexp interpreter. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 11 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/regexp-macro-assembler-irregexp-inl.h ('k') | 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-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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 src += kStepSize; 520 src += kStepSize;
521 } 521 }
522 } 522 }
523 #endif 523 #endif
524 while (dest < limit) { 524 while (dest < limit) {
525 *dest++ = static_cast<sinkchar>(*src++); 525 *dest++ = static_cast<sinkchar>(*src++);
526 } 526 }
527 } 527 }
528 528
529 529
530 static inline int Load16(const byte* ptr) {
531 #ifdef CAN_READ_UNALIGNED
532 return *reinterpret_cast<const uint16_t*>(ptr);
533 #else
534 uint32_t word;
535 word = ptr[1];
536 word |= ptr[0] << 8;
537 return word;
538 #endif
539 }
540
541
542 static inline int Load32(const byte* ptr) {
543 #ifdef CAN_READ_UNALIGNED
544 return *reinterpret_cast<const uint32_t*>(ptr);
545 #else
546 uint32_t word;
547 word = ptr[3];
548 word |= ptr[2] << 8;
549 word |= ptr[1] << 16;
550 word |= ptr[0] << 24;
551 return word;
552 #endif
553 }
554
555
556 static inline void Store16(byte* ptr, uint16_t value) {
557 #ifdef CAN_READ_UNALIGNED
558 *reinterpret_cast<uint16_t*>(ptr) = value;
559 #else
560 // Cast to avoid warning C4244 when compiling with Microsoft Visual C++.
561 ptr[1] = static_cast<byte>(value);
562 ptr[0] = value >> 8;
563 #endif
564 }
565
566
567 static inline void Store32(byte* ptr, uint32_t value) {
568 #ifdef CAN_READ_UNALIGNED
569 *reinterpret_cast<uint32_t*>(ptr) = value;
570 #else
571 ptr[3] = value;
572 ptr[2] = value >> 8;
573 ptr[1] = value >> 16;
574 ptr[0] = value >> 24;
575 #endif
576 }
577
578
579 } } // namespace v8::internal 530 } } // namespace v8::internal
580 531
581 #endif // V8_UTILS_H_ 532 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/regexp-macro-assembler-irregexp-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698