OLD | NEW |
---|---|
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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 | 545 |
546 Semaphore* OS::CreateSemaphore(int count) { | 546 Semaphore* OS::CreateSemaphore(int count) { |
547 return new LinuxSemaphore(count); | 547 return new LinuxSemaphore(count); |
548 } | 548 } |
549 | 549 |
550 | 550 |
551 #ifdef ENABLE_LOGGING_AND_PROFILING | 551 #ifdef ENABLE_LOGGING_AND_PROFILING |
552 | 552 |
553 static Sampler* active_sampler_ = NULL; | 553 static Sampler* active_sampler_ = NULL; |
554 | 554 |
555 | |
556 #if !defined(__GLIBC__) && defined(__arm__) | |
Kasper Lund
2009/04/07 13:32:08
How about __thumb__ ?
| |
557 // Android runs a fairly new Linux kernel, so signal info is there, | |
558 // but the C library doesn't have the structs defined. | |
559 | |
560 struct sigcontext { | |
561 uint32_t trap_no; | |
562 uint32_t error_code; | |
563 uint32_t oldmask; | |
564 uint32_t gregs[16]; | |
565 uint32_t arm_cpsr; | |
566 uint32_t fault_address; | |
567 }; | |
568 typedef uint32_t __sigset_t; | |
569 typedef struct sigcontext mcontext_t; | |
570 typedef struct ucontext { | |
571 uint32_t uc_flags; | |
572 struct ucontext *uc_link; | |
573 stack_t uc_stack; | |
574 mcontext_t uc_mcontext; | |
575 __sigset_t uc_sigmask; | |
576 } ucontext_t; | |
577 enum ArmRegisters {R15 = 15, R13 = 13, R11 = 11}; | |
578 | |
579 #endif | |
580 | |
581 | |
555 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { | 582 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
556 // Ucontext is a glibc extension - no profiling on Android at the moment. | |
557 #ifdef __GLIBC__ | |
558 USE(info); | 583 USE(info); |
559 if (signal != SIGPROF) return; | 584 if (signal != SIGPROF) return; |
560 if (active_sampler_ == NULL) return; | 585 if (active_sampler_ == NULL) return; |
561 | 586 |
562 TickSample sample; | 587 TickSample sample; |
563 | 588 |
564 // If profiling, we extract the current pc and sp. | 589 // If profiling, we extract the current pc and sp. |
565 if (active_sampler_->IsProfiling()) { | 590 if (active_sampler_->IsProfiling()) { |
566 // Extracting the sample from the context is extremely machine dependent. | 591 // Extracting the sample from the context is extremely machine dependent. |
567 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 592 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
568 mcontext_t& mcontext = ucontext->uc_mcontext; | 593 mcontext_t& mcontext = ucontext->uc_mcontext; |
569 #if defined (__arm__) || defined(__thumb__) | 594 #if defined (__arm__) || defined(__thumb__) |
570 sample.pc = mcontext.gregs[R15]; | 595 sample.pc = mcontext.gregs[R15]; |
571 sample.sp = mcontext.gregs[R13]; | 596 sample.sp = mcontext.gregs[R13]; |
572 sample.fp = mcontext.gregs[R11]; | 597 sample.fp = mcontext.gregs[R11]; |
573 #else | 598 #else |
574 sample.pc = mcontext.gregs[REG_EIP]; | 599 sample.pc = mcontext.gregs[REG_EIP]; |
575 sample.sp = mcontext.gregs[REG_ESP]; | 600 sample.sp = mcontext.gregs[REG_ESP]; |
576 sample.fp = mcontext.gregs[REG_EBP]; | 601 sample.fp = mcontext.gregs[REG_EBP]; |
577 #endif | 602 #endif |
578 } | 603 } |
579 | 604 |
580 // We always sample the VM state. | 605 // We always sample the VM state. |
581 sample.state = Logger::state(); | 606 sample.state = Logger::state(); |
582 | 607 |
583 active_sampler_->Tick(&sample); | 608 active_sampler_->Tick(&sample); |
584 #endif | |
585 } | 609 } |
586 | 610 |
587 | 611 |
588 class Sampler::PlatformData : public Malloced { | 612 class Sampler::PlatformData : public Malloced { |
589 public: | 613 public: |
590 PlatformData() { | 614 PlatformData() { |
591 signal_handler_installed_ = false; | 615 signal_handler_installed_ = false; |
592 } | 616 } |
593 | 617 |
594 bool signal_handler_installed_; | 618 bool signal_handler_installed_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 } | 668 } |
645 | 669 |
646 // This sampler is no longer the active sampler. | 670 // This sampler is no longer the active sampler. |
647 active_sampler_ = NULL; | 671 active_sampler_ = NULL; |
648 active_ = false; | 672 active_ = false; |
649 } | 673 } |
650 | 674 |
651 #endif // ENABLE_LOGGING_AND_PROFILING | 675 #endif // ENABLE_LOGGING_AND_PROFILING |
652 | 676 |
653 } } // namespace v8::internal | 677 } } // namespace v8::internal |
OLD | NEW |