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

Side by Side Diff: src/platform-macos.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 | « src/platform-linux.cc ('k') | src/platform-win32.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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 mach_port_t task_self_; 541 mach_port_t task_self_;
542 thread_act_t profiled_thread_; 542 thread_act_t profiled_thread_;
543 pthread_t sampler_thread_; 543 pthread_t sampler_thread_;
544 544
545 // Sampler thread handler. 545 // Sampler thread handler.
546 void Runner() { 546 void Runner() {
547 // Loop until the sampler is disengaged. 547 // Loop until the sampler is disengaged.
548 while (sampler_->IsActive()) { 548 while (sampler_->IsActive()) {
549 TickSample sample; 549 TickSample sample;
550 550
551 // We always sample the VM state.
552 sample.state = Logger::state();
553
551 // If profiling, we record the pc and sp of the profiled thread. 554 // If profiling, we record the pc and sp of the profiled thread.
552 if (sampler_->IsProfiling() 555 if (sampler_->IsProfiling()
553 && KERN_SUCCESS == thread_suspend(profiled_thread_)) { 556 && KERN_SUCCESS == thread_suspend(profiled_thread_)) {
554 #if V8_HOST_ARCH_X64 557 #if V8_HOST_ARCH_X64
555 thread_state_flavor_t flavor = x86_THREAD_STATE64; 558 thread_state_flavor_t flavor = x86_THREAD_STATE64;
556 x86_thread_state64_t state; 559 x86_thread_state64_t state;
557 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; 560 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT;
558 #if __DARWIN_UNIX03 561 #if __DARWIN_UNIX03
559 #define REGISTER_FIELD(name) __r ## name 562 #define REGISTER_FIELD(name) __r ## name
560 #else 563 #else
(...skipping 17 matching lines...) Expand all
578 reinterpret_cast<natural_t*>(&state), 581 reinterpret_cast<natural_t*>(&state),
579 &count) == KERN_SUCCESS) { 582 &count) == KERN_SUCCESS) {
580 sample.pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); 583 sample.pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
581 sample.sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); 584 sample.sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
582 sample.fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); 585 sample.fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
583 sampler_->SampleStack(&sample); 586 sampler_->SampleStack(&sample);
584 } 587 }
585 thread_resume(profiled_thread_); 588 thread_resume(profiled_thread_);
586 } 589 }
587 590
588 // We always sample the VM state.
589 sample.state = Logger::state();
590 // Invoke tick handler with program counter and stack pointer. 591 // Invoke tick handler with program counter and stack pointer.
591 sampler_->Tick(&sample); 592 sampler_->Tick(&sample);
592 593
593 // Wait until next sampling. 594 // Wait until next sampling.
594 usleep(sampler_->interval_ * 1000); 595 usleep(sampler_->interval_ * 1000);
595 } 596 }
596 } 597 }
597 }; 598 };
598 599
599 #undef REGISTER_FIELD 600 #undef REGISTER_FIELD
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 653
653 // Deallocate Mach port for thread. 654 // Deallocate Mach port for thread.
654 if (IsProfiling()) { 655 if (IsProfiling()) {
655 mach_port_deallocate(data_->task_self_, data_->profiled_thread_); 656 mach_port_deallocate(data_->task_self_, data_->profiled_thread_);
656 } 657 }
657 } 658 }
658 659
659 #endif // ENABLE_LOGGING_AND_PROFILING 660 #endif // ENABLE_LOGGING_AND_PROFILING
660 661
661 } } // namespace v8::internal 662 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698