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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 str[str.length() - 1] = '\0'; | 276 str[str.length() - 1] = '\0'; |
277 return -1; | 277 return -1; |
278 } else { | 278 } else { |
279 return n; | 279 return n; |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 | 283 |
284 #if defined(V8_TARGET_ARCH_IA32) | 284 #if defined(V8_TARGET_ARCH_IA32) |
285 static OS::MemCopyFunction memcopy_function = NULL; | 285 static OS::MemCopyFunction memcopy_function = NULL; |
286 static Mutex* memcopy_function_mutex = OS::CreateMutex(); | 286 static LazyMutex memcopy_function_mutex = LAZY_MUTEX_INITIALIZER; |
287 // Defined in codegen-ia32.cc. | 287 // Defined in codegen-ia32.cc. |
288 OS::MemCopyFunction CreateMemCopyFunction(); | 288 OS::MemCopyFunction CreateMemCopyFunction(); |
289 | 289 |
290 // Copy memory area to disjoint memory area. | 290 // Copy memory area to disjoint memory area. |
291 void OS::MemCopy(void* dest, const void* src, size_t size) { | 291 void OS::MemCopy(void* dest, const void* src, size_t size) { |
292 if (memcopy_function == NULL) { | 292 if (memcopy_function == NULL) { |
293 ScopedLock lock(memcopy_function_mutex); | 293 ScopedLock lock(memcopy_function_mutex.Pointer()); |
294 if (memcopy_function == NULL) { | 294 if (memcopy_function == NULL) { |
295 OS::MemCopyFunction temp = CreateMemCopyFunction(); | 295 OS::MemCopyFunction temp = CreateMemCopyFunction(); |
296 MemoryBarrier(); | 296 MemoryBarrier(); |
297 memcopy_function = temp; | 297 memcopy_function = temp; |
298 } | 298 } |
299 } | 299 } |
300 // Note: here we rely on dependent reads being ordered. This is true | 300 // Note: here we rely on dependent reads being ordered. This is true |
301 // on all architectures we currently support. | 301 // on all architectures we currently support. |
302 (*memcopy_function)(dest, src, size); | 302 (*memcopy_function)(dest, src, size); |
303 #ifdef DEBUG | 303 #ifdef DEBUG |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 return ntohl(value); | 491 return ntohl(value); |
492 } | 492 } |
493 | 493 |
494 | 494 |
495 Socket* OS::CreateSocket() { | 495 Socket* OS::CreateSocket() { |
496 return new POSIXSocket(); | 496 return new POSIXSocket(); |
497 } | 497 } |
498 | 498 |
499 | 499 |
500 } } // namespace v8::internal | 500 } } // namespace v8::internal |
OLD | NEW |