Chromium Code Reviews| 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; | |
|
Michael Starzinger
2013/04/16 09:41:42
nit: Add an empty newline after "memmove_function"
Jakob Kummerow
2013/04/16 12:29:42
Done.
| |
| 326 // Defined in codegen-ia32.cc. | 331 // Defined in codegen-ia32.cc. |
| 327 OS::MemCopyFunction CreateMemCopyFunction(); | 332 OS::MemMoveFunction CreateMemMoveFunction(); |
| 328 | 333 |
| 329 // Copy memory area to disjoint memory area. | 334 // Copy memory area. No restrictions. |
| 330 void OS::MemCopy(void* dest, const void* src, size_t size) { | 335 void OS::MemMove(void* dest, const void* src, size_t size) { |
| 331 // Note: here we rely on dependent reads being ordered. This is true | 336 // Note: here we rely on dependent reads being ordered. This is true |
| 332 // on all architectures we currently support. | 337 // on all architectures we currently support. |
| 333 (*memcopy_function)(dest, src, size); | 338 (*memmove_function)(dest, src, size); |
| 334 #ifdef DEBUG | |
| 335 CHECK_EQ(0, memcmp(dest, src, size)); | |
| 336 #endif | |
| 337 } | 339 } |
| 340 | |
| 338 #endif // V8_TARGET_ARCH_IA32 | 341 #endif // V8_TARGET_ARCH_IA32 |
| 339 | 342 |
| 340 | 343 |
| 341 void POSIXPostSetUp() { | 344 void POSIXPostSetUp() { |
| 342 #if defined(V8_TARGET_ARCH_IA32) | 345 #if defined(V8_TARGET_ARCH_IA32) |
| 343 memcopy_function = CreateMemCopyFunction(); | 346 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
| 347 if (generated_memmove != NULL) { | |
| 348 memmove_function = generated_memmove; | |
| 349 } | |
| 344 #endif | 350 #endif |
| 345 init_fast_sin_function(); | 351 init_fast_sin_function(); |
| 346 init_fast_cos_function(); | 352 init_fast_cos_function(); |
| 347 init_fast_tan_function(); | 353 init_fast_tan_function(); |
| 348 init_fast_log_function(); | 354 init_fast_log_function(); |
| 349 // fast_exp is initialized lazily. | 355 // fast_exp is initialized lazily. |
| 350 init_fast_sqrt_function(); | 356 init_fast_sqrt_function(); |
| 351 } | 357 } |
| 352 | 358 |
| 353 // ---------------------------------------------------------------------------- | 359 // ---------------------------------------------------------------------------- |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 return ntohl(value); | 562 return ntohl(value); |
| 557 } | 563 } |
| 558 | 564 |
| 559 | 565 |
| 560 Socket* OS::CreateSocket() { | 566 Socket* OS::CreateSocket() { |
| 561 return new POSIXSocket(); | 567 return new POSIXSocket(); |
| 562 } | 568 } |
| 563 | 569 |
| 564 | 570 |
| 565 } } // namespace v8::internal | 571 } } // namespace v8::internal |
| OLD | NEW |