OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 #if defined(V8_TARGET_ARCH_IA32) | 208 #if defined(V8_TARGET_ARCH_IA32) |
209 static OS::MemCopyFunction memcopy_function = NULL; | 209 static OS::MemCopyFunction memcopy_function = NULL; |
210 static Mutex* memcopy_function_mutex = OS::CreateMutex(); | 210 static Mutex* memcopy_function_mutex = OS::CreateMutex(); |
211 // Defined in codegen-ia32.cc. | 211 // Defined in codegen-ia32.cc. |
212 OS::MemCopyFunction CreateMemCopyFunction(); | 212 OS::MemCopyFunction CreateMemCopyFunction(); |
213 | 213 |
214 // Copy memory area to disjoint memory area. | 214 // Copy memory area to disjoint memory area. |
215 void OS::MemCopy(void* dest, const void* src, size_t size) { | 215 void OS::MemCopy(void* dest, const void* src, size_t size) { |
216 if (memcopy_function == NULL) { | 216 if (memcopy_function == NULL) { |
217 ScopedLock lock(memcopy_function_mutex); | 217 ScopedLock lock(memcopy_function_mutex); |
218 Isolate::EnsureDefaultIsolate(); | |
219 if (memcopy_function == NULL) { | 218 if (memcopy_function == NULL) { |
220 OS::MemCopyFunction temp = CreateMemCopyFunction(); | 219 OS::MemCopyFunction temp = CreateMemCopyFunction(); |
221 MemoryBarrier(); | 220 MemoryBarrier(); |
222 memcopy_function = temp; | 221 memcopy_function = temp; |
223 } | 222 } |
224 } | 223 } |
| 224 // Note: here we rely on dependent reads being ordered. This is true |
| 225 // on all architectures we currently support. |
225 (*memcopy_function)(dest, src, size); | 226 (*memcopy_function)(dest, src, size); |
226 #ifdef DEBUG | 227 #ifdef DEBUG |
227 CHECK_EQ(0, memcmp(dest, src, size)); | 228 CHECK_EQ(0, memcmp(dest, src, size)); |
228 #endif | 229 #endif |
229 } | 230 } |
230 #endif // V8_TARGET_ARCH_IA32 | 231 #endif // V8_TARGET_ARCH_IA32 |
231 | 232 |
232 // ---------------------------------------------------------------------------- | 233 // ---------------------------------------------------------------------------- |
233 // POSIX string support. | 234 // POSIX string support. |
234 // | 235 // |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 return ntohl(value); | 415 return ntohl(value); |
415 } | 416 } |
416 | 417 |
417 | 418 |
418 Socket* OS::CreateSocket() { | 419 Socket* OS::CreateSocket() { |
419 return new POSIXSocket(); | 420 return new POSIXSocket(); |
420 } | 421 } |
421 | 422 |
422 | 423 |
423 } } // namespace v8::internal | 424 } } // namespace v8::internal |
OLD | NEW |