OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/profiler/tick-sample.h" | 5 #include "src/profiler/tick-sample.h" |
6 | 6 |
7 #include "include/v8-profiler.h" | 7 #include "include/v8-profiler.h" |
8 #include "src/frames-inl.h" | 8 #include "src/frames-inl.h" |
9 #include "src/msan.h" | 9 #include "src/msan.h" |
10 #include "src/simulator.h" | 10 #include "src/simulator.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 namespace { | 80 namespace { |
81 | 81 |
82 #if defined(USE_SIMULATOR) | 82 #if defined(USE_SIMULATOR) |
83 class SimulatorHelper { | 83 class SimulatorHelper { |
84 public: | 84 public: |
85 // Returns true if register values were successfully retrieved | 85 // Returns true if register values were successfully retrieved |
86 // from the simulator, otherwise returns false. | 86 // from the simulator, otherwise returns false. |
87 static bool FillRegisters(Isolate* isolate, v8::RegisterState* state); | 87 static bool FillRegisters(Isolate* isolate, v8::RegisterState* state); |
88 }; | 88 }; |
89 | 89 |
90 bool SimulatorHelper::FillRegisters(Isolate* isolate, | 90 bool SimulatorHelper::FillRegisters(Isolate* isolate, RegisterState* state) { |
91 v8::RegisterState* state) { | |
92 Simulator* simulator = isolate->thread_local_top()->simulator_; | 91 Simulator* simulator = isolate->thread_local_top()->simulator_; |
93 // Check if there is active simulator. | 92 // Check if there is active simulator. |
94 if (simulator == NULL) return false; | 93 if (simulator == nullptr) return false; |
95 #if V8_TARGET_ARCH_ARM | 94 #if V8_TARGET_ARCH_ARM |
96 if (!simulator->has_bad_pc()) { | 95 if (simulator->has_bad_pc()) return false; |
97 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | 96 state->pc = reinterpret_cast<void*>(simulator->get_pc()); |
98 } | 97 state->sp = reinterpret_cast<void*>(simulator->get_register(Simulator::sp)); |
99 state->sp = reinterpret_cast<Address>(simulator->get_register(Simulator::sp)); | 98 state->fp = reinterpret_cast<void*>(simulator->get_register(Simulator::r11)); |
100 state->fp = | |
101 reinterpret_cast<Address>(simulator->get_register(Simulator::r11)); | |
102 #elif V8_TARGET_ARCH_ARM64 | 99 #elif V8_TARGET_ARCH_ARM64 |
103 state->pc = reinterpret_cast<Address>(simulator->pc()); | 100 state->pc = reinterpret_cast<void*>(simulator->pc()); |
104 state->sp = reinterpret_cast<Address>(simulator->sp()); | 101 state->sp = reinterpret_cast<void*>(simulator->sp()); |
105 state->fp = reinterpret_cast<Address>(simulator->fp()); | 102 state->fp = reinterpret_cast<void*>(simulator->fp()); |
106 #elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 103 #elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
107 if (!simulator->has_bad_pc()) { | 104 if (simulator->has_bad_pc()) return false; |
108 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | 105 state->pc = reinterpret_cast<void*>(simulator->get_pc()); |
109 } | 106 state->sp = reinterpret_cast<void*>(simulator->get_register(Simulator::sp)); |
110 state->sp = reinterpret_cast<Address>(simulator->get_register(Simulator::sp)); | 107 state->fp = reinterpret_cast<void*>(simulator->get_register(Simulator::fp)); |
111 state->fp = reinterpret_cast<Address>(simulator->get_register(Simulator::fp)); | |
112 #elif V8_TARGET_ARCH_PPC | 108 #elif V8_TARGET_ARCH_PPC |
113 if (!simulator->has_bad_pc()) { | 109 if (simulator->has_bad_pc()) return false; |
114 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | 110 state->pc = reinterpret_cast<void*>(simulator->get_pc()); |
115 } | 111 state->sp = reinterpret_cast<void*>(simulator->get_register(Simulator::sp)); |
116 state->sp = reinterpret_cast<Address>(simulator->get_register(Simulator::sp)); | 112 state->fp = reinterpret_cast<void*>(simulator->get_register(Simulator::fp)); |
117 state->fp = reinterpret_cast<Address>(simulator->get_register(Simulator::fp)); | |
118 #elif V8_TARGET_ARCH_S390 | 113 #elif V8_TARGET_ARCH_S390 |
119 if (!simulator->has_bad_pc()) { | 114 if (simulator->has_bad_pc()) return false; |
120 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | 115 state->pc = reinterpret_cast<void*>(simulator->get_pc()); |
121 } | 116 state->sp = reinterpret_cast<void*>(simulator->get_register(Simulator::sp)); |
122 state->sp = reinterpret_cast<Address>(simulator->get_register(Simulator::sp)); | 117 state->fp = reinterpret_cast<void*>(simulator->get_register(Simulator::fp)); |
123 state->fp = reinterpret_cast<Address>(simulator->get_register(Simulator::fp)); | |
124 #endif | 118 #endif |
125 if (state->sp == 0 || state->fp == 0) { | 119 if (state->sp == 0 || state->fp == 0) { |
126 // It possible that the simulator is interrupted while it is updating | 120 // It possible that the simulator is interrupted while it is updating |
127 // the sp or fp register. ARM64 simulator does this in two steps: | 121 // the sp or fp register. ARM64 simulator does this in two steps: |
128 // first setting it to zero and then setting it to the new value. | 122 // first setting it to zero and then setting it to the new value. |
129 // Bailout if sp/fp doesn't contain the new value. | 123 // Bailout if sp/fp doesn't contain the new value. |
130 // | 124 // |
131 // FIXME: The above doesn't really solve the issue. | 125 // TODO(alph): The above doesn't really solve the issue. |
132 // If a 64-bit target is executed on a 32-bit host even the final | 126 // If a 64-bit target is executed on a 32-bit host even the final |
133 // write is non-atomic, so it might obtain a half of the result. | 127 // write is non-atomic, so it might obtain a half of the result. |
134 // Moreover as long as the register set code uses memcpy (as of now), | 128 // Moreover as long as the register set code uses memcpy (as of now), |
135 // it is not guaranteed to be atomic even when both host and target | 129 // it is not guaranteed to be atomic even when both host and target |
136 // are of same bitness. | 130 // are of same bitness. |
137 return false; | 131 return false; |
138 } | 132 } |
139 return true; | 133 return true; |
140 } | 134 } |
141 #endif // USE_SIMULATOR | 135 #endif // USE_SIMULATOR |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 RecordCEntryFrame record_c_entry_frame, | 241 RecordCEntryFrame record_c_entry_frame, |
248 bool update_stats) { | 242 bool update_stats) { |
249 v8::TickSample::Init(reinterpret_cast<v8::Isolate*>(isolate), state, | 243 v8::TickSample::Init(reinterpret_cast<v8::Isolate*>(isolate), state, |
250 record_c_entry_frame, update_stats); | 244 record_c_entry_frame, update_stats); |
251 if (pc == nullptr) return; | 245 if (pc == nullptr) return; |
252 timestamp = base::TimeTicks::HighResolutionNow(); | 246 timestamp = base::TimeTicks::HighResolutionNow(); |
253 } | 247 } |
254 | 248 |
255 } // namespace internal | 249 } // namespace internal |
256 } // namespace v8 | 250 } // namespace v8 |
OLD | NEW |