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 10 matching lines...) Expand all Loading... |
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(DARWIN) && (CPU(X86) || CPU(X86_64)) | 31 #if OS(MACOSX) && (CPU(X86) || CPU(X86_64)) |
32 #include <emmintrin.h> | 32 #include <emmintrin.h> |
33 #endif | 33 #endif |
34 | 34 |
35 namespace WTF { | 35 namespace WTF { |
36 | 36 |
37 // Assuming that a pointer is the size of a "machine word", then | 37 // 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. | 38 // uintptr_t is an integer type that is also a machine word. |
39 typedef uintptr_t MachineWord; | 39 typedef uintptr_t MachineWord; |
40 const uintptr_t machineWordAlignmentMask = sizeof(MachineWord) - 1; | 40 const uintptr_t machineWordAlignmentMask = sizeof(MachineWord) - 1; |
41 | 41 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 allCharBits |= *characters; | 97 allCharBits |= *characters; |
98 ++characters; | 98 ++characters; |
99 } | 99 } |
100 | 100 |
101 MachineWord nonASCIIBitMask = NonASCIIMask<sizeof(MachineWord), CharacterTyp
e>::value(); | 101 MachineWord nonASCIIBitMask = NonASCIIMask<sizeof(MachineWord), CharacterTyp
e>::value(); |
102 return !(allCharBits & nonASCIIBitMask); | 102 return !(allCharBits & nonASCIIBitMask); |
103 } | 103 } |
104 | 104 |
105 inline void copyLCharsFromUCharSource(LChar* destination, const UChar* source, s
ize_t length) | 105 inline void copyLCharsFromUCharSource(LChar* destination, const UChar* source, s
ize_t length) |
106 { | 106 { |
107 #if OS(DARWIN) && (CPU(X86) || CPU(X86_64)) | 107 #if OS(MACOSX) && (CPU(X86) || CPU(X86_64)) |
108 const uintptr_t memoryAccessSize = 16; // Memory accesses on 16 byte (128 bi
t) alignment | 108 const uintptr_t memoryAccessSize = 16; // Memory accesses on 16 byte (128 bi
t) alignment |
109 const uintptr_t memoryAccessMask = memoryAccessSize - 1; | 109 const uintptr_t memoryAccessMask = memoryAccessSize - 1; |
110 | 110 |
111 size_t i = 0; | 111 size_t i = 0; |
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 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |