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

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

Issue 7353017: 2011-07-13: Version 3.4.12 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 5 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-freebsd.cc ('k') | src/platform-macos.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 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 384
385 void OS::Free(void* address, const size_t size) { 385 void OS::Free(void* address, const size_t size) {
386 // TODO(1240712): munmap has a return value which is ignored here. 386 // TODO(1240712): munmap has a return value which is ignored here.
387 int result = munmap(address, size); 387 int result = munmap(address, size);
388 USE(result); 388 USE(result);
389 ASSERT(result == 0); 389 ASSERT(result == 0);
390 } 390 }
391 391
392 392
393 #ifdef ENABLE_HEAP_PROTECTION
394
395 void OS::Protect(void* address, size_t size) {
396 // TODO(1240712): mprotect has a return value which is ignored here.
397 mprotect(address, size, PROT_READ);
398 }
399
400
401 void OS::Unprotect(void* address, size_t size, bool is_executable) {
402 // TODO(1240712): mprotect has a return value which is ignored here.
403 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
404 mprotect(address, size, prot);
405 }
406
407 #endif
408
409
410 void OS::Sleep(int milliseconds) { 393 void OS::Sleep(int milliseconds) {
411 unsigned int ms = static_cast<unsigned int>(milliseconds); 394 unsigned int ms = static_cast<unsigned int>(milliseconds);
412 usleep(1000 * ms); 395 usleep(1000 * ms);
413 } 396 }
414 397
415 398
416 void OS::Abort() { 399 void OS::Abort() {
417 // Redirect to std abort to signal abnormal program termination. 400 // Redirect to std abort to signal abnormal program termination.
418 abort(); 401 abort();
419 } 402 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 459 }
477 460
478 461
479 PosixMemoryMappedFile::~PosixMemoryMappedFile() { 462 PosixMemoryMappedFile::~PosixMemoryMappedFile() {
480 if (memory_) munmap(memory_, size_); 463 if (memory_) munmap(memory_, size_);
481 fclose(file_); 464 fclose(file_);
482 } 465 }
483 466
484 467
485 void OS::LogSharedLibraryAddresses() { 468 void OS::LogSharedLibraryAddresses() {
486 #ifdef ENABLE_LOGGING_AND_PROFILING
487 // This function assumes that the layout of the file is as follows: 469 // This function assumes that the layout of the file is as follows:
488 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] 470 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
489 // If we encounter an unexpected situation we abort scanning further entries. 471 // If we encounter an unexpected situation we abort scanning further entries.
490 FILE* fp = fopen("/proc/self/maps", "r"); 472 FILE* fp = fopen("/proc/self/maps", "r");
491 if (fp == NULL) return; 473 if (fp == NULL) return;
492 474
493 // Allocate enough room to be able to store a full file name. 475 // Allocate enough room to be able to store a full file name.
494 const int kLibNameLen = FILENAME_MAX + 1; 476 const int kLibNameLen = FILENAME_MAX + 1;
495 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); 477 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen));
496 478
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // Entry not describing executable data. Skip to end of line to setup 515 // Entry not describing executable data. Skip to end of line to setup
534 // reading the next entry. 516 // reading the next entry.
535 do { 517 do {
536 c = getc(fp); 518 c = getc(fp);
537 } while ((c != EOF) && (c != '\n')); 519 } while ((c != EOF) && (c != '\n'));
538 if (c == EOF) break; 520 if (c == EOF) break;
539 } 521 }
540 } 522 }
541 free(lib_name); 523 free(lib_name);
542 fclose(fp); 524 fclose(fp);
543 #endif
544 } 525 }
545 526
546 527
547 static const char kGCFakeMmap[] = "/tmp/__v8_gc__"; 528 static const char kGCFakeMmap[] = "/tmp/__v8_gc__";
548 529
549 530
550 void OS::SignalCodeMovingGC() { 531 void OS::SignalCodeMovingGC() {
551 #ifdef ENABLE_LOGGING_AND_PROFILING
552 // Support for ll_prof.py. 532 // Support for ll_prof.py.
553 // 533 //
554 // The Linux profiler built into the kernel logs all mmap's with 534 // The Linux profiler built into the kernel logs all mmap's with
555 // PROT_EXEC so that analysis tools can properly attribute ticks. We 535 // PROT_EXEC so that analysis tools can properly attribute ticks. We
556 // do a mmap with a name known by ll_prof.py and immediately munmap 536 // do a mmap with a name known by ll_prof.py and immediately munmap
557 // it. This injects a GC marker into the stream of events generated 537 // it. This injects a GC marker into the stream of events generated
558 // by the kernel and allows us to synchronize V8 code log and the 538 // by the kernel and allows us to synchronize V8 code log and the
559 // kernel log. 539 // kernel log.
560 int size = sysconf(_SC_PAGESIZE); 540 int size = sysconf(_SC_PAGESIZE);
561 FILE* f = fopen(kGCFakeMmap, "w+"); 541 FILE* f = fopen(kGCFakeMmap, "w+");
562 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, 542 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE,
563 fileno(f), 0); 543 fileno(f), 0);
564 ASSERT(addr != MAP_FAILED); 544 ASSERT(addr != MAP_FAILED);
565 munmap(addr, size); 545 munmap(addr, size);
566 fclose(f); 546 fclose(f);
567 #endif
568 } 547 }
569 548
570 549
571 int OS::StackWalk(Vector<OS::StackFrame> frames) { 550 int OS::StackWalk(Vector<OS::StackFrame> frames) {
572 // backtrace is a glibc extension. 551 // backtrace is a glibc extension.
573 #ifdef __GLIBC__ 552 #ifdef __GLIBC__
574 int frames_size = frames.length(); 553 int frames_size = frames.length();
575 ScopedVector<void*> addresses(frames_size); 554 ScopedVector<void*> addresses(frames_size);
576 555
577 int frames_count = backtrace(addresses.start(), frames_size); 556 int frames_count = backtrace(addresses.start(), frames_size);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. 831 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup.
853 } 832 }
854 } 833 }
855 834
856 835
857 Semaphore* OS::CreateSemaphore(int count) { 836 Semaphore* OS::CreateSemaphore(int count) {
858 return new LinuxSemaphore(count); 837 return new LinuxSemaphore(count);
859 } 838 }
860 839
861 840
862 #ifdef ENABLE_LOGGING_AND_PROFILING
863
864 #if !defined(__GLIBC__) && (defined(__arm__) || defined(__thumb__)) 841 #if !defined(__GLIBC__) && (defined(__arm__) || defined(__thumb__))
865 // Android runs a fairly new Linux kernel, so signal info is there, 842 // Android runs a fairly new Linux kernel, so signal info is there,
866 // but the C library doesn't have the structs defined. 843 // but the C library doesn't have the structs defined.
867 844
868 struct sigcontext { 845 struct sigcontext {
869 uint32_t trap_no; 846 uint32_t trap_no;
870 uint32_t error_code; 847 uint32_t error_code;
871 uint32_t oldmask; 848 uint32_t oldmask;
872 uint32_t gregs[16]; 849 uint32_t gregs[16];
873 uint32_t arm_cpsr; 850 uint32_t arm_cpsr;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 SignalSender::AddActiveSampler(this); 1118 SignalSender::AddActiveSampler(this);
1142 } 1119 }
1143 1120
1144 1121
1145 void Sampler::Stop() { 1122 void Sampler::Stop() {
1146 ASSERT(IsActive()); 1123 ASSERT(IsActive());
1147 SignalSender::RemoveActiveSampler(this); 1124 SignalSender::RemoveActiveSampler(this);
1148 SetActive(false); 1125 SetActive(false);
1149 } 1126 }
1150 1127
1151 #endif // ENABLE_LOGGING_AND_PROFILING
1152 1128
1153 } } // namespace v8::internal 1129 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698