| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 StackFrame::Type type; | 146 StackFrame::Type type; |
| 158 if (thread_ != NULL) { | 147 if (thread_ != NULL) { |
| 159 type = ExitFrame::GetStateForFramePointer( | 148 type = ExitFrame::GetStateForFramePointer( |
| 160 Isolate::c_entry_fp(thread_), &state); | 149 Isolate::c_entry_fp(thread_), &state); |
| 161 handler_ = StackHandler::FromAddress( | 150 handler_ = StackHandler::FromAddress( |
| 162 Isolate::handler(thread_)); | 151 Isolate::handler(thread_)); |
| 163 } else { | 152 } else { |
| 164 ASSERT(fp_ != NULL); | 153 ASSERT(fp_ != NULL); |
| 165 state.fp = fp_; | 154 state.fp = fp_; |
| 166 state.sp = sp_; | 155 state.sp = sp_; |
| 167 state.pc_address = ResolveReturnAddressLocation( | 156 state.pc_address = StackFrame::ResolveReturnAddressLocation( |
| 168 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp_))); | 157 reinterpret_cast<Address*>(StandardFrame::ComputePCAddress(fp_))); |
| 169 type = StackFrame::ComputeType(isolate(), &state); | 158 type = StackFrame::ComputeType(isolate(), &state); |
| 170 } | 159 } |
| 171 if (SingletonFor(type) == NULL) return; | 160 if (SingletonFor(type) == NULL) return; |
| 172 frame_ = SingletonFor(type, &state); | 161 frame_ = SingletonFor(type, &state); |
| 173 } | 162 } |
| 174 | 163 |
| 175 | 164 |
| 176 StackFrame* StackFrameIterator::SingletonFor(StackFrame::Type type, | 165 StackFrame* StackFrameIterator::SingletonFor(StackFrame::Type type, |
| 177 StackFrame::State* state) { | 166 StackFrame::State* state) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (code != holder) { | 402 if (code != holder) { |
| 414 holder = reinterpret_cast<Code*>(code); | 403 holder = reinterpret_cast<Code*>(code); |
| 415 pc = holder->instruction_start() + pc_offset; | 404 pc = holder->instruction_start() + pc_offset; |
| 416 *pc_address = pc; | 405 *pc_address = pc; |
| 417 } | 406 } |
| 418 } | 407 } |
| 419 | 408 |
| 420 | 409 |
| 421 void StackFrame::SetReturnAddressLocationResolver( | 410 void StackFrame::SetReturnAddressLocationResolver( |
| 422 ReturnAddressLocationResolver resolver) { | 411 ReturnAddressLocationResolver resolver) { |
| 423 ASSERT(return_address_location_resolver == NULL); | 412 ASSERT(return_address_location_resolver_ == NULL); |
| 424 return_address_location_resolver = resolver; | 413 return_address_location_resolver_ = resolver; |
| 425 } | 414 } |
| 426 | 415 |
| 427 | 416 |
| 428 StackFrame::Type StackFrame::ComputeType(Isolate* isolate, State* state) { | 417 StackFrame::Type StackFrame::ComputeType(Isolate* isolate, State* state) { |
| 429 ASSERT(state->fp != NULL); | 418 ASSERT(state->fp != NULL); |
| 430 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) { | 419 if (StandardFrame::IsArgumentsAdaptorFrame(state->fp)) { |
| 431 return ARGUMENTS_ADAPTOR; | 420 return ARGUMENTS_ADAPTOR; |
| 432 } | 421 } |
| 433 // The marker and function offsets overlap. If the marker isn't a | 422 // The marker and function offsets overlap. If the marker isn't a |
| 434 // smi then the frame is a JavaScript frame -- and the marker is | 423 // smi then the frame is a JavaScript frame -- and the marker is |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 495 |
| 507 Code* ExitFrame::unchecked_code() const { | 496 Code* ExitFrame::unchecked_code() const { |
| 508 return reinterpret_cast<Code*>(code_slot()); | 497 return reinterpret_cast<Code*>(code_slot()); |
| 509 } | 498 } |
| 510 | 499 |
| 511 | 500 |
| 512 void ExitFrame::ComputeCallerState(State* state) const { | 501 void ExitFrame::ComputeCallerState(State* state) const { |
| 513 // Set up the caller state. | 502 // Set up the caller state. |
| 514 state->sp = caller_sp(); | 503 state->sp = caller_sp(); |
| 515 state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset); | 504 state->fp = Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset); |
| 516 state->pc_address = ResolveReturnAddressLocation( | 505 state->pc_address = StackFrame::ResolveReturnAddressLocation( |
| 517 reinterpret_cast<Address*>(fp() + ExitFrameConstants::kCallerPCOffset)); | 506 reinterpret_cast<Address*>(fp() + ExitFrameConstants::kCallerPCOffset)); |
| 518 } | 507 } |
| 519 | 508 |
| 520 | 509 |
| 521 void ExitFrame::SetCallerFp(Address caller_fp) { | 510 void ExitFrame::SetCallerFp(Address caller_fp) { |
| 522 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp; | 511 Memory::Address_at(fp() + ExitFrameConstants::kCallerFPOffset) = caller_fp; |
| 523 } | 512 } |
| 524 | 513 |
| 525 | 514 |
| 526 void ExitFrame::Iterate(ObjectVisitor* v) const { | 515 void ExitFrame::Iterate(ObjectVisitor* v) const { |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 ZoneList<StackFrame*> list(10, zone); | 1603 ZoneList<StackFrame*> list(10, zone); |
| 1615 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1604 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 1616 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1605 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
| 1617 list.Add(frame, zone); | 1606 list.Add(frame, zone); |
| 1618 } | 1607 } |
| 1619 return list.ToVector(); | 1608 return list.ToVector(); |
| 1620 } | 1609 } |
| 1621 | 1610 |
| 1622 | 1611 |
| 1623 } } // namespace v8::internal | 1612 } } // namespace v8::internal |
| OLD | NEW |