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

Side by Side Diff: sky/engine/wtf/text/ASCIIFastPath.h

Issue 709603006: Remove a bunch of OS(MACOSX) code (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Even more Created 6 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 3 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 10 matching lines...) Expand all
21 21
22 #ifndef ASCIIFastPath_h 22 #ifndef ASCIIFastPath_h
23 #define ASCIIFastPath_h 23 #define ASCIIFastPath_h
24 24
25 #include "wtf/Alignment.h" 25 #include "wtf/Alignment.h"
26 #include "wtf/CPU.h" 26 #include "wtf/CPU.h"
27 #include "wtf/StdLibExtras.h" 27 #include "wtf/StdLibExtras.h"
28 #include "wtf/unicode/Unicode.h" 28 #include "wtf/unicode/Unicode.h"
29 #include <stdint.h> 29 #include <stdint.h>
30 30
31 #if OS(MACOSX) && (CPU(X86) || CPU(X86_64))
32 #include <emmintrin.h>
33 #endif
34
35 namespace WTF { 31 namespace WTF {
36 32
37 // Assuming that a pointer is the size of a "machine word", then 33 // Assuming that a pointer is the size of a "machine word", then
38 // uintptr_t is an integer type that is also a machine word. 34 // uintptr_t is an integer type that is also a machine word.
39 typedef uintptr_t MachineWord; 35 typedef uintptr_t MachineWord;
40 const uintptr_t machineWordAlignmentMask = sizeof(MachineWord) - 1; 36 const uintptr_t machineWordAlignmentMask = sizeof(MachineWord) - 1;
41 37
42 inline bool isAlignedToMachineWord(const void* pointer) 38 inline bool isAlignedToMachineWord(const void* pointer)
43 { 39 {
44 return !(reinterpret_cast<uintptr_t>(pointer) & machineWordAlignmentMask); 40 return !(reinterpret_cast<uintptr_t>(pointer) & machineWordAlignmentMask);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 allCharBits |= *characters; 93 allCharBits |= *characters;
98 ++characters; 94 ++characters;
99 } 95 }
100 96
101 MachineWord nonASCIIBitMask = NonASCIIMask<sizeof(MachineWord), CharacterTyp e>::value(); 97 MachineWord nonASCIIBitMask = NonASCIIMask<sizeof(MachineWord), CharacterTyp e>::value();
102 return !(allCharBits & nonASCIIBitMask); 98 return !(allCharBits & nonASCIIBitMask);
103 } 99 }
104 100
105 inline void copyLCharsFromUCharSource(LChar* destination, const UChar* source, s ize_t length) 101 inline void copyLCharsFromUCharSource(LChar* destination, const UChar* source, s ize_t length)
106 { 102 {
107 #if OS(MACOSX) && (CPU(X86) || CPU(X86_64)) 103 #if COMPILER(GCC) && CPU(ARM_NEON) && !(CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN)) & & defined(NDEBUG)
108 const uintptr_t memoryAccessSize = 16; // Memory accesses on 16 byte (128 bi t) alignment
109 const uintptr_t memoryAccessMask = memoryAccessSize - 1;
110
111 size_t i = 0;
112 for (;i < length && !isAlignedTo<memoryAccessMask>(&source[i]); ++i) {
113 ASSERT(!(source[i] & 0xff00));
114 destination[i] = static_cast<LChar>(source[i]);
115 }
116
117 const uintptr_t sourceLoadSize = 32; // Process 32 bytes (16 UChars) each it eration
118 const size_t ucharsPerLoop = sourceLoadSize / sizeof(UChar);
119 if (length > ucharsPerLoop) {
120 const size_t endLength = length - ucharsPerLoop + 1;
121 for (; i < endLength; i += ucharsPerLoop) {
122 #if ENABLE(ASSERT)
123 for (unsigned checkIndex = 0; checkIndex < ucharsPerLoop; ++checkInd ex)
124 ASSERT(!(source[i+checkIndex] & 0xff00));
125 #endif
126 __m128i first8UChars = _mm_load_si128(reinterpret_cast<const __m128i *>(&source[i]));
127 __m128i second8UChars = _mm_load_si128(reinterpret_cast<const __m128 i*>(&source[i+8]));
128 __m128i packedChars = _mm_packus_epi16(first8UChars, second8UChars);
129 _mm_storeu_si128(reinterpret_cast<__m128i*>(&destination[i]), packed Chars);
130 }
131 }
132
133 for (; i < length; ++i) {
134 ASSERT(!(source[i] & 0xff00));
135 destination[i] = static_cast<LChar>(source[i]);
136 }
137 #elif COMPILER(GCC) && CPU(ARM_NEON) && !(CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN)) && defined(NDEBUG)
138 const LChar* const end = destination + length; 104 const LChar* const end = destination + length;
139 const uintptr_t memoryAccessSize = 8; 105 const uintptr_t memoryAccessSize = 8;
140 106
141 if (length >= (2 * memoryAccessSize) - 1) { 107 if (length >= (2 * memoryAccessSize) - 1) {
142 // Prefix: align dst on 64 bits. 108 // Prefix: align dst on 64 bits.
143 const uintptr_t memoryAccessMask = memoryAccessSize - 1; 109 const uintptr_t memoryAccessMask = memoryAccessSize - 1;
144 while (!isAlignedTo<memoryAccessMask>(destination)) 110 while (!isAlignedTo<memoryAccessMask>(destination))
145 *destination++ = static_cast<LChar>(*source++); 111 *destination++ = static_cast<LChar>(*source++);
146 112
147 // Vector interleaved unpack, we only store the lower 8 bits. 113 // Vector interleaved unpack, we only store the lower 8 bits.
(...skipping 14 matching lines...) Expand all
162 for (size_t i = 0; i < length; ++i) { 128 for (size_t i = 0; i < length; ++i) {
163 ASSERT(!(source[i] & 0xff00)); 129 ASSERT(!(source[i] & 0xff00));
164 destination[i] = static_cast<LChar>(source[i]); 130 destination[i] = static_cast<LChar>(source[i]);
165 } 131 }
166 #endif 132 #endif
167 } 133 }
168 134
169 } // namespace WTF 135 } // namespace WTF
170 136
171 #endif // ASCIIFastPath_h 137 #endif // ASCIIFastPath_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698