yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 30 | #include "ast.h" |
| 31 | #include "deoptimizer.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 32 | #include "frames-inl.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 33 | #include "full-codegen.h" |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 34 | #include "lazy-instance.h" |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 35 | #include "mark-compact.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 36 | #include "safepoint-table.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | #include "scopeinfo.h" |
| 38 | #include "string-stream.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 39 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 40 | #include "allocation-inl.h" |
| 41 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 42 | namespace v8 { |
| 43 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 44 | |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 45 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 46 | ReturnAddressLocationResolver |
| 47 | StackFrame::return_address_location_resolver_ = NULL; |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 48 | |
| 49 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 50 | // Iterator that supports traversing the stack handlers of a |
| 51 | // particular frame. Needs to know the top of the handler chain. |
| 52 | class StackHandlerIterator BASE_EMBEDDED { |
| 53 | public: |
| 54 | StackHandlerIterator(const StackFrame* frame, StackHandler* handler) |
| 55 | : limit_(frame->fp()), handler_(handler) { |
| 56 | // Make sure the handler has already been unwound to this frame. |
| 57 | ASSERT(frame->sp() <= handler->address()); |
| 58 | } |
| 59 | |
| 60 | StackHandler* handler() const { return handler_; } |
| 61 | |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 62 | bool done() { |
| 63 | return handler_ == NULL || handler_->address() > limit_; |
| 64 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 65 | void Advance() { |
| 66 | ASSERT(!done()); |
| 67 | handler_ = handler_->next(); |
| 68 | } |
| 69 | |
| 70 | private: |
| 71 | const Address limit_; |
| 72 | StackHandler* handler_; |
| 73 | }; |
| 74 | |
| 75 | |
| 76 | // ------------------------------------------------------------------------- |
| 77 | |
| 78 | |
| 79 | #define INITIALIZE_SINGLETON(type, field) field##_(this), |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 80 | StackFrameIteratorBase::StackFrameIteratorBase(Isolate* isolate, |
| 81 | bool can_access_heap_objects) |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 82 | : isolate_(isolate), |
| 83 | STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON) |
| 84 | frame_(NULL), handler_(NULL), |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 85 | can_access_heap_objects_(can_access_heap_objects) { |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 86 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 87 | #undef INITIALIZE_SINGLETON |
| 88 | |
| 89 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 90 | StackFrameIterator::StackFrameIterator(Isolate* isolate) |
| 91 | : StackFrameIteratorBase(isolate, true) { |
| 92 | Reset(isolate->thread_local_top()); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | StackFrameIterator::StackFrameIterator(Isolate* isolate, ThreadLocalTop* t) |
| 97 | : StackFrameIteratorBase(isolate, true) { |
| 98 | Reset(t); |
| 99 | } |
| 100 | |
| 101 | |
| 102 | void StackFrameIterator::Advance() { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 103 | ASSERT(!done()); |
| 104 | // Compute the state of the calling frame before restoring |
| 105 | // callee-saved registers and unwinding handlers. This allows the |
| 106 | // frame code that computes the caller state to access the top |
| 107 | // handler and the value of any callee-saved register if needed. |
| 108 | StackFrame::State state; |
| 109 | StackFrame::Type type = frame_->GetCallerState(&state); |
| 110 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 111 | // Unwind handlers corresponding to the current frame. |
| 112 | StackHandlerIterator it(frame_, handler_); |
| 113 | while (!it.done()) it.Advance(); |
| 114 | handler_ = it.handler(); |
| 115 | |
| 116 | // Advance to the calling frame. |
| 117 | frame_ = SingletonFor(type, &state); |
| 118 | |
| 119 | // When we're done iterating over the stack frames, the handler |
| 120 | // chain must have been completely unwound. |
| 121 | ASSERT(!done() || handler_ == NULL); |
| 122 | } |
| 123 | |
| 124 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 125 | void StackFrameIterator::Reset(ThreadLocalTop* top) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 126 | StackFrame::State state; |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 127 | StackFrame::Type type = ExitFrame::GetStateForFramePointer( |
| 128 | Isolate::c_entry_fp(top), &state); |
| 129 | handler_ = StackHandler::FromAddress(Isolate::handler(top)); |
danno@chromium.org | d43f645 | 2013-04-30 16:42:35 +0000 | [diff] [blame] | 130 | if (SingletonFor(type) == NULL) return; |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 131 | frame_ = SingletonFor(type, &state); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 135 | StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 136 | StackFrame::State* state) { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 137 | if (type == StackFrame::NONE) return NULL; |
| 138 | StackFrame* result = SingletonFor(type); |
| 139 | ASSERT(result != NULL); |
| 140 | result->state_ = *state; |
| 141 | return result; |
| 142 | } |
| 143 | |
| 144 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 145 | StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 146 | #define FRAME_TYPE_CASE(type, field) \ |
| 147 | case StackFrame::type: result = &field##_; break; |
| 148 | |
| 149 | StackFrame* result = NULL; |
| 150 | switch (type) { |
| 151 | case StackFrame::NONE: return NULL; |
| 152 | STACK_FRAME_TYPE_LIST(FRAME_TYPE_CASE) |
| 153 | default: break; |
| 154 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 155 | return result; |
| 156 | |
| 157 | #undef FRAME_TYPE_CASE |
| 158 | } |
| 159 | |
| 160 | |
| 161 | // ------------------------------------------------------------------------- |
| 162 | |
| 163 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 164 | JavaScriptFrameIterator::JavaScriptFrameIterator( |
| 165 | Isolate* isolate, StackFrame::Id id) |
| 166 | : iterator_(isolate) { |
| 167 | while (!done()) { |
| 168 | Advance(); |
| 169 | if (frame()->id() == id) return; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | |
| 174 | void JavaScriptFrameIterator::Advance() { |
| 175 | do { |
| 176 | iterator_.Advance(); |
| 177 | } while (!iterator_.done() && !iterator_.frame()->is_java_script()); |
| 178 | } |
| 179 | |
| 180 | |
| 181 | void JavaScriptFrameIterator::AdvanceToArgumentsFrame() { |
| 182 | if (!frame()->has_adapted_arguments()) return; |
| 183 | iterator_.Advance(); |
| 184 | ASSERT(iterator_.frame()->is_arguments_adaptor()); |
| 185 | } |
| 186 | |
| 187 | |
| 188 | // ------------------------------------------------------------------------- |
| 189 | |
| 190 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 191 | StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate) |
| 192 | : JavaScriptFrameIterator(isolate) { |
| 193 | if (!done() && !IsValidFrame()) Advance(); |
| 194 | } |
| 195 | |
| 196 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 197 | void StackTraceFrameIterator::Advance() { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 198 | while (true) { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 199 | JavaScriptFrameIterator::Advance(); |
| 200 | if (done()) return; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 201 | if (IsValidFrame()) return; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 205 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 206 | bool StackTraceFrameIterator::IsValidFrame() { |
| 207 | if (!frame()->function()->IsJSFunction()) return false; |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 208 | Object* script = frame()->function()->shared()->script(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 209 | // Don't show functions from native scripts to user. |
| 210 | return (script->IsScript() && |
| 211 | Script::TYPE_NATIVE != Script::cast(script)->type()->value()); |
| 212 | } |
| 213 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 214 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 215 | // ------------------------------------------------------------------------- |
| 216 | |
| 217 | |
| 218 | SafeStackFrameIterator::SafeStackFrameIterator( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 219 | Isolate* isolate, |
machenbach@chromium.org | c1789ee | 2013-07-05 07:09:57 +0000 | [diff] [blame] | 220 | Address fp, Address sp, Address js_entry_sp) |
| 221 | : StackFrameIteratorBase(isolate, false), |
| 222 | low_bound_(sp), |
| 223 | high_bound_(js_entry_sp), |
| 224 | top_frame_type_(StackFrame::NONE) { |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 225 | StackFrame::State state; |
| 226 | StackFrame::Type type; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 227 | ThreadLocalTop* top = isolate->thread_local_top(); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 228 | if (IsValidTop(top)) { |
| 229 | type = ExitFrame::GetStateForFramePointer(Isolate::c_entry_fp(top), &state); |
machenbach@chromium.org | c1789ee | 2013-07-05 07:09:57 +0000 | [diff] [blame] | 230 | top_frame_type_ = type; |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 231 | } else if (IsValidStackAddress(fp)) { |
| 232 | ASSERT(fp != NULL); |
| 233 | state.fp = fp; |
| 234 | state.sp = sp; |
| 235 | state.pc_address = StackFrame::ResolveReturnAddressLocation( |
| 236 | reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp))); |
machenbach@chromium.org | c1789ee | 2013-07-05 07:09:57 +0000 | [diff] [blame] | 237 | // StackFrame::ComputeType will read both kContextOffset and kMarkerOffset, |
| 238 | // we check only that kMarkerOffset is within the stack bounds and do |
| 239 | // compile time check that kContextOffset slot is pushed on the stack before |
| 240 | // kMarkerOffset. |
| 241 | STATIC_ASSERT(StandardFrameConstants::kMarkerOffset < |
| 242 | StandardFrameConstants::kContextOffset); |
| 243 | Address frame_marker = fp + StandardFrameConstants::kMarkerOffset; |
| 244 | if (IsValidStackAddress(frame_marker)) { |
| 245 | type = StackFrame::ComputeType(this, &state); |
| 246 | top_frame_type_ = type; |
| 247 | } else { |
| 248 | // Mark the frame as JAVA_SCRIPT if we cannot determine its type. |
| 249 | // The frame anyways will be skipped. |
| 250 | type = StackFrame::JAVA_SCRIPT; |
| 251 | // Top frame is incomplete so we cannot reliably determine its type. |
| 252 | top_frame_type_ = StackFrame::NONE; |
| 253 | } |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 254 | } else { |
| 255 | return; |
| 256 | } |
| 257 | if (SingletonFor(type) == NULL) return; |
| 258 | frame_ = SingletonFor(type, &state); |
| 259 | |
| 260 | if (!done()) Advance(); |
| 261 | } |
| 262 | |
| 263 | |
| 264 | bool SafeStackFrameIterator::IsValidTop(ThreadLocalTop* top) const { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 265 | Address fp = Isolate::c_entry_fp(top); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 266 | if (!IsValidExitFrame(fp)) return false; |
| 267 | // There should be at least one JS_ENTRY stack handler. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 268 | return Isolate::handler(top) != NULL; |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 272 | void SafeStackFrameIterator::AdvanceOneFrame() { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 273 | ASSERT(!done()); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 274 | StackFrame* last_frame = frame_; |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 275 | Address last_sp = last_frame->sp(), last_fp = last_frame->fp(); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 276 | // Before advancing to the next stack frame, perform pointer validity tests. |
| 277 | if (!IsValidFrame(last_frame) || !IsValidCaller(last_frame)) { |
| 278 | frame_ = NULL; |
| 279 | return; |
| 280 | } |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 281 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 282 | // Advance to the previous frame. |
| 283 | StackFrame::State state; |
| 284 | StackFrame::Type type = frame_->GetCallerState(&state); |
| 285 | frame_ = SingletonFor(type, &state); |
| 286 | if (frame_ == NULL) return; |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 287 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 288 | // Check that we have actually moved to the previous frame in the stack. |
| 289 | if (frame_->sp() < last_sp || frame_->fp() < last_fp) { |
| 290 | frame_ = NULL; |
| 291 | } |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 295 | bool SafeStackFrameIterator::IsValidFrame(StackFrame* frame) const { |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 296 | return IsValidStackAddress(frame->sp()) && IsValidStackAddress(frame->fp()); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | |
| 300 | bool SafeStackFrameIterator::IsValidCaller(StackFrame* frame) { |
| 301 | StackFrame::State state; |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 302 | if (frame->is_entry() || frame->is_entry_construct()) { |
| 303 | // See EntryFrame::GetCallerState. It computes the caller FP address |
| 304 | // and calls ExitFrame::GetStateForFramePointer on it. We need to be |
| 305 | // sure that caller FP address is valid. |
| 306 | Address caller_fp = Memory::Address_at( |
| 307 | frame->fp() + EntryFrameConstants::kCallerFPOffset); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 308 | if (!IsValidExitFrame(caller_fp)) return false; |
ager@chromium.org | 41826e7 | 2009-03-30 13:30:57 +0000 | [diff] [blame] | 309 | } else if (frame->is_arguments_adaptor()) { |
| 310 | // See ArgumentsAdaptorFrame::GetCallerStackPointer. It assumes that |
| 311 | // the number of arguments is stored on stack as Smi. We need to check |
| 312 | // that it really an Smi. |
| 313 | Object* number_of_args = reinterpret_cast<ArgumentsAdaptorFrame*>(frame)-> |
| 314 | GetExpression(0); |
| 315 | if (!number_of_args->IsSmi()) { |
| 316 | return false; |
| 317 | } |
| 318 | } |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 319 | frame->ComputeCallerState(&state); |
| 320 | return IsValidStackAddress(state.sp) && IsValidStackAddress(state.fp) && |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 321 | SingletonFor(frame->GetCallerState(&state)) != NULL; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 325 | bool SafeStackFrameIterator::IsValidExitFrame(Address fp) const { |
| 326 | if (!IsValidStackAddress(fp)) return false; |
| 327 | Address sp = ExitFrame::ComputeStackPointer(fp); |
| 328 | if (!IsValidStackAddress(sp)) return false; |
| 329 | StackFrame::State state; |
| 330 | ExitFrame::FillState(fp, sp, &state); |
| 331 | if (!IsValidStackAddress(reinterpret_cast<Address>(state.pc_address))) { |
| 332 | return false; |
| 333 | } |
| 334 | return *state.pc_address != NULL; |
| 335 | } |
| 336 | |
| 337 | |
| 338 | void SafeStackFrameIterator::Advance() { |
| 339 | while (true) { |
| 340 | AdvanceOneFrame(); |
| 341 | if (done()) return; |
| 342 | if (frame_->is_java_script()) return; |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 343 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 347 | // ------------------------------------------------------------------------- |
| 348 | |
| 349 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 350 | Code* StackFrame::GetSafepointData(Isolate* isolate, |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 351 | Address inner_pointer, |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 352 | SafepointEntry* safepoint_entry, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 353 | unsigned* stack_slots) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 354 | InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry = |
| 355 | isolate->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 356 | if (!entry->safepoint_entry.is_valid()) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 357 | entry->safepoint_entry = entry->code->GetSafepointEntry(inner_pointer); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 358 | ASSERT(entry->safepoint_entry.is_valid()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 359 | } else { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 360 | ASSERT(entry->safepoint_entry.Equals( |
| 361 | entry->code->GetSafepointEntry(inner_pointer))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | // Fill in the results and return the code. |
| 365 | Code* code = entry->code; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 366 | *safepoint_entry = entry->safepoint_entry; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 367 | *stack_slots = code->stack_slots(); |
| 368 | return code; |
| 369 | } |
| 370 | |
| 371 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 372 | bool StackFrame::HasHandler() const { |
| 373 | StackHandlerIterator it(this, top_handler()); |
| 374 | return !it.done(); |
| 375 | } |
| 376 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 377 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 378 | #ifdef DEBUG |
| 379 | static bool GcSafeCodeContains(HeapObject* object, Address addr); |
| 380 | #endif |
| 381 | |
| 382 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 383 | void StackFrame::IteratePc(ObjectVisitor* v, |
| 384 | Address* pc_address, |
| 385 | Code* holder) { |
| 386 | Address pc = *pc_address; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 387 | ASSERT(GcSafeCodeContains(holder, pc)); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 388 | unsigned pc_offset = static_cast<unsigned>(pc - holder->instruction_start()); |
| 389 | Object* code = holder; |
| 390 | v->VisitPointer(&code); |
| 391 | if (code != holder) { |
| 392 | holder = reinterpret_cast<Code*>(code); |
| 393 | pc = holder->instruction_start() + pc_offset; |
| 394 | *pc_address = pc; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 395 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 399 | void StackFrame::SetReturnAddressLocationResolver( |
| 400 | ReturnAddressLocationResolver resolver) { |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 401 | ASSERT(return_address_location_resolver_ == NULL); |
| 402 | return_address_location_resolver_ = resolver; |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 406 | StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, |
| 407 | State* state) { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 408 | ASSERT(state->fp != NULL); |
| 409 | if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) { |
| 410 | return ARGUMENTS_ADAPTOR; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 411 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 412 | // The marker and function offsets overlap. If the marker isn't a |
| 413 | // smi then the frame is a JavaScript frame -- and the marker is |
| 414 | // really the function. |
| 415 | const int offset = StandardFrameConstants::kMarkerOffset; |
| 416 | Object* marker = Memory::Object_at(state->fp + offset); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 417 | if (!marker->IsSmi()) { |
| 418 | // If we're using a "safe" stack iterator, we treat optimized |
| 419 | // frames as normal JavaScript frames to avoid having to look |
| 420 | // into the heap to determine the state. This is safe as long |
| 421 | // as nobody tries to GC... |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 422 | if (!iterator->can_access_heap_objects_) return JAVA_SCRIPT; |
| 423 | Code::Kind kind = GetContainingCode(iterator->isolate(), |
| 424 | *(state->pc_address))->kind(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 425 | ASSERT(kind == Code::FUNCTION || kind == Code::OPTIMIZED_FUNCTION); |
| 426 | return (kind == Code::OPTIMIZED_FUNCTION) ? OPTIMIZED : JAVA_SCRIPT; |
| 427 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 428 | return static_cast<StackFrame::Type>(Smi::cast(marker)->value()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 432 | #ifdef DEBUG |
| 433 | bool StackFrame::can_access_heap_objects() const { |
| 434 | return iterator_->can_access_heap_objects_; |
| 435 | } |
| 436 | #endif |
| 437 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 438 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 439 | StackFrame::Type StackFrame::GetCallerState(State* state) const { |
| 440 | ComputeCallerState(state); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 441 | return ComputeType(iterator_, state); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 445 | Address StackFrame::UnpaddedFP() const { |
jkummerow@chromium.org | 93a47f4 | 2013-07-02 14:43:41 +0000 | [diff] [blame] | 446 | #if V8_TARGET_ARCH_IA32 |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 447 | if (!is_optimized()) return fp(); |
| 448 | int32_t alignment_state = Memory::int32_at( |
| 449 | fp() + JavaScriptFrameConstants::kDynamicAlignmentStateOffset); |
| 450 | |
| 451 | return (alignment_state == kAlignmentPaddingPushed) ? |
| 452 | (fp() + kPointerSize) : fp(); |
| 453 | #else |
| 454 | return fp(); |
| 455 | #endif |
| 456 | } |
| 457 | |
| 458 | |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 459 | Code* EntryFrame::unchecked_code() const { |
danno@chromium.org | 72204d5 | 2012-10-31 10:02:10 +0000 | [diff] [blame] | 460 | return HEAP->js_entry_code(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 464 | void EntryFrame::ComputeCallerState(State* state) const { |
| 465 | GetCallerState(state); |
| 466 | } |
| 467 | |
| 468 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 469 | void EntryFrame::SetCallerFp(Address caller_fp) { |
| 470 | const int offset = EntryFrameConstants::kCallerFPOffset; |
| 471 | Memory::Address_at(this->fp() + offset) = caller_fp; |
| 472 | } |
| 473 | |
| 474 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 475 | StackFrame::Type EntryFrame::GetCallerState(State* state) const { |
| 476 | const int offset = EntryFrameConstants::kCallerFPOffset; |
| 477 | Address fp = Memory::Address_at(this->fp() + offset); |
| 478 | return ExitFrame::GetStateForFramePointer(fp, state); |
| 479 | } |
| 480 | |
| 481 | |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 482 | Code* EntryConstructFrame::unchecked_code() const { |
danno@chromium.org | 72204d5 | 2012-10-31 10:02:10 +0000 | [diff] [blame] | 483 | return HEAP->js_construct_entry_code(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 487 | Object*& ExitFrame::code_slot() const { |
| 488 | const int offset = ExitFrameConstants::kCodeOffset; |
| 489 | return Memory::Object_at(fp() + offset); |
| 490 | } |
| 491 | |
| 492 | |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 493 | Code* ExitFrame::unchecked_code() const { |
| 494 | return reinterpret_cast<Code*>(code_slot()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 498 | void ExitFrame::ComputeCallerState(State* state) const { |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 499 | // Set up the caller state. |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 500 | state->sp = caller_sp(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 501 | state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset); |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 502 | state->pc_address = ResolveReturnAddressLocation( |
| 503 | reinterpret_cast<Address*>(fp() + ExitFrameConstants::kCallerPCOffset)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 507 | void ExitFrame::SetCallerFp(Address caller_fp) { |
| 508 | Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp; |
| 509 | } |
| 510 | |
| 511 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 512 | void ExitFrame::Iterate(ObjectVisitor* v) const { |
| 513 | // The arguments are traversed as part of the expression stack of |
| 514 | // the calling frame. |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 515 | IteratePc(v, pc_address(), LookupCode()); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 516 | v->VisitPointer(&code_slot()); |
| 517 | } |
| 518 | |
| 519 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 520 | Address ExitFrame::GetCallerStackPointer() const { |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 521 | return fp() + ExitFrameConstants::kCallerSPDisplacement; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 525 | StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) { |
| 526 | if (fp == 0) return NONE; |
| 527 | Address sp = ComputeStackPointer(fp); |
| 528 | FillState(fp, sp, state); |
| 529 | ASSERT(*state->pc_address != NULL); |
| 530 | return EXIT; |
| 531 | } |
| 532 | |
| 533 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 534 | Address ExitFrame::ComputeStackPointer(Address fp) { |
| 535 | return Memory::Address_at(fp + ExitFrameConstants::kSPOffset); |
| 536 | } |
| 537 | |
| 538 | |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 539 | void ExitFrame::FillState(Address fp, Address sp, State* state) { |
| 540 | state->sp = sp; |
| 541 | state->fp = fp; |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 542 | state->pc_address = ResolveReturnAddressLocation( |
| 543 | reinterpret_cast<Address*>(sp - 1 * kPointerSize)); |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 547 | Address StandardFrame::GetExpressionAddress(int n) const { |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 548 | const int offset = StandardFrameConstants::kExpressionsOffset; |
| 549 | return fp() + offset - n * kPointerSize; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 553 | Object* StandardFrame::GetExpression(Address fp, int index) { |
| 554 | return Memory::Object_at(GetExpressionAddress(fp, index)); |
| 555 | } |
| 556 | |
| 557 | |
| 558 | Address StandardFrame::GetExpressionAddress(Address fp, int n) { |
| 559 | const int offset = StandardFrameConstants::kExpressionsOffset; |
| 560 | return fp + offset - n * kPointerSize; |
| 561 | } |
| 562 | |
| 563 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 564 | int StandardFrame::ComputeExpressionsCount() const { |
| 565 | const int offset = |
| 566 | StandardFrameConstants::kExpressionsOffset + kPointerSize; |
| 567 | Address base = fp() + offset; |
| 568 | Address limit = sp(); |
| 569 | ASSERT(base >= limit); // stack grows downwards |
| 570 | // Include register-allocated locals in number of expressions. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 571 | return static_cast<int>((base - limit) / kPointerSize); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 575 | void StandardFrame::ComputeCallerState(State* state) const { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 576 | state->sp = caller_sp(); |
| 577 | state->fp = caller_fp(); |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 578 | state->pc_address = ResolveReturnAddressLocation( |
| 579 | reinterpret_cast<Address*>(ComputePCAddress(fp()))); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 583 | void StandardFrame::SetCallerFp(Address caller_fp) { |
| 584 | Memory::Address_at(fp() + StandardFrameConstants::kCallerFPOffset) = |
| 585 | caller_fp; |
| 586 | } |
| 587 | |
| 588 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 589 | bool StandardFrame::IsExpressionInsideHandler(int n) const { |
| 590 | Address address = GetExpressionAddress(n); |
| 591 | for (StackHandlerIterator it(this, top_handler()); !it.done(); it.Advance()) { |
| 592 | if (it.handler()->includes(address)) return true; |
| 593 | } |
| 594 | return false; |
| 595 | } |
| 596 | |
| 597 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 598 | void StandardFrame::IterateCompiledFrame(ObjectVisitor* v) const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 599 | // Make sure that we're not doing "safe" stack frame iteration. We cannot |
| 600 | // possibly find pointers in optimized frames in that state. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 601 | ASSERT(can_access_heap_objects()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 602 | |
| 603 | // Compute the safepoint information. |
| 604 | unsigned stack_slots = 0; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 605 | SafepointEntry safepoint_entry; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 606 | Code* code = StackFrame::GetSafepointData( |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 607 | isolate(), pc(), &safepoint_entry, &stack_slots); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 608 | unsigned slot_space = stack_slots * kPointerSize; |
| 609 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 610 | // Visit the outgoing parameters. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 611 | Object** parameters_base = &Memory::Object_at(sp()); |
| 612 | Object** parameters_limit = &Memory::Object_at( |
| 613 | fp() + JavaScriptFrameConstants::kFunctionOffset - slot_space); |
| 614 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 615 | // Visit the parameters that may be on top of the saved registers. |
| 616 | if (safepoint_entry.argument_count() > 0) { |
| 617 | v->VisitPointers(parameters_base, |
| 618 | parameters_base + safepoint_entry.argument_count()); |
| 619 | parameters_base += safepoint_entry.argument_count(); |
| 620 | } |
| 621 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 622 | // Skip saved double registers. |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 623 | if (safepoint_entry.has_doubles()) { |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 624 | // Number of doubles not known at snapshot time. |
| 625 | ASSERT(!Serializer::enabled()); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 626 | parameters_base += DoubleRegister::NumAllocatableRegisters() * |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 627 | kDoubleSize / kPointerSize; |
| 628 | } |
| 629 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 630 | // Visit the registers that contain pointers if any. |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 631 | if (safepoint_entry.HasRegisters()) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 632 | for (int i = kNumSafepointRegisters - 1; i >=0; i--) { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 633 | if (safepoint_entry.HasRegisterAt(i)) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 634 | int reg_stack_index = MacroAssembler::SafepointRegisterStackIndex(i); |
| 635 | v->VisitPointer(parameters_base + reg_stack_index); |
| 636 | } |
| 637 | } |
| 638 | // Skip the words containing the register values. |
| 639 | parameters_base += kNumSafepointRegisters; |
| 640 | } |
| 641 | |
| 642 | // We're done dealing with the register bits. |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 643 | uint8_t* safepoint_bits = safepoint_entry.bits(); |
| 644 | safepoint_bits += kNumSafepointRegisters >> kBitsPerByteLog2; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 645 | |
| 646 | // Visit the rest of the parameters. |
| 647 | v->VisitPointers(parameters_base, parameters_limit); |
| 648 | |
| 649 | // Visit pointer spill slots and locals. |
| 650 | for (unsigned index = 0; index < stack_slots; index++) { |
| 651 | int byte_index = index >> kBitsPerByteLog2; |
| 652 | int bit_index = index & (kBitsPerByte - 1); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 653 | if ((safepoint_bits[byte_index] & (1U << bit_index)) != 0) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 654 | v->VisitPointer(parameters_limit + index); |
| 655 | } |
| 656 | } |
| 657 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 658 | // Visit the return address in the callee and incoming arguments. |
| 659 | IteratePc(v, pc_address(), code); |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 660 | |
| 661 | // Visit the context in stub frame and JavaScript frame. |
| 662 | // Visit the function in JavaScript frame. |
| 663 | Object** fixed_base = &Memory::Object_at( |
| 664 | fp() + StandardFrameConstants::kMarkerOffset); |
| 665 | Object** fixed_limit = &Memory::Object_at(fp()); |
| 666 | v->VisitPointers(fixed_base, fixed_limit); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | |
| 670 | void StubFrame::Iterate(ObjectVisitor* v) const { |
| 671 | IterateCompiledFrame(v); |
| 672 | } |
| 673 | |
| 674 | |
| 675 | Code* StubFrame::unchecked_code() const { |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame^] | 676 | return static_cast<Code*>(isolate()->FindCodeObject(pc())); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | |
| 680 | Address StubFrame::GetCallerStackPointer() const { |
| 681 | return fp() + ExitFrameConstants::kCallerSPDisplacement; |
| 682 | } |
| 683 | |
| 684 | |
| 685 | int StubFrame::GetNumberOfIncomingArguments() const { |
| 686 | return 0; |
| 687 | } |
| 688 | |
| 689 | |
| 690 | void OptimizedFrame::Iterate(ObjectVisitor* v) const { |
| 691 | #ifdef DEBUG |
| 692 | // Make sure that optimized frames do not contain any stack handlers. |
| 693 | StackHandlerIterator it(this, top_handler()); |
| 694 | ASSERT(it.done()); |
| 695 | #endif |
| 696 | |
| 697 | IterateCompiledFrame(v); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 698 | } |
jkummerow@chromium.org | 5323a9c | 2012-12-10 19:00:50 +0000 | [diff] [blame] | 699 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 700 | |
| 701 | void JavaScriptFrame::SetParameterValue(int index, Object* value) const { |
| 702 | Memory::Object_at(GetParameterSlot(index)) = value; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | |
| 706 | bool JavaScriptFrame::IsConstructor() const { |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 707 | Address fp = caller_fp(); |
| 708 | if (has_adapted_arguments()) { |
| 709 | // Skip the arguments adaptor frame and look at the real caller. |
| 710 | fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset); |
| 711 | } |
| 712 | return IsConstructFrame(fp); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 716 | int JavaScriptFrame::GetArgumentsLength() const { |
| 717 | // If there is an arguments adaptor frame get the arguments length from it. |
| 718 | if (has_adapted_arguments()) { |
| 719 | return Smi::cast(GetExpression(caller_fp(), 0))->value(); |
| 720 | } else { |
| 721 | return GetNumberOfIncomingArguments(); |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 726 | Code* JavaScriptFrame::unchecked_code() const { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 727 | return function()->code(); |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 731 | int JavaScriptFrame::GetNumberOfIncomingArguments() const { |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 732 | ASSERT(can_access_heap_objects() && |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 733 | isolate()->heap()->gc_state() == Heap::NOT_IN_GC); |
| 734 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 735 | return function()->shared()->formal_parameter_count(); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 739 | Address JavaScriptFrame::GetCallerStackPointer() const { |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 740 | return fp() + StandardFrameConstants::kCallerSPOffset; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 744 | void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) { |
| 745 | ASSERT(functions->length() == 0); |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 746 | functions->Add(function()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | |
| 750 | void JavaScriptFrame::Summarize(List<FrameSummary>* functions) { |
| 751 | ASSERT(functions->length() == 0); |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 752 | Code* code_pointer = LookupCode(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 753 | int offset = static_cast<int>(pc() - code_pointer->address()); |
| 754 | FrameSummary summary(receiver(), |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 755 | function(), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 756 | code_pointer, |
| 757 | offset, |
| 758 | IsConstructor()); |
| 759 | functions->Add(summary); |
| 760 | } |
| 761 | |
| 762 | |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 763 | void JavaScriptFrame::PrintTop(Isolate* isolate, |
| 764 | FILE* file, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 765 | bool print_args, |
| 766 | bool print_line_number) { |
| 767 | // constructor calls |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 768 | HandleScope scope(isolate); |
rossberg@chromium.org | 79e7902 | 2013-06-03 15:43:46 +0000 | [diff] [blame] | 769 | DisallowHeapAllocation no_allocation; |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 770 | JavaScriptFrameIterator it(isolate); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 771 | while (!it.done()) { |
| 772 | if (it.frame()->is_java_script()) { |
| 773 | JavaScriptFrame* frame = it.frame(); |
| 774 | if (frame->IsConstructor()) PrintF(file, "new "); |
| 775 | // function name |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 776 | JSFunction* fun = frame->function(); |
| 777 | fun->PrintName(); |
| 778 | Code* js_code = frame->unchecked_code(); |
| 779 | Address pc = frame->pc(); |
| 780 | int code_offset = |
| 781 | static_cast<int>(pc - js_code->instruction_start()); |
| 782 | PrintF("+%d", code_offset); |
| 783 | SharedFunctionInfo* shared = fun->shared(); |
| 784 | if (print_line_number) { |
| 785 | Code* code = Code::cast( |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame^] | 786 | v8::internal::Isolate::Current()->FindCodeObject(pc)); |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 787 | int source_pos = code->SourcePosition(pc); |
| 788 | Object* maybe_script = shared->script(); |
| 789 | if (maybe_script->IsScript()) { |
| 790 | Handle<Script> script(Script::cast(maybe_script)); |
| 791 | int line = GetScriptLineNumberSafe(script, source_pos) + 1; |
| 792 | Object* script_name_raw = script->name(); |
| 793 | if (script_name_raw->IsString()) { |
| 794 | String* script_name = String::cast(script->name()); |
| 795 | SmartArrayPointer<char> c_script_name = |
| 796 | script_name->ToCString(DISALLOW_NULLS, |
| 797 | ROBUST_STRING_TRAVERSAL); |
| 798 | PrintF(file, " at %s:%d", *c_script_name, line); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 799 | } else { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 800 | PrintF(file, " at <unknown>:%d", line); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 801 | } |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 802 | } else { |
| 803 | PrintF(file, " at <unknown>:<unknown>"); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 804 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | if (print_args) { |
| 808 | // function arguments |
| 809 | // (we are intentionally only printing the actually |
| 810 | // supplied parameters, not all parameters required) |
| 811 | PrintF(file, "(this="); |
| 812 | frame->receiver()->ShortPrint(file); |
| 813 | const int length = frame->ComputeParametersCount(); |
| 814 | for (int i = 0; i < length; i++) { |
| 815 | PrintF(file, ", "); |
| 816 | frame->GetParameter(i)->ShortPrint(file); |
| 817 | } |
| 818 | PrintF(file, ")"); |
| 819 | } |
| 820 | break; |
| 821 | } |
| 822 | it.Advance(); |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 827 | void JavaScriptFrame::SaveOperandStack(FixedArray* store, |
| 828 | int* stack_handler_index) const { |
| 829 | int operands_count = store->length(); |
| 830 | ASSERT_LE(operands_count, ComputeOperandsCount()); |
| 831 | |
| 832 | // Visit the stack in LIFO order, saving operands and stack handlers into the |
| 833 | // array. The saved stack handlers store a link to the next stack handler, |
| 834 | // which will allow RestoreOperandStack to rewind the handlers. |
| 835 | StackHandlerIterator it(this, top_handler()); |
| 836 | int i = operands_count - 1; |
| 837 | *stack_handler_index = -1; |
| 838 | for (; !it.done(); it.Advance()) { |
| 839 | StackHandler* handler = it.handler(); |
| 840 | // Save operands pushed after the handler was pushed. |
| 841 | for (; GetOperandSlot(i) < handler->address(); i--) { |
| 842 | store->set(i, GetOperand(i)); |
| 843 | } |
| 844 | ASSERT_GE(i + 1, StackHandlerConstants::kSlotCount); |
| 845 | ASSERT_EQ(handler->address(), GetOperandSlot(i)); |
| 846 | int next_stack_handler_index = i + 1 - StackHandlerConstants::kSlotCount; |
| 847 | handler->Unwind(isolate(), store, next_stack_handler_index, |
| 848 | *stack_handler_index); |
| 849 | *stack_handler_index = next_stack_handler_index; |
| 850 | i -= StackHandlerConstants::kSlotCount; |
| 851 | } |
| 852 | |
| 853 | // Save any remaining operands. |
| 854 | for (; i >= 0; i--) { |
| 855 | store->set(i, GetOperand(i)); |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | |
| 860 | void JavaScriptFrame::RestoreOperandStack(FixedArray* store, |
| 861 | int stack_handler_index) { |
| 862 | int operands_count = store->length(); |
| 863 | ASSERT_LE(operands_count, ComputeOperandsCount()); |
| 864 | int i = 0; |
| 865 | while (i <= stack_handler_index) { |
| 866 | if (i < stack_handler_index) { |
| 867 | // An operand. |
| 868 | ASSERT_EQ(GetOperand(i), isolate()->heap()->the_hole_value()); |
| 869 | Memory::Object_at(GetOperandSlot(i)) = store->get(i); |
| 870 | i++; |
| 871 | } else { |
| 872 | // A stack handler. |
| 873 | ASSERT_EQ(i, stack_handler_index); |
| 874 | // The FixedArray store grows up. The stack grows down. So the operand |
| 875 | // slot for i actually points to the bottom of the top word in the |
| 876 | // handler. The base of the StackHandler* is the address of the bottom |
| 877 | // word, which will be the last slot that is in the handler. |
| 878 | int handler_slot_index = i + StackHandlerConstants::kSlotCount - 1; |
| 879 | StackHandler *handler = |
| 880 | StackHandler::FromAddress(GetOperandSlot(handler_slot_index)); |
| 881 | stack_handler_index = handler->Rewind(isolate(), store, i, fp()); |
| 882 | i += StackHandlerConstants::kSlotCount; |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | for (; i < operands_count; i++) { |
| 887 | ASSERT_EQ(GetOperand(i), isolate()->heap()->the_hole_value()); |
| 888 | Memory::Object_at(GetOperandSlot(i)) = store->get(i); |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 893 | void FrameSummary::Print() { |
| 894 | PrintF("receiver: "); |
| 895 | receiver_->ShortPrint(); |
| 896 | PrintF("\nfunction: "); |
| 897 | function_->shared()->DebugName()->ShortPrint(); |
| 898 | PrintF("\ncode: "); |
| 899 | code_->ShortPrint(); |
| 900 | if (code_->kind() == Code::FUNCTION) PrintF(" NON-OPT"); |
| 901 | if (code_->kind() == Code::OPTIMIZED_FUNCTION) PrintF(" OPT"); |
| 902 | PrintF("\npc: %d\n", offset_); |
| 903 | } |
| 904 | |
| 905 | |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 906 | JSFunction* OptimizedFrame::LiteralAt(FixedArray* literal_array, |
| 907 | int literal_id) { |
| 908 | if (literal_id == Translation::kSelfLiteralId) { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 909 | return function(); |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | return JSFunction::cast(literal_array->get(literal_id)); |
| 913 | } |
| 914 | |
| 915 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 916 | void OptimizedFrame::Summarize(List<FrameSummary>* frames) { |
| 917 | ASSERT(frames->length() == 0); |
| 918 | ASSERT(is_optimized()); |
| 919 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 920 | int deopt_index = Safepoint::kNoDeoptimizationIndex; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 921 | DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 922 | FixedArray* literal_array = data->LiteralArray(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 923 | |
| 924 | // BUG(3243555): Since we don't have a lazy-deopt registered at |
| 925 | // throw-statements, we can't use the translation at the call-site of |
| 926 | // throw. An entry with no deoptimization index indicates a call-site |
| 927 | // without a lazy-deopt. As a consequence we are not allowed to inline |
| 928 | // functions containing throw. |
| 929 | if (deopt_index == Safepoint::kNoDeoptimizationIndex) { |
| 930 | JavaScriptFrame::Summarize(frames); |
| 931 | return; |
| 932 | } |
| 933 | |
| 934 | TranslationIterator it(data->TranslationByteArray(), |
| 935 | data->TranslationIndex(deopt_index)->value()); |
| 936 | Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 937 | ASSERT(opcode == Translation::BEGIN); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 938 | it.Next(); // Drop frame count. |
| 939 | int jsframe_count = it.Next(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 940 | |
| 941 | // We create the summary in reverse order because the frames |
| 942 | // in the deoptimization translation are ordered bottom-to-top. |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 943 | bool is_constructor = IsConstructor(); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 944 | int i = jsframe_count; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 945 | while (i > 0) { |
| 946 | opcode = static_cast<Translation::Opcode>(it.Next()); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 947 | if (opcode == Translation::JS_FRAME) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 948 | i--; |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 949 | BailoutId ast_id = BailoutId(it.Next()); |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 950 | JSFunction* function = LiteralAt(literal_array, it.Next()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 951 | it.Next(); // Skip height. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 952 | |
| 953 | // The translation commands are ordered and the receiver is always |
| 954 | // at the first position. Since we are always at a call when we need |
| 955 | // to construct a stack trace, the receiver is always in a stack slot. |
| 956 | opcode = static_cast<Translation::Opcode>(it.Next()); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 957 | ASSERT(opcode == Translation::STACK_SLOT || |
| 958 | opcode == Translation::LITERAL); |
| 959 | int index = it.Next(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 960 | |
| 961 | // Get the correct receiver in the optimized frame. |
| 962 | Object* receiver = NULL; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 963 | if (opcode == Translation::LITERAL) { |
| 964 | receiver = data->LiteralArray()->get(index); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 965 | } else { |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 966 | // Positive index means the value is spilled to the locals |
| 967 | // area. Negative means it is stored in the incoming parameter |
| 968 | // area. |
| 969 | if (index >= 0) { |
| 970 | receiver = GetExpression(index); |
| 971 | } else { |
| 972 | // Index -1 overlaps with last parameter, -n with the first parameter, |
| 973 | // (-n - 1) with the receiver with n being the number of parameters |
| 974 | // of the outermost, optimized frame. |
| 975 | int parameter_count = ComputeParametersCount(); |
| 976 | int parameter_index = index + parameter_count; |
| 977 | receiver = (parameter_index == -1) |
| 978 | ? this->receiver() |
| 979 | : this->GetParameter(parameter_index); |
| 980 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | Code* code = function->shared()->code(); |
| 984 | DeoptimizationOutputData* output_data = |
| 985 | DeoptimizationOutputData::cast(code->deoptimization_data()); |
| 986 | unsigned entry = Deoptimizer::GetOutputInfo(output_data, |
| 987 | ast_id, |
| 988 | function->shared()); |
| 989 | unsigned pc_offset = |
| 990 | FullCodeGenerator::PcField::decode(entry) + Code::kHeaderSize; |
| 991 | ASSERT(pc_offset > 0); |
| 992 | |
| 993 | FrameSummary summary(receiver, function, code, pc_offset, is_constructor); |
| 994 | frames->Add(summary); |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 995 | is_constructor = false; |
| 996 | } else if (opcode == Translation::CONSTRUCT_STUB_FRAME) { |
| 997 | // The next encountered JS_FRAME will be marked as a constructor call. |
| 998 | it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| 999 | ASSERT(!is_constructor); |
| 1000 | is_constructor = true; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1001 | } else { |
| 1002 | // Skip over operands to advance to the next opcode. |
| 1003 | it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| 1004 | } |
| 1005 | } |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1006 | ASSERT(!is_constructor); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | |
| 1010 | DeoptimizationInputData* OptimizedFrame::GetDeoptimizationData( |
| 1011 | int* deopt_index) { |
| 1012 | ASSERT(is_optimized()); |
| 1013 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1014 | JSFunction* opt_function = function(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1015 | Code* code = opt_function->code(); |
| 1016 | |
| 1017 | // The code object may have been replaced by lazy deoptimization. Fall |
| 1018 | // back to a slow search in this case to find the original optimized |
| 1019 | // code object. |
| 1020 | if (!code->contains(pc())) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1021 | code = isolate()->inner_pointer_to_code_cache()-> |
| 1022 | GcSafeFindCodeForInnerPointer(pc()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1023 | } |
| 1024 | ASSERT(code != NULL); |
| 1025 | ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 1026 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 1027 | SafepointEntry safepoint_entry = code->GetSafepointEntry(pc()); |
| 1028 | *deopt_index = safepoint_entry.deoptimization_index(); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1029 | ASSERT(*deopt_index != Safepoint::kNoDeoptimizationIndex); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1030 | |
| 1031 | return DeoptimizationInputData::cast(code->deoptimization_data()); |
| 1032 | } |
| 1033 | |
| 1034 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1035 | int OptimizedFrame::GetInlineCount() { |
| 1036 | ASSERT(is_optimized()); |
| 1037 | |
| 1038 | int deopt_index = Safepoint::kNoDeoptimizationIndex; |
| 1039 | DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
| 1040 | |
| 1041 | TranslationIterator it(data->TranslationByteArray(), |
| 1042 | data->TranslationIndex(deopt_index)->value()); |
| 1043 | Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 1044 | ASSERT(opcode == Translation::BEGIN); |
| 1045 | USE(opcode); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1046 | it.Next(); // Drop frame count. |
| 1047 | int jsframe_count = it.Next(); |
| 1048 | return jsframe_count; |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1052 | void OptimizedFrame::GetFunctions(List<JSFunction*>* functions) { |
| 1053 | ASSERT(functions->length() == 0); |
| 1054 | ASSERT(is_optimized()); |
| 1055 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1056 | int deopt_index = Safepoint::kNoDeoptimizationIndex; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1057 | DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index); |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1058 | FixedArray* literal_array = data->LiteralArray(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1059 | |
| 1060 | TranslationIterator it(data->TranslationByteArray(), |
| 1061 | data->TranslationIndex(deopt_index)->value()); |
| 1062 | Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| 1063 | ASSERT(opcode == Translation::BEGIN); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1064 | it.Next(); // Drop frame count. |
| 1065 | int jsframe_count = it.Next(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1066 | |
| 1067 | // We insert the frames in reverse order because the frames |
| 1068 | // in the deoptimization translation are ordered bottom-to-top. |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1069 | while (jsframe_count > 0) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1070 | opcode = static_cast<Translation::Opcode>(it.Next()); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1071 | if (opcode == Translation::JS_FRAME) { |
| 1072 | jsframe_count--; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1073 | it.Next(); // Skip ast id. |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1074 | JSFunction* function = LiteralAt(literal_array, it.Next()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1075 | it.Next(); // Skip height. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1076 | functions->Add(function); |
| 1077 | } else { |
| 1078 | // Skip over operands to advance to the next opcode. |
| 1079 | it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1085 | int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const { |
| 1086 | return Smi::cast(GetExpression(0))->value(); |
| 1087 | } |
| 1088 | |
| 1089 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1090 | Address ArgumentsAdaptorFrame::GetCallerStackPointer() const { |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 1091 | return fp() + StandardFrameConstants::kCallerSPOffset; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1092 | } |
| 1093 | |
| 1094 | |
| 1095 | Address InternalFrame::GetCallerStackPointer() const { |
| 1096 | // Internal frames have no arguments. The stack pointer of the |
| 1097 | // caller is at a fixed offset from the frame pointer. |
| 1098 | return fp() + StandardFrameConstants::kCallerSPOffset; |
| 1099 | } |
| 1100 | |
| 1101 | |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 1102 | Code* ArgumentsAdaptorFrame::unchecked_code() const { |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1103 | return isolate()->builtins()->builtin( |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1104 | Builtins::kArgumentsAdaptorTrampoline); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 1108 | Code* InternalFrame::unchecked_code() const { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1109 | const int offset = InternalFrameConstants::kCodeOffset; |
| 1110 | Object* code = Memory::Object_at(fp() + offset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1111 | ASSERT(code != NULL); |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 1112 | return reinterpret_cast<Code*>(code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | |
| 1116 | void StackFrame::PrintIndex(StringStream* accumulator, |
| 1117 | PrintMode mode, |
| 1118 | int index) { |
| 1119 | accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); |
| 1120 | } |
| 1121 | |
| 1122 | |
| 1123 | void JavaScriptFrame::Print(StringStream* accumulator, |
| 1124 | PrintMode mode, |
| 1125 | int index) const { |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 1126 | HandleScope scope(isolate()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1127 | Object* receiver = this->receiver(); |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1128 | JSFunction* function = this->function(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1129 | |
| 1130 | accumulator->PrintSecurityTokenIfChanged(function); |
| 1131 | PrintIndex(accumulator, mode, index); |
| 1132 | Code* code = NULL; |
| 1133 | if (IsConstructor()) accumulator->Add("new "); |
| 1134 | accumulator->PrintFunction(function, receiver, &code); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 1135 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1136 | // Get scope information for nicer output, if possible. If code is NULL, or |
| 1137 | // doesn't contain scope info, scope_info will return 0 for the number of |
| 1138 | // parameters, stack local variables, context local variables, stack slots, |
| 1139 | // or context slots. |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1140 | Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate())); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 1141 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1142 | Handle<SharedFunctionInfo> shared(function->shared()); |
| 1143 | scope_info = Handle<ScopeInfo>(shared->scope_info()); |
| 1144 | Object* script_obj = shared->script(); |
| 1145 | if (script_obj->IsScript()) { |
| 1146 | Handle<Script> script(Script::cast(script_obj)); |
| 1147 | accumulator->Add(" ["); |
| 1148 | accumulator->PrintName(script->name()); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 1149 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1150 | Address pc = this->pc(); |
| 1151 | if (code != NULL && code->kind() == Code::FUNCTION && |
| 1152 | pc >= code->instruction_start() && pc < code->instruction_end()) { |
| 1153 | int source_pos = code->SourcePosition(pc); |
| 1154 | int line = GetScriptLineNumberSafe(script, source_pos) + 1; |
| 1155 | accumulator->Add(":%d", line); |
| 1156 | } else { |
| 1157 | int function_start_pos = shared->start_position(); |
| 1158 | int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; |
| 1159 | accumulator->Add(":~%d", line); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 1160 | } |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1161 | |
| 1162 | accumulator->Add("] "); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1165 | accumulator->Add("(this=%o", receiver); |
| 1166 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1167 | // Print the parameters. |
| 1168 | int parameters_count = ComputeParametersCount(); |
| 1169 | for (int i = 0; i < parameters_count; i++) { |
| 1170 | accumulator->Add(","); |
| 1171 | // If we have a name for the parameter we print it. Nameless |
| 1172 | // parameters are either because we have more actual parameters |
| 1173 | // than formal parameters or because we have no scope information. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1174 | if (i < scope_info->ParameterCount()) { |
| 1175 | accumulator->PrintName(scope_info->ParameterName(i)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1176 | accumulator->Add("="); |
| 1177 | } |
| 1178 | accumulator->Add("%o", GetParameter(i)); |
| 1179 | } |
| 1180 | |
| 1181 | accumulator->Add(")"); |
| 1182 | if (mode == OVERVIEW) { |
| 1183 | accumulator->Add("\n"); |
| 1184 | return; |
| 1185 | } |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 1186 | if (is_optimized()) { |
| 1187 | accumulator->Add(" {\n// optimized frame\n}\n"); |
| 1188 | return; |
| 1189 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1190 | accumulator->Add(" {\n"); |
| 1191 | |
| 1192 | // Compute the number of locals and expression stack elements. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1193 | int stack_locals_count = scope_info->StackLocalCount(); |
| 1194 | int heap_locals_count = scope_info->ContextLocalCount(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1195 | int expressions_count = ComputeExpressionsCount(); |
| 1196 | |
| 1197 | // Print stack-allocated local variables. |
| 1198 | if (stack_locals_count > 0) { |
| 1199 | accumulator->Add(" // stack-allocated locals\n"); |
| 1200 | } |
| 1201 | for (int i = 0; i < stack_locals_count; i++) { |
| 1202 | accumulator->Add(" var "); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1203 | accumulator->PrintName(scope_info->StackLocalName(i)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1204 | accumulator->Add(" = "); |
| 1205 | if (i < expressions_count) { |
| 1206 | accumulator->Add("%o", GetExpression(i)); |
| 1207 | } else { |
| 1208 | accumulator->Add("// no expression found - inconsistent frame?"); |
| 1209 | } |
| 1210 | accumulator->Add("\n"); |
| 1211 | } |
| 1212 | |
| 1213 | // Try to get hold of the context of this frame. |
| 1214 | Context* context = NULL; |
| 1215 | if (this->context() != NULL && this->context()->IsContext()) { |
| 1216 | context = Context::cast(this->context()); |
| 1217 | } |
| 1218 | |
| 1219 | // Print heap-allocated local variables. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1220 | if (heap_locals_count > 0) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1221 | accumulator->Add(" // heap-allocated locals\n"); |
| 1222 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1223 | for (int i = 0; i < heap_locals_count; i++) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1224 | accumulator->Add(" var "); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1225 | accumulator->PrintName(scope_info->ContextLocalName(i)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1226 | accumulator->Add(" = "); |
| 1227 | if (context != NULL) { |
| 1228 | if (i < context->length()) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1229 | accumulator->Add("%o", context->get(Context::MIN_CONTEXT_SLOTS + i)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1230 | } else { |
| 1231 | accumulator->Add( |
| 1232 | "// warning: missing context slot - inconsistent frame?"); |
| 1233 | } |
| 1234 | } else { |
| 1235 | accumulator->Add("// warning: no context found - inconsistent frame?"); |
| 1236 | } |
| 1237 | accumulator->Add("\n"); |
| 1238 | } |
| 1239 | |
| 1240 | // Print the expression stack. |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1241 | int expressions_start = stack_locals_count; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1242 | if (expressions_start < expressions_count) { |
| 1243 | accumulator->Add(" // expression stack (top to bottom)\n"); |
| 1244 | } |
| 1245 | for (int i = expressions_count - 1; i >= expressions_start; i--) { |
| 1246 | if (IsExpressionInsideHandler(i)) continue; |
| 1247 | accumulator->Add(" [%02d] : %o\n", i, GetExpression(i)); |
| 1248 | } |
| 1249 | |
| 1250 | // Print details about the function. |
| 1251 | if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1252 | SharedFunctionInfo* shared = function->shared(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1253 | accumulator->Add("--------- s o u r c e c o d e ---------\n"); |
| 1254 | shared->SourceCodePrint(accumulator, FLAG_max_stack_trace_source_length); |
| 1255 | accumulator->Add("\n-----------------------------------------\n"); |
| 1256 | } |
| 1257 | |
| 1258 | accumulator->Add("}\n\n"); |
| 1259 | } |
| 1260 | |
| 1261 | |
| 1262 | void ArgumentsAdaptorFrame::Print(StringStream* accumulator, |
| 1263 | PrintMode mode, |
| 1264 | int index) const { |
| 1265 | int actual = ComputeParametersCount(); |
| 1266 | int expected = -1; |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1267 | JSFunction* function = this->function(); |
| 1268 | expected = function->shared()->formal_parameter_count(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1269 | |
| 1270 | PrintIndex(accumulator, mode, index); |
| 1271 | accumulator->Add("arguments adaptor frame: %d->%d", actual, expected); |
| 1272 | if (mode == OVERVIEW) { |
| 1273 | accumulator->Add("\n"); |
| 1274 | return; |
| 1275 | } |
| 1276 | accumulator->Add(" {\n"); |
| 1277 | |
| 1278 | // Print actual arguments. |
| 1279 | if (actual > 0) accumulator->Add(" // actual arguments\n"); |
| 1280 | for (int i = 0; i < actual; i++) { |
| 1281 | accumulator->Add(" [%02d] : %o", i, GetParameter(i)); |
| 1282 | if (expected != -1 && i >= expected) { |
| 1283 | accumulator->Add(" // not passed to callee"); |
| 1284 | } |
| 1285 | accumulator->Add("\n"); |
| 1286 | } |
| 1287 | |
| 1288 | accumulator->Add("}\n\n"); |
| 1289 | } |
| 1290 | |
| 1291 | |
| 1292 | void EntryFrame::Iterate(ObjectVisitor* v) const { |
| 1293 | StackHandlerIterator it(this, top_handler()); |
| 1294 | ASSERT(!it.done()); |
| 1295 | StackHandler* handler = it.handler(); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1296 | ASSERT(handler->is_js_entry()); |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1297 | handler->Iterate(v, LookupCode()); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1298 | #ifdef DEBUG |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1299 | // Make sure that the entry frame does not contain more than one |
| 1300 | // stack handler. |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1301 | it.Advance(); |
| 1302 | ASSERT(it.done()); |
| 1303 | #endif |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1304 | IteratePc(v, pc_address(), LookupCode()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | |
| 1308 | void StandardFrame::IterateExpressions(ObjectVisitor* v) const { |
| 1309 | const int offset = StandardFrameConstants::kContextOffset; |
| 1310 | Object** base = &Memory::Object_at(sp()); |
| 1311 | Object** limit = &Memory::Object_at(fp() + offset) + 1; |
| 1312 | for (StackHandlerIterator it(this, top_handler()); !it.done(); it.Advance()) { |
| 1313 | StackHandler* handler = it.handler(); |
| 1314 | // Traverse pointers down to - but not including - the next |
| 1315 | // handler in the handler chain. Update the base to skip the |
| 1316 | // handler and allow the handler to traverse its own pointers. |
| 1317 | const Address address = handler->address(); |
| 1318 | v->VisitPointers(base, reinterpret_cast<Object**>(address)); |
| 1319 | base = reinterpret_cast<Object**>(address + StackHandlerConstants::kSize); |
| 1320 | // Traverse the pointers in the handler itself. |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1321 | handler->Iterate(v, LookupCode()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1322 | } |
| 1323 | v->VisitPointers(base, limit); |
| 1324 | } |
| 1325 | |
| 1326 | |
| 1327 | void JavaScriptFrame::Iterate(ObjectVisitor* v) const { |
| 1328 | IterateExpressions(v); |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1329 | IteratePc(v, pc_address(), LookupCode()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | |
| 1333 | void InternalFrame::Iterate(ObjectVisitor* v) const { |
| 1334 | // Internal frames only have object pointers on the expression stack |
| 1335 | // as they never have any arguments. |
| 1336 | IterateExpressions(v); |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1337 | IteratePc(v, pc_address(), LookupCode()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 1341 | void StubFailureTrampolineFrame::Iterate(ObjectVisitor* v) const { |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 1342 | Object** base = &Memory::Object_at(sp()); |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 1343 | Object** limit = &Memory::Object_at(fp() + |
| 1344 | kFirstRegisterParameterFrameOffset); |
| 1345 | v->VisitPointers(base, limit); |
| 1346 | base = &Memory::Object_at(fp() + StandardFrameConstants::kMarkerOffset); |
| 1347 | const int offset = StandardFrameConstants::kContextOffset; |
| 1348 | limit = &Memory::Object_at(fp() + offset) + 1; |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 1349 | v->VisitPointers(base, limit); |
| 1350 | IteratePc(v, pc_address(), LookupCode()); |
| 1351 | } |
| 1352 | |
| 1353 | |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 1354 | Address StubFailureTrampolineFrame::GetCallerStackPointer() const { |
| 1355 | return fp() + StandardFrameConstants::kCallerSPOffset; |
| 1356 | } |
| 1357 | |
| 1358 | |
| 1359 | Code* StubFailureTrampolineFrame::unchecked_code() const { |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 1360 | Code* trampoline; |
| 1361 | StubFailureTrampolineStub(NOT_JS_FUNCTION_STUB_MODE). |
| 1362 | FindCodeInCache(&trampoline, isolate()); |
| 1363 | if (trampoline->contains(pc())) { |
| 1364 | return trampoline; |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 1365 | } |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 1366 | |
| 1367 | StubFailureTrampolineStub(JS_FUNCTION_STUB_MODE). |
| 1368 | FindCodeInCache(&trampoline, isolate()); |
| 1369 | if (trampoline->contains(pc())) { |
| 1370 | return trampoline; |
| 1371 | } |
| 1372 | |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 1373 | UNREACHABLE(); |
| 1374 | return NULL; |
| 1375 | } |
| 1376 | |
| 1377 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1378 | // ------------------------------------------------------------------------- |
| 1379 | |
| 1380 | |
| 1381 | JavaScriptFrame* StackFrameLocator::FindJavaScriptFrame(int n) { |
| 1382 | ASSERT(n >= 0); |
| 1383 | for (int i = 0; i <= n; i++) { |
| 1384 | while (!iterator_.frame()->is_java_script()) iterator_.Advance(); |
| 1385 | if (i == n) return JavaScriptFrame::cast(iterator_.frame()); |
| 1386 | iterator_.Advance(); |
| 1387 | } |
| 1388 | UNREACHABLE(); |
| 1389 | return NULL; |
| 1390 | } |
| 1391 | |
| 1392 | |
| 1393 | // ------------------------------------------------------------------------- |
| 1394 | |
| 1395 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1396 | static Map* GcSafeMapOfCodeSpaceObject(HeapObject* object) { |
| 1397 | MapWord map_word = object->map_word(); |
| 1398 | return map_word.IsForwardingAddress() ? |
| 1399 | map_word.ToForwardingAddress()->map() : map_word.ToMap(); |
| 1400 | } |
| 1401 | |
| 1402 | |
| 1403 | static int GcSafeSizeOfCodeSpaceObject(HeapObject* object) { |
| 1404 | return object->SizeFromMap(GcSafeMapOfCodeSpaceObject(object)); |
| 1405 | } |
| 1406 | |
| 1407 | |
| 1408 | #ifdef DEBUG |
| 1409 | static bool GcSafeCodeContains(HeapObject* code, Address addr) { |
| 1410 | Map* map = GcSafeMapOfCodeSpaceObject(code); |
| 1411 | ASSERT(map == code->GetHeap()->code_map()); |
| 1412 | Address start = code->address(); |
| 1413 | Address end = code->address() + code->SizeFromMap(map); |
| 1414 | return start <= addr && addr < end; |
| 1415 | } |
| 1416 | #endif |
| 1417 | |
| 1418 | |
| 1419 | Code* InnerPointerToCodeCache::GcSafeCastToCode(HeapObject* object, |
| 1420 | Address inner_pointer) { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1421 | Code* code = reinterpret_cast<Code*>(object); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1422 | ASSERT(code != NULL && GcSafeCodeContains(code, inner_pointer)); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1423 | return code; |
| 1424 | } |
| 1425 | |
| 1426 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1427 | Code* InnerPointerToCodeCache::GcSafeFindCodeForInnerPointer( |
| 1428 | Address inner_pointer) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1429 | Heap* heap = isolate_->heap(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1430 | // Check if the inner pointer points into a large object chunk. |
jkummerow@chromium.org | 531dfe8 | 2012-03-20 13:01:16 +0000 | [diff] [blame] | 1431 | LargePage* large_page = heap->lo_space()->FindPage(inner_pointer); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1432 | if (large_page != NULL) { |
| 1433 | return GcSafeCastToCode(large_page->GetObject(), inner_pointer); |
| 1434 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1435 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1436 | // Iterate through the page until we reach the end or find an object starting |
| 1437 | // after the inner pointer. |
| 1438 | Page* page = Page::FromAddress(inner_pointer); |
| 1439 | |
| 1440 | Address addr = page->skip_list()->StartFor(inner_pointer); |
| 1441 | |
| 1442 | Address top = heap->code_space()->top(); |
| 1443 | Address limit = heap->code_space()->limit(); |
| 1444 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1445 | while (true) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1446 | if (addr == top && addr != limit) { |
| 1447 | addr = limit; |
| 1448 | continue; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1449 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1450 | |
| 1451 | HeapObject* obj = HeapObject::FromAddress(addr); |
| 1452 | int obj_size = GcSafeSizeOfCodeSpaceObject(obj); |
| 1453 | Address next_addr = addr + obj_size; |
| 1454 | if (next_addr > inner_pointer) return GcSafeCastToCode(obj, inner_pointer); |
| 1455 | addr = next_addr; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1456 | } |
| 1457 | } |
| 1458 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1459 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1460 | InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* |
| 1461 | InnerPointerToCodeCache::GetCacheEntry(Address inner_pointer) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1462 | isolate_->counters()->pc_to_code()->Increment(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1463 | ASSERT(IsPowerOf2(kInnerPointerToCodeCacheSize)); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1464 | uint32_t hash = ComputeIntegerHash( |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1465 | static_cast<uint32_t>(reinterpret_cast<uintptr_t>(inner_pointer)), |
| 1466 | v8::internal::kZeroHashSeed); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1467 | uint32_t index = hash & (kInnerPointerToCodeCacheSize - 1); |
| 1468 | InnerPointerToCodeCacheEntry* entry = cache(index); |
| 1469 | if (entry->inner_pointer == inner_pointer) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1470 | isolate_->counters()->pc_to_code_cached()->Increment(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1471 | ASSERT(entry->code == GcSafeFindCodeForInnerPointer(inner_pointer)); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1472 | } else { |
| 1473 | // Because this code may be interrupted by a profiling signal that |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1474 | // also queries the cache, we cannot update inner_pointer before the code |
| 1475 | // has been set. Otherwise, we risk trying to use a cache entry before |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1476 | // the code has been computed. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1477 | entry->code = GcSafeFindCodeForInnerPointer(inner_pointer); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 1478 | entry->safepoint_entry.Reset(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1479 | entry->inner_pointer = inner_pointer; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1480 | } |
| 1481 | return entry; |
| 1482 | } |
| 1483 | |
| 1484 | |
| 1485 | // ------------------------------------------------------------------------- |
| 1486 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1487 | |
| 1488 | void StackHandler::Unwind(Isolate* isolate, |
| 1489 | FixedArray* array, |
| 1490 | int offset, |
| 1491 | int previous_handler_offset) const { |
| 1492 | STATIC_ASSERT(StackHandlerConstants::kSlotCount == 5); |
| 1493 | ASSERT_LE(0, offset); |
| 1494 | ASSERT_GE(array->length(), offset + 5); |
| 1495 | // Unwinding a stack handler into an array chains it in the opposite |
| 1496 | // direction, re-using the "next" slot as a "previous" link, so that stack |
| 1497 | // handlers can be later re-wound in the correct order. Decode the "state" |
| 1498 | // slot into "index" and "kind" and store them separately, using the fp slot. |
| 1499 | array->set(offset, Smi::FromInt(previous_handler_offset)); // next |
| 1500 | array->set(offset + 1, *code_address()); // code |
| 1501 | array->set(offset + 2, Smi::FromInt(static_cast<int>(index()))); // state |
| 1502 | array->set(offset + 3, *context_address()); // context |
| 1503 | array->set(offset + 4, Smi::FromInt(static_cast<int>(kind()))); // fp |
| 1504 | |
| 1505 | *isolate->handler_address() = next()->address(); |
| 1506 | } |
| 1507 | |
| 1508 | |
| 1509 | int StackHandler::Rewind(Isolate* isolate, |
| 1510 | FixedArray* array, |
| 1511 | int offset, |
| 1512 | Address fp) { |
| 1513 | STATIC_ASSERT(StackHandlerConstants::kSlotCount == 5); |
| 1514 | ASSERT_LE(0, offset); |
| 1515 | ASSERT_GE(array->length(), offset + 5); |
| 1516 | Smi* prev_handler_offset = Smi::cast(array->get(offset)); |
| 1517 | Code* code = Code::cast(array->get(offset + 1)); |
| 1518 | Smi* smi_index = Smi::cast(array->get(offset + 2)); |
| 1519 | Object* context = array->get(offset + 3); |
| 1520 | Smi* smi_kind = Smi::cast(array->get(offset + 4)); |
| 1521 | |
| 1522 | unsigned state = KindField::encode(static_cast<Kind>(smi_kind->value())) | |
| 1523 | IndexField::encode(static_cast<unsigned>(smi_index->value())); |
| 1524 | |
| 1525 | Memory::Address_at(address() + StackHandlerConstants::kNextOffset) = |
| 1526 | *isolate->handler_address(); |
| 1527 | Memory::Object_at(address() + StackHandlerConstants::kCodeOffset) = code; |
| 1528 | Memory::uintptr_at(address() + StackHandlerConstants::kStateOffset) = state; |
| 1529 | Memory::Object_at(address() + StackHandlerConstants::kContextOffset) = |
| 1530 | context; |
| 1531 | Memory::Address_at(address() + StackHandlerConstants::kFPOffset) = fp; |
| 1532 | |
| 1533 | *isolate->handler_address() = address(); |
| 1534 | |
| 1535 | return prev_handler_offset->value(); |
| 1536 | } |
| 1537 | |
| 1538 | |
| 1539 | // ------------------------------------------------------------------------- |
| 1540 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1541 | int NumRegs(RegList reglist) { |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 1542 | return CompilerIntrinsics::CountSetBits(reglist); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1543 | } |
| 1544 | |
| 1545 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1546 | struct JSCallerSavedCodeData { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1547 | int reg_code[kNumJSCallerSaved]; |
| 1548 | }; |
| 1549 | |
fschneider@chromium.org | 7d10be5 | 2012-04-10 12:30:14 +0000 | [diff] [blame] | 1550 | JSCallerSavedCodeData caller_saved_code_data; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1551 | |
fschneider@chromium.org | 7d10be5 | 2012-04-10 12:30:14 +0000 | [diff] [blame] | 1552 | void SetUpJSCallerSavedCodeData() { |
| 1553 | int i = 0; |
| 1554 | for (int r = 0; r < kNumRegs; r++) |
| 1555 | if ((kJSCallerSaved & (1 << r)) != 0) |
| 1556 | caller_saved_code_data.reg_code[i++] = r; |
| 1557 | |
| 1558 | ASSERT(i == kNumJSCallerSaved); |
| 1559 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1560 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 1561 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1562 | int JSCallerSavedCode(int n) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1563 | ASSERT(0 <= n && n < kNumJSCallerSaved); |
fschneider@chromium.org | 7d10be5 | 2012-04-10 12:30:14 +0000 | [diff] [blame] | 1564 | return caller_saved_code_data.reg_code[n]; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 1568 | #define DEFINE_WRAPPER(type, field) \ |
| 1569 | class field##_Wrapper : public ZoneObject { \ |
| 1570 | public: /* NOLINT */ \ |
| 1571 | field##_Wrapper(const field& original) : frame_(original) { \ |
| 1572 | } \ |
| 1573 | field frame_; \ |
| 1574 | }; |
| 1575 | STACK_FRAME_TYPE_LIST(DEFINE_WRAPPER) |
| 1576 | #undef DEFINE_WRAPPER |
| 1577 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1578 | static StackFrame* AllocateFrameCopy(StackFrame* frame, Zone* zone) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 1579 | #define FRAME_TYPE_CASE(type, field) \ |
| 1580 | case StackFrame::type: { \ |
| 1581 | field##_Wrapper* wrapper = \ |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1582 | new(zone) field##_Wrapper(*(reinterpret_cast<field*>(frame))); \ |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 1583 | return &wrapper->frame_; \ |
| 1584 | } |
| 1585 | |
| 1586 | switch (frame->type()) { |
| 1587 | STACK_FRAME_TYPE_LIST(FRAME_TYPE_CASE) |
| 1588 | default: UNREACHABLE(); |
| 1589 | } |
| 1590 | #undef FRAME_TYPE_CASE |
| 1591 | return NULL; |
| 1592 | } |
| 1593 | |
mstarzinger@chromium.org | e0e1b0d | 2013-07-08 08:38:06 +0000 | [diff] [blame] | 1594 | |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 1595 | Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1596 | ZoneList<StackFrame*> list(10, zone); |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 1597 | for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1598 | StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1599 | list.Add(frame, zone); |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 1600 | } |
| 1601 | return list.ToVector(); |
| 1602 | } |
| 1603 | |
| 1604 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1605 | } } // namespace v8::internal |