Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 #include "src/json-parser.h" | 33 #include "src/json-parser.h" |
| 34 #include "src/messages.h" | 34 #include "src/messages.h" |
| 35 #include "src/natives.h" | 35 #include "src/natives.h" |
| 36 #include "src/parser.h" | 36 #include "src/parser.h" |
| 37 #include "src/profile-generator-inl.h" | 37 #include "src/profile-generator-inl.h" |
| 38 #include "src/property.h" | 38 #include "src/property.h" |
| 39 #include "src/property-details.h" | 39 #include "src/property-details.h" |
| 40 #include "src/prototype.h" | 40 #include "src/prototype.h" |
| 41 #include "src/runtime.h" | 41 #include "src/runtime.h" |
| 42 #include "src/runtime-profiler.h" | 42 #include "src/runtime-profiler.h" |
| 43 #include "src/sampler.h" | |
| 43 #include "src/scanner-character-streams.h" | 44 #include "src/scanner-character-streams.h" |
| 44 #include "src/simulator.h" | 45 #include "src/simulator.h" |
| 45 #include "src/snapshot.h" | 46 #include "src/snapshot.h" |
| 46 #include "src/unicode-inl.h" | 47 #include "src/unicode-inl.h" |
| 47 #include "src/v8threads.h" | 48 #include "src/v8threads.h" |
| 48 #include "src/version.h" | 49 #include "src/version.h" |
| 49 #include "src/vm-state-inl.h" | 50 #include "src/vm-state-inl.h" |
| 50 | 51 |
| 51 | 52 |
| 52 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 53 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
| (...skipping 6565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6618 } | 6619 } |
| 6619 | 6620 |
| 6620 | 6621 |
| 6621 void V8::CancelTerminateExecution(Isolate* isolate) { | 6622 void V8::CancelTerminateExecution(Isolate* isolate) { |
| 6622 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6623 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6623 i_isolate->stack_guard()->ClearTerminateExecution(); | 6624 i_isolate->stack_guard()->ClearTerminateExecution(); |
| 6624 i_isolate->CancelTerminateExecution(); | 6625 i_isolate->CancelTerminateExecution(); |
| 6625 } | 6626 } |
| 6626 | 6627 |
| 6627 | 6628 |
| 6629 RegisterState::RegisterState(const context_t& context) { | |
| 6630 #if V8_OS_POSIX && !V8_OS_CYGWIN | |
|
yurys
2014/09/19 08:08:12
One of the goals of having sampler API is to event
| |
| 6631 #if !V8_OS_OPENBSD | |
| 6632 const mcontext_t& mcontext = context.uc_mcontext; | |
| 6633 #endif | |
| 6634 #if V8_OS_LINUX | |
| 6635 #if V8_HOST_ARCH_IA32 | |
| 6636 pc = reinterpret_cast<void*>(mcontext.gregs[REG_EIP]); | |
| 6637 sp = reinterpret_cast<void*>(mcontext.gregs[REG_ESP]); | |
| 6638 fp = reinterpret_cast<void*>(mcontext.gregs[REG_EBP]); | |
| 6639 #elif V8_HOST_ARCH_X64 | |
| 6640 pc = reinterpret_cast<void*>(mcontext.gregs[REG_RIP]); | |
| 6641 sp = reinterpret_cast<void*>(mcontext.gregs[REG_RSP]); | |
| 6642 fp = reinterpret_cast<void*>(mcontext.gregs[REG_RBP]); | |
| 6643 #elif V8_HOST_ARCH_ARM | |
| 6644 #if defined(__GLIBC__) && !defined(__UCLIBC__) && \ | |
| 6645 (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | |
| 6646 // Old GLibc ARM versions used a gregs[] array to access the register | |
| 6647 // values from mcontext_t. | |
| 6648 pc = reinterpret_cast<void*>(mcontext.gregs[R15]); | |
| 6649 sp = reinterpret_cast<void*>(mcontext.gregs[R13]); | |
| 6650 fp = reinterpret_cast<void*>(mcontext.gregs[R11]); | |
| 6651 #else | |
| 6652 pc = reinterpret_cast<void*>(mcontext.arm_pc); | |
| 6653 sp = reinterpret_cast<void*>(mcontext.arm_sp); | |
| 6654 fp = reinterpret_cast<void*>(mcontext.arm_fp); | |
| 6655 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && | |
| 6656 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | |
| 6657 #elif V8_HOST_ARCH_ARM64 | |
| 6658 pc = reinterpret_cast<void*>(mcontext.pc); | |
| 6659 sp = reinterpret_cast<void*>(mcontext.sp); | |
| 6660 // FP is an alias for x29. | |
| 6661 fp = reinterpret_cast<void*>(mcontext.regs[29]); | |
| 6662 #elif V8_HOST_ARCH_MIPS | |
| 6663 pc = reinterpret_cast<void*>(mcontext.pc); | |
| 6664 sp = reinterpret_cast<void*>(mcontext.gregs[29]); | |
| 6665 fp = reinterpret_cast<void*>(mcontext.gregs[30]); | |
| 6666 #elif V8_HOST_ARCH_MIPS64 | |
| 6667 pc = reinterpret_cast<void*>(mcontext.pc); | |
| 6668 sp = reinterpret_cast<void*>(mcontext.gregs[29]); | |
| 6669 fp = reinterpret_cast<void*>(mcontext.gregs[30]); | |
| 6670 #endif // V8_HOST_ARCH_* | |
| 6671 #elif V8_OS_MACOSX | |
| 6672 #if V8_HOST_ARCH_X64 | |
| 6673 #if __DARWIN_UNIX03 | |
| 6674 pc = reinterpret_cast<void*>(mcontext->__ss.__rip); | |
| 6675 sp = reinterpret_cast<void*>(mcontext->__ss.__rsp); | |
| 6676 fp = reinterpret_cast<void*>(mcontext->__ss.__rbp); | |
| 6677 #else // !__DARWIN_UNIX03 | |
| 6678 pc = reinterpret_cast<void*>(mcontext->ss.rip); | |
| 6679 sp = reinterpret_cast<void*>(mcontext->ss.rsp); | |
| 6680 fp = reinterpret_cast<void*>(mcontext->ss.rbp); | |
| 6681 #endif // __DARWIN_UNIX03 | |
| 6682 #elif V8_HOST_ARCH_IA32 | |
| 6683 #if __DARWIN_UNIX03 | |
| 6684 pc = reinterpret_cast<void*>(mcontext->__ss.__eip); | |
| 6685 sp = reinterpret_cast<void*>(mcontext->__ss.__esp); | |
| 6686 fp = reinterpret_cast<void*>(mcontext->__ss.__ebp); | |
| 6687 #else // !__DARWIN_UNIX03 | |
| 6688 pc = reinterpret_cast<void*>(mcontext->ss.eip); | |
| 6689 sp = reinterpret_cast<void*>(mcontext->ss.esp); | |
| 6690 fp = reinterpret_cast<void*>(mcontext->ss.ebp); | |
| 6691 #endif // __DARWIN_UNIX03 | |
| 6692 #endif // V8_HOST_ARCH_IA32 | |
| 6693 #elif V8_OS_FREEBSD | |
| 6694 #if V8_HOST_ARCH_IA32 | |
| 6695 pc = reinterpret_cast<void*>(mcontext.mc_eip); | |
| 6696 sp = reinterpret_cast<void*>(mcontext.mc_esp); | |
| 6697 fp = reinterpret_cast<void*>(mcontext.mc_ebp); | |
| 6698 #elif V8_HOST_ARCH_X64 | |
| 6699 pc = reinterpret_cast<void*>(mcontext.mc_rip); | |
| 6700 sp = reinterpret_cast<void*>(mcontext.mc_rsp); | |
| 6701 fp = reinterpret_cast<void*>(mcontext.mc_rbp); | |
| 6702 #elif V8_HOST_ARCH_ARM | |
| 6703 pc = reinterpret_cast<void*>(mcontext.mc_r15); | |
| 6704 sp = reinterpret_cast<void*>(mcontext.mc_r13); | |
| 6705 fp = reinterpret_cast<void*>(mcontext.mc_r11); | |
| 6706 #endif // V8_HOST_ARCH_* | |
| 6707 #elif V8_OS_NETBSD | |
| 6708 #if V8_HOST_ARCH_IA32 | |
| 6709 pc = reinterpret_cast<void*>(mcontext.__gregs[_REG_EIP]); | |
| 6710 sp = reinterpret_cast<void*>(mcontext.__gregs[_REG_ESP]); | |
| 6711 fp = reinterpret_cast<void*>(mcontext.__gregs[_REG_EBP]); | |
| 6712 #elif V8_HOST_ARCH_X64 | |
| 6713 pc = reinterpret_cast<void*>(mcontext.__gregs[_REG_RIP]); | |
| 6714 sp = reinterpret_cast<void*>(mcontext.__gregs[_REG_RSP]); | |
| 6715 fp = reinterpret_cast<void*>(mcontext.__gregs[_REG_RBP]); | |
| 6716 #endif // V8_HOST_ARCH_* | |
| 6717 #elif V8_OS_OPENBSD | |
| 6718 #if V8_HOST_ARCH_IA32 | |
| 6719 pc = reinterpret_cast<void*>(ucontext->sc_eip); | |
| 6720 sp = reinterpret_cast<void*>(ucontext->sc_esp); | |
| 6721 fp = reinterpret_cast<void*>(ucontext->sc_ebp); | |
| 6722 #elif V8_HOST_ARCH_X64 | |
| 6723 pc = reinterpret_cast<void*>(ucontext->sc_rip); | |
| 6724 sp = reinterpret_cast<void*>(ucontext->sc_rsp); | |
| 6725 fp = reinterpret_cast<void*>(ucontext->sc_rbp); | |
| 6726 #endif // V8_HOST_ARCH_* | |
| 6727 #elif V8_OS_SOLARIS | |
| 6728 pc = reinterpret_cast<void*>(mcontext.gregs[REG_PC]); | |
| 6729 sp = reinterpret_cast<void*>(mcontext.gregs[REG_SP]); | |
| 6730 fp = reinterpret_cast<void*>(mcontext.gregs[REG_FP]); | |
| 6731 #elif V8_OS_QNX | |
| 6732 #if V8_HOST_ARCH_IA32 | |
| 6733 pc = reinterpret_cast<void*>(mcontext.cpu.eip); | |
| 6734 sp = reinterpret_cast<void*>(mcontext.cpu.esp); | |
| 6735 fp = reinterpret_cast<void*>(mcontext.cpu.ebp); | |
| 6736 #elif V8_HOST_ARCH_ARM | |
| 6737 pc = reinterpret_cast<void*>(mcontext.cpu.gpr[ARM_REG_PC]); | |
| 6738 sp = reinterpret_cast<void*>(mcontext.cpu.gpr[ARM_REG_SP]); | |
| 6739 fp = reinterpret_cast<void*>(mcontext.cpu.gpr[ARM_REG_FP]); | |
| 6740 #endif // V8_HOST_ARCH_* | |
| 6741 #endif // V8_OS_QNX | |
| 6742 | |
| 6743 #elif V8_OS_WIN || V8_OS_CYGWIN | |
| 6744 #if V8_HOST_ARCH_X64 | |
| 6745 pc = reinterpret_cast<void*>(context.Rip); | |
| 6746 sp = reinterpret_cast<void*>(context.Rsp); | |
| 6747 fp = reinterpret_cast<void*>(context.Rbp); | |
| 6748 #else | |
| 6749 pc = reinterpret_cast<void*>(context.Eip); | |
| 6750 sp = reinterpret_cast<void*>(context.Esp); | |
| 6751 fp = reinterpret_cast<void*>(context.Ebp); | |
| 6752 #endif // V8_HOST_ARCH_X64 | |
| 6753 #endif // V8_OS_POSIX && !V8_OS_CYGWIN / V8_OS_WIN || V8_OS_CYGWIN | |
| 6754 } | |
| 6755 | |
| 6756 | |
| 6628 void Isolate::RequestInterrupt(InterruptCallback callback, void* data) { | 6757 void Isolate::RequestInterrupt(InterruptCallback callback, void* data) { |
| 6629 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); | 6758 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); |
| 6630 i_isolate->set_api_interrupt_callback(callback); | 6759 i_isolate->set_api_interrupt_callback(callback); |
| 6631 i_isolate->set_api_interrupt_callback_data(data); | 6760 i_isolate->set_api_interrupt_callback_data(data); |
| 6632 i_isolate->stack_guard()->RequestApiInterrupt(); | 6761 i_isolate->stack_guard()->RequestApiInterrupt(); |
| 6633 } | 6762 } |
| 6634 | 6763 |
| 6635 | 6764 |
| 6636 void Isolate::ClearInterrupt() { | 6765 void Isolate::ClearInterrupt() { |
| 6637 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); | 6766 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6768 i::Heap* heap = isolate->heap(); | 6897 i::Heap* heap = isolate->heap(); |
| 6769 heap_statistics->total_heap_size_ = heap->CommittedMemory(); | 6898 heap_statistics->total_heap_size_ = heap->CommittedMemory(); |
| 6770 heap_statistics->total_heap_size_executable_ = | 6899 heap_statistics->total_heap_size_executable_ = |
| 6771 heap->CommittedMemoryExecutable(); | 6900 heap->CommittedMemoryExecutable(); |
| 6772 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); | 6901 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
| 6773 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); | 6902 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
| 6774 heap_statistics->heap_size_limit_ = heap->MaxReserved(); | 6903 heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
| 6775 } | 6904 } |
| 6776 | 6905 |
| 6777 | 6906 |
| 6907 void Isolate::GetSample(const RegisterState& state, Sample* sample) { | |
| 6908 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | |
| 6909 i::TickSample tick_sample; | |
| 6910 tick_sample.Init(isolate, state); | |
|
loislo
2014/09/19 08:58:16
can we pass sample into Init method and fill it th
| |
| 6911 sample = new (sample) Sample(&tick_sample.stack[0], | |
| 6912 &tick_sample.stack[tick_sample.frames_count]); | |
| 6913 } | |
| 6914 | |
| 6915 | |
| 6778 void Isolate::SetEventLogger(LogEventCallback that) { | 6916 void Isolate::SetEventLogger(LogEventCallback that) { |
| 6779 // Do not overwrite the event logger if we want to log explicitly. | 6917 // Do not overwrite the event logger if we want to log explicitly. |
| 6780 if (i::FLAG_log_timer_events) return; | 6918 if (i::FLAG_log_timer_events) return; |
| 6781 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6919 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 6782 isolate->set_event_logger(that); | 6920 isolate->set_event_logger(that); |
| 6783 } | 6921 } |
| 6784 | 6922 |
| 6785 | 6923 |
| 6786 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { | 6924 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { |
| 6787 if (callback == NULL) return; | 6925 if (callback == NULL) return; |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7745 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7883 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7746 Address callback_address = | 7884 Address callback_address = |
| 7747 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7885 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7748 VMState<EXTERNAL> state(isolate); | 7886 VMState<EXTERNAL> state(isolate); |
| 7749 ExternalCallbackScope call_scope(isolate, callback_address); | 7887 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7750 callback(info); | 7888 callback(info); |
| 7751 } | 7889 } |
| 7752 | 7890 |
| 7753 | 7891 |
| 7754 } } // namespace v8::internal | 7892 } } // namespace v8::internal |
| OLD | NEW |