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

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

Issue 660452: Assign to "sample.state" before reading it. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « no previous file | src/platform-linux.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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 560
561 static Sampler* active_sampler_ = NULL; 561 static Sampler* active_sampler_ = NULL;
562 562
563 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { 563 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
564 USE(info); 564 USE(info);
565 if (signal != SIGPROF) return; 565 if (signal != SIGPROF) return;
566 if (active_sampler_ == NULL) return; 566 if (active_sampler_ == NULL) return;
567 567
568 TickSample sample; 568 TickSample sample;
569 569
570 // We always sample the VM state.
571 sample.state = Logger::state();
572
570 // If profiling, we extract the current pc and sp. 573 // If profiling, we extract the current pc and sp.
571 if (active_sampler_->IsProfiling()) { 574 if (active_sampler_->IsProfiling()) {
572 // Extracting the sample from the context is extremely machine dependent. 575 // Extracting the sample from the context is extremely machine dependent.
573 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 576 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
574 mcontext_t& mcontext = ucontext->uc_mcontext; 577 mcontext_t& mcontext = ucontext->uc_mcontext;
575 #if V8_HOST_ARCH_IA32 578 #if V8_HOST_ARCH_IA32
576 sample.pc = reinterpret_cast<Address>(mcontext.mc_eip); 579 sample.pc = reinterpret_cast<Address>(mcontext.mc_eip);
577 sample.sp = reinterpret_cast<Address>(mcontext.mc_esp); 580 sample.sp = reinterpret_cast<Address>(mcontext.mc_esp);
578 sample.fp = reinterpret_cast<Address>(mcontext.mc_ebp); 581 sample.fp = reinterpret_cast<Address>(mcontext.mc_ebp);
579 #elif V8_HOST_ARCH_X64 582 #elif V8_HOST_ARCH_X64
580 sample.pc = reinterpret_cast<Address>(mcontext.mc_rip); 583 sample.pc = reinterpret_cast<Address>(mcontext.mc_rip);
581 sample.sp = reinterpret_cast<Address>(mcontext.mc_rsp); 584 sample.sp = reinterpret_cast<Address>(mcontext.mc_rsp);
582 sample.fp = reinterpret_cast<Address>(mcontext.mc_rbp); 585 sample.fp = reinterpret_cast<Address>(mcontext.mc_rbp);
583 #elif V8_HOST_ARCH_ARM 586 #elif V8_HOST_ARCH_ARM
584 sample.pc = reinterpret_cast<Address>(mcontext.mc_r15); 587 sample.pc = reinterpret_cast<Address>(mcontext.mc_r15);
585 sample.sp = reinterpret_cast<Address>(mcontext.mc_r13); 588 sample.sp = reinterpret_cast<Address>(mcontext.mc_r13);
586 sample.fp = reinterpret_cast<Address>(mcontext.mc_r11); 589 sample.fp = reinterpret_cast<Address>(mcontext.mc_r11);
587 #endif 590 #endif
588 active_sampler_->SampleStack(&sample); 591 active_sampler_->SampleStack(&sample);
589 } 592 }
590 593
591 // We always sample the VM state.
592 sample.state = Logger::state();
593
594 active_sampler_->Tick(&sample); 594 active_sampler_->Tick(&sample);
595 } 595 }
596 596
597 597
598 class Sampler::PlatformData : public Malloced { 598 class Sampler::PlatformData : public Malloced {
599 public: 599 public:
600 PlatformData() { 600 PlatformData() {
601 signal_handler_installed_ = false; 601 signal_handler_installed_ = false;
602 } 602 }
603 603
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 } 654 }
655 655
656 // This sampler is no longer the active sampler. 656 // This sampler is no longer the active sampler.
657 active_sampler_ = NULL; 657 active_sampler_ = NULL;
658 active_ = false; 658 active_ = false;
659 } 659 }
660 660
661 #endif // ENABLE_LOGGING_AND_PROFILING 661 #endif // ENABLE_LOGGING_AND_PROFILING
662 662
663 } } // namespace v8::internal 663 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698