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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/ic_data.h" | 10 #include "vm/ic_data.h" |
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 | 1709 |
1710 // Now call the static function. The breakpoint handler function | 1710 // Now call the static function. The breakpoint handler function |
1711 // ensures that the call target is compiled. | 1711 // ensures that the call target is compiled. |
1712 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | 1712 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); |
1713 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); | 1713 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); |
1714 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1714 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
1715 __ jmp(ECX); | 1715 __ jmp(ECX); |
1716 } | 1716 } |
1717 | 1717 |
1718 | 1718 |
| 1719 // TOS(0): return address (Dart code). |
| 1720 void StubCode::GenerateBreakpointReturnStub(Assembler* assembler) { |
| 1721 __ EnterFrame(0); |
| 1722 __ pushl(EAX); |
| 1723 __ CallRuntimeFromStub(kBreakpointReturnHandlerRuntimeEntry); |
| 1724 __ popl(EAX); |
| 1725 __ LeaveFrame(); |
| 1726 |
| 1727 // Instead of returning to the patched Dart function, emulate the |
| 1728 // smashed return code pattern and return to the function's caller. |
| 1729 __ popl(ECX); // Discard return address to patched dart code. |
| 1730 // Execute function epilog code that was smashed in the Dart code. |
| 1731 __ LeaveFrame(); |
| 1732 __ ret(); |
| 1733 } |
| 1734 |
| 1735 |
1719 // ECX: Inline cache data array. | 1736 // ECX: Inline cache data array. |
1720 // EDX: Arguments array. | 1737 // EDX: Arguments array. |
1721 // TOS(0): return address (Dart code). | 1738 // TOS(0): return address (Dart code). |
1722 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { | 1739 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { |
1723 __ EnterFrame(0); | 1740 __ EnterFrame(0); |
1724 __ pushl(ECX); | 1741 __ pushl(ECX); |
1725 __ pushl(EDX); | 1742 __ pushl(EDX); |
1726 __ CallRuntimeFromStub(kBreakpointDynamicHandlerRuntimeEntry); | 1743 __ CallRuntimeFromStub(kBreakpointDynamicHandlerRuntimeEntry); |
1727 __ popl(EDX); | 1744 __ popl(EDX); |
1728 __ popl(ECX); | 1745 __ popl(ECX); |
1729 __ LeaveFrame(); | 1746 __ LeaveFrame(); |
1730 // Now call the dynamic function. | 1747 |
| 1748 // Find out which dispatch stub to call. |
| 1749 Label ic_cache_one_arg; |
| 1750 __ movl(EBX, FieldAddress(ECX, |
| 1751 Array::data_offset() + ICData::kNumArgsCheckedIndex * kWordSize)); |
| 1752 const Immediate value = |
| 1753 Immediate(reinterpret_cast<int32_t>(Smi::New(1))); |
| 1754 __ cmpl(EBX, value); |
| 1755 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); |
| 1756 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); |
| 1757 __ Bind(&ic_cache_one_arg); |
1731 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); | 1758 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); |
1732 } | 1759 } |
1733 | 1760 |
1734 } // namespace dart | 1761 } // namespace dart |
1735 | 1762 |
1736 #endif // defined TARGET_ARCH_IA32 | 1763 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |