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

Side by Side Diff: src/sampler.cc

Issue 14208012: Move StackTracer to sampler.h (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 7 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/sampler.h ('k') | test/cctest/test-log-stack-tracer.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include <mach/mach.h> 52 #include <mach/mach.h>
53 53
54 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) 54 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
55 55
56 #include "win32-headers.h" 56 #include "win32-headers.h"
57 57
58 #endif 58 #endif
59 59
60 #include "v8.h" 60 #include "v8.h"
61 61
62 #include "frames-inl.h"
62 #include "log.h" 63 #include "log.h"
63 #include "platform.h" 64 #include "platform.h"
64 #include "simulator.h" 65 #include "simulator.h"
65 #include "v8threads.h" 66 #include "v8threads.h"
66 67
67 68
68 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) 69 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T)
69 70
70 // Not all versions of Android's C library provide ucontext_t. 71 // Not all versions of Android's C library provide ucontext_t.
71 // Detect this and provide custom but compatible definitions. Note that these 72 // Detect this and provide custom but compatible definitions. Note that these
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 List<Sampler*> active_samplers_; 613 List<Sampler*> active_samplers_;
613 614
614 DISALLOW_COPY_AND_ASSIGN(SamplerThread); 615 DISALLOW_COPY_AND_ASSIGN(SamplerThread);
615 }; 616 };
616 617
617 618
618 Mutex* SamplerThread::mutex_ = NULL; 619 Mutex* SamplerThread::mutex_ = NULL;
619 SamplerThread* SamplerThread::instance_ = NULL; 620 SamplerThread* SamplerThread::instance_ = NULL;
620 621
621 622
623 //
624 // StackTracer implementation
625 //
626 DISABLE_ASAN void TickSample::Trace(Isolate* isolate) {
627 ASSERT(isolate->IsInitialized());
628
629 // Avoid collecting traces while doing GC.
630 if (state == GC) return;
631
632 const Address js_entry_sp =
633 Isolate::js_entry_sp(isolate->thread_local_top());
634 if (js_entry_sp == 0) {
635 // Not executing JS now.
636 return;
637 }
638
639 external_callback = isolate->external_callback();
640
641 SafeStackTraceFrameIterator it(isolate, fp, sp, sp, js_entry_sp);
642 int i = 0;
643 while (!it.done() && i < TickSample::kMaxFramesCount) {
644 stack[i++] = it.frame()->pc();
645 it.Advance();
646 }
647 frames_count = i;
648 }
649
650
622 void Sampler::SetUp() { 651 void Sampler::SetUp() {
623 SamplerThread::SetUp(); 652 SamplerThread::SetUp();
624 } 653 }
625 654
626 655
627 void Sampler::TearDown() { 656 void Sampler::TearDown() {
628 SamplerThread::TearDown(); 657 SamplerThread::TearDown();
629 } 658 }
630 659
631 660
(...skipping 19 matching lines...) Expand all
651 } 680 }
652 681
653 682
654 void Sampler::Stop() { 683 void Sampler::Stop() {
655 ASSERT(IsActive()); 684 ASSERT(IsActive());
656 SamplerThread::RemoveActiveSampler(this); 685 SamplerThread::RemoveActiveSampler(this);
657 SetActive(false); 686 SetActive(false);
658 } 687 }
659 688
660 void Sampler::SampleStack(TickSample* sample) { 689 void Sampler::SampleStack(TickSample* sample) {
661 StackTracer::Trace(isolate_, sample); 690 sample->Trace(isolate_);
662 if (++samples_taken_ < 0) samples_taken_ = 0; 691 if (++samples_taken_ < 0) samples_taken_ = 0;
663 } 692 }
664 693
665 } } // namespace v8::internal 694 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/sampler.h ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698