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