Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1049)

Side by Side Diff: src/platform-posix.cc

Issue 302563004: Move OS::MemCopy and OS::MemMove out of platform to utils (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Platform-specific code for POSIX goes here. This is not a platform on its 5 // Platform-specific code for POSIX goes here. This is not a platform on its
6 // own, but contains the parts which are the same across the POSIX platforms 6 // own, but contains the parts which are the same across the POSIX platforms
7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX.
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <pthread.h> 10 #include <pthread.h>
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // If the length is zero, the assignment fails. 435 // If the length is zero, the assignment fails.
436 if (str.length() > 0) 436 if (str.length() > 0)
437 str[str.length() - 1] = '\0'; 437 str[str.length() - 1] = '\0';
438 return -1; 438 return -1;
439 } else { 439 } else {
440 return n; 440 return n;
441 } 441 }
442 } 442 }
443 443
444 444
445 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
446 static void MemMoveWrapper(void* dest, const void* src, size_t size) {
447 memmove(dest, src, size);
448 }
449
450
451 // Initialize to library version so we can call this at any time during startup.
452 static OS::MemMoveFunction memmove_function = &MemMoveWrapper;
453
454 // Defined in codegen-ia32.cc.
455 OS::MemMoveFunction CreateMemMoveFunction();
456
457 // Copy memory area. No restrictions.
458 void OS::MemMove(void* dest, const void* src, size_t size) {
459 if (size == 0) return;
460 // Note: here we rely on dependent reads being ordered. This is true
461 // on all architectures we currently support.
462 (*memmove_function)(dest, src, size);
463 }
464
465 #elif defined(V8_HOST_ARCH_ARM)
466 void OS::MemCopyUint16Uint8Wrapper(uint16_t* dest,
467 const uint8_t* src,
468 size_t chars) {
469 uint16_t *limit = dest + chars;
470 while (dest < limit) {
471 *dest++ = static_cast<uint16_t>(*src++);
472 }
473 }
474
475
476 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper;
477 OS::MemCopyUint16Uint8Function OS::memcopy_uint16_uint8_function =
478 &OS::MemCopyUint16Uint8Wrapper;
479 // Defined in codegen-arm.cc.
480 OS::MemCopyUint8Function CreateMemCopyUint8Function(
481 OS::MemCopyUint8Function stub);
482 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
483 OS::MemCopyUint16Uint8Function stub);
484
485 #elif defined(V8_HOST_ARCH_MIPS)
486 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper;
487 // Defined in codegen-mips.cc.
488 OS::MemCopyUint8Function CreateMemCopyUint8Function(
489 OS::MemCopyUint8Function stub);
490 #endif
491
492
493 void OS::PostSetUp() {
494 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
495 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction();
496 if (generated_memmove != NULL) {
497 memmove_function = generated_memmove;
498 }
499 #elif defined(V8_HOST_ARCH_ARM)
500 OS::memcopy_uint8_function =
501 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
502 OS::memcopy_uint16_uint8_function =
503 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper);
504 #elif defined(V8_HOST_ARCH_MIPS)
505 OS::memcopy_uint8_function =
506 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
507 #endif
508 }
509
510
511 // ---------------------------------------------------------------------------- 445 // ----------------------------------------------------------------------------
512 // POSIX string support. 446 // POSIX string support.
513 // 447 //
514 448
515 char* OS::StrChr(char* str, int c) { 449 char* OS::StrChr(char* str, int c) {
516 return strchr(str, c); 450 return strchr(str, c);
517 } 451 }
518 452
519 453
520 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { 454 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 685
752 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { 686 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
753 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); 687 pthread_key_t pthread_key = LocalKeyToPthreadKey(key);
754 int result = pthread_setspecific(pthread_key, value); 688 int result = pthread_setspecific(pthread_key, value);
755 ASSERT_EQ(0, result); 689 ASSERT_EQ(0, result);
756 USE(result); 690 USE(result);
757 } 691 }
758 692
759 693
760 } } // namespace v8::internal 694 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698