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

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

Issue 6794050: Revert "[Arguments] Merge (7442,7496] from bleeding_edge." (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
Patch Set: Created 9 years, 8 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-cygwin.cc ('k') | src/platform-posix.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 30 matching lines...) Expand all
41 #include <semaphore.h> 41 #include <semaphore.h>
42 #include <signal.h> 42 #include <signal.h>
43 #include <libkern/OSAtomic.h> 43 #include <libkern/OSAtomic.h>
44 #include <mach/mach.h> 44 #include <mach/mach.h>
45 #include <mach/semaphore.h> 45 #include <mach/semaphore.h>
46 #include <mach/task.h> 46 #include <mach/task.h>
47 #include <mach/vm_statistics.h> 47 #include <mach/vm_statistics.h>
48 #include <sys/time.h> 48 #include <sys/time.h>
49 #include <sys/resource.h> 49 #include <sys/resource.h>
50 #include <sys/types.h> 50 #include <sys/types.h>
51 #include <sys/sysctl.h>
52 #include <stdarg.h> 51 #include <stdarg.h>
53 #include <stdlib.h> 52 #include <stdlib.h>
54 #include <string.h>
55 #include <errno.h> 53 #include <errno.h>
56 54
57 #undef MAP_TYPE 55 #undef MAP_TYPE
58 56
59 #include "v8.h" 57 #include "v8.h"
60 58
61 #include "platform.h" 59 #include "platform.h"
62 #include "vm-state-inl.h" 60 #include "vm-state-inl.h"
63 61
64 // Manually define these here as weak imports, rather than including execinfo.h. 62 // Manually define these here as weak imports, rather than including execinfo.h.
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 pthread_create(&thread_handle_data()->thread_, attr_ptr, ThreadEntry, this); 500 pthread_create(&thread_handle_data()->thread_, attr_ptr, ThreadEntry, this);
503 ASSERT(IsValid()); 501 ASSERT(IsValid());
504 } 502 }
505 503
506 504
507 void Thread::Join() { 505 void Thread::Join() {
508 pthread_join(thread_handle_data()->thread_, NULL); 506 pthread_join(thread_handle_data()->thread_, NULL);
509 } 507 }
510 508
511 509
512 #ifdef V8_FAST_TLS_SUPPORTED
513
514 static Atomic32 tls_base_offset_initialized = 0;
515 intptr_t kMacTlsBaseOffset = 0;
516
517 // It's safe to do the initialization more that once, but it has to be
518 // done at least once.
519 static void InitializeTlsBaseOffset() {
520 const size_t kBufferSize = 128;
521 char buffer[kBufferSize];
522 size_t buffer_size = kBufferSize;
523 int ctl_name[] = { CTL_KERN , KERN_OSRELEASE };
524 if (sysctl(ctl_name, 2, buffer, &buffer_size, NULL, 0) != 0) {
525 V8_Fatal(__FILE__, __LINE__, "V8 failed to get kernel version");
526 }
527 // The buffer now contains a string of the form XX.YY.ZZ, where
528 // XX is the major kernel version component.
529 // Make sure the buffer is 0-terminated.
530 buffer[kBufferSize - 1] = '\0';
531 char* period_pos = strchr(buffer, '.');
532 *period_pos = '\0';
533 int kernel_version_major =
534 static_cast<int>(strtol(buffer, NULL, 10)); // NOLINT
535 // The constants below are taken from pthreads.s from the XNU kernel
536 // sources archive at www.opensource.apple.com.
537 if (kernel_version_major < 11) {
538 // 8.x.x (Tiger), 9.x.x (Leopard), 10.x.x (Snow Leopard) have the
539 // same offsets.
540 #if defined(V8_HOST_ARCH_IA32)
541 kMacTlsBaseOffset = 0x48;
542 #else
543 kMacTlsBaseOffset = 0x60;
544 #endif
545 } else {
546 // 11.x.x (Lion) changed the offset.
547 kMacTlsBaseOffset = 0;
548 }
549
550 Release_Store(&tls_base_offset_initialized, 1);
551 }
552
553 static void CheckFastTls(Thread::LocalStorageKey key) {
554 void* expected = reinterpret_cast<void*>(0x1234CAFE);
555 Thread::SetThreadLocal(key, expected);
556 void* actual = Thread::GetExistingThreadLocal(key);
557 if (expected != actual) {
558 V8_Fatal(__FILE__, __LINE__,
559 "V8 failed to initialize fast TLS on current kernel");
560 }
561 Thread::SetThreadLocal(key, NULL);
562 }
563
564 #endif // V8_FAST_TLS_SUPPORTED
565
566
567 Thread::LocalStorageKey Thread::CreateThreadLocalKey() { 510 Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
568 #ifdef V8_FAST_TLS_SUPPORTED
569 bool check_fast_tls = false;
570 if (tls_base_offset_initialized == 0) {
571 check_fast_tls = true;
572 InitializeTlsBaseOffset();
573 }
574 #endif
575 pthread_key_t key; 511 pthread_key_t key;
576 int result = pthread_key_create(&key, NULL); 512 int result = pthread_key_create(&key, NULL);
577 USE(result); 513 USE(result);
578 ASSERT(result == 0); 514 ASSERT(result == 0);
579 LocalStorageKey typed_key = static_cast<LocalStorageKey>(key); 515 return static_cast<LocalStorageKey>(key);
580 #ifdef V8_FAST_TLS_SUPPORTED
581 // If we just initialized fast TLS support, make sure it works.
582 if (check_fast_tls) CheckFastTls(typed_key);
583 #endif
584 return typed_key;
585 } 516 }
586 517
587 518
588 void Thread::DeleteThreadLocalKey(LocalStorageKey key) { 519 void Thread::DeleteThreadLocalKey(LocalStorageKey key) {
589 pthread_key_t pthread_key = static_cast<pthread_key_t>(key); 520 pthread_key_t pthread_key = static_cast<pthread_key_t>(key);
590 int result = pthread_key_delete(pthread_key); 521 int result = pthread_key_delete(pthread_key);
591 USE(result); 522 USE(result);
592 ASSERT(result == 0); 523 ASSERT(result == 0);
593 } 524 }
594 525
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 787
857 void Sampler::Stop() { 788 void Sampler::Stop() {
858 ASSERT(IsActive()); 789 ASSERT(IsActive());
859 SamplerThread::RemoveActiveSampler(this); 790 SamplerThread::RemoveActiveSampler(this);
860 SetActive(false); 791 SetActive(false);
861 } 792 }
862 793
863 #endif // ENABLE_LOGGING_AND_PROFILING 794 #endif // ENABLE_LOGGING_AND_PROFILING
864 795
865 } } // namespace v8::internal 796 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-cygwin.cc ('k') | src/platform-posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698