| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "safepoint-table.h" | 36 #include "safepoint-table.h" |
| 37 #include "scopeinfo.h" | 37 #include "scopeinfo.h" |
| 38 #include "string-stream.h" | 38 #include "string-stream.h" |
| 39 | 39 |
| 40 #include "allocation-inl.h" | 40 #include "allocation-inl.h" |
| 41 | 41 |
| 42 namespace v8 { | 42 namespace v8 { |
| 43 namespace internal { | 43 namespace internal { |
| 44 | 44 |
| 45 | 45 |
| 46 static ReturnAddressLocationResolver return_address_location_resolver = NULL; | 46 ReturnAddressLocationResolver |
| 47 | 47 StackFrame::return_address_location_resolver_ = NULL; |
| 48 | |
| 49 // Resolves pc_address through the resolution address function if one is set. | |
| 50 static inline Address* ResolveReturnAddressLocation(Address* pc_address) { | |
| 51 if (return_address_location_resolver == NULL) { | |
| 52 return pc_address; | |
| 53 } else { | |
| 54 return reinterpret_cast<Address*>( | |
| 55 return_address_location_resolver( | |
| 56 reinterpret_cast<uintptr_t>(pc_address))); | |
| 57 } | |
| 58 } | |
| 59 | 48 |
| 60 | 49 |
| 61 // Iterator that supports traversing the stack handlers of a | 50 // Iterator that supports traversing the stack handlers of a |
| 62 // particular frame. Needs to know the top of the handler chain. | 51 // particular frame. Needs to know the top of the handler chain. |
| 63 class StackHandlerIterator BASE_EMBEDDED { | 52 class StackHandlerIterator BASE_EMBEDDED { |
| 64 public: | 53 public: |
| 65 StackHandlerIterator(const StackFrame* frame, StackHandler* handler) | 54 StackHandlerIterator(const StackFrame* frame, StackHandler* handler) |
| 66 : limit_(frame->fp()), handler_(handler) { | 55 : limit_(frame->fp()), handler_(handler) { |
| 67 // Make sure the handler has already been unwound to this frame. | 56 // Make sure the handler has already been unwound to this frame. |
| 68 ASSERT(frame->sp() <= handler->address()); | 57 ASSERT(frame->sp() <= handler->address()); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 low_bound_(low_bound), high_bound_(high_bound) { | 221 low_bound_(low_bound), high_bound_(high_bound) { |
| 233 StackFrame::State state; | 222 StackFrame::State state; |
| 234 StackFrame::Type type; | 223 StackFrame::Type type; |
| 235 ThreadLocalTop* top = isolate->thread_local_top(); | 224 ThreadLocalTop* top = isolate->thread_local_top(); |
| 236 if (IsValidTop(top)) { | 225 if (IsValidTop(top)) { |
| 237 type = ExitFrame::GetStateForFramePointer(Isolate::c_entry_fp(top), &state); | 226 type = ExitFrame::GetStateForFramePointer(Isolate::c_entry_fp(top), &state); |
| 238 } else if (IsValidStackAddress(fp)) { | 227 } else if (IsValidStackAddress(fp)) { |
| 239 ASSERT(fp != NULL); | 228 ASSERT(fp != NULL); |
| 240 state.fp = fp; | 229 state.fp = fp; |
| 241 state.sp = sp; | 230 state.sp = sp; |
| 242 state.pc_address = ResolveReturnAddressLocation( | 231 state.pc_address = StackFrame::ResolveReturnAddressLocation( |
| 243 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp))); | 232 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp))); |
| 244 type = StackFrame::ComputeType(this, &state); | 233 type = StackFrame::ComputeType(this, &state); |
| 245 } else { | 234 } else { |
| 246 return; | 235 return; |
| 247 } | 236 } |
| 248 if (SingletonFor(type) == NULL) return; | 237 if (SingletonFor(type) == NULL) return; |
| 249 frame_ = SingletonFor(type, &state); | 238 frame_ = SingletonFor(type, &state); |
| 250 | 239 |
| 251 if (!done()) Advance(); | 240 if (!done()) Advance(); |
| 252 } | 241 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 if (code != holder) { | 371 if (code != holder) { |
| 383 holder = reinterpret_cast<Code*>(code); | 372 holder = reinterpret_cast<Code*>(code); |
| 384 pc = holder->instruction_start() + pc_offset; | 373 pc = holder->instruction_start() + pc_offset; |
| 385 *pc_address = pc; | 374 *pc_address = pc; |
| 386 } | 375 } |
| 387 } | 376 } |
| 388 | 377 |
| 389 | 378 |
| 390 void StackFrame::SetReturnAddressLocationResolver( | 379 void StackFrame::SetReturnAddressLocationResolver( |
| 391 ReturnAddressLocationResolver resolver) { | 380 ReturnAddressLocationResolver resolver) { |
| 392 ASSERT(return_address_location_resolver == NULL); | 381 ASSERT(return_address_location_resolver_ == NULL); |
| 393 return_address_location_resolver = resolver; | 382 return_address_location_resolver_ = resolver; |
| 394 } | 383 } |
| 395 | 384 |
| 396 | 385 |
| 397 StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, | 386 StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, |
| 398 State* state) { | 387 State* state) { |
| 399 ASSERT(state->fp != NULL); | 388 ASSERT(state->fp != NULL); |
| 400 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) { | 389 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) { |
| 401 return ARGUMENTS_ADAPTOR; | 390 return ARGUMENTS_ADAPTOR; |
| 402 } | 391 } |
| 403 // The marker and function offsets overlap. If the marker isn't a | 392 // The marker and function offsets overlap. If the marker isn't a |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 ZoneList<StackFrame*> list(10, zone); | 1585 ZoneList<StackFrame*> list(10, zone); |
| 1597 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1586 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1598 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1587 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1599 list.Add(frame, zone); | 1588 list.Add(frame, zone); |
| 1600 } | 1589 } |
| 1601 return list.ToVector(); | 1590 return list.ToVector(); |
| 1602 } | 1591 } |
| 1603 | 1592 |
| 1604 | 1593 |
| 1605 } } // namespace v8::internal | 1594 } } // namespace v8::internal |
| OLD | NEW |