| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if (str.length() > 0) | 315 if (str.length() > 0) |
| 316 str[str.length() - 1] = '\0'; | 316 str[str.length() - 1] = '\0'; |
| 317 return -1; | 317 return -1; |
| 318 } else { | 318 } else { |
| 319 return n; | 319 return n; |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 | 323 |
| 324 #if defined(V8_TARGET_ARCH_IA32) | 324 #if defined(V8_TARGET_ARCH_IA32) |
| 325 static OS::MemCopyFunction memcopy_function = NULL; | 325 static void MemMoveWrapper(void* dest, const void* src, size_t size) { |
| 326 memmove(dest, src, size); |
| 327 } |
| 328 |
| 329 // Initialize to library version so we can call this at any time during startup. |
| 330 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; |
| 331 |
| 326 // Defined in codegen-ia32.cc. | 332 // Defined in codegen-ia32.cc. |
| 327 OS::MemCopyFunction CreateMemCopyFunction(); | 333 OS::MemMoveFunction CreateMemMoveFunction(); |
| 328 | 334 |
| 329 // Copy memory area to disjoint memory area. | 335 // Copy memory area. No restrictions. |
| 330 void OS::MemCopy(void* dest, const void* src, size_t size) { | 336 void OS::MemMove(void* dest, const void* src, size_t size) { |
| 331 // Note: here we rely on dependent reads being ordered. This is true | 337 // Note: here we rely on dependent reads being ordered. This is true |
| 332 // on all architectures we currently support. | 338 // on all architectures we currently support. |
| 333 (*memcopy_function)(dest, src, size); | 339 (*memmove_function)(dest, src, size); |
| 334 #ifdef DEBUG | |
| 335 CHECK_EQ(0, memcmp(dest, src, size)); | |
| 336 #endif | |
| 337 } | 340 } |
| 341 |
| 338 #endif // V8_TARGET_ARCH_IA32 | 342 #endif // V8_TARGET_ARCH_IA32 |
| 339 | 343 |
| 340 | 344 |
| 341 void POSIXPostSetUp() { | 345 void POSIXPostSetUp() { |
| 342 #if defined(V8_TARGET_ARCH_IA32) | 346 #if defined(V8_TARGET_ARCH_IA32) |
| 343 memcopy_function = CreateMemCopyFunction(); | 347 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
| 348 if (generated_memmove != NULL) { |
| 349 memmove_function = generated_memmove; |
| 350 } |
| 344 #endif | 351 #endif |
| 345 init_fast_sin_function(); | 352 init_fast_sin_function(); |
| 346 init_fast_cos_function(); | 353 init_fast_cos_function(); |
| 347 init_fast_tan_function(); | 354 init_fast_tan_function(); |
| 348 init_fast_log_function(); | 355 init_fast_log_function(); |
| 349 // fast_exp is initialized lazily. | 356 // fast_exp is initialized lazily. |
| 350 init_fast_sqrt_function(); | 357 init_fast_sqrt_function(); |
| 351 } | 358 } |
| 352 | 359 |
| 353 // ---------------------------------------------------------------------------- | 360 // ---------------------------------------------------------------------------- |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 return ntohl(value); | 563 return ntohl(value); |
| 557 } | 564 } |
| 558 | 565 |
| 559 | 566 |
| 560 Socket* OS::CreateSocket() { | 567 Socket* OS::CreateSocket() { |
| 561 return new POSIXSocket(); | 568 return new POSIXSocket(); |
| 562 } | 569 } |
| 563 | 570 |
| 564 | 571 |
| 565 } } // namespace v8::internal | 572 } } // namespace v8::internal |
| OLD | NEW |