| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/instructions.h" | 8 #include "vm/instructions.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/stack_frame.h" | 10 #include "vm/stack_frame.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 // The constant kExitLinkOffsetInEntryFrame must be kept in sync with the | 14 // The constant kExitLinkOffsetInEntryFrame must be kept in sync with the |
| 15 // code in the InvokeDartCode stub. | 15 // code in the InvokeDartCode stub. |
| 16 static const int kExitLinkOffsetInEntryFrame = -4 * kWordSize; | 16 static const int kExitLinkOffsetInEntryFrame = -4 * kWordSize; |
| 17 static const int kPcAddressOffsetFromSp = -1 * kWordSize; | 17 static const int kPcAddressOffsetFromSp = -1 * kWordSize; |
| 18 static const int kSpOffsetFromPreviousFp = 2 * kWordSize; | 18 static const int kSpOffsetFromPreviousFp = 2 * kWordSize; |
| 19 | 19 |
| 20 | 20 |
| 21 static bool ExitedFromStub(uword exit_marker) { | |
| 22 if (exit_marker != 0) { | |
| 23 uword caller_pc = *reinterpret_cast<uword*>(exit_marker + kWordSize); | |
| 24 uword call_instr_pc = caller_pc - CallPattern::InstructionLength(); | |
| 25 uword call_target = CallPattern(call_instr_pc).TargetAddress(); | |
| 26 return StubCode::InStubCallToRuntimeStubCode(call_target); | |
| 27 } | |
| 28 return false; | |
| 29 } | |
| 30 | |
| 31 | |
| 32 intptr_t StackFrame::PcAddressOffsetFromSp() { | 21 intptr_t StackFrame::PcAddressOffsetFromSp() { |
| 33 return kPcAddressOffsetFromSp; | 22 return kPcAddressOffsetFromSp; |
| 34 } | 23 } |
| 35 | 24 |
| 36 | 25 |
| 37 uword StackFrame::GetCallerSp() const { | 26 uword StackFrame::GetCallerSp() const { |
| 38 return fp() + kSpOffsetFromPreviousFp; | 27 return fp() + kSpOffsetFromPreviousFp; |
| 39 } | 28 } |
| 40 | 29 |
| 41 | 30 |
| 42 uword StackFrame::GetCallerFp() const { | 31 uword StackFrame::GetCallerFp() const { |
| 43 return *(reinterpret_cast<uword*>(fp())); | 32 return *(reinterpret_cast<uword*>(fp())); |
| 44 } | 33 } |
| 45 | 34 |
| 46 | 35 |
| 47 intptr_t EntryFrame::ExitLinkOffset() { | 36 intptr_t EntryFrame::ExitLinkOffset() { |
| 48 return kExitLinkOffsetInEntryFrame; | 37 return kExitLinkOffsetInEntryFrame; |
| 49 } | 38 } |
| 50 | 39 |
| 51 | 40 |
| 52 void StackFrameIterator::SetupLastExitFrameData() { | 41 void StackFrameIterator::SetupLastExitFrameData() { |
| 53 Isolate* current = Isolate::Current(); | 42 Isolate* current = Isolate::Current(); |
| 54 uword exit_marker = current->top_exit_frame_info(); | 43 uword exit_marker = current->top_exit_frame_info(); |
| 55 frames_.fp_ = exit_marker; | 44 frames_.fp_ = exit_marker; |
| 56 frames_.from_stub_exitframe_ = ExitedFromStub(exit_marker); | |
| 57 } | 45 } |
| 58 | 46 |
| 59 | 47 |
| 60 void StackFrameIterator::SetupNextExitFrameData() { | 48 void StackFrameIterator::SetupNextExitFrameData() { |
| 61 uword exit_address = entry_.fp() + kExitLinkOffsetInEntryFrame; | 49 uword exit_address = entry_.fp() + kExitLinkOffsetInEntryFrame; |
| 62 uword exit_marker = *reinterpret_cast<uword*>(exit_address); | 50 uword exit_marker = *reinterpret_cast<uword*>(exit_address); |
| 63 frames_.fp_ = exit_marker; | 51 frames_.fp_ = exit_marker; |
| 64 frames_.from_stub_exitframe_ = ExitedFromStub(exit_marker); | |
| 65 frames_.sp_ = 0; | 52 frames_.sp_ = 0; |
| 66 } | 53 } |
| 67 | 54 |
| 68 } // namespace dart | 55 } // namespace dart |
| 69 | 56 |
| 70 #endif // defined TARGET_ARCH_IA32 | 57 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |