OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 } | 2057 } |
2058 | 2058 |
2059 void SampleContext(Sampler* sampler) { | 2059 void SampleContext(Sampler* sampler) { |
2060 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); | 2060 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); |
2061 if (profiled_thread == NULL) return; | 2061 if (profiled_thread == NULL) return; |
2062 | 2062 |
2063 // Context used for sampling the register state of the profiled thread. | 2063 // Context used for sampling the register state of the profiled thread. |
2064 CONTEXT context; | 2064 CONTEXT context; |
2065 memset(&context, 0, sizeof(context)); | 2065 memset(&context, 0, sizeof(context)); |
2066 | 2066 |
2067 Isolate* isolate = sampler->isolate(); | |
2068 TickSample sample_obj; | 2067 TickSample sample_obj; |
2069 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); | 2068 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); |
2070 if (sample == NULL) sample = &sample_obj; | 2069 if (sample == NULL) sample = &sample_obj; |
2071 | 2070 |
2072 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); | 2071 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); |
2073 if (SuspendThread(profiled_thread) == kSuspendFailed) return; | 2072 if (SuspendThread(profiled_thread) == kSuspendFailed) return; |
2074 sample->state = isolate->current_vm_state(); | 2073 sample->state = sampler->isolate()->current_vm_state(); |
2075 | 2074 |
2076 context.ContextFlags = CONTEXT_FULL; | 2075 context.ContextFlags = CONTEXT_FULL; |
2077 if (GetThreadContext(profiled_thread, &context) != 0) { | 2076 if (GetThreadContext(profiled_thread, &context) != 0) { |
2078 #if V8_HOST_ARCH_X64 | 2077 #if V8_HOST_ARCH_X64 |
2079 sample->pc = reinterpret_cast<Address>(context.Rip); | 2078 sample->pc = reinterpret_cast<Address>(context.Rip); |
2080 sample->sp = reinterpret_cast<Address>(context.Rsp); | 2079 sample->sp = reinterpret_cast<Address>(context.Rsp); |
2081 sample->fp = reinterpret_cast<Address>(context.Rbp); | 2080 sample->fp = reinterpret_cast<Address>(context.Rbp); |
2082 #else | 2081 #else |
2083 sample->pc = reinterpret_cast<Address>(context.Eip); | 2082 sample->pc = reinterpret_cast<Address>(context.Eip); |
2084 sample->sp = reinterpret_cast<Address>(context.Esp); | 2083 sample->sp = reinterpret_cast<Address>(context.Esp); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2148 | 2147 |
2149 | 2148 |
2150 void Sampler::Stop() { | 2149 void Sampler::Stop() { |
2151 ASSERT(IsActive()); | 2150 ASSERT(IsActive()); |
2152 SamplerThread::RemoveActiveSampler(this); | 2151 SamplerThread::RemoveActiveSampler(this); |
2153 SetActive(false); | 2152 SetActive(false); |
2154 } | 2153 } |
2155 | 2154 |
2156 | 2155 |
2157 } } // namespace v8::internal | 2156 } } // namespace v8::internal |
OLD | NEW |