OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 for (;i < length && !isAlignedTo<memoryAccessMask>(&source[i]); ++i) { | 112 for (;i < length && !isAlignedTo<memoryAccessMask>(&source[i]); ++i) { |
113 ASSERT(!(source[i] & 0xff00)); | 113 ASSERT(!(source[i] & 0xff00)); |
114 destination[i] = static_cast<LChar>(source[i]); | 114 destination[i] = static_cast<LChar>(source[i]); |
115 } | 115 } |
116 | 116 |
117 const uintptr_t sourceLoadSize = 32; // Process 32 bytes (16 UChars) each it
eration | 117 const uintptr_t sourceLoadSize = 32; // Process 32 bytes (16 UChars) each it
eration |
118 const size_t ucharsPerLoop = sourceLoadSize / sizeof(UChar); | 118 const size_t ucharsPerLoop = sourceLoadSize / sizeof(UChar); |
119 if (length > ucharsPerLoop) { | 119 if (length > ucharsPerLoop) { |
120 const size_t endLength = length - ucharsPerLoop + 1; | 120 const size_t endLength = length - ucharsPerLoop + 1; |
121 for (; i < endLength; i += ucharsPerLoop) { | 121 for (; i < endLength; i += ucharsPerLoop) { |
122 #ifndef NDEBUG | 122 #if ENABLE(ASSERT) |
123 for (unsigned checkIndex = 0; checkIndex < ucharsPerLoop; ++checkInd
ex) | 123 for (unsigned checkIndex = 0; checkIndex < ucharsPerLoop; ++checkInd
ex) |
124 ASSERT(!(source[i+checkIndex] & 0xff00)); | 124 ASSERT(!(source[i+checkIndex] & 0xff00)); |
125 #endif | 125 #endif |
126 __m128i first8UChars = _mm_load_si128(reinterpret_cast<const __m128i
*>(&source[i])); | 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])); | 127 __m128i second8UChars = _mm_load_si128(reinterpret_cast<const __m128
i*>(&source[i+8])); |
128 __m128i packedChars = _mm_packus_epi16(first8UChars, second8UChars); | 128 __m128i packedChars = _mm_packus_epi16(first8UChars, second8UChars); |
129 _mm_storeu_si128(reinterpret_cast<__m128i*>(&destination[i]), packed
Chars); | 129 _mm_storeu_si128(reinterpret_cast<__m128i*>(&destination[i]), packed
Chars); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
(...skipping 29 matching lines...) Expand all Loading... |
162 for (size_t i = 0; i < length; ++i) { | 162 for (size_t i = 0; i < length; ++i) { |
163 ASSERT(!(source[i] & 0xff00)); | 163 ASSERT(!(source[i] & 0xff00)); |
164 destination[i] = static_cast<LChar>(source[i]); | 164 destination[i] = static_cast<LChar>(source[i]); |
165 } | 165 } |
166 #endif | 166 #endif |
167 } | 167 } |
168 | 168 |
169 } // namespace WTF | 169 } // namespace WTF |
170 | 170 |
171 #endif // ASCIIFastPath_h | 171 #endif // ASCIIFastPath_h |
OLD | NEW |