| OLD | NEW |
| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 #if defined(USE_SIMULATOR) | 250 #if defined(USE_SIMULATOR) |
| 251 inline void FillRegisters(TickSample* sample) { | 251 inline void FillRegisters(TickSample* sample) { |
| 252 #if V8_TARGET_ARCH_ARM | 252 #if V8_TARGET_ARCH_ARM |
| 253 sample->pc = reinterpret_cast<Address>(simulator_->get_pc()); | 253 sample->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 254 sample->sp = reinterpret_cast<Address>(simulator_->get_register( | 254 sample->sp = reinterpret_cast<Address>(simulator_->get_register( |
| 255 Simulator::sp)); | 255 Simulator::sp)); |
| 256 sample->fp = reinterpret_cast<Address>(simulator_->get_register( | 256 sample->fp = reinterpret_cast<Address>(simulator_->get_register( |
| 257 Simulator::r11)); | 257 Simulator::r11)); |
| 258 #elif V8_TARGET_ARCH_A64 | 258 #elif V8_TARGET_ARCH_A64 |
| 259 if (simulator_->sp() == 0 || simulator_->fp() == 0) { |
| 260 // It possible that the simulator is interrupted while it is updating |
| 261 // the sp or fp register. A64 simulator does this in two steps: |
| 262 // first setting it to zero and then setting it to the new value. |
| 263 // Bailout if sp/fp doesn't contain the new value. |
| 264 return; |
| 265 } |
| 259 sample->pc = reinterpret_cast<Address>(simulator_->pc()); | 266 sample->pc = reinterpret_cast<Address>(simulator_->pc()); |
| 260 sample->sp = reinterpret_cast<Address>(simulator_->sp()); | 267 sample->sp = reinterpret_cast<Address>(simulator_->sp()); |
| 261 sample->fp = reinterpret_cast<Address>(simulator_->lr()); | 268 sample->fp = reinterpret_cast<Address>(simulator_->fp()); |
| 262 #elif V8_TARGET_ARCH_MIPS | 269 #elif V8_TARGET_ARCH_MIPS |
| 263 sample->pc = reinterpret_cast<Address>(simulator_->get_pc()); | 270 sample->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 264 sample->sp = reinterpret_cast<Address>(simulator_->get_register( | 271 sample->sp = reinterpret_cast<Address>(simulator_->get_register( |
| 265 Simulator::sp)); | 272 Simulator::sp)); |
| 266 sample->fp = reinterpret_cast<Address>(simulator_->get_register( | 273 sample->fp = reinterpret_cast<Address>(simulator_->get_register( |
| 267 Simulator::fp)); | 274 Simulator::fp)); |
| 268 #endif | 275 #endif |
| 269 } | 276 } |
| 270 #endif // USE_SIMULATOR | 277 #endif // USE_SIMULATOR |
| 271 | 278 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 Sampler* sampler = isolate->logger()->sampler(); | 341 Sampler* sampler = isolate->logger()->sampler(); |
| 335 if (sampler == NULL || !sampler->IsActive()) return; | 342 if (sampler == NULL || !sampler->IsActive()) return; |
| 336 | 343 |
| 337 SampleHelper helper; | 344 SampleHelper helper; |
| 338 TickSample* sample = helper.Init(sampler, isolate); | 345 TickSample* sample = helper.Init(sampler, isolate); |
| 339 if (sample == NULL) return; | 346 if (sample == NULL) return; |
| 340 | 347 |
| 341 #if defined(USE_SIMULATOR) | 348 #if defined(USE_SIMULATOR) |
| 342 helper.FillRegisters(sample); | 349 helper.FillRegisters(sample); |
| 343 // It possible that the simulator is interrupted while it is updating | 350 // It possible that the simulator is interrupted while it is updating |
| 344 // the sp register. A64 simulator does this in two steps: | 351 // the sp or fp register. A64 simulator does this in two steps: |
| 345 // first setting it to zero and then setting it to the new value. | 352 // first setting it to zero and then setting it to the new value. |
| 346 // Bailout if sp doesn't contain the new value. | 353 // Bailout if sp/fp doesn't contain the new value. |
| 347 if (sample->sp == 0) return; | 354 if (sample->sp == 0 || sample->fp == 0) return; |
| 348 #else | 355 #else |
| 349 // Extracting the sample from the context is extremely machine dependent. | 356 // Extracting the sample from the context is extremely machine dependent. |
| 350 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 357 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 351 mcontext_t& mcontext = ucontext->uc_mcontext; | 358 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 352 sample->state = isolate->current_vm_state(); | 359 sample->state = isolate->current_vm_state(); |
| 353 #if defined(__linux__) || defined(__ANDROID__) | 360 #if defined(__linux__) || defined(__ANDROID__) |
| 354 #if V8_HOST_ARCH_IA32 | 361 #if V8_HOST_ARCH_IA32 |
| 355 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 362 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
| 356 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 363 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
| 357 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 364 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 SamplerThread::RemoveActiveSampler(this); | 710 SamplerThread::RemoveActiveSampler(this); |
| 704 SetActive(false); | 711 SetActive(false); |
| 705 } | 712 } |
| 706 | 713 |
| 707 void Sampler::SampleStack(TickSample* sample) { | 714 void Sampler::SampleStack(TickSample* sample) { |
| 708 sample->Trace(isolate_); | 715 sample->Trace(isolate_); |
| 709 if (++samples_taken_ < 0) samples_taken_ = 0; | 716 if (++samples_taken_ < 0) samples_taken_ = 0; |
| 710 } | 717 } |
| 711 | 718 |
| 712 } } // namespace v8::internal | 719 } } // namespace v8::internal |
| OLD | NEW |