OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 7509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7520 | 7520 |
7521 | 7521 |
7522 void Isolate::GetStackSample(const RegisterState& state, void** frames, | 7522 void Isolate::GetStackSample(const RegisterState& state, void** frames, |
7523 size_t frames_limit, SampleInfo* sample_info) { | 7523 size_t frames_limit, SampleInfo* sample_info) { |
7524 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7524 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7525 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame, | 7525 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame, |
7526 frames, frames_limit, sample_info); | 7526 frames, frames_limit, sample_info); |
7527 } | 7527 } |
7528 | 7528 |
7529 | 7529 |
7530 void Isolate::GetStackSample(RegisterState* state, void** frames, | |
alph
2016/04/27 22:29:20
v8 usually do not put that much implementation spe
| |
7531 size_t frames_limit, SampleInfo* sample_info) { | |
7532 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | |
7533 #if defined(USE_SIMULATOR) | |
7534 i::Simulator *simulator = isolate->thread_local_top()->simulator_; | |
7535 if (simulator != NULL) { | |
7536 #if V8_TARGET_ARCH_ARM | |
7537 if (!simulator->has_bad_pc()) { | |
7538 state->pc = reinterpret_cast<void*>(simulator->get_pc()); | |
7539 } | |
7540 state->sp = reinterpret_cast<void*>(simulator->get_register( | |
7541 i::Simulator::sp)); | |
7542 state->fp = reinterpret_cast<void*>(simulator->get_register( | |
7543 i::Simulator::r11)); | |
7544 #elif V8_TARGET_ARCH_ARM64 | |
7545 if (simulator->sp() == 0 || simulator->fp() == 0) { | |
7546 // It's possible that the simulator is interrupted while it is updating | |
7547 // the sp or fp register. ARM64 simulator does this in two steps: | |
7548 // first setting it to zero and then setting it to a new value. | |
7549 // Bailout if sp/fp doesn't contain the new value. | |
7550 // | |
7551 // FIXME: The above doesn't really solve the issue. | |
7552 // If a 64-bit target is executed on a 32-bit host even the final | |
7553 // write is non-atomic, so it might obtain a half of the result. | |
7554 // Moreover as long as the register set code uses memcpy (as of now), | |
7555 // it is not guaranteed to be atomic even when both host and target | |
7556 // are of same bitness. | |
7557 return; | |
7558 } | |
7559 state->pc = reinterpret_cast<void*>(simulator->pc()); | |
7560 state->sp = reinterpret_cast<void*>(simulator->sp()); | |
7561 state->fp = reinterpret_cast<void*>(simulator->fp()); | |
7562 #elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | |
7563 if (!simulator->has_bad_pc()) { | |
7564 state->pc = reinterpret_cast<void*>(simulator->get_pc()); | |
7565 } | |
7566 state->sp = reinterpret_cast<void*>(simulator->get_register( | |
7567 i::Simulator::sp)); | |
7568 state->fp = reinterpret_cast<void*>(simulator->get_register( | |
7569 i::Simulator::fp)); | |
7570 #elif V8_TARGET_ARCH_PPC | |
7571 if (!simulator->has_bad_pc()) { | |
7572 state->pc = reinterpret_cast<void*>(simulator->get_pc()); | |
7573 } | |
7574 state->sp = | |
7575 reinterpret_cast<void*>(simulator->get_register(i::Simulator::sp)); | |
7576 state->fp = | |
7577 reinterpret_cast<void*>(simulator->get_register(i::Simulator::fp)); | |
7578 #elif V8_TARGET_ARCH_S390 | |
7579 if (!simulator->has_bad_pc()) { | |
7580 state->pc = reinterpret_cast<void*>(simulator->get_pc()); | |
7581 } | |
7582 state->sp = | |
7583 reinterpret_cast<void*>(simulator->get_register(i::Simulator::sp)); | |
7584 state->fp = | |
7585 reinterpret_cast<void*>(simulator->get_register(i::Simulator::fp)); | |
7586 #endif | |
7587 } | |
7588 #endif // USE_SIMULATOR | |
7589 i::TickSample::GetStackSample(isolate, *state, | |
7590 i::TickSample::kSkipCEntryFrame, | |
7591 frames, frames_limit, sample_info); | |
7592 } | |
7593 | |
7594 | |
7530 void Isolate::SetEventLogger(LogEventCallback that) { | 7595 void Isolate::SetEventLogger(LogEventCallback that) { |
7531 // Do not overwrite the event logger if we want to log explicitly. | 7596 // Do not overwrite the event logger if we want to log explicitly. |
7532 if (i::FLAG_log_internal_timer_events) return; | 7597 if (i::FLAG_log_internal_timer_events) return; |
7533 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7598 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7534 isolate->set_event_logger(that); | 7599 isolate->set_event_logger(that); |
7535 } | 7600 } |
7536 | 7601 |
7537 | 7602 |
7538 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { | 7603 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) { |
7539 if (callback == NULL) return; | 7604 if (callback == NULL) return; |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8838 Address callback_address = | 8903 Address callback_address = |
8839 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8904 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8840 VMState<EXTERNAL> state(isolate); | 8905 VMState<EXTERNAL> state(isolate); |
8841 ExternalCallbackScope call_scope(isolate, callback_address); | 8906 ExternalCallbackScope call_scope(isolate, callback_address); |
8842 callback(info); | 8907 callback(info); |
8843 } | 8908 } |
8844 | 8909 |
8845 | 8910 |
8846 } // namespace internal | 8911 } // namespace internal |
8847 } // namespace v8 | 8912 } // namespace v8 |
OLD | NEW |